From d0ec0c90f3e010833af507d2a9ac6b68a031f0d8 Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Tue, 17 Sep 2013 11:22:48 +0100 Subject: [PATCH] Clean up logging system --- .../compbio/data/sequence/RNAStructReader.java | 19 +- engine/compbio/engine/LoadBalancer.java | 6 +- engine/compbio/engine/client/ConfExecutable.java | 3 +- .../engine/conf/RunnerConfigMarshaller.java | 3 +- engine/compbio/engine/local/ExecutableWrapper.java | 1 - runner/compbio/runner/OptionCombinator.java | 251 +++++++++----------- runner/compbio/runner/Util.java | 47 +--- runner/compbio/runner/conservation/AACon.java | 5 - runner/compbio/runner/disorder/Disembl.java | 7 +- runner/compbio/runner/disorder/GlobPlot.java | 6 +- runner/compbio/runner/disorder/IUPred.java | 9 +- runner/compbio/runner/disorder/Jronn.java | 4 +- runner/compbio/runner/msa/ClustalO.java | 12 +- runner/compbio/runner/msa/ClustalW.java | 2 +- runner/compbio/runner/msa/Mafft.java | 2 +- runner/compbio/runner/msa/Muscle.java | 2 +- runner/compbio/runner/msa/Probcons.java | 2 +- runner/compbio/runner/msa/Tcoffee.java | 3 +- runner/compbio/runner/structure/RNAalifold.java | 7 +- webservices/compbio/stat/collector/DirCleaner.java | 8 - .../compbio/stat/collector/InputFilter.java | 9 +- webservices/compbio/stat/servlet/DisplayStat.java | 15 +- .../servlet/HttpCodeResponseServiceStatus.java | 6 +- .../compbio/stat/servlet/util/StatCollection.java | 1 - webservices/compbio/ws/client/AAConClient.java | 74 ++---- webservices/compbio/ws/client/Jws2Client.java | 4 - webservices/compbio/ws/server/GAUtils.java | 6 +- webservices/compbio/ws/server/WSUtil.java | 46 +--- 28 files changed, 183 insertions(+), 377 deletions(-) diff --git a/datamodel/compbio/data/sequence/RNAStructReader.java b/datamodel/compbio/data/sequence/RNAStructReader.java index 4292554..4fd364a 100644 --- a/datamodel/compbio/data/sequence/RNAStructReader.java +++ b/datamodel/compbio/data/sequence/RNAStructReader.java @@ -17,8 +17,6 @@ import org.apache.log4j.Logger; public class RNAStructReader { - private static Logger log = Logger.getLogger(RNAStructReader.class); - // Whitespace patterns static String s = "[+\\s=]+"; static String bracket = "\\(|\\)|\\{|\\}|\\[|\\]"; @@ -124,15 +122,13 @@ public class RNAStructReader { assert (sline != null && Pattern.matches(AlifoldLine.ensembleFreq.regex, sline)) : error + "Found 'freeEnergy' line on its own"; - structs.add("Free energy of ensemble (kcal/mol) followed by " - + "frequency of mfe structure in ensemble"); + structs.add("Free energy of ensemble (kcal/mol) followed by frequency of mfe structure in ensemble"); scores.add(Float.parseFloat(sc.findInLine(floatP))); scores.add(Float.parseFloat(nsc.findInLine(floatP))); data.add(newSetScore(AlifoldResult.ensembleValues, scores)); // jump line sline = reader.readLine(); } - assert(!ftype.equals(AlifoldLine.ensembleFreq)) : error + "Wasn't expecting 'frequency of mfe structure'!"; @@ -142,11 +138,7 @@ public class RNAStructReader { error + "Wasn't expecting an alignment sequence!"; assert(!ftype.equals(AlifoldLine.OTHER)) : error + "Wasn't expecting this whatever it is: " + fline; - if (Pattern.matches("^\\s*$", fline)) { - log.warn("While parsing alifold stdout: A line is either empty or" - + " contains only whitespace"); - } - + fline = sline; } @@ -237,7 +229,7 @@ public class RNAStructReader { } else if (Pattern.matches(freqP, token)) { return RNAOut.FREQ; } - + return RNAOut.OTHER; } @@ -277,7 +269,6 @@ public class RNAStructReader { public static enum AlifoldResult { mfeStructure, contactProbabilityStructure, MEAStucture, centroidStructure, stochBTStructure, consensusAlignment, ensembleValues, contactProbabilities } - // Print the full regex Strings for testing public static void main(String[] args) { @@ -285,7 +276,5 @@ public class RNAStructReader { System.out.println(l.toString() + ": " + l.regex.replace("^","").replace("$","")); } } - - -} +} diff --git a/engine/compbio/engine/LoadBalancer.java b/engine/compbio/engine/LoadBalancer.java index 6185d42..e73e283 100644 --- a/engine/compbio/engine/LoadBalancer.java +++ b/engine/compbio/engine/LoadBalancer.java @@ -58,10 +58,8 @@ public class LoadBalancer { // If data set is deemed too big for local execution, than give a // cluster engine // If limit is not defined then defaults to executing on the cluster - Limit limit = executable - .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET); - log.trace("Inspecting whether the job can be executed locally using limit: " - + limit); + Limit limit = executable.getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET); + log.trace("Inspecting whether the job can be executed locally using limit: " + limit); if (limit == null || limit.isExceeded(dataSet)) { log.debug("Job EXCEEDS LOCAL execution LIMIT targeting for cluster execution! "); return Executable.ExecProvider.Cluster; diff --git a/engine/compbio/engine/client/ConfExecutable.java b/engine/compbio/engine/client/ConfExecutable.java index d5fbbe7..d8260c8 100644 --- a/engine/compbio/engine/client/ConfExecutable.java +++ b/engine/compbio/engine/client/ConfExecutable.java @@ -67,8 +67,7 @@ public class ConfExecutable implements ConfiguredExecutable { // TODO think about appropriate exception here ConfExecutable(RunConfiguration rconf) { try { - exec = (Executable) Class.forName(rconf.runnerClassName) - .newInstance(); + exec = (Executable) Class.forName(rconf.runnerClassName).newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { diff --git a/engine/compbio/engine/conf/RunnerConfigMarshaller.java b/engine/compbio/engine/conf/RunnerConfigMarshaller.java index 4fbd3a0..b206eb6 100644 --- a/engine/compbio/engine/conf/RunnerConfigMarshaller.java +++ b/engine/compbio/engine/conf/RunnerConfigMarshaller.java @@ -46,8 +46,7 @@ import compbio.util.SysPrefs; public class RunnerConfigMarshaller { - private static final Logger log = Logger - .getLogger(RunnerConfigMarshaller.class); + private static final Logger log = Logger.getLogger(RunnerConfigMarshaller.class); private final JAXBContext ctx; diff --git a/engine/compbio/engine/local/ExecutableWrapper.java b/engine/compbio/engine/local/ExecutableWrapper.java index 5809be4..8718013 100644 --- a/engine/compbio/engine/local/ExecutableWrapper.java +++ b/engine/compbio/engine/local/ExecutableWrapper.java @@ -24,7 +24,6 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.util.List; -import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; diff --git a/runner/compbio/runner/OptionCombinator.java b/runner/compbio/runner/OptionCombinator.java index a19cafa..86bf35d 100644 --- a/runner/compbio/runner/OptionCombinator.java +++ b/runner/compbio/runner/OptionCombinator.java @@ -48,164 +48,149 @@ import compbio.util.annotation.Immutable; @Immutable public final class OptionCombinator { - private static Logger log = Logger.getLogger(OptionCombinator.class); - private static final String MINVALUE = "-100"; - private static final String MAXVALUE = "100"; - - private static final Random rand = new Random(); - private final RunnerConfig> rconfig; + private static Logger log = Logger.getLogger(OptionCombinator.class); + private static final String MINVALUE = "-100"; + private static final String MAXVALUE = "100"; + + private static final Random rand = new Random(); + private final RunnerConfig> rconfig; + + public OptionCombinator(RunnerConfig> rconfig) { + if (rconfig == null) { + throw new IllegalArgumentException("RunnerConfig must be provided!"); + } + this.rconfig = rconfig; + } - public OptionCombinator(RunnerConfig> rconfig) { - if (rconfig == null) { - throw new IllegalArgumentException("RunnerConfig must be provided!"); + public List optionsToCommandString(List> options) { + List strOptions = new ArrayList(); + for (Option option : options) { + strOptions.add(optionToCommandString(option)); + } + return strOptions; } - this.rconfig = rconfig; - } - public List optionsToCommandString(List> options) { - List strOptions = new ArrayList(); - for (Option option : options) { - strOptions.add(optionToCommandString(option)); + public List getOptionsAtRandom() { + return optionsToCommandString(getAllOptions()); } - return strOptions; - } - - public List getOptionsAtRandom() { - return optionsToCommandString(getAllOptions()); - } - - public List> getAllOptions() { - return new ArrayList>(rconfig.getOptions()); - } - - static String optionToCommandString(Option option) { - int size = option.getOptionNames().size(); - int idx = rand.nextInt(size); - return option.getOptionNames().get(idx); - } - - public List> getAllParameters() { - List> args = new ArrayList>(); - for (Parameter prm : rconfig.getParameters()) { - // Make sure there is a default value linked to the parameter to use - // later - // prm.setDefaultValue(getValue(prm)); - args.add(prm); + + public List> getAllOptions() { + return new ArrayList>(rconfig.getOptions()); } - return args; - } - public List argumentsToCommandString( - List> arguments) { - return argumentsToCommandString(arguments, rconfig); - } + static String optionToCommandString(Option option) { + int size = option.getOptionNames().size(); + int idx = rand.nextInt(size); + return option.getOptionNames().get(idx); + } - public static List argumentsToCommandString( - List> arguments, - RunnerConfig> rconfig) { + public List> getAllParameters() { + List> args = new ArrayList>(); + for (Parameter prm : rconfig.getParameters()) { + // Make sure there is a default value linked to the parameter to use later + // prm.setDefaultValue(getValue(prm)); + args.add(prm); + } + return args; + } - if (arguments == null || rconfig == null) { - throw new NullPointerException( - "Arguments and RunnerConfig objects must be provided!"); + public List argumentsToCommandString(List> arguments) { + return argumentsToCommandString(arguments, rconfig); } - List command = new ArrayList(); - for (Option option : arguments) { - - if (option instanceof Parameter) { - Parameter prm = (Parameter) option; - command.add(prm.getOptionName() + rconfig.getPrmSeparator() - + getValue(prm)); - log.trace("Setting parameter " + prm); - } else { - log.trace("Setting option " + option); - command.add(optionToCommandString(option)); - } + public static List argumentsToCommandString(List> arguments,RunnerConfig> rconfig) { + if (arguments == null || rconfig == null) { + throw new NullPointerException("Arguments and RunnerConfig objects must be provided!"); + } + + List command = new ArrayList(); + for (Option option : arguments) { + if (option instanceof Parameter) { + Parameter prm = (Parameter) option; + command.add(prm.getOptionName() + rconfig.getPrmSeparator() + getValue(prm)); + log.trace("Setting parameter " + prm); + } else { + log.trace("Setting option " + option); + command.add(optionToCommandString(option)); + } + } + return command; } - return command; - } - - public List parametersToCommandString( - List> orderedList, Map, String> prmValue) { - List args = new ArrayList(); - for (Parameter param : orderedList) { - args.add(param.getOptionName() + rconfig.getPrmSeparator() - + prmValue.get(param)); + + public List parametersToCommandString(List> orderedList, Map, String> prmValue) { + List args = new ArrayList(); + for (Parameter param : orderedList) { + args.add(param.getOptionName() + rconfig.getPrmSeparator() + prmValue.get(param)); + } + return args; } - return args; - } - public Map, String> getAllConstrainedParametersWithBorderValues( - boolean minValue) { - Map, String> paramValue = new HashMap, String>(); - for (Parameter prm : rconfig.getParameters()) { - ValueConstrain vc = prm.getValidValue(); - if (vc == null) { - continue; - } - String value = ""; - if (minValue) { - value = getLowBorderValue(prm); - } else { - value = getUpperBorderValue(prm); - } - paramValue.put(prm, value); + public Map, String> getAllConstrainedParametersWithBorderValues( boolean minValue) { + Map, String> paramValue = new HashMap, String>(); + for (Parameter prm : rconfig.getParameters()) { + ValueConstrain vc = prm.getValidValue(); + if (vc == null) { + continue; + } + String value = getUpperBorderValue(prm); + if (minValue) { + value = getLowBorderValue(prm); + } + paramValue.put(prm, value); + } + return paramValue; } - return paramValue; - } - public Map, String> getAllConstrainedParametersWithRandomValues() { + public Map, String> getAllConstrainedParametersWithRandomValues() { Map, String> paramValue = new HashMap, String>(); - for (Parameter prm : rconfig.getParameters()) { - ValueConstrain vc = prm.getValidValue(); - if (vc == null) { - continue; - } - paramValue.put(prm, getRandomValue(prm)); + for (Parameter prm : rconfig.getParameters()) { + ValueConstrain vc = prm.getValidValue(); + if (vc == null) { + continue; + } + paramValue.put(prm, getRandomValue(prm)); + } + return paramValue; } - return paramValue; - } - String getLowBorderValue(Parameter param) { - assert param != null; - ValueConstrain vc = param.getValidValue(); - Number minVal = vc.getMin(); - return minVal == null ? MINVALUE : minVal.toString(); - } + String getLowBorderValue(Parameter param) { + assert param != null; + ValueConstrain vc = param.getValidValue(); + Number minVal = vc.getMin(); + return minVal == null ? MINVALUE : minVal.toString(); + } - String getUpperBorderValue(Parameter param) { - assert param != null; - ValueConstrain vc = param.getValidValue(); - Number maxVal = vc.getMax(); - return maxVal == null ? MAXVALUE : maxVal.toString(); - } + String getUpperBorderValue(Parameter param) { + assert param != null; + ValueConstrain vc = param.getValidValue(); + Number maxVal = vc.getMax(); + return maxVal == null ? MAXVALUE : maxVal.toString(); + } - String getRandomValue(Parameter param) { - assert param != null; - String low = getLowBorderValue(param); - String high = getUpperBorderValue(param); - ValueConstrain vc = param.getValidValue(); + String getRandomValue(Parameter param) { + assert param != null; + String low = getLowBorderValue(param); + String high = getUpperBorderValue(param); + ValueConstrain vc = param.getValidValue(); - if (vc.getType() == ValueConstrain.Type.Float) { - return new Double(Util.getRandomNumber(Double.parseDouble(low), - Double.parseDouble(high))).toString(); + if (vc.getType() == ValueConstrain.Type.Float) { + return new Double(Util.getRandomNumber(Double.parseDouble(low), Double.parseDouble(high))).toString(); + } + return new Integer(Util.getRandomNumber(Integer.parseInt(low), Integer.parseInt(high))).toString(); } - return new Integer(Util.getRandomNumber(Integer.parseInt(low), Integer - .parseInt(high))).toString(); - } - static String getValue(Parameter param) { + static String getValue(Parameter param) { assert param != null; if (param.getDefaultValue() != null) { - log.trace("Returning default value: " + param.getDefaultValue()); - return param.getDefaultValue(); + log.trace("Returning default value: " + param.getDefaultValue()); + return param.getDefaultValue(); } else { - // Some parameters do not have default values e.g. seq type - nuc or - // protein - List passValues = param.getPossibleValues(); - int idx = rand.nextInt(passValues.size()); - log.trace("Returning random value: " + passValues.get(idx)); - return passValues.get(idx); + // Some parameters do not have default values e.g. seq type - nuc or protein + List passValues = param.getPossibleValues(); + int idx = rand.nextInt(passValues.size()); + log.trace("Returning random value: " + passValues.get(idx)); + return passValues.get(idx); + } } - } + } diff --git a/runner/compbio/runner/Util.java b/runner/compbio/runner/Util.java index 6f0ec09..a0123a2 100644 --- a/runner/compbio/runner/Util.java +++ b/runner/compbio/runner/Util.java @@ -20,24 +20,11 @@ package compbio.runner; import java.io.File; import java.io.FileInputStream; -import java.io.FileReader; -import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.util.Arrays; import java.util.List; -import java.util.ArrayList; import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.TreeMap; -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import java.util.Scanner; - - - import org.apache.log4j.Logger; @@ -46,29 +33,20 @@ import compbio.data.sequence.ClustalAlignmentUtil; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.RNAStructScoreManager; import compbio.data.sequence.Score; -import compbio.data.sequence.ScoreManager; -import compbio.data.sequence.Range; import compbio.data.sequence.RNAStructReader; import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; import compbio.engine.client.ConfExecutable; import compbio.engine.client.ConfiguredExecutable; import compbio.engine.client.Executable; -import compbio.engine.conf.PropertyHelperManager; import compbio.metadata.JobSubmissionException; import compbio.metadata.PresetManager; import compbio.metadata.RunnerConfig; -import compbio.util.PropertyHelper; public final class Util { public static Logger log = Logger.getLogger(Util.class); - private static final PropertyHelper ph = PropertyHelperManager - .getPropertyHelper(); - - public static final String SPACE = " "; - public static synchronized RunnerConfig getSupportedOptions( Class> clazz) { try { @@ -133,7 +111,6 @@ public final class Util { public static void writeInput(List sequences, ConfiguredExecutable exec) throws JobSubmissionException { - try { File filein = new File(exec.getInput()); FileOutputStream fout = new FileOutputStream(filein); @@ -148,7 +125,7 @@ public final class Util { + e.getLocalizedMessage(), e); } } - + public static void writeClustalInput(List sequences, ConfiguredExecutable exec, char gapChar) throws JobSubmissionException { @@ -167,7 +144,6 @@ public final class Util { } } - public static RNAStructScoreManager readRNAStruct(String workDirectory, String structFile) throws IOException, FileNotFoundException { @@ -196,28 +172,7 @@ public final class Util { new FileInputStream(aliFile)); } } - - - public static String readFile(File inputFile) throws - FileNotFoundException, IOException { - - BufferedReader input = new BufferedReader(new FileReader(inputFile)); - - String file = new String(); - String line = new String(); - - while (true) { - line = input.readLine(); - - if (line != null) { - file = file + line + "\r\n"; - } else break; - } - // Close file - input.close(); - return file; - } } diff --git a/runner/compbio/runner/conservation/AACon.java b/runner/compbio/runner/conservation/AACon.java index 0f96077..d34bb09 100644 --- a/runner/compbio/runner/conservation/AACon.java +++ b/runner/compbio/runner/conservation/AACon.java @@ -28,7 +28,6 @@ import java.util.List; import org.apache.log4j.Logger; -import compbio.data.sequence.SMERFSConstraints; import compbio.data.sequence.ScoreManager; import compbio.data.sequence.SequenceUtil; import compbio.engine.client.CommandBuilder; @@ -59,10 +58,6 @@ public class AACon extends SkeletalExecutable { public static final String KEY_VALUE_SEPARATOR = "="; public static final String STAT_FILE = "stat.txt"; - private final int windowWidth = SMERFSConstraints.DEFAULT_WINDOW_SIZE; - private final SMERFSConstraints colScoreMethod = SMERFSConstraints.MID_SCORE; - private final double gapTreshold = SMERFSConstraints.DEFAULT_GAP_THRESHOLD; - public AACon() { addParameters(Arrays.asList("-jar", getLibPath(), "-d=" + STAT_FILE, "-f=RESULT_NO_ALIGNMENT")); diff --git a/runner/compbio/runner/disorder/Disembl.java b/runner/compbio/runner/disorder/Disembl.java index 7c54af1..46b2e5c 100644 --- a/runner/compbio/runner/disorder/Disembl.java +++ b/runner/compbio/runner/disorder/Disembl.java @@ -53,14 +53,10 @@ import compbio.runner.Util; * This is not a standard DisEMBL! The script has been modified! * */ -public class Disembl extends SkeletalExecutable - implements - PipedExecutable { +public class Disembl extends SkeletalExecutable implements PipedExecutable { private static Logger log = Logger.getLogger(Disembl.class); - public static final String KEY_VALUE_SEPARATOR = Util.SPACE; - /** * For the region to be considered disordered the values must exceed these */ @@ -104,6 +100,7 @@ public class Disembl extends SkeletalExecutable log.trace("DRESULTS: " + results); return results; } + @Override public Disembl setInput(String inFile) { super.setInput(inFile); diff --git a/runner/compbio/runner/disorder/GlobPlot.java b/runner/compbio/runner/disorder/GlobPlot.java index 6530f5f..a20a8d2 100644 --- a/runner/compbio/runner/disorder/GlobPlot.java +++ b/runner/compbio/runner/disorder/GlobPlot.java @@ -46,14 +46,10 @@ import compbio.runner.Util; * This is not a standard GlobPlot! The script has been modified! * */ -public class GlobPlot extends SkeletalExecutable - implements - PipedExecutable { +public class GlobPlot extends SkeletalExecutable implements PipedExecutable { private static Logger log = Logger.getLogger(GlobPlot.class); - public static final String KEY_VALUE_SEPARATOR = Util.SPACE; - /* The parameter list there must not contain same values! */ public GlobPlot() { // remove default input to prevent it to appear in the parameters list diff --git a/runner/compbio/runner/disorder/IUPred.java b/runner/compbio/runner/disorder/IUPred.java index 5d20829..2092ab0 100644 --- a/runner/compbio/runner/disorder/IUPred.java +++ b/runner/compbio/runner/disorder/IUPred.java @@ -15,10 +15,7 @@ package compbio.runner.disorder; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; -import java.util.Arrays; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; @@ -32,7 +29,6 @@ import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; -import compbio.runner.msa.Mafft; /** * iupred sequenceFile @@ -48,7 +44,6 @@ public class IUPred extends SkeletalExecutable { private static final String SHORT_OUTPUT = "out.short"; private static final String LONG_OUTPUT = "out.long"; - @Override @SuppressWarnings("unchecked") public ScoreManager getResults(String workDirectory) @@ -109,8 +104,6 @@ public class IUPred extends SkeletalExecutable { } } - - @Override public IUPred setInput(String inFile) { super.setInput(inFile); @@ -118,7 +111,6 @@ public class IUPred extends SkeletalExecutable { return this; } - @Override public IUPred setOutput(String outFile) { log.warn("IUpred output is predefined and cannot be set!"); @@ -130,6 +122,7 @@ public class IUPred extends SkeletalExecutable { "are always either of those 3 files (depending on the method called): " + GLOB_OUTPUT + ", " + SHORT_OUTPUT + ", "+ LONG_OUTPUT); } + @Override public String getOutput() { log.warn("IUpred output is predefined and is one of the three files " + diff --git a/runner/compbio/runner/disorder/Jronn.java b/runner/compbio/runner/disorder/Jronn.java index d9d388f..55a1868 100644 --- a/runner/compbio/runner/disorder/Jronn.java +++ b/runner/compbio/runner/disorder/Jronn.java @@ -57,7 +57,6 @@ public class Jronn extends SkeletalExecutable { private final String ncorePrm = "-n="; - public static final String KEY_VALUE_SEPARATOR = Util.SPACE; public static final String STAT_FILE = "stat.txt"; public Jronn() { @@ -93,8 +92,7 @@ public class Jronn extends SkeletalExecutable { String settings = ph.getProperty("jronn.jar.file"); if (compbio.util.Util.isEmpty(settings)) { throw new NullPointerException( - "Please define jronn.jar.file property in Executable.properties file" - + "and initialize it with the location of jronn jar file"); + "Please define jronn.jar.file property in Executable.properties file and initialize it with the location of jronn jar file"); } if (new File(settings).isAbsolute()) { // Jronn jar can be found so no actions necessary diff --git a/runner/compbio/runner/msa/ClustalO.java b/runner/compbio/runner/msa/ClustalO.java index e5c93b3..da35cee 100644 --- a/runner/compbio/runner/msa/ClustalO.java +++ b/runner/compbio/runner/msa/ClustalO.java @@ -36,12 +36,12 @@ import compbio.runner.Util; public class ClustalO extends SkeletalExecutable { private static Logger log = Logger.getLogger(ClustalO.class); + private static final String EXEC_STAT_FILE = "stat.log"; - public static final String KEY_VALUE_SEPARATOR = "="; - /* + /** * Number of cores parameter name */ private final static String ncorePrm = "--threads"; @@ -52,7 +52,6 @@ public class ClustalO extends SkeletalExecutable { */ private int ncoreNumber = 0; - /** * --threads= Number of processors to use * @@ -60,8 +59,7 @@ public class ClustalO extends SkeletalExecutable { */ public ClustalO() { super(KEY_VALUE_SEPARATOR); - addParameters(Arrays.asList("--outfmt=clustal", "-v", "--log=" - + EXEC_STAT_FILE)); + addParameters(Arrays.asList("--outfmt=clustal", "-v", "--log=" + EXEC_STAT_FILE)); // set default in, outs and err files this.setInput(super.inputFile); this.setOutput(super.outputFile); @@ -130,8 +128,7 @@ public class ClustalO extends SkeletalExecutable { public void setNCore(int ncoreNumber) { if (ncoreNumber < 1 || ncoreNumber > 100) { - throw new IndexOutOfBoundsException( - "Number of cores must be within 1 and 100 "); + throw new IndexOutOfBoundsException("Number of cores must be within 1 and 100 "); } this.ncoreNumber = ncoreNumber; cbuilder.setParam(ncorePrm, Integer.toString(getNCore())); @@ -141,5 +138,4 @@ public class ClustalO extends SkeletalExecutable { return ncoreNumber; } - } diff --git a/runner/compbio/runner/msa/ClustalW.java b/runner/compbio/runner/msa/ClustalW.java index 16b5734..a3bab89 100644 --- a/runner/compbio/runner/msa/ClustalW.java +++ b/runner/compbio/runner/msa/ClustalW.java @@ -89,7 +89,7 @@ public class ClustalW extends SkeletalExecutable { convertInputNameToTreeName()); } - /* + /** * Clustal output tree with same name as input file but .dnd extension e.g. * this methods do similar conversion TO122.fasta -> TO122.dnd or * TO122.fasta.in -> TO122.fasta.dnd It does not seems that there is any diff --git a/runner/compbio/runner/msa/Mafft.java b/runner/compbio/runner/msa/Mafft.java index b360a82..fb5ca60 100644 --- a/runner/compbio/runner/msa/Mafft.java +++ b/runner/compbio/runner/msa/Mafft.java @@ -51,7 +51,7 @@ public class Mafft extends SkeletalExecutable implements PipedExecutable< private final String MATRIX_PAR_NAME = "--aamatrix"; - public static final String KEY_VALUE_SEPARATOR = Util.SPACE; + public static final String KEY_VALUE_SEPARATOR = " "; public Mafft() { // remove default input to prevent it to appear in the parameters list diff --git a/runner/compbio/runner/msa/Muscle.java b/runner/compbio/runner/msa/Muscle.java index 54c7732..20c76ac 100644 --- a/runner/compbio/runner/msa/Muscle.java +++ b/runner/compbio/runner/msa/Muscle.java @@ -43,7 +43,7 @@ public class Muscle extends SkeletalExecutable { private static final String EXEC_STAT_FILE = "stat.log"; - public static final String KEY_VALUE_SEPARATOR = Util.SPACE; + public static final String KEY_VALUE_SEPARATOR = " "; /** * Default options are diff --git a/runner/compbio/runner/msa/Probcons.java b/runner/compbio/runner/msa/Probcons.java index 532ba30..c4f2015 100644 --- a/runner/compbio/runner/msa/Probcons.java +++ b/runner/compbio/runner/msa/Probcons.java @@ -40,7 +40,7 @@ public class Probcons extends SkeletalExecutable private final static String ANNOTATION = "annotation.txt"; - public static final String KEY_VALUE_SEPARATOR = Util.SPACE; + public static final String KEY_VALUE_SEPARATOR = " "; /** */ diff --git a/runner/compbio/runner/msa/Tcoffee.java b/runner/compbio/runner/msa/Tcoffee.java index 645b994..7108bec 100644 --- a/runner/compbio/runner/msa/Tcoffee.java +++ b/runner/compbio/runner/msa/Tcoffee.java @@ -42,8 +42,7 @@ public class Tcoffee extends SkeletalExecutable private static Logger log = Logger.getLogger(Tcoffee.class); - private static PropertyHelper ph = PropertyHelperManager - .getPropertyHelper(); + private static PropertyHelper ph = PropertyHelperManager.getPropertyHelper(); public static final String KEY_VALUE_SEPARATOR = "="; diff --git a/runner/compbio/runner/structure/RNAalifold.java b/runner/compbio/runner/structure/RNAalifold.java index 918918e..996e7d8 100644 --- a/runner/compbio/runner/structure/RNAalifold.java +++ b/runner/compbio/runner/structure/RNAalifold.java @@ -1,6 +1,5 @@ package compbio.runner.structure; - import java.io.FileNotFoundException; import java.io.IOException; @@ -14,13 +13,12 @@ import compbio.runner.Util; public class RNAalifold extends SkeletalExecutable implements PipedExecutable { - - + private static Logger log = Logger.getLogger(RNAalifold.class); // May not be necessary as defult is "" but still dont know // How to deal with different key value separators for different params - public static final String KEY_VALUE_SEPARATOR = Util.SPACE; + public static final String KEY_VALUE_SEPARATOR = " "; public RNAalifold() { super(KEY_VALUE_SEPARATOR); @@ -51,7 +49,6 @@ public class RNAalifold extends SkeletalExecutable throws ResultNotAvailableException { try { return Util.readRNAStruct(workDirectory, getOutput()); - } catch (FileNotFoundException e) { log.error(e.getMessage(), e.getCause()); throw new ResultNotAvailableException(e); diff --git a/webservices/compbio/stat/collector/DirCleaner.java b/webservices/compbio/stat/collector/DirCleaner.java index 0171128..f3e2118 100644 --- a/webservices/compbio/stat/collector/DirCleaner.java +++ b/webservices/compbio/stat/collector/DirCleaner.java @@ -19,21 +19,13 @@ package compbio.stat.collector; import java.io.File; import java.io.FileFilter; -import java.io.IOException; -import java.sql.SQLException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; import org.apache.log4j.Logger; import compbio.engine.Cleaner; -import compbio.engine.client.Executable; import compbio.engine.client.PathValidator; -import compbio.engine.client.SkeletalExecutable; -import compbio.metadata.JobStatus; import compbio.stat.collector.JobStat; -import compbio.util.FileUtil; /** * Number of runs of each WS = number of folders with name diff --git a/webservices/compbio/stat/collector/InputFilter.java b/webservices/compbio/stat/collector/InputFilter.java index 4c36445..03466fe 100644 --- a/webservices/compbio/stat/collector/InputFilter.java +++ b/webservices/compbio/stat/collector/InputFilter.java @@ -40,6 +40,7 @@ public class InputFilter { private static boolean compareLines(File input, String[] reference) { BufferedReader reader = null; + boolean status = true; try { reader = new BufferedReader(new FileReader(input)); // only compare first four lines of the file with reference @@ -47,11 +48,13 @@ public class InputFilter { for (int i = 0; i < 4; i++) { String line = reader.readLine(); if (Util.isEmpty(line)) { - return false; + status = false; + break; } line = line.trim(); if (!line.equals(reference[i].trim())) { - return false; + status = false; + break; } } reader.close(); @@ -60,6 +63,6 @@ public class InputFilter { } finally { FileUtil.closeSilently(reader); } - return true; + return status; } } diff --git a/webservices/compbio/stat/servlet/DisplayStat.java b/webservices/compbio/stat/servlet/DisplayStat.java index 119b9b1..86f3e05 100644 --- a/webservices/compbio/stat/servlet/DisplayStat.java +++ b/webservices/compbio/stat/servlet/DisplayStat.java @@ -49,28 +49,23 @@ public class DisplayStat extends HttpServlet { toCal.add(Calendar.MONTH, 1); try { - StatCollection stats = StatCollection.newStatCollecton(fromDate, - toCal.getTime()); + StatCollection stats = StatCollection.newStatCollecton(fromDate, toCal.getTime()); log.trace("Stats: " + stats); req.setAttribute("stat", stats); req.setAttribute("statTotal", Totals.sumStats(stats.getAllStat())); - req.setAttribute("statTotalCluster", - Totals.sumStats(stats.getClusterStat())); - req.setAttribute("statTotalLocal", - Totals.sumStats(stats.getLocalStat())); + req.setAttribute("statTotalCluster", Totals.sumStats(stats.getClusterStat())); + req.setAttribute("statTotalLocal", Totals.sumStats(stats.getLocalStat())); req.setAttribute("startDate", fromDate); req.setAttribute("stopDate", toCal.getTime()); log.trace("from " + fromDate + " to " + toCal.getTime()); - RequestDispatcher dispatcher = req - .getRequestDispatcher("statpages/Statistics.jsp"); + RequestDispatcher dispatcher = req.getRequestDispatcher("statpages/Statistics.jsp"); dispatcher.forward(req, resp); - } catch (SQLException e) { log.error(e.getMessage(), e); throw new ServletException(e); } - } + } diff --git a/webservices/compbio/stat/servlet/HttpCodeResponseServiceStatus.java b/webservices/compbio/stat/servlet/HttpCodeResponseServiceStatus.java index 35a35a4..b36f700 100644 --- a/webservices/compbio/stat/servlet/HttpCodeResponseServiceStatus.java +++ b/webservices/compbio/stat/servlet/HttpCodeResponseServiceStatus.java @@ -71,8 +71,7 @@ public class HttpCodeResponseServiceStatus extends HttpServlet { // convert it to http://localhost:8080/jabaws StringBuffer jabawspath = req.getRequestURL(); jabawspath = jabawspath.delete( - jabawspath.indexOf("/" - + HttpCodeResponseServiceStatus.class.getSimpleName()), + jabawspath.indexOf("/" + HttpCodeResponseServiceStatus.class.getSimpleName()), jabawspath.length()); boolean operating = false; // save for the future use @@ -110,8 +109,7 @@ public class HttpCodeResponseServiceStatus extends HttpServlet { "Service: " + failedService + "\n is not available! Error message:\n " + failMessage); - } - } + } diff --git a/webservices/compbio/stat/servlet/util/StatCollection.java b/webservices/compbio/stat/servlet/util/StatCollection.java index 88d96bb..c646207 100644 --- a/webservices/compbio/stat/servlet/util/StatCollection.java +++ b/webservices/compbio/stat/servlet/util/StatCollection.java @@ -29,7 +29,6 @@ import org.apache.log4j.Logger; import compbio.stat.collector.StatDB; import compbio.stat.collector.StatProcessor; -import compbio.stat.servlet.DisplayStat; import compbio.ws.client.Services; public class StatCollection { diff --git a/webservices/compbio/ws/client/AAConClient.java b/webservices/compbio/ws/client/AAConClient.java index f7f2603..2fd40f8 100644 --- a/webservices/compbio/ws/client/AAConClient.java +++ b/webservices/compbio/ws/client/AAConClient.java @@ -62,12 +62,11 @@ import compbio.ws.server.AAConWS; */ public class AAConClient { - /* + /** * Use java.util.Logger instead of log4j logger to reduce the size of the * client package */ - private static final Logger log = Logger.getLogger(AAConClient.class - .getCanonicalName()); + private static final Logger log = Logger.getLogger(AAConClient.class.getCanonicalName()); /** * The fully qualified web service namespace @@ -78,7 +77,6 @@ public class AAConClient { * Web service host */ static final String hostname = "http://www.compbio.dundee.ac.uk/aacon"; - // static final String hostname = "http://localhost:8080/jabaws"; /** * Web service name @@ -96,7 +94,6 @@ public class AAConClient { */ @SuppressWarnings("unchecked") AAConClient(String[] cmd) throws IOException { - File inputFile = IOHelper.getFile(cmd, inputkey, true); File outFile = IOHelper.getFile(cmd, outputkey, false); File parametersFile = IOHelper.getFile(cmd, paramFile, true); @@ -110,8 +107,7 @@ public class AAConClient { List> customOptions = null; if (parametersFile != null) { List prms = IOHelper.loadParameters(parametersFile); - customOptions = MetadataHelper.processParameters(prms, - msaws.getRunnerOptions()); + customOptions = MetadataHelper.processParameters(prms, msaws.getRunnerOptions()); } ScoreManager result = null; if (inputFile != null) { @@ -157,8 +153,7 @@ public class AAConClient { try { result.writeOut(writer); } catch (IOException e) { - System.err - .println("Problems writing output file! Stack trace is below: "); + System.err.println("Problems writing output file! Stack trace is below: "); e.printStackTrace(); } finally { if (writer != null) { @@ -194,8 +189,7 @@ public class AAConClient { QName portName = new QName(QUALIFIED_SERVICE_NAME, "AAConWS" + "Port"); @SuppressWarnings("unchecked") - SequenceAnnotation serviceIF = serv.getPort(portName, - SequenceAnnotation.class); + SequenceAnnotation serviceIF = serv.getPort(portName, SequenceAnnotation.class); log.log(Level.FINE, "Connected successfully!"); return serviceIF; @@ -225,8 +219,7 @@ public class AAConClient { String jobId = null; if (customOptions != null && preset != null) { - System.out - .println("WARN: Parameters (-f) are defined together with a preset (-r) ignoring preset!"); + System.out.println("WARN: Parameters (-f) are defined together with a preset (-r) ignoring preset!"); } if (customOptions != null) { jobId = wsproxy.customAnalize(fastalist, customOptions); @@ -239,14 +232,12 @@ public class AAConClient { scores = wsproxy.getAnnotation(jobId); } catch (IOException e) { - System.err - .println("Exception while reading the input file. " + System.err.println("Exception while reading the input file. " + "Check that the input file contains a list of fasta formatted sequences! " + "Exception details are below:"); e.printStackTrace(); } catch (JobSubmissionException e) { - System.err - .println("Exception while submitting job to a web server. " + System.err.println("Exception while submitting job to a web server. " + "Exception details are below:"); e.printStackTrace(); } catch (ResultNotAvailableException e) { @@ -257,14 +248,12 @@ public class AAConClient { // ignore and propagate an interruption Thread.currentThread().interrupt(); } catch (WrongParameterException e) { - System.err - .println("Exception while parsing the web method input parameters. " + System.err.println("Exception while parsing the web method input parameters. " + "Exception details are below:"); e.printStackTrace(); } catch (UnknownFileFormatException e) { - System.err - .println("Exception while attempting to read the input file " - + "Exception details are below:"); + System.err.println("Exception while attempting to read the input file " + + "Exception details are below:"); System.out.println(e.getMessage()); e.printStackTrace(); } @@ -278,38 +267,20 @@ public class AAConClient { */ static void printUsage(int exitStatus) { System.out.println(); - System.out.println("Usage: " - + " ACTION [OPTIONS] "); + System.out.println("Usage: ACTION [OPTIONS] "); System.out.println(); System.out.println("ACTIONS: "); - System.out - .println(inputkey - + pseparator - + " - full path to fasta or Clustal formatted alignment file "); - System.out.println(paramList - + " - lists parameters supported by web service"); - System.out.println(presetList - + " - lists presets supported by web service"); + System.out.println(inputkey + pseparator + " - full path to fasta or Clustal formatted alignment file "); + System.out.println(paramList + " - lists parameters supported by web service"); + System.out.println(presetList + " - lists presets supported by web service"); System.out.println(limitList + " - lists web services limits"); - System.out - .println("Please note that if input file is specified other actions are ignored"); - - System.out.println(); + System.out.println("Please note that if input file is specified other actions are ignored\n"); System.out.println("OPTIONS (only for use with -i action):"); - - System.out.println(presetkey + pseparator - + " - name of the preset to use"); - System.out - .println(outputkey - + pseparator - + " - full path to the file where to write the result"); - System.out - .println("-f= - the name of the file with the list of parameters to use."); - System.out - .println("Please note that -r and -f options cannot be used together. " - + "Conservation is calculated with either a preset or " - + "the parameters from the file, but not both!"); - + System.out.println(presetkey + pseparator + " - name of the preset to use"); + System.out.println(outputkey + pseparator + " - full path to the file where to write the result"); + System.out.println("-f= - the name of the file with the list of parameters to use."); + System.out.println("Please note that -r and -f options cannot be used together. " + + "Conservation is calculated with either a preset or parameters from the file, but not both!"); System.exit(exitStatus); } @@ -353,8 +324,7 @@ public class AAConClient { try { new AAConClient(args); } catch (IOException e) { - log.log(Level.SEVERE, "IOException in client! " + e.getMessage(), - e.getCause()); + log.log(Level.SEVERE, "IOException in client! " + e.getMessage(), e.getCause()); System.err.println("Cannot write output file! Stack trace: "); e.printStackTrace(); } diff --git a/webservices/compbio/ws/client/Jws2Client.java b/webservices/compbio/ws/client/Jws2Client.java index 2a2f3d1..d46d978 100644 --- a/webservices/compbio/ws/client/Jws2Client.java +++ b/webservices/compbio/ws/client/Jws2Client.java @@ -27,7 +27,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.net.ConnectException; @@ -50,7 +49,6 @@ import compbio.data.msa.MsaWS; import compbio.data.msa.RegistryWS; import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.Alignment; -import compbio.data.sequence.AlignmentMetadata; import compbio.data.sequence.JpredAlignment; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.ScoreManager; @@ -512,7 +510,6 @@ public class Jws2Client { * */ public static void main(String[] args) { - if (args == null) { System.out.println(Constraints.help_text); System.exit(1); @@ -522,7 +519,6 @@ public class Jws2Client { System.out.println(Constraints.help_text); System.exit(1); } - try { new Jws2Client(args); } catch (IOException e) { diff --git a/webservices/compbio/ws/server/GAUtils.java b/webservices/compbio/ws/server/GAUtils.java index 6555802..53acc88 100644 --- a/webservices/compbio/ws/server/GAUtils.java +++ b/webservices/compbio/ws/server/GAUtils.java @@ -19,12 +19,10 @@ public class GAUtils { private static final Logger log = Logger.getLogger(GAUtils.class); - static PropertyHelper PROP_HELPER = PropertyHelperManager - .getPropertyHelper(); + static PropertyHelper PROP_HELPER = PropertyHelperManager.getPropertyHelper(); // compbio.dundee.ac.uk GA tracker - private static AnalyticsConfigData config = new AnalyticsConfigData( - "UA-5356328-1"); + private static AnalyticsConfigData config = new AnalyticsConfigData("UA-5356328-1"); private static GoogleAnalyticsTracker TRACKER = new GoogleAnalyticsTracker( config); diff --git a/webservices/compbio/ws/server/WSUtil.java b/webservices/compbio/ws/server/WSUtil.java index 07d005d..d0c9226 100644 --- a/webservices/compbio/ws/server/WSUtil.java +++ b/webservices/compbio/ws/server/WSUtil.java @@ -115,8 +115,7 @@ public final class WSUtil { static void reportUsage(ConfiguredExecutable confExec, Logger logger) { if (GAUtils.IS_GA_ENABLED) { - Services service = ServicesUtil.getServiceByRunner(confExec - .getExecutable().getClass()); + Services service = ServicesUtil.getServiceByRunner(confExec.getExecutable().getClass()); GAUtils.reportUsage(service); logger.info("Reporting GA usage for " + service); } @@ -128,15 +127,14 @@ public final class WSUtil { if (limit != null && limit.isExceeded(sequences)) { throw LimitExceededException.newLimitExceeded(limit, sequences); } - log.debug("Method: " + method + " with task: " + confExec.getTaskId()); compbio.runner.Util.writeInput(sequences, confExec); AsyncExecutor engine = Configurator.getAsyncEngine(confExec); String jobId = engine.submitJob(confExec); reportUsage(confExec, log); return jobId; } - - // Same as analize but Alifold takes clustal input not fasta + + // Same as analize(...) but RNAalifold takes clustal input not fasta // An if condition in the above method might be a better solution but // you need a way of finding out the type of confExec at runtime @@ -146,8 +144,6 @@ public final class WSUtil { if (limit != null && limit.isExceeded(sequences)) { throw LimitExceededException.newLimitExceeded(limit, sequences); } - log.debug("Method: " + method + " with task: " + confExec.getTaskId()); - // This line is different from the above method compbio.runner.Util.writeClustalInput(sequences, confExec, '-'); AsyncExecutor engine = Configurator.getAsyncEngine(confExec); String jobId = engine.submitJob(confExec); @@ -210,44 +206,8 @@ public final class WSUtil { AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine.getResults(jobId); ScoreManager mas = aacon.getResults(); - log.trace(jobId + " getConservation : " + mas); return mas; } - - /* - * UNUSED - * - * @SuppressWarnings("unchecked") static LimitsManager - * getLimits(Class> clazz, WebServiceContext - * wsContext) { - * - * String LIMIT_KEY = CACHE_KEY + clazz.getCanonicalName(); LimitsManager - * limit = (LimitsManager) getObjectFromApplContext( LIMIT_KEY, - * wsContext); if (limit == null) { synchronized (WSUtil.class) { limit = - * (LimitsManager) getObjectFromApplContext(LIMIT_KEY, wsContext); if - * (limit == null) { limit = compbio.runner.Util - * .getLimits((Class>) clazz); - * addObjectToApplContext(wsContext, LIMIT_KEY, limit); } } } return limit; - * } - * - * static void addObjectToApplContext(WebServiceContext wsContext, String - * objKey, Object obj) { assert !Util.isEmpty(objKey) : - * "Key for the object must not be empty! "; assert wsContext != null; - * - * ServletContext ctx = ((javax.servlet.ServletContext) wsContext - * .getMessageContext().get(MessageContext. SERVLET_CONTEXT)); assert ctx != - * null; log.debug("Adding object with key '" + objKey + "' and value '" + - * obj + "' to the application context"); ctx.setAttribute(objKey, obj); } - * static Object getObjectFromApplContext(String objKey, WebServiceContext - * wsContext) { assert !Util.isEmpty(objKey) : - * "Key for the object must not be empty! "; assert wsContext != null; - * - * ServletContext ctx = ((javax.servlet.ServletContext) wsContext - * .getMessageContext().get(MessageContext. SERVLET_CONTEXT)); Object obj = - * ctx.getAttribute(objKey); log.trace("Retrieving object with key '" + - * objKey + "' and value '" + obj + "' from the application context"); - * return obj; } - */ } -- 1.7.10.2