From 91a8bb459a0f7101e7006ae62fb614c841fbeae1 Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Fri, 2 Aug 2013 11:41:08 +0100 Subject: [PATCH] Impove coding style --- .../compbio/engine/client/SkeletalExecutable.java | 41 ++++++-------------- .../compbio/engine/conf/PropertyHelperManager.java | 16 ++++---- runner/compbio/runner/disorder/Jronn.java | 20 ++++------ runner/compbio/runner/msa/Mafft.java | 39 ++++--------------- 4 files changed, 34 insertions(+), 82 deletions(-) diff --git a/engine/compbio/engine/client/SkeletalExecutable.java b/engine/compbio/engine/client/SkeletalExecutable.java index 369f8e7..b991440 100644 --- a/engine/compbio/engine/client/SkeletalExecutable.java +++ b/engine/compbio/engine/client/SkeletalExecutable.java @@ -34,8 +34,7 @@ import compbio.util.Util; public abstract class SkeletalExecutable implements Executable { - protected static final PropertyHelper ph = PropertyHelperManager - .getPropertyHelper(); + protected static final PropertyHelper ph = PropertyHelperManager.getPropertyHelper(); private static Logger log = Logger.getLogger(SkeletalExecutable.class); @@ -79,11 +78,8 @@ public abstract class SkeletalExecutable implements Executable { } public SkeletalExecutable setOutput(String outFile) { - if (compbio.util.Util.isEmpty(outFile) - || PathValidator.isAbsolutePath(outFile)) { - throw new IllegalArgumentException( - "Output file must not be NULL and Absolute path could not be used! Please provide the filename only. Value provided: " - + outFile); + if (compbio.util.Util.isEmpty(outFile) || PathValidator.isAbsolutePath(outFile)) { + throw new IllegalArgumentException("Output file must not be NULL and Absolute path could not be used! Please provide the filename only. Value provided: " + outFile); } this.outputFile = outFile; this.isOutputSet = true; @@ -91,11 +87,8 @@ public abstract class SkeletalExecutable implements Executable { } public SkeletalExecutable setError(String errFile) { - if (compbio.util.Util.isEmpty(errFile) - || PathValidator.isAbsolutePath(errFile)) { - throw new IllegalArgumentException( - "Error file must not be NULL and Absolute path could not be used! Please provide the filename only. Value provided: " - + errFile); + if (compbio.util.Util.isEmpty(errFile) || PathValidator.isAbsolutePath(errFile)) { + throw new IllegalArgumentException("Error file must not be NULL and Absolute path could not be used! Please provide the filename only. Value provided: " + errFile); } this.errorFile = errFile; this.isErrorSet = true; @@ -152,8 +145,7 @@ public abstract class SkeletalExecutable implements Executable { // necessary continue; } - String absMatrixPath = compbio.engine.client.Util - .convertToAbsolute(propertyPath); + String absMatrixPath = compbio.engine.client.Util.convertToAbsolute(propertyPath); command.value = absMatrixPath + File.separator + command.value; cbuilder.setParam(command); } @@ -263,20 +255,16 @@ public abstract class SkeletalExecutable implements Executable { @Override public String getClusterJobSettings() { - String settings = ph.getProperty(getType().getSimpleName() - .toLowerCase() + ".cluster.settings"); + String settings = ph.getProperty(getType().getSimpleName().toLowerCase() + ".cluster.settings"); return settings == null ? "" : settings; } /** - * - * @return number of cpus to use on the cluster or 0 if the value is - * undefined + * @return number of cpus to use on the cluster or 0 if the value is undefined */ public static int getClusterCpuNum(Class> type) { int cpus = 0; - String cpuNum = ph.getProperty(type.getSimpleName().toLowerCase() - + ".cluster.cpunum"); + String cpuNum = ph.getProperty(type.getSimpleName().toLowerCase() + ".cluster.cpunum"); if (compbio.util.Util.isEmpty(cpuNum)) { return 0; } @@ -284,15 +272,12 @@ public abstract class SkeletalExecutable implements Executable { cpus = Integer.parseInt(cpuNum); } catch (NumberFormatException e) { // safe to ignore - log.debug("Number of cpus to use for cluster execution is defined but could not be parsed as integer! Given value is: " - + cpuNum); + log.debug("Number of cpus to use for cluster execution is defined but could not be parsed as integer! Given value is: " + cpuNum); return 0; } if (cpus < 1 || cpus > 100) { - throw new InvalidParameterException( - "Number of cpu for cluster execution must be within 1 and 100! " - + "Look at the value of 'tcoffee.cluster.cpunum' property. Given value is " - + cpus); + throw new InvalidParameterException("Number of cpu for cluster execution must be within 1 and 100! " + + "Look at the value of 'tcoffee.cluster.cpunum' property. Given value is " + cpus); } return cpus; } @@ -335,9 +320,7 @@ public abstract class SkeletalExecutable implements Executable { } /** - * * @return subclasses must return their type */ public abstract Class getType(); - } diff --git a/engine/compbio/engine/conf/PropertyHelperManager.java b/engine/compbio/engine/conf/PropertyHelperManager.java index bf33409..0255289 100644 --- a/engine/compbio/engine/conf/PropertyHelperManager.java +++ b/engine/compbio/engine/conf/PropertyHelperManager.java @@ -110,19 +110,17 @@ public final class PropertyHelperManager { f = f.getParentFile(); } } catch (URISyntaxException e) { - String message = "Could not find resources path! Problems locating PropertyHelperManager class! " + e.getLocalizedMessage(); - log.error(message, e.getCause()); - throw new RuntimeException(message, e.getCause()); + String mes = "Could not find resources path! Problems locating PropertyHelperManager class! "; + log.error(mes + e.getLocalizedMessage(), e.getCause()); + throw new RuntimeException(mes + e.getLocalizedMessage(), e.getCause()); } catch (IllegalArgumentException e) { // Classes are in the jar file, using different method to determine // the path new File(INCORRECT URL) throws it - log.debug( - "It looks like classes are in the jar file. " - + "Attempting a different method to determinine the path to the resources " - + e.getLocalizedMessage(), e.getCause()); + String mes = "It looks like classes are in the jar file. " + + "Attempting a different method to determinine the path to the resources"; + log.debug(mes + e.getLocalizedMessage(), e.getCause()); try { - f = new File(PropertyHelperManager.class.getProtectionDomain() - .getCodeSource().getLocation().toURI().getPath()); + f = new File(PropertyHelperManager.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()); // Iterate up the hierarchy to find a root project directory // This time there is not need to walk up all class packages diff --git a/runner/compbio/runner/disorder/Jronn.java b/runner/compbio/runner/disorder/Jronn.java index 55200c2..d9d388f 100644 --- a/runner/compbio/runner/disorder/Jronn.java +++ b/runner/compbio/runner/disorder/Jronn.java @@ -49,10 +49,10 @@ public class Jronn extends SkeletalExecutable { private static Logger log = Logger.getLogger(Jronn.class); - /** - * Number of cores to use, defaults to 1 for local execution or the value of - * "jronn.cluster.cpunum" property for cluster execution - */ +/* + * Number of cores to use, defaults to 1 for local execution or the value of + * "jronn.cluster.cpunum" property for cluster execution + */ private int ncoreNumber = 0; private final String ncorePrm = "-n="; @@ -61,8 +61,7 @@ public class Jronn extends SkeletalExecutable { public static final String STAT_FILE = "stat.txt"; public Jronn() { - addParameters(Arrays.asList("-jar", getLibPath(), "-s=" + STAT_FILE, - "-f=H")); + addParameters(Arrays.asList("-jar", getLibPath(), "-s=" + STAT_FILE, "-f=H")); } @SuppressWarnings("unchecked") @@ -71,10 +70,8 @@ public class Jronn extends SkeletalExecutable { throws ResultNotAvailableException { ScoreManager sequences = null; try { - InputStream inStream = new FileInputStream(new File(workDirectory, - getOutput())); - sequences = ScoreManager.newInstanceSingleScore(SequenceUtil - .readJRonn(inStream)); + InputStream inStream = new FileInputStream(new File(workDirectory, getOutput())); + sequences = ScoreManager.newInstanceSingleScore(SequenceUtil.readJRonn(inStream)); inStream.close(); } catch (FileNotFoundException e) { log.error(e.getMessage(), e.getCause()); @@ -151,8 +148,7 @@ public class Jronn extends SkeletalExecutable { @Override public CommandBuilder getParameters(ExecProvider provider) { - // If number of cores is provided, set it for the cluster execution - // only! + // If number of cores is provided, set it for the cluster execution only! if (provider == Executable.ExecProvider.Cluster) { int cpunum = SkeletalExecutable.getClusterCpuNum(getType()); cpunum = (cpunum == 0) ? 1 : cpunum; diff --git a/runner/compbio/runner/msa/Mafft.java b/runner/compbio/runner/msa/Mafft.java index 86c7599..b360a82 100644 --- a/runner/compbio/runner/msa/Mafft.java +++ b/runner/compbio/runner/msa/Mafft.java @@ -38,16 +38,13 @@ import compbio.runner.Util; * @author pvtroshin * */ -public class Mafft extends SkeletalExecutable - implements - PipedExecutable { - /* - * TODO get rid of piping: Mafft now supports --out option for output file. - * Multi-threading supported with e.g. "thread 4" only for Linux, so JABAWS - * will not support it for now, it also need editing of mafft makefile - */ - - +public class Mafft extends SkeletalExecutable implements PipedExecutable { +/* + * TODO get rid of piping: Mafft now supports --out option for output file. + * Multi-threading supported with e.g. "thread 4" only for Linux, so JABAWS + * will not support it for now, it also need editing of mafft makefile + */ + private static Logger log = Logger.getLogger(Mafft.class); private static String autoOption = "--auto"; @@ -107,26 +104,4 @@ public class Mafft extends SkeletalExecutable public Class getType() { return (Class) this.getClass(); } - - /* - * @Override public List getParameters( - * compbio.runner.Executable.ExecProvider provider) { for (int i = 0; i < - * param.size(); i++) { String par = param.get(i); if - * (isMatrixParameter(par)) { String matrixName = getValue(i); if (new - * File(matrixName).isAbsolute()) { // Matrix can be found so no actions - * necessary // This method has been called already and the matrix name // - * is modified to contain full path // no further actions is necessary - * break; } String matrixPath = Util.getExecProperty("matrix.path", this); - * String absMatrixPath = Util.convertToAbsolute(matrixPath); param.remove(i - * + 1); param.remove(i); super.addParameter(MATRIX_PAR_NAME); - * super.addParameter(absMatrixPath + File.separator + matrixName); break; } - * } return super.getParameters(provider); } - * - * boolean isMatrixParameter(String parameter) { assert - * !compbio.util.Util.isEmpty(parameter); if - * (parameter.toUpperCase().startsWith(MATRIX_PAR_NAME)) { return true; } - * return false; } - * - * String getValue(int i) { return param.get(i + 1); } - */ } -- 1.7.10.2