package bicat.GO;

/**
 *
 * @author Hamed
 * /**
 
 * For its execution, a batch file called getGenemerge  is needed.
 * 
 */



import javax.swing.JOptionPane;
import bicat.gui.BicatGui;
import bicat.run_machine.SwingWorker;
import java.io.File;
import bicat.run_machine.RunMachine;

public class GeneMerge2 extends RunMachine {

	static BicatGui owner;
        
        
        
        
        public  String GENE_ASSOCIARION_FILE="D:\\Master_nottingham\\work\\Bicat\\GeneMerge\\S_cerevisiae.BP";
        public  String DESCRIPTION_FILE="D:\\Master_nottingham\\work\\Bicat\\GeneMerge\\GO.BP.use";
        public  static String GENE_MERGE_DIRECTORY;//owner.currentDirectoryPath+"//genemerge";
        public  String POPULATION_FILE_PATH;//owner.POPULATION_FILE_PATH;
        
        public   String exported;//=owner.EXPORTED_CLUSTER_FILE_PATH;
        public  String goclusetr;//=owner.GO_CLUSTER_FILE_PATH;
        
        
        
	public GeneMerge2(BicatGui o) {
		owner = o;
	}

public native void run_GeneMerge(String s1,String s2,String s3,String s4,String s5);
	static {
		                
            
            System.load("D:\\Master_nottingham\\work\\Bicat\\GeneMerge\\getGeneMerge.exe"); 
            
            try { 
             
           //  System.load(GENE_MERGE_DIRECTORY+"//getGeneMerge.exe");
                           
            }catch(Exception ex)
            {
                ex.printStackTrace();                
            }
            // System.load(owner.currentDirectoryPath + "/geneMerge/GeneMerge1.2.pl");
            //System.load("D:\\Master_nottingham\\work\\Bicat\\GeneMerge\\getGeneMerge.bat");
	    System.out.println("GeneMerge loaded");
	
        }

	public synchronized void getGeneMergeFile() {

		final SwingWorker worker = new SwingWorker() {

			public Object construct() {
				// new RunMachineCC(null).runCC();
				//if (BicatGui.debug)System.out.println("Noise Th : "+ bicluster_Finda.getNoise_Th() +" ,  PR: "+  bicluster_Finda.getPr());
				run_GeneMerge(GENE_ASSOCIARION_FILE,DESCRIPTION_FILE, POPULATION_FILE_PATH,exported,goclusetr);

				if (owner.debug) {
					System.out.println("Started bicluster in a new thread!\n");
				}

				return null;
			}

			public void finished() {

				//System.out.println("Getting results from bicluster_find... "+ owner.currentDirectoryPath + "/output.bicluster_find");

			JOptionPane.showMessageDialog(null,"GeneMerge Calculations finished.\nThe results can be found in the bicluster results section of the current dataset.");

			}
		};
		worker.start();
	}
        
        
        
        
        
        
        
        
        
        
public void setGeneMergeConfigurations(String organism,String GoType)
{
     /* set here the  geneassociation files and the description file according to the 
     * organisms and the go type.
     */
    
    
}


public static Process  testrun_GeneMerge(){

	Process proc=null;
            try { 
             
              // Runtime.getRuntime().exec(new String [] {"cmd" ,"/c", "start","getgenemerge",GENE_ASSOCIARION_FILE,DESCRIPTION_FILE,POPULATION_FILE_PATH,owner.EXPORTED_CLUSTER_FILE_PATH,owner.GO_CLUSTER_FILE_PATH},null,new File(GENE_MERGE_DIRECTORY));
          //  proc= Runtime.getRuntime().exec(new String [] {"cmd","/c","start","getgenemerge",GENE_ASSOCIARION_FILE,DESCRIPTION_FILE,POPULATION_FILE_PATH,owner.EXPORTED_CLUSTER_FILE_PATH,owner.GO_CLUSTER_FILE_PATH},null,new File(GENE_MERGE_DIRECTORY));
            //String cmd="perl "+GENE_MERGE_DIRECTORY+"//GeneMerge1.2.pl "+GENE_MERGE_DIRECTORY+"//"+GENE_ASSOCIARION_FILE +" "+GENE_MERGE_DIRECTORY+"//"+DESCRIPTION_FILE+" "+POPULATION_FILE_PATH +" "+owner.EXPORTED_CLUSTER_FILE_PATH+" "+owner.GO_CLUSTER_FILE_PATH;
             //proc= Runtime.getRuntime().exec(cmd);
            //System.out.println(cmd);
            
            }catch(Exception ex)
            {
                ex.printStackTrace();
                
            }
         
            System.out.println("GeneMerge  is running here in the method...");
	return proc;
                  
}




}





    
