Mercurial > repos > yufei-luo > s_mart
annotate smart_toolShed/SMART/Java/Sav/ProgramLauncher.java @ 0:e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
| author | yufei-luo | 
|---|---|
| date | Thu, 17 Jan 2013 10:52:14 -0500 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 1 /** | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 2 * | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 3 * Copyright INRA-URGI 2009-2010 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 4 * | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 5 * This software is governed by the CeCILL license under French law and | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 6 * abiding by the rules of distribution of free software. You can use, | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 7 * modify and/ or redistribute the software under the terms of the CeCILL | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 8 * license as circulated by CEA, CNRS and INRIA at the following URL | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 9 * "http://www.cecill.info". | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 10 * | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 11 * As a counterpart to the access to the source code and rights to copy, | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 12 * modify and redistribute granted by the license, users are provided only | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 13 * with a limited warranty and the software's author, the holder of the | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 14 * economic rights, and the successive licensors have only limited | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 15 * liability. | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 16 * | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 17 * In this respect, the user's attention is drawn to the risks associated | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 18 * with loading, using, modifying and/or developing or reproducing the | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 19 * software by the user in light of its specific status of free software, | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 20 * that may mean that it is complicated to manipulate, and that also | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 21 * therefore means that it is reserved for developers and experienced | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 22 * professionals having in-depth computer knowledge. Users are therefore | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 23 * encouraged to load and test the software's suitability as regards their | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 24 * requirements in conditions enabling the security of their systems and/or | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 25 * data to be ensured and, more generally, to use and operate it in the | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 26 * same conditions as regards security. | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 27 * | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 28 * The fact that you are presently reading this means that you have had | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 29 * knowledge of the CeCILL license and that you accept its terms. | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 30 * | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 31 */ | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 32 import java.util.*; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 33 import java.io.*; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 34 import javax.swing.SwingUtilities; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 35 import javax.swing.*; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 36 import java.util.concurrent.CountDownLatch; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 37 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 38 public class ProgramLauncher extends SwingWorker<Boolean, String> { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 39 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 40 String[] command; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 41 JTextArea logArea; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 42 JLabel messageField; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 43 JProgressBar progressBar; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 44 JLabel etaField; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 45 int exitValue; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 46 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 47 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 48 public ProgramLauncher (LinkedList <String> c, JTextArea la, JLabel mf, JProgressBar pb, JLabel ef) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 49 command = new String[c.size()]; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 50 logArea = la; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 51 messageField = mf; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 52 progressBar = pb; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 53 etaField = ef; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 54 exitValue = -1; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 55 c.toArray(command); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 56 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 57 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 58 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 59 public ProgramLauncher (String[] c, JTextArea la, JLabel mf, JProgressBar pb, JLabel ef) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 60 command = c; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 61 logArea = la; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 62 messageField = mf; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 63 progressBar = pb; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 64 etaField = ef; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 65 exitValue = -1; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 66 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 67 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 68 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 69 @Override | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 70 public Boolean doInBackground() { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 71 ProcessBuilder pb = new ProcessBuilder(command); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 72 Process process = null; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 73 BufferedReader outputReader = null; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 74 pb = pb.redirectErrorStream(true); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 75 Map<String, String> env = pb.environment(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 76 env.put("PYTHONPATH", System.getProperty("user.dir") + java.io.File.separator + "Python"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 77 env.put("SMARTPATH", System.getProperty("user.dir") + java.io.File.separator + "Python"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 78 env.put("SMARTMYSQLPATH", Global.mysqlCommand); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 79 env.put("SMARTRPATH", Global.rCommand); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 80 String commandJoined = Arrays.toString(command); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 81 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 82 try { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 83 publish("=== Starting command '" + commandJoined.trim() + "' ===\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 84 process = pb.start(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 85 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 86 BufferedInputStream outputStream = new BufferedInputStream(process.getInputStream()); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 87 InputStream is = process.getInputStream(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 88 InputStreamReader isr = new InputStreamReader(is); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 89 outputReader = new BufferedReader(isr); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 90 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 91 catch (Exception exception) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 92 publish("!Process cannot be started (command is '" + commandJoined + "')!\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 93 exception.printStackTrace(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 94 return Boolean.FALSE; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 95 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 96 if (outputReader == null) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 97 publish("!Problem in the output of the command!\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 98 return Boolean.FALSE; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 99 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 100 else { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 101 try { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 102 String line; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 103 while ((line = outputReader.readLine()) != null) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 104 publish(line + "\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 105 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 106 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 107 catch (IOException e) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 108 e.printStackTrace(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 109 publish("!Cannot get the output of the command!\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 110 return Boolean.FALSE; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 111 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 112 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 113 try { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 114 process.waitFor(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 115 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 116 catch (InterruptedException e) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 117 e.printStackTrace(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 118 publish("!Cannot wait for the end of the command!\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 119 return Boolean.FALSE; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 120 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 121 try { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 122 exitValue = process.exitValue(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 123 System.out.println(exitValue); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 124 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 125 catch (IllegalThreadStateException e) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 126 e.printStackTrace(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 127 publish("!Cannot get the exit value of the command!\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 128 return Boolean.FALSE; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 129 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 130 if (exitValue != 0) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 131 publish("!Problem during the execution of the command '" + commandJoined + "'!\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 132 return Boolean.FALSE; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 133 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 134 publish("=== Ending command '" + commandJoined.trim() + "' ===\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 135 return Boolean.TRUE; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 136 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 137 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 138 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 139 @Override | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 140 protected void process(List<String> chunks) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 141 String message = ""; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 142 String text = logArea.getText(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 143 for (String chunk: chunks) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 144 text += chunk; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 145 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 146 for (String lineSeparatedByCarriageReturn: text.split("\n")) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 147 for (String line: lineSeparatedByCarriageReturn.split("\r")) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 148 boolean progressLine = false; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 149 if (line.matches(".*\\[=*\\s*\\]\\s*\\d*/\\d*\\s*")) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 150 String[] ratioElements = line.split("\\]")[1].trim().split("/"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 151 int current = Integer.parseInt(ratioElements[0].trim()); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 152 int aim = Integer.parseInt(ratioElements[1].trim()); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 153 messageField.setText(line.split("\\[")[0].trim()); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 154 progressBar.setValue(current * 100 / aim); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 155 etaField.setText(""); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 156 progressLine = true; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 157 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 158 else if (line.matches(".*\\[=*\\s*\\]\\s*\\d*/\\d*\\s*ETA:\\s*.*")) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 159 String[] ratioElements = line.split("\\]")[1].split("E")[0].trim().split("/"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 160 int current = Integer.parseInt(ratioElements[0].trim()); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 161 int aim = Integer.parseInt(ratioElements[1].trim()); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 162 String eta = line.split("ETA:")[1].trim(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 163 messageField.setText(line.split("\\[")[0].trim()); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 164 progressBar.setValue(current * 100 / aim); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 165 etaField.setText("ETA: " + eta); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 166 progressLine = true; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 167 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 168 else if (line.matches(".*\\[=*\\s*\\]\\s*\\d*\\s*completed in.*")) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 169 String nbElements = line.split("\\]")[1].split("completed")[0].trim(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 170 String timeSpent = line.split("completed in")[1].trim(); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 171 message += line.split("\\[")[0].trim() + ": " + nbElements + " elements completed in " + timeSpent + "\n"; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 172 messageField.setText(line.split("\\[")[0].trim()); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 173 progressLine = true; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 174 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 175 if (! progressLine) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 176 message += line + "\n"; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 177 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 178 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 179 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 180 String lines[] = message.split("\n"); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 181 String toBeWritten = ""; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 182 for (int i = Math.max(0, lines.length - Global.logAreaSize); i < lines.length; i++) { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 183 toBeWritten += lines[i] + "\n"; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 184 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 185 logArea.setText(toBeWritten); | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 186 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 187 | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 188 public int getExitValue() { | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 189 return exitValue; | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 190 } | 
| 
e0f8dcca02ed
Uploaded S-MART tool. A toolbox manages RNA-Seq and ChIP-Seq data.
 yufei-luo parents: diff
changeset | 191 } | 
