* consensus. Potential bug - records 60 chars length alignment where\r
* Clustal would have recorded 50 chars.\r
* \r
- * @param outStream\r
+ * @param out\r
* \r
* @param alignment\r
* @throws IOException\r
/**\r
* Header data can contain non-ASCII symbols and read in UTF8\r
* \r
- * @param input\r
+ * @param inputFile\r
* the file containing the list of FASTA formatted sequences to\r
* read from\r
* @throws FileNotFoundException\r
/**\r
* Return Ranges if any Collections.EMPTY_SET otherwise\r
* \r
- * @return\r
+ * @return ordered set of Range\r
*/\r
public TreeSet<Range> getRanges() {\r
return ranges;\r
* \r
* @param scores\r
* the list of scores to output\r
- * @param output\r
- * the stream to output the data to\r
+ * @param writer\r
* @throws IOException\r
* if the OutputStream cannot be written into\r
* @throws NullPointerException\r
* Read IUPred output\r
* \r
* @param result\r
- * @return\r
+ * @return Map key->sequence name, value->Score\r
* @throws IOException\r
* @throws UnknownFileFormatException\r
*/\r
* \r
* @param inStream\r
* the InputStream connected to the JRonn output file\r
- * @return List of {@link AnnotatedSequence} objects\r
+ * @return Map key=sequence name value=Score\r
* @throws IOException\r
* is thrown if the inStream has problems accessing the data\r
* @throws UnknownFileFormatException\r
* \r
* \r
* @param input\r
- * @return\r
+ * the InputStream\r
+ * @return Map key=sequence name, value=set of score\r
* @throws IOException\r
* @throws UnknownFileFormatException\r
*/\r
* \r
* \r
* @param input\r
- * @return\r
+ * @return Map key=sequence name, value=set of score\r
* @throws IOException\r
* @throws UnknownFileFormatException\r
*/\r
import compbio.engine.client.PathValidator;\r
import compbio.engine.local.ExecutableWrapper;\r
\r
+@Deprecated\r
public class Cleaner {\r
\r
private static final Logger log = Logger.getLogger(Cleaner.class);\r
* \r
* @param workDirectory\r
* @param files\r
- * @return\r
+ * @return This method returns true if all files specified by List files\r
+ * were successfully removed, false otherwise\r
*/\r
public static boolean deleteFiles(ConfiguredExecutable<?> exec) {\r
\r
if (success) {\r
log.trace(type + filename + " was successfully removed");\r
} else {\r
- log\r
- .debug("Could not remove "\r
- + type\r
- + ": "\r
- + filename\r
- + " reportedly created by executable. Insufficient access right?");\r
+ log.debug("Could not remove "\r
+ + type\r
+ + ": "\r
+ + filename\r
+ + " reportedly created by executable. Insufficient access right?");\r
}\r
} else {\r
log.debug("File: " + filename\r
\r
public class FilePuller implements Delayed {\r
\r
- private static final Logger log = Logger.getLogger(FilePuller.class);\r
-\r
- // 5 minutes in nanosec\r
- private static long defaultDelay = 1000 * 1000 * 1000L * 5 * 60;\r
- private final File file;\r
- private long lastAccessTime;\r
- private FileWatcher watcher;\r
- final int chunkSize;\r
-\r
- // used for testing only\r
- long delay = 0;\r
-\r
- private FilePuller(String file, int size) {\r
- FileWatcher.validateInput(file, size);\r
- if (compbio.util.Util.isEmpty(file)) {\r
- throw new NullPointerException("File name must be provided!");\r
+ private static final Logger log = Logger.getLogger(FilePuller.class);\r
+\r
+ // 5 minutes in nanosec\r
+ private static long defaultDelay = 1000 * 1000 * 1000L * 5 * 60;\r
+ private final File file;\r
+ private long lastAccessTime;\r
+ private FileWatcher watcher;\r
+ final int chunkSize;\r
+\r
+ // used for testing only\r
+ long delay = 0;\r
+\r
+ private FilePuller(String file, int size) {\r
+ FileWatcher.validateInput(file, size);\r
+ if (compbio.util.Util.isEmpty(file)) {\r
+ throw new NullPointerException("File name must be provided!");\r
+ }\r
+ // The fact that the file may not exist at a time does not matter here\r
+ if (!PathValidator.isAbsolutePath(file)) {\r
+ throw new IllegalArgumentException("Absolute path to the File "\r
+ + file + " is expected but not provided!");\r
+ }\r
+ this.file = new File(file);\r
+ this.chunkSize = size;\r
+ this.lastAccessTime = System.nanoTime();\r
}\r
- // The fact that the file may not exist at a time does not matter here\r
- if (!PathValidator.isAbsolutePath(file)) {\r
- throw new IllegalArgumentException("Absolute path to the File "\r
- + file + " is expected but not provided!");\r
+\r
+ private FilePuller(String file) {\r
+ if (compbio.util.Util.isEmpty(file)) {\r
+ throw new NullPointerException("File name must be provided!");\r
+ }\r
+ // The fact that the file may not exist at a time does not matter here\r
+ if (!PathValidator.isAbsolutePath(file)) {\r
+ throw new IllegalArgumentException("Absolute path to the File "\r
+ + file + " is expected but not provided!");\r
+ }\r
+ this.file = new File(file);\r
+ this.chunkSize = 3;\r
+ this.lastAccessTime = System.nanoTime();\r
}\r
- this.file = new File(file);\r
- this.chunkSize = size;\r
- this.lastAccessTime = System.nanoTime();\r
- }\r
-\r
- private FilePuller(String file) {\r
- if (compbio.util.Util.isEmpty(file)) {\r
- throw new NullPointerException("File name must be provided!");\r
+\r
+ public static FilePuller newFilePuller(String file, int chunkSize) {\r
+ return new FilePuller(file, chunkSize);\r
}\r
- // The fact that the file may not exist at a time does not matter here\r
- if (!PathValidator.isAbsolutePath(file)) {\r
- throw new IllegalArgumentException("Absolute path to the File "\r
- + file + " is expected but not provided!");\r
+\r
+ /**\r
+ * Progress Puller is designed to read 3 characters from the beginning of\r
+ * the file, nothing more. Intended to be used in conjunction with a tool\r
+ * which output progress as a percent value from 0 to 100. In any cases\r
+ * progress could not be more than the largest byte value 255.\r
+ * \r
+ * @param file\r
+ * @return instance\r
+ */\r
+ public static FilePuller newProgressPuller(String file) {\r
+ return new FilePuller(file);\r
}\r
- this.file = new File(file);\r
- this.chunkSize = 3;\r
- this.lastAccessTime = System.nanoTime();\r
- }\r
-\r
- public static FilePuller newFilePuller(String file, int chunkSize) {\r
- return new FilePuller(file, chunkSize);\r
- }\r
-\r
- /**\r
- * Progress Puller is designed to read 3 characters from the beginning of\r
- * the file, nothing more. Intended to be used in conjunction with a tool\r
- * which output progress as a percent value from 0 to 100. In any cases\r
- * progress could not be more than the largest byte value 255.\r
- * \r
- * @param file\r
- * @return\r
- */\r
- public static FilePuller newProgressPuller(String file) {\r
- return new FilePuller(file);\r
- }\r
-\r
- public ChunkHolder pull(long position) throws IOException {\r
- initPull();\r
- String valueUTF16 = watcher.pull(position);\r
- String value = null;\r
- if (valueUTF16 != null) {\r
- value = removeInvalidXMLCharacters(valueUTF16);\r
+\r
+ public ChunkHolder pull(long position) throws IOException {\r
+ initPull();\r
+ String valueUTF16 = watcher.pull(position);\r
+ String value = null;\r
+ if (valueUTF16 != null) {\r
+ value = removeInvalidXMLCharacters(valueUTF16);\r
+ }\r
+ return new ChunkHolder(value, watcher.getCursorPosition());\r
}\r
- return new ChunkHolder(value, watcher.getCursorPosition());\r
- }\r
-\r
- /**\r
- * This method ensures that the output String has only valid XML unicode\r
- * characters as specified by the XML 1.0 standard. For reference, please\r
- * see the standard.\r
- * \r
- * @param The\r
- * String whose non-valid characters we want to remove.\r
- * \r
- * @return The in String, stripped of non-valid characters.\r
- */\r
- static String removeInvalidXMLCharacters(String str) {\r
- assert str != null;\r
-\r
- StringBuilder out = new StringBuilder(); // Used to hold the output.\r
- int codePoint; // Used to reference the current character.\r
-\r
- // For test\r
- // String ss = "\ud801\udc00"; // This is actualy one unicode character,\r
- // represented by two code units!!!.\r
- // System.out.println(ss.codePointCount(0, ss.length()));// See: 1\r
- int i = 0;\r
- String value = null;\r
- try {\r
- // make sure the string contain only UTF-8 characters\r
- value = new String(str.getBytes("UTF-8"), "UTF-8");\r
- } catch (UnsupportedEncodingException e) {\r
- // will not happen\r
- throw new AssertionError("UTF-8 charset is not supported!!!");\r
+\r
+ /**\r
+ * This method ensures that the output String has only valid XML unicode\r
+ * characters as specified by the XML 1.0 standard. For reference, please\r
+ * see the standard.\r
+ * \r
+ * @param The\r
+ * String whose non-valid characters we want to remove.\r
+ * \r
+ * @return The in String, stripped of non-valid characters.\r
+ */\r
+ static String removeInvalidXMLCharacters(String str) {\r
+ assert str != null;\r
+\r
+ StringBuilder out = new StringBuilder(); // Used to hold the output.\r
+ int codePoint; // Used to reference the current character.\r
+\r
+ // For test\r
+ // String ss = "\ud801\udc00"; // This is actualy one unicode character,\r
+ // represented by two code units!!!.\r
+ // System.out.println(ss.codePointCount(0, ss.length()));// See: 1\r
+ int i = 0;\r
+ String value = null;\r
+ try {\r
+ // make sure the string contain only UTF-8 characters\r
+ value = new String(str.getBytes("UTF-8"), "UTF-8");\r
+ } catch (UnsupportedEncodingException e) {\r
+ // will not happen\r
+ throw new AssertionError("UTF-8 charset is not supported!!!");\r
+ }\r
+ while (i < value.length()) {\r
+ codePoint = value.codePointAt(i); // This is the unicode code of the\r
+ // character.\r
+ if ((codePoint == 0x9)\r
+ || // Consider testing larger ranges first to\r
+ // improve speed.\r
+ (codePoint == 0xA) || (codePoint == 0xD)\r
+ || ((codePoint >= 0x20) && (codePoint <= 0xD7FF))\r
+ || ((codePoint >= 0xE000) && (codePoint <= 0xFFFD))\r
+ || ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF))) {\r
+\r
+ out.append(Character.toChars(codePoint));\r
+ }\r
+\r
+ i += Character.charCount(codePoint);\r
+ /*\r
+ * Increment with the number of code units(java chars) needed to\r
+ * represent a Unicode char.\r
+ */\r
+ }\r
+ return out.toString();\r
}\r
- while (i < value.length()) {\r
- codePoint = value.codePointAt(i); // This is the unicode code of the\r
- // character.\r
- if ((codePoint == 0x9)\r
- || // Consider testing larger ranges first to\r
- // improve speed.\r
- (codePoint == 0xA) || (codePoint == 0xD)\r
- || ((codePoint >= 0x20) && (codePoint <= 0xD7FF))\r
- || ((codePoint >= 0xE000) && (codePoint <= 0xFFFD))\r
- || ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF))) {\r
-\r
- out.append(Character.toChars(codePoint));\r
- }\r
-\r
- i += Character.charCount(codePoint);\r
- /*\r
- * Increment with the number of code units(java chars) needed to\r
- * represent a Unicode char.\r
- */\r
+\r
+ public void initPull() {\r
+ this.lastAccessTime = System.nanoTime();\r
+ if (!isFileCreated()) {\r
+ throw new IllegalStateException("File " + file.getAbsolutePath()\r
+ + " has not been created yet! Cannot pull.");\r
+ }\r
+ if (watcher == null) {\r
+ init();\r
+ }\r
}\r
- return out.toString();\r
- }\r
-\r
- public void initPull() {\r
- this.lastAccessTime = System.nanoTime();\r
- if (!isFileCreated()) {\r
- throw new IllegalStateException("File " + file.getAbsolutePath()\r
- + " has not been created yet! Cannot pull.");\r
+\r
+ public String getFile() {\r
+ return file.getAbsolutePath();\r
}\r
- if (watcher == null) {\r
- init();\r
+\r
+ public boolean isFileCreated() {\r
+ this.lastAccessTime = System.nanoTime();\r
+ return file.exists();\r
}\r
- }\r
-\r
- public String getFile() {\r
- return file.getAbsolutePath();\r
- }\r
-\r
- public boolean isFileCreated() {\r
- this.lastAccessTime = System.nanoTime();\r
- return file.exists();\r
- }\r
-\r
- public void waitForFile(long maxWaitSeconds) {\r
- long waited = 0;\r
- int step = 500;\r
- while (true) {\r
- if (isFileCreated()) {\r
- break;\r
- }\r
- try {\r
- Thread.sleep(step);\r
- // TODO is this needed? this.lastAccessTime = System.nanoTime();\r
- } catch (InterruptedException e) {\r
- // Propagate interruption up the stack trace for anyone\r
- // interested\r
- Thread.currentThread().interrupt();\r
- log.debug("Thread interruped during waiting for file "\r
- + file.getAbsolutePath() + " to be created. Message: "\r
- + e.getMessage());\r
- break;\r
- }\r
- waited += step;\r
- if (waited / 1000 >= maxWaitSeconds) {\r
- break;\r
- }\r
+\r
+ public void waitForFile(long maxWaitSeconds) {\r
+ long waited = 0;\r
+ int step = 500;\r
+ while (true) {\r
+ if (isFileCreated()) {\r
+ break;\r
+ }\r
+ try {\r
+ Thread.sleep(step);\r
+ // TODO is this needed? this.lastAccessTime = System.nanoTime();\r
+ } catch (InterruptedException e) {\r
+ // Propagate interruption up the stack trace for anyone\r
+ // interested\r
+ Thread.currentThread().interrupt();\r
+ log.debug("Thread interruped during waiting for file "\r
+ + file.getAbsolutePath() + " to be created. Message: "\r
+ + e.getMessage());\r
+ break;\r
+ }\r
+ waited += step;\r
+ if (waited / 1000 >= maxWaitSeconds) {\r
+ break;\r
+ }\r
+ }\r
}\r
- }\r
\r
- public boolean hasMoreData() throws IOException {\r
- this.lastAccessTime = System.nanoTime();\r
- if (!isFileCreated()) {\r
- throw new IllegalStateException("File " + file.getAbsolutePath()\r
- + " has not been created yet! Cannot pull.");\r
+ public boolean hasMoreData() throws IOException {\r
+ this.lastAccessTime = System.nanoTime();\r
+ if (!isFileCreated()) {\r
+ throw new IllegalStateException("File " + file.getAbsolutePath()\r
+ + " has not been created yet! Cannot pull.");\r
+ }\r
+ if (watcher == null) {\r
+ init();\r
+ }\r
+ return watcher.hasMore();\r
}\r
- if (watcher == null) {\r
- init();\r
+\r
+ private synchronized void init() {\r
+ // Check watcher==null is duplicated to avoid adding synchronization to\r
+ // access methods\r
+ if (watcher == null) {\r
+ if (chunkSize < FileWatcher.MIN_CHUNK_SIZE_BYTES) {\r
+ watcher = FileWatcher\r
+ .newProgressWatcher(file.getAbsolutePath());\r
+ log.debug("Init Progress watcher with file: "\r
+ + file.getAbsolutePath());\r
+ } else {\r
+ watcher = FileWatcher.newFileWatcher(file.getAbsolutePath(),\r
+ chunkSize);\r
+ log.debug("Init File watcher with file: "\r
+ + file.getAbsolutePath());\r
+ }\r
+\r
+ }\r
}\r
- return watcher.hasMore();\r
- }\r
-\r
- private synchronized void init() {\r
- // Check watcher==null is duplicated to avoid adding synchronization to\r
- // access methods\r
- if (watcher == null) {\r
- if (chunkSize < FileWatcher.MIN_CHUNK_SIZE_BYTES) {\r
- watcher = FileWatcher\r
- .newProgressWatcher(file.getAbsolutePath());\r
- log.debug("Init Progress watcher with file: "\r
- + file.getAbsolutePath());\r
- } else {\r
- watcher = FileWatcher.newFileWatcher(file.getAbsolutePath(),\r
- chunkSize);\r
- log.debug("Init File watcher with file: "\r
- + file.getAbsolutePath());\r
- }\r
\r
+ @Override\r
+ public int compareTo(Delayed o) {\r
+ return new Long(this.getDelay(TimeUnit.NANOSECONDS)).compareTo(o\r
+ .getDelay(TimeUnit.NANOSECONDS));\r
}\r
- }\r
-\r
- @Override\r
- public int compareTo(Delayed o) {\r
- return new Long(this.getDelay(TimeUnit.NANOSECONDS)).compareTo(o\r
- .getDelay(TimeUnit.NANOSECONDS));\r
- }\r
-\r
- /*\r
- * This must return remaining delay associated with the object!\r
- * (non-Javadoc)\r
- * \r
- * @see java.util.concurrent.Delayed#getDelay(java.util.concurrent.TimeUnit)\r
- */\r
- @Override\r
- public long getDelay(final TimeUnit unit) {\r
- long idleTime = System.nanoTime() - lastAccessTime;\r
- long delayVal = (delay == 0 ? defaultDelay : delay);\r
- return unit.convert(delayVal - idleTime, TimeUnit.NANOSECONDS);\r
- }\r
-\r
- void setDelay(long delay, TimeUnit unit) {\r
- assert delay > 0;\r
- this.delay = TimeUnit.NANOSECONDS.convert(delay, unit);\r
- assert delay < defaultDelay;\r
- }\r
-\r
- long getDelayValue(TimeUnit unit) {\r
- return (delay == 0 ? unit.convert(defaultDelay, TimeUnit.NANOSECONDS)\r
- : unit.convert(delay, TimeUnit.NANOSECONDS));\r
- }\r
-\r
- public void disconnect() {\r
- synchronized (this) {\r
- if (watcher != null) {\r
- watcher.disconnect();\r
- watcher = null;\r
- }\r
+\r
+ /*\r
+ * This must return remaining delay associated with the object!\r
+ * (non-Javadoc)\r
+ * \r
+ * @see java.util.concurrent.Delayed#getDelay(java.util.concurrent.TimeUnit)\r
+ */\r
+ @Override\r
+ public long getDelay(final TimeUnit unit) {\r
+ long idleTime = System.nanoTime() - lastAccessTime;\r
+ long delayVal = (delay == 0 ? defaultDelay : delay);\r
+ return unit.convert(delayVal - idleTime, TimeUnit.NANOSECONDS);\r
}\r
- }\r
-\r
- boolean disconnected() {\r
- return watcher == null;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- String value = "File: " + this.file.getAbsolutePath() + "\n";\r
- value += "Delay (s): " + getDelayValue(TimeUnit.SECONDS) + "\n";\r
- long exp = getDelay(TimeUnit.MILLISECONDS);\r
- if (exp > 0) {\r
- value += "Expire in (ms): " + exp + "\n";\r
- } else {\r
- value += "This object has expired" + "\n";\r
+\r
+ void setDelay(long delay, TimeUnit unit) {\r
+ assert delay > 0;\r
+ this.delay = TimeUnit.NANOSECONDS.convert(delay, unit);\r
+ assert delay < defaultDelay;\r
}\r
- value += "ChunkSize " + this.chunkSize + "\n";\r
- return value;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (obj == null) {\r
- return false;\r
+\r
+ long getDelayValue(TimeUnit unit) {\r
+ return (delay == 0\r
+ ? unit.convert(defaultDelay, TimeUnit.NANOSECONDS)\r
+ : unit.convert(delay, TimeUnit.NANOSECONDS));\r
+ }\r
+\r
+ public void disconnect() {\r
+ synchronized (this) {\r
+ if (watcher != null) {\r
+ watcher.disconnect();\r
+ watcher = null;\r
+ }\r
+ }\r
}\r
- if (!(obj instanceof FilePuller)) {\r
- return false;\r
+\r
+ boolean disconnected() {\r
+ return watcher == null;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ String value = "File: " + this.file.getAbsolutePath() + "\n";\r
+ value += "Delay (s): " + getDelayValue(TimeUnit.SECONDS) + "\n";\r
+ long exp = getDelay(TimeUnit.MILLISECONDS);\r
+ if (exp > 0) {\r
+ value += "Expire in (ms): " + exp + "\n";\r
+ } else {\r
+ value += "This object has expired" + "\n";\r
+ }\r
+ value += "ChunkSize " + this.chunkSize + "\n";\r
+ return value;\r
}\r
- FilePuller fp = (FilePuller) obj;\r
- if (!this.file.equals(fp.file)) {\r
- return false;\r
+\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (obj == null) {\r
+ return false;\r
+ }\r
+ if (!(obj instanceof FilePuller)) {\r
+ return false;\r
+ }\r
+ FilePuller fp = (FilePuller) obj;\r
+ if (!this.file.equals(fp.file)) {\r
+ return false;\r
+ }\r
+ // Other fields does not matter\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return this.file.hashCode();\r
+ }\r
+\r
+ public byte getProgress() throws IOException {\r
+ initPull();\r
+ return watcher.getProgress();\r
}\r
- // Other fields does not matter\r
- return true;\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return this.file.hashCode();\r
- }\r
-\r
- public byte getProgress() throws IOException {\r
- initPull();\r
- return watcher.getProgress();\r
- }\r
\r
}\r
* the called to ensure this will not happen!\r
* \r
* @param fpuller\r
- * @return\r
+ * @return true if the same filepooler is already in cache\r
*/\r
public static boolean put(final FilePuller fpuller) {\r
sweep();\r
}\r
\r
boolean setParam(Parameter param) {\r
- boolean overriden= paramList.put(param.name, param) != null;\r
- if(overriden) {\r
- log.warn("Key " + param.name + " in the command list has been overriden! ");\r
+ boolean overriden = paramList.put(param.name, param) != null;\r
+ if (overriden) {\r
+ log.warn("Key " + param.name\r
+ + " in the command list has been overriden! ");\r
}\r
return overriden;\r
}\r
// paramValue!\r
// e.g. paramName could be a path to the file with spaces\r
if (paramValue != null && paramName.contains(nameValueSeparator)) {\r
- log\r
- .warn("WARN: paramName "\r
- + paramName\r
- + " contains nameValue separator. Removing the separator...");\r
+ log.warn("WARN: paramName "\r
+ + paramName\r
+ + " contains nameValue separator. Removing the separator...");\r
paramName = paramName.trim().substring(0, paramName.length() - 1);\r
}\r
if (paramValue != null && paramName.contains(nameValueSeparator)) {\r
}\r
\r
public boolean setParam(String paramName, String paramValue) {\r
- return setParam( new Parameter(paramName, paramValue));\r
+ return setParam(new Parameter(paramName, paramValue));\r
}\r
\r
public List<String> getCommands() {\r
* is that it accepts a List of Options as an input\r
* \r
* @param arguments\r
- * @return\r
+ * @return the instance of the CommandBuilder\r
*/\r
public static <T> CommandBuilder<T> newCommandBuilder(\r
List<? extends Option<T>> arguments, String nameValueSeparator) {\r
}\r
\r
boolean isWhiteSpaceSeparator() {\r
- return nameValueSeparator.trim().length()==0;\r
+ return nameValueSeparator.trim().length() == 0;\r
}\r
\r
List<Parameter> getCommandList() {\r
* \r
* @param <V>\r
* @param clazz\r
- * @return\r
+ * @return LimitsManager instance\r
* @throws IOException\r
*/\r
public static <V> LimitsManager<V> getRunnerLimits(Class<V> clazz)\r
* Whether a certain path is absolute or not is operation system dependent!\r
* \r
* @param path\r
- * @return\r
+ * @return true is the path is absolute, false otherwise\r
*/\r
public static boolean isAbsolutePath(String path) {\r
assert path != null : "Path is NULL! Not NULL path expected";\r
* handling\r
* \r
* @author pvtroshin\r
- * @date October 2009\r
+ * @version 1.0 October 2009\r
* @param <T>\r
*/\r
public interface PipedExecutable<T> extends Executable<T> {\r
/**\r
* Returns the absolute path to the Java executable from JAVA_HOME\r
* \r
- * @return\r
+ * @return returns the absolute path to the Java executable from JAVA_HOME\r
*/\r
public static String getJava() {\r
String javahome = System.getProperty("java.home");\r
* Single cluster job runner class\r
* \r
* @author pvtroshin\r
- * @date August 2009\r
+ * @version 1.0 August 2009\r
* \r
- * TODO after call to submitJob() no setters really work as the job\r
- * template gets deleted, this needs to be taken into account in this\r
- * class design!\r
+ * TODO after call to submitJob() no setters really work as the job\r
+ * template gets deleted, this needs to be taken into account in this\r
+ * class design!\r
*/\r
public class AsyncJobRunner implements AsyncExecutor {\r
\r
// Once the job has been waited for it will be finished\r
// Next time it will not be found in the session, so removed from the\r
// job list\r
- compbio.engine.client.Util.writeStatFile(compbio.engine.Configurator\r
- .getWorkDirectory(jobId), JobStatus.FINISHED.toString());\r
+ compbio.engine.client.Util.writeStatFile(\r
+ compbio.engine.Configurator.getWorkDirectory(jobId),\r
+ JobStatus.FINISHED.toString());\r
\r
return status;\r
}\r
* in therms of a Sessions, not a JobStatus Should only be used for testing!\r
* \r
* @param status\r
- * @return\r
+ * @return job status\r
* @throws DrmaaException\r
*/\r
@Deprecated\r
public static String getJobStatus(final int status) throws DrmaaException {\r
String statusString = null;\r
switch (status) {\r
- case Session.UNDETERMINED:\r
- statusString = "Job status cannot be determined\n";\r
- break;\r
- case Session.QUEUED_ACTIVE:\r
- statusString = "Job is queued and active\n";\r
- break;\r
- case Session.SYSTEM_ON_HOLD:\r
- statusString = "Job is queued and in system hold\n";\r
- break;\r
- case Session.USER_ON_HOLD:\r
- statusString = "Job is queued and in user hold\n";\r
- break;\r
- case Session.USER_SYSTEM_ON_HOLD:\r
- statusString = "Job is queued and in user and system hold\n";\r
- break;\r
- case Session.RUNNING:\r
- statusString = "Job is running\n";\r
- break;\r
- case Session.SYSTEM_SUSPENDED:\r
- statusString = "Job is system suspended\n";\r
- break;\r
- case Session.USER_SUSPENDED:\r
- statusString = "Job is user suspended\n";\r
- break;\r
- case Session.USER_SYSTEM_SUSPENDED:\r
- statusString = "Job is user and system suspended\n";\r
- break;\r
- case Session.DONE:\r
- statusString = "Job finished normally\n";\r
- break;\r
- case Session.FAILED:\r
- statusString = "Job finished, but failed\n";\r
- break;\r
+ case Session.UNDETERMINED :\r
+ statusString = "Job status cannot be determined\n";\r
+ break;\r
+ case Session.QUEUED_ACTIVE :\r
+ statusString = "Job is queued and active\n";\r
+ break;\r
+ case Session.SYSTEM_ON_HOLD :\r
+ statusString = "Job is queued and in system hold\n";\r
+ break;\r
+ case Session.USER_ON_HOLD :\r
+ statusString = "Job is queued and in user hold\n";\r
+ break;\r
+ case Session.USER_SYSTEM_ON_HOLD :\r
+ statusString = "Job is queued and in user and system hold\n";\r
+ break;\r
+ case Session.RUNNING :\r
+ statusString = "Job is running\n";\r
+ break;\r
+ case Session.SYSTEM_SUSPENDED :\r
+ statusString = "Job is system suspended\n";\r
+ break;\r
+ case Session.USER_SUSPENDED :\r
+ statusString = "Job is user suspended\n";\r
+ break;\r
+ case Session.USER_SYSTEM_SUSPENDED :\r
+ statusString = "Job is user and system suspended\n";\r
+ break;\r
+ case Session.DONE :\r
+ statusString = "Job finished normally\n";\r
+ break;\r
+ case Session.FAILED :\r
+ statusString = "Job finished, but failed\n";\r
+ break;\r
}\r
return statusString;\r
}\r
import org.ggf.drmaa.Session;\r
import org.ggf.drmaa.SessionFactory;\r
\r
-public class _DrmaaExample {\r
+class _DrmaaExample {\r
\r
private static int NBULKS = 3;\r
private static int JOB_CHUNK = 8;\r
import org.ggf.drmaa.SessionFactory;\r
import org.ggf.drmaa.Version;\r
\r
-public class _JobStatus {\r
+class _JobStatus {\r
\r
- \r
- \r
public static void main(String[] args) {\r
\r
SessionFactory factory = SessionFactory.getFactory();\r
* must include this copyright and license notice.\r
*/\r
package compbio.engine.cluster.dundee;\r
-import static compbio.engine.cluster.dundee._QueueConstraints.*;\r
+import static compbio.engine.cluster.dundee._QueueConstraints.FIRST_MEMORY_LIMIT;\r
+import static compbio.engine.cluster.dundee._QueueConstraints.LONG_TIME_LIMIT;\r
+import static compbio.engine.cluster.dundee._QueueConstraints.MAX_MEMORY_LIMIT;\r
+import static compbio.engine.cluster.dundee._QueueConstraints.SHORT_TIME_LIMIT;\r
\r
+@Deprecated\r
public enum _Queue {\r
\r
/*\r
- * devel.q 4Gb or 16Gb 8 hour I\r
- 64bit-pri.q 4Gb or 16Gb 24 hours B\r
- 64bit.q 4Gb or 16Gb None B\r
- bigint.q 32Gb 8 h I\r
- bigmem.q 32Gb None B \r
+ * devel.q 4Gb or 16Gb 8 hour I 64bit-pri.q 4Gb or 16Gb 24 hours B 64bit.q\r
+ * 4Gb or 16Gb None B bigint.q 32Gb 8 h I bigmem.q 32Gb None B\r
*/\r
\r
/**\r
* Order of the constraint reflect the priority of the queue\r
*/\r
- DEVEL(FIRST_MEMORY_LIMIT, SHORT_TIME_LIMIT,"devel.q"), \r
- PRIBIT64(FIRST_MEMORY_LIMIT,LONG_TIME_LIMIT,"64bit-pri.q"), \r
- BIT64(FIRST_MEMORY_LIMIT,0,"64bit.q"), \r
- BIGINT(MAX_MEMORY_LIMIT,SHORT_TIME_LIMIT,"bigint.q"), \r
- BIGMEM(MAX_MEMORY_LIMIT,0,"bigmem.q");\r
- \r
- \r
+ DEVEL(FIRST_MEMORY_LIMIT, SHORT_TIME_LIMIT, "devel.q"), PRIBIT64(\r
+ FIRST_MEMORY_LIMIT, LONG_TIME_LIMIT, "64bit-pri.q"), BIT64(\r
+ FIRST_MEMORY_LIMIT, 0, "64bit.q"), BIGINT(MAX_MEMORY_LIMIT,\r
+ SHORT_TIME_LIMIT, "bigint.q"), BIGMEM(MAX_MEMORY_LIMIT, 0,\r
+ "bigmem.q");\r
+\r
int maxMemory;\r
int maxRuntime;\r
String qname;\r
private _Queue(int maxMemory, int maxRuntime, String qname) {\r
- this.maxMemory=maxMemory;\r
- this.maxRuntime=maxRuntime;\r
- this.qname = qname; \r
+ this.maxMemory = maxMemory;\r
+ this.maxRuntime = maxRuntime;\r
+ this.qname = qname;\r
}\r
- \r
+\r
// -q 64bit.q -l qname=64bit.q -l h_vmem=8000M -l ram=8000M\r
@Override\r
public String toString() {\r
\r
/**\r
* 0 - unlimited\r
+ * \r
* @return max runtime in hours\r
*/\r
- public int getTimeLimit() { \r
+ public int getTimeLimit() {\r
return this.maxRuntime;\r
}\r
- \r
+\r
/**\r
* \r
- * @return true if the queue has time limit, false overwise \r
+ * @return true if the queue has time limit, false overwise\r
*/\r
- public boolean hasTimeLimit() { \r
- return this.maxRuntime != 0; \r
+ public boolean hasTimeLimit() {\r
+ return this.maxRuntime != 0;\r
}\r
/**\r
* return max memory limit in Mb\r
+ * \r
* @return\r
*/\r
- public int getMemoryLimit() { \r
+ public int getMemoryLimit() {\r
return this.maxMemory;\r
}\r
- \r
- public static _Queue getQueueByMemoryRequirements(int maxMemory) { \r
- if(maxMemory>FIRST_MEMORY_LIMIT) {\r
+\r
+ public static _Queue getQueueByMemoryRequirements(int maxMemory) {\r
+ if (maxMemory > FIRST_MEMORY_LIMIT) {\r
return BIGMEM;\r
- } else if(maxMemory<MAX_MEMORY_LIMIT)\r
- return BIT64; \r
- else { \r
- throw new UnsupportedOperationException("Cluster does not support tasks requiring more than 30000M of memory");\r
+ } else if (maxMemory < MAX_MEMORY_LIMIT)\r
+ return BIT64;\r
+ else {\r
+ throw new UnsupportedOperationException(\r
+ "Cluster does not support tasks requiring more than 30000M of memory");\r
}\r
}\r
\r
- public static _Queue getQueue(int maxMemory, int timeLimitInHours) { \r
- if(timeLimitInHours==0) { \r
+ public static _Queue getQueue(int maxMemory, int timeLimitInHours) {\r
+ if (timeLimitInHours == 0) {\r
return getQueueByMemoryRequirements(maxMemory);\r
- } else { \r
- if(timeLimitInHours<=SHORT_TIME_LIMIT) { \r
- if(maxMemory<=FIRST_MEMORY_LIMIT) { \r
+ } else {\r
+ if (timeLimitInHours <= SHORT_TIME_LIMIT) {\r
+ if (maxMemory <= FIRST_MEMORY_LIMIT) {\r
return DEVEL;\r
- }else if(maxMemory<=MAX_MEMORY_LIMIT){ \r
+ } else if (maxMemory <= MAX_MEMORY_LIMIT) {\r
return BIGINT;\r
- } else { \r
- throw new UnsupportedOperationException("Cluster does not support tasks requiring more than 30000M of memory");\r
+ } else {\r
+ throw new UnsupportedOperationException(\r
+ "Cluster does not support tasks requiring more than 30000M of memory");\r
}\r
- } else { \r
+ } else {\r
// timeLimit > 8\r
- if(timeLimitInHours <= LONG_TIME_LIMIT && maxMemory <=FIRST_MEMORY_LIMIT) { \r
- return PRIBIT64; \r
- } else if( maxMemory<= MAX_MEMORY_LIMIT){ \r
+ if (timeLimitInHours <= LONG_TIME_LIMIT\r
+ && maxMemory <= FIRST_MEMORY_LIMIT) {\r
+ return PRIBIT64;\r
+ } else if (maxMemory <= MAX_MEMORY_LIMIT) {\r
return BIGMEM;\r
- } else { \r
- throw new UnsupportedOperationException("Cluster does not support tasks requiring more than 30000M of memory");\r
+ } else {\r
+ throw new UnsupportedOperationException(\r
+ "Cluster does not support tasks requiring more than 30000M of memory");\r
}\r
}\r
}\r
}\r
- \r
- public _Queue getQueue(String queueName) { \r
- switch(this) { \r
- case DEVEL: \r
- if ( queueName.equals(DEVEL.toString())) { \r
- return DEVEL;\r
- }\r
- break;\r
- case PRIBIT64: \r
- if ( queueName.equals(PRIBIT64.toString())) { \r
- return PRIBIT64;\r
- }\r
- break;\r
- case BIT64: \r
- if ( queueName.equals(BIT64.toString())) { \r
- return BIT64;\r
- }\r
- break;\r
- case BIGMEM: \r
- if ( queueName.equals(BIGMEM.toString())) { \r
- return BIGMEM;\r
- }\r
- break;\r
- case BIGINT: \r
- if ( queueName.equals(BIGINT.toString())) { \r
- return BIGINT;\r
- }\r
- break; \r
+\r
+ public _Queue getQueue(String queueName) {\r
+ switch (this) {\r
+ case DEVEL :\r
+ if (queueName.equals(DEVEL.toString())) {\r
+ return DEVEL;\r
+ }\r
+ break;\r
+ case PRIBIT64 :\r
+ if (queueName.equals(PRIBIT64.toString())) {\r
+ return PRIBIT64;\r
+ }\r
+ break;\r
+ case BIT64 :\r
+ if (queueName.equals(BIT64.toString())) {\r
+ return BIT64;\r
+ }\r
+ break;\r
+ case BIGMEM :\r
+ if (queueName.equals(BIGMEM.toString())) {\r
+ return BIGMEM;\r
+ }\r
+ break;\r
+ case BIGINT :\r
+ if (queueName.equals(BIGINT.toString())) {\r
+ return BIGINT;\r
+ }\r
+ break;\r
}\r
// such queue appears to be not defined in the system!\r
- return null; \r
+ return null;\r
}\r
\r
}\r
*/\r
package compbio.engine.cluster.dundee;\r
\r
-public final class _QueueConstraints {\r
+@Deprecated\r
+final class _QueueConstraints {\r
\r
- private _QueueConstraints() {} \r
+ private _QueueConstraints() {\r
+ }\r
\r
public static final int SHORT_TIME_LIMIT = 8;\r
- public static final int LONG_TIME_LIMIT = 24; \r
+ public static final int LONG_TIME_LIMIT = 24;\r
public static final int FIRST_MEMORY_LIMIT = 14000;\r
- public static final int MAX_MEMORY_LIMIT = 30000; \r
-\r
+ public static final int MAX_MEMORY_LIMIT = 30000;\r
\r
}\r
import java.net.URISyntaxException;\r
import java.net.URL;\r
\r
-import javax.naming.ConfigurationException;\r
-\r
import org.apache.log4j.Logger;\r
\r
import compbio.util.PropertyHelper;\r
* \r
* Try 1 - succeed.\r
* \r
- * @return\r
+ * @return an instance\r
*/\r
public static PropertyHelper getPropertyHelper() {\r
if (ph == null) {\r
* binaries WEB-INF classes compbio engine conf If the structure changes it\r
* must be reflected in this method\r
* \r
- * @return\r
- * @throws ConfigurationException\r
+ * @return the local path\r
+ * @throws RuntimeException\r
+ * if cannot determine the local path\r
*/\r
public static String getLocalPath() {\r
String clname = PropertyHelperManager.class.getSimpleName();\r
throws JAXBException {\r
\r
if (classes != null) {\r
- List<Class<?>> classesList = new ArrayList<Class<?>>(Arrays\r
- .asList(classes));\r
+ List<Class<?>> classesList = new ArrayList<Class<?>>(\r
+ Arrays.asList(classes));\r
classesList.add(rootClass);\r
ctx = JAXBContext.newInstance(classesList.toArray(new Class<?>[0]));\r
} else {\r
\r
/**\r
* \r
- * @return\r
+ * @return validator instance\r
* @throws SAXException\r
*/\r
public static Validator getValidator(String schemafile) throws SAXException {\r
}\r
JAXBContext ctx = null;\r
if (classes != null) {\r
- List<Class<?>> classesList = new ArrayList<Class<?>>(Arrays\r
- .asList(classes));\r
+ List<Class<?>> classesList = new ArrayList<Class<?>>(\r
+ Arrays.asList(classes));\r
classesList.add(resultElemType);\r
ctx = JAXBContext.newInstance(classesList.toArray(new Class<?>[0]));\r
} else {\r
\r
import compbio.util.Util;\r
\r
+@Deprecated\r
public final class _Key {\r
\r
public final static String DELIM = "#";\r
.getTask(jobId);\r
// The job has already finished or cancelled.\r
if (future == null) {\r
- log\r
- .debug("Did not find future for local job "\r
- + jobId\r
- + " will not cancel it. Perhaps it has finished or cancelled already.");\r
+ log.debug("Did not find future for local job "\r
+ + jobId\r
+ + " will not cancel it. Perhaps it has finished or cancelled already.");\r
return false;\r
}\r
LocalEngineUtil.cancelJob(future, getWorkDirectory(jobId));\r
/**\r
* \r
* @param jobId\r
- * @return\r
+ * @return true if all files were removed, false otherwise\r
*/\r
@Override\r
public boolean cleanup(String jobId) {\r
* This method returns the single instance of CachedThreadPoolExecutor which\r
* it cashes internally\r
* \r
- * @return\r
+ * @return the instance\r
*/\r
public synchronized static LocalExecutorService getExecutor() {\r
if (INSTANCE == null) {\r
* TODO it may be better to persists task from different place\r
* \r
* @author pvtroshin\r
- * @Date October 2009\r
+ * @version 1.0 October 2009\r
+ * @deprecated\r
*/\r
-public class _TrackingExecutor extends AbstractExecutorService {\r
+@Deprecated\r
+class _TrackingExecutor extends AbstractExecutorService {\r
\r
private final ExecutorService executor;\r
\r
\r
import compbio.engine.cluster.dundee._Queue;\r
\r
+@Deprecated\r
public class _NativeSpecHelper {\r
\r
int maxCalculationTime;\r
import compbio.metadata.Limit;\r
import compbio.metadata.LimitsManager;\r
\r
-public abstract class _SkeletalCommandBuilder implements\r
- Executable<_SkeletalCommandBuilder> {\r
+@Deprecated\r
+public abstract class _SkeletalCommandBuilder\r
+ implements\r
+ Executable<_SkeletalCommandBuilder> {\r
\r
String tmpDirectory;\r
String name;\r
// TODO Auto-generated method stub\r
return null;\r
}\r
- \r
+\r
@Override\r
public String getClusterJobSettings() {\r
// TODO Auto-generated method stub\r
- return null; \r
+ return null;\r
}\r
\r
}\r
* \r
* -clwstrict - write output in clustal format\r
* \r
- * @param workDirectory\r
*/\r
public Muscle() {\r
/*\r
public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
\r
/**\r
- * \r
- * @param workDirectory\r
*/\r
public Probcons() {\r
addParameters(Arrays.asList("-v", "-clustalw", "-annot", ANNOTATION));\r
import compbio.util.PropertyHelper;\r
\r
public class Tcoffee extends SkeletalExecutable<Tcoffee>\r
- implements PipedExecutable<Tcoffee> {\r
+ implements\r
+ PipedExecutable<Tcoffee> {\r
\r
private static Logger log = Logger.getLogger(Tcoffee.class);\r
\r
private final static String ncorePrm = "-n_core";\r
\r
/**\r
- * \r
- * @param workDirectory\r
*/\r
public Tcoffee() {\r
super(KEY_VALUE_SEPARATOR);\r
int cpunum = SkeletalExecutable.getClusterCpuNum(getType());\r
if (cpunum != 0) {\r
setNCore(cpunum);\r
- } \r
+ }\r
}\r
return super.getParameters(provider);\r
}\r
\r
-\r
@SuppressWarnings("unchecked")\r
@Override\r
public Class<Tcoffee> getType() {\r
* tested or tested less then a one second ago.\r
* \r
* @param service\r
- * @return\r
+ * @return when last time tested\r
*/\r
int getLastTested(Services service);\r
/**\r
* \r
* @param jobId\r
* @param position\r
- * @return\r
+ * @return ChunkHolder\r
*/\r
public ChunkHolder pullExecStatistics(String jobId, long position) {\r
// Execution stat is not supported\r
* @author pvtroshin\r
* @date October 2009\r
*/\r
+@Deprecated\r
public class SimpleWSPublisher {\r
\r
- public SimpleWSPublisher(Object exec, String context) {\r
+ public SimpleWSPublisher(Object exec, String context) {\r
\r
- }\r
+ }\r
\r
- public static void main(String[] args) {\r
- if (args.length != 2) {\r
- System.out.println("Usage: ");\r
- System.out.println("SimpleWSPublisher context class");\r
- System.out\r
- .println("where context is a context name, the name after the address by "\r
- + "which web service can be called e.g. Clustal "\r
- + " and class is a web service implementation class");\r
+ public static void main(String[] args) {\r
+ if (args.length != 2) {\r
+ System.out.println("Usage: ");\r
+ System.out.println("SimpleWSPublisher context class");\r
+ System.out\r
+ .println("where context is a context name, the name after the address by "\r
+ + "which web service can be called e.g. Clustal "\r
+ + " and class is a web service implementation class");\r
\r
+ }\r
+ String context = args[0];\r
+ String clazzName = args[1];\r
+ try {\r
+ Class<?> clazz = Class.forName(clazzName);\r
+ if (!clazz.isAnnotationPresent(WebService.class)) {\r
+ System.out.println("Can only start web services. "\r
+ + "Please check whether the class provided is "\r
+ + "annotated with Webservice annotation");\r
+ System.exit(1);\r
+ }\r
+ Endpoint.publish("http://127.0.0.1:7979/" + context,\r
+ clazz.newInstance());\r
+ } catch (InstantiationException e) {\r
+ e.printStackTrace();\r
+ System.exit(1);\r
+ } catch (IllegalAccessException e) {\r
+ e.printStackTrace();\r
+ System.exit(1);\r
+ } catch (ClassNotFoundException e) {\r
+ e.printStackTrace();\r
+ System.exit(1);\r
+ } catch (IllegalArgumentException e) {\r
+ e.printStackTrace();\r
+ System.exit(1);\r
+ }\r
}\r
- String context = args[0];\r
- String clazzName = args[1];\r
- try {\r
- Class<?> clazz = Class.forName(clazzName);\r
- if (!clazz.isAnnotationPresent(WebService.class)) {\r
- System.out.println("Can only start web services. "\r
- + "Please check whether the class provided is "\r
- + "annotated with Webservice annotation");\r
- System.exit(1);\r
- }\r
- Endpoint.publish("http://127.0.0.1:7979/" + context, clazz\r
- .newInstance());\r
- } catch (InstantiationException e) {\r
- e.printStackTrace();\r
- System.exit(1);\r
- } catch (IllegalAccessException e) {\r
- e.printStackTrace();\r
- System.exit(1);\r
- } catch (ClassNotFoundException e) {\r
- e.printStackTrace();\r
- System.exit(1);\r
- } catch (IllegalArgumentException e) {\r
- e.printStackTrace();\r
- System.exit(1);\r
- }\r
- }\r
}\r