package org.cipres.kepler.jrun; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import org.cipres.guigen.*; import org.cipres.helpers.JRun; import org.cipres.helpers.RegistryGuigenWrapper; public class JRunTester { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub // GUIGen part String xmlLocation = "/Users/zhijieguan/work/ClustalW/clustalw.xml"; File guiXmlFile = new File(xmlLocation); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { new TestGui(guiXmlFile, null, null, new RegistryGuigenWrapper(), false); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } final ArrayList argsFileLines = new ArrayList(); try { final FileReader argsFile = new FileReader("/Users/zhijieguan/work/ClustalW/argum.txt"); final BufferedReader reader = new BufferedReader(argsFile); String line; while ((line = reader.readLine()) != null) argsFileLines.add(line); } catch (final IOException ioErr) { ioErr.printStackTrace(); } // test1 is to test the general execution of ClustalW // with the command generated by GUIGen // wait until the execution finishes try { JRun test1 = new JRun(); test1.setExecutable("/Users/zhijieguan/work/ClustalW/clustalw"); // test1.setArguments(" -infile=/Users/zhijieguan/work/ClustalW/globin.pep -outfile=/Users/zhijieguan/work/ClustalW/aout.txt -output=NEXUS -quicktree=fast -ktuple=1 -topdiags=5 -window=5 -pairgap=3 -score=percent "); test1.setArguments((String[]) argsFileLines.toArray(new String[argsFileLines.size()])); test1.setOutputFilename("/Users/zhijieguan/work/ClustalW/runout"); test1.setErrorFilename("/Users/zhijieguan/work/ClustalW/runerror"); test1.setWorkingDirPath("/Users/zhijieguan/work/ClustalW/"); test1.setWaitForExecution(true); System.out.println(test1.execute()); System.out.println(test1.getExitCode()); System.out.println("Standard Output: \n" + test1.getStandardOutput()); System.out.println("Standard Error: \n" + test1.getStandardError()); } catch (final InterruptedException interruptedErr) { interruptedErr.printStackTrace(); } catch (final IOException ioErr) { ioErr.printStackTrace(); } } }