From: Fábio Madeira Date: Tue, 28 Feb 2017 12:21:51 +0000 (+0000) Subject: JWS-113 Commented Jpred entries in the datamodel, runner and webservices java source... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=68fe46f278b4ec408d6c68677bd56199aac749b3;p=jabaws.git JWS-113 Commented Jpred entries in the datamodel, runner and webservices java source code. --- diff --git a/datamodel/compbio/data/sequence/Alignment.java b/datamodel/compbio/data/sequence/Alignment.java index cf76839..35c4df0 100644 --- a/datamodel/compbio/data/sequence/Alignment.java +++ b/datamodel/compbio/data/sequence/Alignment.java @@ -41,7 +41,7 @@ import compbio.util.annotation.Immutable; * @version 1.0 September 2009 * */ -@XmlSeeAlso({JpredAlignment.class}) +//@XmlSeeAlso({JpredAlignment.class}) @XmlAccessorType(XmlAccessType.FIELD) public class Alignment { diff --git a/datamodel/compbio/data/sequence/JpredAlignment.java b/datamodel/compbio/data/sequence/JpredAlignment.java index d7d8c5d..41f1eab 100644 --- a/datamodel/compbio/data/sequence/JpredAlignment.java +++ b/datamodel/compbio/data/sequence/JpredAlignment.java @@ -17,213 +17,213 @@ * must include this copyright and license notice. */ -package compbio.data.sequence; - -import java.util.List; -import java.util.ArrayList; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; - -import compbio.util.annotation.Immutable; -import compbio.data.sequence.Alignment; -/** - * Multiple sequence alignment and Jpred prediction. - * - * Does not give any guarantees on the content of individual FastaSequece - * records. It does not guarantee neither the uniqueness of the names of - * sequences nor it guarantees the uniqueness of the sequences. - * - * @see FastaSequence - * @see AlignmentMetadata - * - * @author pvtroshin - * - * @version 1.0 September 2009 - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -public class JpredAlignment extends Alignment{ - - private JpredAlignment() { - // This has to has a default constructor for JaxB - } - - /** - * @param sequences - * @param program - * @param gapchar - */ - public JpredAlignment(List sequences, Program program, char gapchar) { - this.sequences = sequences; - this.metadata = new AlignmentMetadata(Program.Jpred, gapchar); - } - - /** - * - * @param sequences - * @param metadata - */ - public JpredAlignment(List sequences, AlignmentMetadata metadata) { - this.sequences = sequences; - this.metadata = metadata; - } - - private List getRealSeqs() { - List realsequences = new ArrayList(); - for (FastaSequence s : this.sequences) { - if (s.getId().equals("jnetpred") || - s.getId().equals("JNETCONF") || - s.getId().equals("JNETSOL25") || - s.getId().equals("JNETSOL5") || - s.getId().equals("JNETSOL0") || - s.getId().equals("JNETHMM") || - s.getId().equals("JNETHMM") || - s.getId().equals("JNETSOL0") || - s.getId().equals("JNETHMM")) { - // do nothing; - } else { - realsequences.add(s); - } - } - return realsequences; - } - - - public List getJpredSequences() { - List realsequences = new ArrayList(); - for (FastaSequence s : this.sequences) { - if (s.getId().equals("jnetpred") || - s.getId().equals("JNETCONF") || - s.getId().equals("JNETSOL25") || - s.getId().equals("JNETSOL5") || - s.getId().equals("JNETSOL0") || - s.getId().equals("JNETHMM") || - s.getId().equals("JNETHMM") || - s.getId().equals("JNETSOL0") || - s.getId().equals("JNETSOL0") || - s.getId().equals("QUERY")) { - realsequences.add(s); - } - } - return realsequences; - } - /** - * - * @return Jpred prediction - */ - public String getJpredPrediction() { - for (FastaSequence s : this.sequences) { - if (s.getId().equals("jnetpred")) { - return s.getSequence(); - } - } - return new String(""); - } - - /** - * - * @return Jpred JNETSOL25 line - */ - public String getJpredSOL25() { - for (FastaSequence s : this.sequences) { - if (s.getId().equals("JNETSOL25")) { - return s.getSequence(); - } - } - return new String(""); - } - - /** - * - * @return Jpred JNETSOL5 line - */ - public String getJpredSOL5() { - for (FastaSequence s : this.sequences) { - if (s.getId().equals("JNETSOL5")) { - return s.getSequence(); - } - } - return new String(""); - } - /** - * - * @return Jpred JNETSOL0 line - */ - public String getJpredSOL0() { - for (FastaSequence s : this.sequences) { - if (s.getId().equals("JNETSOL0")) { - return s.getSequence(); - } - } - return new String(""); - } - /** - * - * @return Jpred JNETCONF line - */ - public String getJpredJNETCONF() { - for (FastaSequence s : this.sequences) { - if (s.getId().equals("JNETCONF")) { - return s.getSequence(); - } - } - return new String(""); - } - - /** - * - * @return list of FastaSequence records - */ - @Override - public List getSequences() { - return this.getRealSeqs(); - } - - /** - * - * @return a number of sequence in the alignment - */ - @Override - public int getSize() { - return this.getRealSeqs().size(); - } - - /** - * Please note that this implementation does not take the order of sequences - * into account! - */ - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (!(obj instanceof JpredAlignment)) { - return false; - } - JpredAlignment al = (JpredAlignment) obj; - if (this.getSize() != al.getSize()) { - return false; - } - if (!this.getMetadata().equals(al.getMetadata())) { - return false; - } - int outerCounter = 0; - int matchCounter = 0; - for (FastaSequence fs : getSequences()) { - outerCounter++; - for (FastaSequence fs1 : al.getSequences()) { - if (fs.equals(fs1)) { - matchCounter++; - continue; - } - } - // Match for at lease one element was not found! - if (outerCounter != matchCounter) { - return false; - } - } - return true; - } - -} +//package compbio.data.sequence; +// +//import java.util.List; +//import java.util.ArrayList; +// +//import javax.xml.bind.annotation.XmlAccessType; +//import javax.xml.bind.annotation.XmlAccessorType; +// +//import compbio.util.annotation.Immutable; +//import compbio.data.sequence.Alignment; +///** +// * Multiple sequence alignment and Jpred prediction. +// * +// * Does not give any guarantees on the content of individual FastaSequece +// * records. It does not guarantee neither the uniqueness of the names of +// * sequences nor it guarantees the uniqueness of the sequences. +// * +// * @see FastaSequence +// * @see AlignmentMetadata +// * +// * @author pvtroshin +// * +// * @version 1.0 September 2009 +// * +// */ +//@XmlAccessorType(XmlAccessType.FIELD) +//public class JpredAlignment extends Alignment{ +// +// private JpredAlignment() { +// // This has to has a default constructor for JaxB +// } +// +// /** +// * @param sequences +// * @param program +// * @param gapchar +// */ +// public JpredAlignment(List sequences, Program program, char gapchar) { +// this.sequences = sequences; +// this.metadata = new AlignmentMetadata(Program.Jpred, gapchar); +// } +// +// /** +// * +// * @param sequences +// * @param metadata +// */ +// public JpredAlignment(List sequences, AlignmentMetadata metadata) { +// this.sequences = sequences; +// this.metadata = metadata; +// } +// +// private List getRealSeqs() { +// List realsequences = new ArrayList(); +// for (FastaSequence s : this.sequences) { +// if (s.getId().equals("jnetpred") || +// s.getId().equals("JNETCONF") || +// s.getId().equals("JNETSOL25") || +// s.getId().equals("JNETSOL5") || +// s.getId().equals("JNETSOL0") || +// s.getId().equals("JNETHMM") || +// s.getId().equals("JNETHMM") || +// s.getId().equals("JNETSOL0") || +// s.getId().equals("JNETHMM")) { +// // do nothing; +// } else { +// realsequences.add(s); +// } +// } +// return realsequences; +// } +// +// +// public List getJpredSequences() { +// List realsequences = new ArrayList(); +// for (FastaSequence s : this.sequences) { +// if (s.getId().equals("jnetpred") || +// s.getId().equals("JNETCONF") || +// s.getId().equals("JNETSOL25") || +// s.getId().equals("JNETSOL5") || +// s.getId().equals("JNETSOL0") || +// s.getId().equals("JNETHMM") || +// s.getId().equals("JNETHMM") || +// s.getId().equals("JNETSOL0") || +// s.getId().equals("JNETSOL0") || +// s.getId().equals("QUERY")) { +// realsequences.add(s); +// } +// } +// return realsequences; +// } +// /** +// * +// * @return Jpred prediction +// */ +// public String getJpredPrediction() { +// for (FastaSequence s : this.sequences) { +// if (s.getId().equals("jnetpred")) { +// return s.getSequence(); +// } +// } +// return new String(""); +// } +// +// /** +// * +// * @return Jpred JNETSOL25 line +// */ +// public String getJpredSOL25() { +// for (FastaSequence s : this.sequences) { +// if (s.getId().equals("JNETSOL25")) { +// return s.getSequence(); +// } +// } +// return new String(""); +// } +// +// /** +// * +// * @return Jpred JNETSOL5 line +// */ +// public String getJpredSOL5() { +// for (FastaSequence s : this.sequences) { +// if (s.getId().equals("JNETSOL5")) { +// return s.getSequence(); +// } +// } +// return new String(""); +// } +// /** +// * +// * @return Jpred JNETSOL0 line +// */ +// public String getJpredSOL0() { +// for (FastaSequence s : this.sequences) { +// if (s.getId().equals("JNETSOL0")) { +// return s.getSequence(); +// } +// } +// return new String(""); +// } +// /** +// * +// * @return Jpred JNETCONF line +// */ +// public String getJpredJNETCONF() { +// for (FastaSequence s : this.sequences) { +// if (s.getId().equals("JNETCONF")) { +// return s.getSequence(); +// } +// } +// return new String(""); +// } +// +// /** +// * +// * @return list of FastaSequence records +// */ +// @Override +// public List getSequences() { +// return this.getRealSeqs(); +// } +// +// /** +// * +// * @return a number of sequence in the alignment +// */ +// @Override +// public int getSize() { +// return this.getRealSeqs().size(); +// } +// +// /** +// * Please note that this implementation does not take the order of sequences +// * into account! +// */ +// @Override +// public boolean equals(Object obj) { +// if (obj == null) { +// return false; +// } +// if (!(obj instanceof JpredAlignment)) { +// return false; +// } +// JpredAlignment al = (JpredAlignment) obj; +// if (this.getSize() != al.getSize()) { +// return false; +// } +// if (!this.getMetadata().equals(al.getMetadata())) { +// return false; +// } +// int outerCounter = 0; +// int matchCounter = 0; +// for (FastaSequence fs : getSequences()) { +// outerCounter++; +// for (FastaSequence fs1 : al.getSequences()) { +// if (fs.equals(fs1)) { +// matchCounter++; +// continue; +// } +// } +// // Match for at lease one element was not found! +// if (outerCounter != matchCounter) { +// return false; +// } +// } +// return true; +// } +// +//} diff --git a/datamodel/compbio/data/sequence/Program.java b/datamodel/compbio/data/sequence/Program.java index 3c7570a..0c693e9 100644 --- a/datamodel/compbio/data/sequence/Program.java +++ b/datamodel/compbio/data/sequence/Program.java @@ -68,5 +68,5 @@ public enum Program { /** * Jpred */ - Jpred +// Jpred } diff --git a/datamodel/compbio/data/sequence/SequenceUtil.java b/datamodel/compbio/data/sequence/SequenceUtil.java index 376193f..9dec565 100644 --- a/datamodel/compbio/data/sequence/SequenceUtil.java +++ b/datamodel/compbio/data/sequence/SequenceUtil.java @@ -293,10 +293,10 @@ public final class SequenceUtil { } - public static final List readJpredFile(InputStream result) - throws IOException, FileNotFoundException,NullPointerException { - return readFasta (result); - } +// public static final List readJpredFile(InputStream result) +// throws IOException, FileNotFoundException,NullPointerException { +// return readFasta (result); +// } /** * Read IUPred output diff --git a/runner/compbio/runner/predictors/Jpred.java b/runner/compbio/runner/predictors/Jpred.java index 4d94620..3bc10d0 100644 --- a/runner/compbio/runner/predictors/Jpred.java +++ b/runner/compbio/runner/predictors/Jpred.java @@ -16,137 +16,137 @@ * must include this copyright and license notice. */ -package compbio.runner.predictors; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.List; - -import org.apache.log4j.Logger; - -import compbio.data.sequence.JpredAlignment; -import compbio.data.sequence.AlignmentMetadata; -import compbio.data.sequence.Program; -import compbio.data.sequence.SequenceUtil; -import compbio.engine.client.CommandBuilder; -import compbio.engine.client.Executable; -import compbio.engine.client.SkeletalExecutable; -import compbio.metadata.ResultNotAvailableException; - -/** - * Command line - * - * jpred.pl -in d16vpa_.fas -outfile res_d16vpa_ -dbname ported_db -dbpath - * /data/UNIREFdb -ncpu 4 - * - * @author asherstnev - * - */ -public class Jpred extends SkeletalExecutable { - - private static Logger log = Logger.getLogger(Jpred.class); - - /** - * Number of cores to use, defaults to 1 for local execution or the value of - * "jpred.cluster.cpunum" property for cluster execution - */ - private int ncoreNumber = 0; - - public static final String KEY_VALUE_SEPARATOR = " "; - public static final String STAT_FILE = "stat.txt"; - - public Jpred() { - String dbpath = ph.getProperty("jpred.data.uniref.path"); - String dbname = ph.getProperty("jpred.data.uniref.name"); - addParameters(Arrays.asList("-logfile " + STAT_FILE)); - addParameters(Arrays.asList("-dbpath " + dbpath)); - addParameters(Arrays.asList("-dbname " + dbname)); - addParameters(Arrays.asList("-jabaws")); - } - - // HashMap - @SuppressWarnings("unchecked") - @Override - public JpredAlignment getResults(String workDirectory) throws ResultNotAvailableException { - JpredAlignment annotations = null; - try { - InputStream inStream = new FileInputStream(new File(workDirectory, getOutput())); - annotations = new JpredAlignment(SequenceUtil.readJpredFile(inStream), new AlignmentMetadata(Program.Jpred, '-')); - } catch (FileNotFoundException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } catch (IOException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } catch (NullPointerException e) { - log.error(e.getMessage(), e.getCause()); - throw new ResultNotAvailableException(e); - } - return annotations; - } - - @Override - public List getCreatedFiles() { - return Arrays.asList(getOutput(), getError()); - } - - @Override - public Jpred setInput(String inFile) { - super.setInput(inFile); - cbuilder.setParam("-in " + inFile); - return this; - } - - @Override - public Jpred setOutput(String outFile) { - super.setOutput(outFile); - cbuilder.setParam("-outfile " + outFile); - return this; - } - - @SuppressWarnings("unchecked") - @Override - public Class getType() { - return (Class) this.getClass(); - } - - public static String getStatFile() { - return STAT_FILE; - } - - public void setNCore(int ncoreNumber) { - if (0 < ncoreNumber && ncoreNumber < 9) { - this.ncoreNumber = ncoreNumber; - cbuilder.setParam("-ncpu " + Integer.toString(getNCore())); - } else { - throw new IndexOutOfBoundsException("Number of cores must be between 1 and 8 "); - } - } - - int getNCore() { - return ncoreNumber; - } - - @Override - public CommandBuilder getParameters(ExecProvider provider) { - // 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; - setNCore(cpunum); - } else { - // Limit number of cores to 1 for ANY execution which does not set - // Ncores explicitly using setNCore method or is run on local VM - if (ncoreNumber == 0) { - setNCore(1); - } - } - return super.getParameters(provider); - } - -} +//package compbio.runner.predictors; +// +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileNotFoundException; +//import java.io.IOException; +//import java.io.InputStream; +//import java.util.Arrays; +//import java.util.List; +// +//import org.apache.log4j.Logger; +// +//import compbio.data.sequence.JpredAlignment; +//import compbio.data.sequence.AlignmentMetadata; +//import compbio.data.sequence.Program; +//import compbio.data.sequence.SequenceUtil; +//import compbio.engine.client.CommandBuilder; +//import compbio.engine.client.Executable; +//import compbio.engine.client.SkeletalExecutable; +//import compbio.metadata.ResultNotAvailableException; +// +///** +// * Command line +// * +// * jpred.pl -in d16vpa_.fas -outfile res_d16vpa_ -dbname ported_db -dbpath +// * /data/UNIREFdb -ncpu 4 +// * +// * @author asherstnev +// * +// */ +//public class Jpred extends SkeletalExecutable { +// +// private static Logger log = Logger.getLogger(Jpred.class); +// +// /** +// * Number of cores to use, defaults to 1 for local execution or the value of +// * "jpred.cluster.cpunum" property for cluster execution +// */ +// private int ncoreNumber = 0; +// +// public static final String KEY_VALUE_SEPARATOR = " "; +// public static final String STAT_FILE = "stat.txt"; +// +// public Jpred() { +// String dbpath = ph.getProperty("jpred.data.uniref.path"); +// String dbname = ph.getProperty("jpred.data.uniref.name"); +// addParameters(Arrays.asList("-logfile " + STAT_FILE)); +// addParameters(Arrays.asList("-dbpath " + dbpath)); +// addParameters(Arrays.asList("-dbname " + dbname)); +// addParameters(Arrays.asList("-jabaws")); +// } +// +// // HashMap +// @SuppressWarnings("unchecked") +// @Override +// public JpredAlignment getResults(String workDirectory) throws ResultNotAvailableException { +// JpredAlignment annotations = null; +// try { +// InputStream inStream = new FileInputStream(new File(workDirectory, getOutput())); +// annotations = new JpredAlignment(SequenceUtil.readJpredFile(inStream), new AlignmentMetadata(Program.Jpred, '-')); +// } catch (FileNotFoundException e) { +// log.error(e.getMessage(), e.getCause()); +// throw new ResultNotAvailableException(e); +// } catch (IOException e) { +// log.error(e.getMessage(), e.getCause()); +// throw new ResultNotAvailableException(e); +// } catch (NullPointerException e) { +// log.error(e.getMessage(), e.getCause()); +// throw new ResultNotAvailableException(e); +// } +// return annotations; +// } +// +// @Override +// public List getCreatedFiles() { +// return Arrays.asList(getOutput(), getError()); +// } +// +// @Override +// public Jpred setInput(String inFile) { +// super.setInput(inFile); +// cbuilder.setParam("-in " + inFile); +// return this; +// } +// +// @Override +// public Jpred setOutput(String outFile) { +// super.setOutput(outFile); +// cbuilder.setParam("-outfile " + outFile); +// return this; +// } +// +// @SuppressWarnings("unchecked") +// @Override +// public Class getType() { +// return (Class) this.getClass(); +// } +// +// public static String getStatFile() { +// return STAT_FILE; +// } +// +// public void setNCore(int ncoreNumber) { +// if (0 < ncoreNumber && ncoreNumber < 9) { +// this.ncoreNumber = ncoreNumber; +// cbuilder.setParam("-ncpu " + Integer.toString(getNCore())); +// } else { +// throw new IndexOutOfBoundsException("Number of cores must be between 1 and 8 "); +// } +// } +// +// int getNCore() { +// return ncoreNumber; +// } +// +// @Override +// public CommandBuilder getParameters(ExecProvider provider) { +// // 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; +// setNCore(cpunum); +// } else { +// // Limit number of cores to 1 for ANY execution which does not set +// // Ncores explicitly using setNCore method or is run on local VM +// if (ncoreNumber == 0) { +// setNCore(1); +// } +// } +// return super.getParameters(provider); +// } +// +//} diff --git a/testsrc/compbio/data/sequence/SequenceUtilTester.java b/testsrc/compbio/data/sequence/SequenceUtilTester.java index 9468cda..5dbfd28 100644 --- a/testsrc/compbio/data/sequence/SequenceUtilTester.java +++ b/testsrc/compbio/data/sequence/SequenceUtilTester.java @@ -409,18 +409,18 @@ public class SequenceUtilTester { fail(e.getMessage()); } } - @Test - public void ReadJpredResults() { - try { - InputStream inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "Jpred.test1.out"); - List result = SequenceUtil.readJpredFile(inStream); - inStream.close(); - assertNotNull(result); - assertEquals(result.size(), 19); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } +// @Test +// public void ReadJpredResults() { +// try { +// InputStream inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "Jpred.test1.out"); +// List result = SequenceUtil.readJpredFile(inStream); +// inStream.close(); +// assertNotNull(result); +// assertEquals(result.size(), 19); +// } catch (IOException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } } diff --git a/testsrc/compbio/runner/msa/TcoffeeTester.java b/testsrc/compbio/runner/msa/TcoffeeTester.java index 8fc2e99..3f307a8 100644 --- a/testsrc/compbio/runner/msa/TcoffeeTester.java +++ b/testsrc/compbio/runner/msa/TcoffeeTester.java @@ -57,7 +57,7 @@ import compbio.metadata.PresetManager; import compbio.metadata.ResultNotAvailableException; import compbio.metadata.RunnerConfig; import compbio.runner.msa.Tcoffee; -import compbio.runner.predictors.Jpred; +//import compbio.runner.predictors.Jpred; import compbio.util.FileWatcher; import compbio.util.SysPrefs; diff --git a/testsrc/compbio/runner/predictors/JpredTester.java b/testsrc/compbio/runner/predictors/JpredTester.java index f053200..b371184 100644 --- a/testsrc/compbio/runner/predictors/JpredTester.java +++ b/testsrc/compbio/runner/predictors/JpredTester.java @@ -16,347 +16,347 @@ * Any republication or derived work distributed in source code form must include * this copyright and license notice. */ -package compbio.runner.predictors; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; -import java.util.Arrays; - -import javax.xml.bind.ValidationException; - -import org.ggf.drmaa.DrmaaException; -import org.ggf.drmaa.JobInfo; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.JpredAlignment; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitsManager; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.RunnerUtil; -import compbio.util.FileWatcher; -import compbio.util.SysPrefs; - -public class JpredTester { - - public static final String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() + File.separator; - - public static String test_output = "Jpred.test1.out"; - public static String test_input = CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" + File.separator + "Jpred.test1.fasta"; - private Jpred pred; - - @BeforeMethod(alwaysRun = true) - void init() { - pred = new Jpred(); - pred.setInput(test_input); - pred.setOutput(test_output); - } - - // disabled - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void RunOnCluster() { - assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); - try { - PresetManager jpredPreset = RunnerUtil.getPresets(Jpred.class); - assert jpredPreset != null; - ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Cluster); - Preset conf = jpredPreset.getPresetByName("cluster configuration"); - confpred.addParameters(conf.getOptions()); - ClusterRunner runner = ClusterRunner.getInstance(confpred); - assertNotNull(runner, "Runner is NULL"); - - runner.executeJob(); - JobStatus status = runner.getJobStatus(); - assertTrue(status == JobStatus.PENDING || status == JobStatus.RUNNING, "Status of the process is wrong!"); - JobInfo info = runner.getJobInfo(); - assertNotNull(info, "JobInfo is null"); - StatisticManager sm = new StatisticManager(info); - assertNotNull(sm, "Statistic manager is null"); - try { - String exits = sm.getExitStatus(); - assertNotNull("Exit status is null", exits); - // cut 4 trailing zeros from the number - int exitsInt = ClusterEngineUtil.CLUSTER_STAT_IN_SEC.parse(exits).intValue(); - assertEquals(0, exitsInt); - System.out.println(sm.getAllStats()); - } catch (ParseException e) { - e.printStackTrace(); - fail("Parse Exception: " + e.getMessage()); - } - assertTrue(sm.hasExited()); - assertFalse(sm.wasAborted()); - assertFalse(sm.hasDump()); - assertFalse(sm.hasSignaled()); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } - } - - // disabled - @Test(enabled=false,groups = {AllTestSuit.test_group_runner, AllTestSuit.test_group_cluster}) - public void RunOnClusterAsync() { - assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); - try { - pred.addParameters(Arrays.asList("-dbname uniref90", "-dbpath /homes/www-jpred/databases/")); - ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confpred); - String jobId = aengine.submitJob(confpred); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - Thread.sleep(1000); - status = aengine.getJobStatus(jobId); - ConfiguredExecutable result = (ConfiguredExecutable) aengine.getResults(jobId); - assertNotNull(result); - if (status == JobStatus.UNDEFINED || status == JobStatus.FAILED) { - fail("job " + jobId +" failed!"); - break; - } - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void RunLocally() { - try { - ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Local); - confpred.addParameters(Arrays.asList("-dbname ported_db", "-dbpath /data/UNIREFdb/")); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confpred); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - JpredAlignment totalign = (JpredAlignment) confpred.getResults(); - assertNotNull(totalign); - assertEquals(totalign.getSize(), 14); - assertEquals(al1.getResults(), totalign); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void RunLocallyWithPreset() { - try { - ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Local); - PresetManager preset = RunnerUtil.getPresets(Jpred.class); - assert preset != null; - Preset conf = preset.getPresetByName("laptop configuration"); - confpred.addParameters(conf.getOptions()); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confpred); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - JpredAlignment totalign = (JpredAlignment) confpred.getResults(); - assertNotNull(totalign); - assertEquals(totalign.getSize(), 19); - assertEquals(al1.getResults(), totalign); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void readStatistics() { - try { - Jpred jpred = new Jpred(); - jpred.setInput(test_input); - jpred.setOutput(test_output); - ConfiguredExecutable confpred = Configurator.configureExecutable(jpred, Executable.ExecProvider.Local); - PresetManager preset = RunnerUtil.getPresets(Jpred.class); - assert preset != null; - Preset conf = preset.getPresetByName("laptop configuration"); - confpred.addParameters(conf.getOptions()); - - // For local execution use relative - AsyncExecutor sexec = Configurator.getAsyncEngine(confpred); - String jobId = sexec.submitJob(confpred); - String file = confpred.getWorkDirectory() + File.separator + Jpred.getStatFile(); - FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); - int count = 0; - long position = 0; - fw.waitForFile(2); - JobStatus status = sexec.getJobStatus(jobId); - do { - if (fw.hasMoreData()) { - ChunkHolder ch = fw.pull(position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - } - count++; - // Make sure the loop is terminated if the job fails - if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) { - fail("job " + jobId +" failed!"); - break; - } - Thread.sleep(200); - status = sexec.getJobStatus(jobId); - } while (status != JobStatus.FINISHED || fw.hasMoreData()); - - assertTrue(count >= 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void Persistance() { - try { - Jpred jpred = new Jpred(); - jpred.setError("errrr.txt"); - jpred.setInput(test_input); - jpred.setOutput("outtt.txt"); - assertEquals(jpred.getInput(), test_input); - assertEquals(jpred.getError(), "errrr.txt"); - assertEquals(jpred.getOutput(), "outtt.txt"); - ConfiguredExecutable confpred = Configurator.configureExecutable(jpred, Executable.ExecProvider.Local); - confpred.addParameters(Arrays.asList("-dbname ported_db", "-dbpath /data/UNIREFdb/")); - - SyncExecutor sexec = Configurator.getSyncEngine(confpred); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - - // Save run configuration - assertTrue(confpred.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration.load(new FileInputStream(new File(confpred.getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals(((ConfExecutable) confpred).getRunConfiguration(),loadedRun); - - // Load run configuration as ConfExecutable - ConfiguredExecutable jpred2 = (ConfiguredExecutable) confpred.loadRunConfiguration(new FileInputStream(new File(confpred.getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(jpred2); - assertEquals(jpred2.getExecutable().getInput(), test_input); - assertEquals(jpred2.getExecutable().getError(), "errrr.txt"); - assertEquals(jpred2.getExecutable().getOutput(), "outtt.txt"); - - // See in details whether executables are the same - assertEquals(jpred2.getExecutable(), jpred); - ConfiguredExecutable resjpred2 = Configurator.configureExecutable(jpred2.getExecutable(), Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resjpred2, Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void ConfigurationLoading() { - try { - RunnerConfig jpredConfig = ConfExecutable.getRunnerOptions(Jpred.class); - assertNotNull(jpredConfig); - assertTrue(jpredConfig.getArguments().size() > 0); - - PresetManager jpredPreset = ConfExecutable.getRunnerPresets(Jpred.class); - assertNotNull(jpredPreset); - - LimitsManager jpredLimits = ConfExecutable.getRunnerLimits(Jpred.class); - assertNotNull(jpredLimits); - assertTrue(jpredLimits.getLimits().size() > 0); - jpredLimits.validate(jpredPreset); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} +//package compbio.runner.predictors; +// +//import static org.testng.Assert.assertEquals; +//import static org.testng.Assert.assertFalse; +//import static org.testng.Assert.assertNotNull; +//import static org.testng.Assert.assertTrue; +//import static org.testng.Assert.fail; +// +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileNotFoundException; +//import java.io.IOException; +//import java.text.ParseException; +//import java.util.Arrays; +// +//import javax.xml.bind.ValidationException; +// +//import org.ggf.drmaa.DrmaaException; +//import org.ggf.drmaa.JobInfo; +//import org.testng.annotations.BeforeMethod; +//import org.testng.annotations.Test; +// +//import compbio.data.sequence.JpredAlignment; +//import compbio.engine.AsyncExecutor; +//import compbio.engine.Configurator; +//import compbio.engine.FilePuller; +//import compbio.engine.SyncExecutor; +//import compbio.engine.client.ConfExecutable; +//import compbio.engine.client.ConfiguredExecutable; +//import compbio.engine.client.Executable; +//import compbio.engine.client.RunConfiguration; +//import compbio.engine.cluster.drmaa.ClusterEngineUtil; +//import compbio.engine.cluster.drmaa.ClusterRunner; +//import compbio.engine.cluster.drmaa.StatisticManager; +//import compbio.engine.local.LocalRunner; +//import compbio.metadata.AllTestSuit; +//import compbio.metadata.ChunkHolder; +//import compbio.metadata.JobExecutionException; +//import compbio.metadata.JobStatus; +//import compbio.metadata.JobSubmissionException; +//import compbio.metadata.LimitsManager; +//import compbio.metadata.Preset; +//import compbio.metadata.PresetManager; +//import compbio.metadata.ResultNotAvailableException; +//import compbio.metadata.RunnerConfig; +//import compbio.runner.RunnerUtil; +//import compbio.util.FileWatcher; +//import compbio.util.SysPrefs; +// +//public class JpredTester { +// +// public static final String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() + File.separator; +// +// public static String test_output = "Jpred.test1.out"; +// public static String test_input = CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" + File.separator + "Jpred.test1.fasta"; +// private Jpred pred; +// +// @BeforeMethod(alwaysRun = true) +// void init() { +// pred = new Jpred(); +// pred.setInput(test_input); +// pred.setOutput(test_output); +// } +// +// // disabled +// @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) +// public void RunOnCluster() { +// assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); +// try { +// PresetManager jpredPreset = RunnerUtil.getPresets(Jpred.class); +// assert jpredPreset != null; +// ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Cluster); +// Preset conf = jpredPreset.getPresetByName("cluster configuration"); +// confpred.addParameters(conf.getOptions()); +// ClusterRunner runner = ClusterRunner.getInstance(confpred); +// assertNotNull(runner, "Runner is NULL"); +// +// runner.executeJob(); +// JobStatus status = runner.getJobStatus(); +// assertTrue(status == JobStatus.PENDING || status == JobStatus.RUNNING, "Status of the process is wrong!"); +// JobInfo info = runner.getJobInfo(); +// assertNotNull(info, "JobInfo is null"); +// StatisticManager sm = new StatisticManager(info); +// assertNotNull(sm, "Statistic manager is null"); +// try { +// String exits = sm.getExitStatus(); +// assertNotNull("Exit status is null", exits); +// // cut 4 trailing zeros from the number +// int exitsInt = ClusterEngineUtil.CLUSTER_STAT_IN_SEC.parse(exits).intValue(); +// assertEquals(0, exitsInt); +// System.out.println(sm.getAllStats()); +// } catch (ParseException e) { +// e.printStackTrace(); +// fail("Parse Exception: " + e.getMessage()); +// } +// assertTrue(sm.hasExited()); +// assertFalse(sm.wasAborted()); +// assertFalse(sm.hasDump()); +// assertFalse(sm.hasSignaled()); +// +// } catch (JobSubmissionException e) { +// e.printStackTrace(); +// fail("DrmaaException caught:" + e.getMessage()); +// } catch (JobExecutionException e) { +// e.printStackTrace(); +// fail("DrmaaException caught:" + e.getMessage()); +// } catch (DrmaaException e) { +// e.printStackTrace(); +// fail("DrmaaException caught:" + e.getMessage()); +// } +// } +// +// // disabled +// @Test(enabled=false,groups = {AllTestSuit.test_group_runner, AllTestSuit.test_group_cluster}) +// public void RunOnClusterAsync() { +// assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); +// try { +// pred.addParameters(Arrays.asList("-dbname uniref90", "-dbpath /homes/www-jpred/databases/")); +// ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Cluster); +// AsyncExecutor aengine = Configurator.getAsyncEngine(confpred); +// String jobId = aengine.submitJob(confpred); +// assertNotNull(jobId, "Runner is NULL"); +// // let drmaa to start +// Thread.sleep(500); +// JobStatus status = aengine.getJobStatus(jobId); +// while (status != JobStatus.FINISHED) { +// Thread.sleep(1000); +// status = aengine.getJobStatus(jobId); +// ConfiguredExecutable result = (ConfiguredExecutable) aengine.getResults(jobId); +// assertNotNull(result); +// if (status == JobStatus.UNDEFINED || status == JobStatus.FAILED) { +// fail("job " + jobId +" failed!"); +// break; +// } +// } +// } catch (JobSubmissionException e) { +// e.printStackTrace(); +// fail("DrmaaException caught:" + e.getMessage()); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } catch (ResultNotAvailableException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// @Test(groups = {AllTestSuit.test_group_runner}) +// public void RunLocally() { +// try { +// ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Local); +// confpred.addParameters(Arrays.asList("-dbname ported_db", "-dbpath /data/UNIREFdb/")); +// +// // For local execution use relative +// LocalRunner lr = new LocalRunner(confpred); +// lr.executeJob(); +// ConfiguredExecutable al1 = lr.waitForResult(); +// assertNotNull(al1.getResults()); +// JpredAlignment totalign = (JpredAlignment) confpred.getResults(); +// assertNotNull(totalign); +// assertEquals(totalign.getSize(), 14); +// assertEquals(al1.getResults(), totalign); +// } catch (JobSubmissionException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } catch (ResultNotAvailableException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } catch (JobExecutionException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } +// } +// +// @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) +// public void RunLocallyWithPreset() { +// try { +// ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Local); +// PresetManager preset = RunnerUtil.getPresets(Jpred.class); +// assert preset != null; +// Preset conf = preset.getPresetByName("laptop configuration"); +// confpred.addParameters(conf.getOptions()); +// +// // For local execution use relative +// LocalRunner lr = new LocalRunner(confpred); +// lr.executeJob(); +// ConfiguredExecutable al1 = lr.waitForResult(); +// assertNotNull(al1.getResults()); +// JpredAlignment totalign = (JpredAlignment) confpred.getResults(); +// assertNotNull(totalign); +// assertEquals(totalign.getSize(), 19); +// assertEquals(al1.getResults(), totalign); +// } catch (JobSubmissionException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } catch (ResultNotAvailableException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } catch (JobExecutionException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } +// } +// +// @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) +// public void readStatistics() { +// try { +// Jpred jpred = new Jpred(); +// jpred.setInput(test_input); +// jpred.setOutput(test_output); +// ConfiguredExecutable confpred = Configurator.configureExecutable(jpred, Executable.ExecProvider.Local); +// PresetManager preset = RunnerUtil.getPresets(Jpred.class); +// assert preset != null; +// Preset conf = preset.getPresetByName("laptop configuration"); +// confpred.addParameters(conf.getOptions()); +// +// // For local execution use relative +// AsyncExecutor sexec = Configurator.getAsyncEngine(confpred); +// String jobId = sexec.submitJob(confpred); +// String file = confpred.getWorkDirectory() + File.separator + Jpred.getStatFile(); +// FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); +// int count = 0; +// long position = 0; +// fw.waitForFile(2); +// JobStatus status = sexec.getJobStatus(jobId); +// do { +// if (fw.hasMoreData()) { +// ChunkHolder ch = fw.pull(position); +// String chunk = ch.getChunk(); +// position = ch.getNextPosition(); +// } +// count++; +// // Make sure the loop is terminated if the job fails +// if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) { +// fail("job " + jobId +" failed!"); +// break; +// } +// Thread.sleep(200); +// status = sexec.getJobStatus(jobId); +// } while (status != JobStatus.FINISHED || fw.hasMoreData()); +// +// assertTrue(count >= 1); +// ConfiguredExecutable al = sexec.getResults(jobId); +// assertNotNull(al.getResults()); +// } catch (JobSubmissionException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } catch (ResultNotAvailableException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } catch (IOException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) +// public void Persistance() { +// try { +// Jpred jpred = new Jpred(); +// jpred.setError("errrr.txt"); +// jpred.setInput(test_input); +// jpred.setOutput("outtt.txt"); +// assertEquals(jpred.getInput(), test_input); +// assertEquals(jpred.getError(), "errrr.txt"); +// assertEquals(jpred.getOutput(), "outtt.txt"); +// ConfiguredExecutable confpred = Configurator.configureExecutable(jpred, Executable.ExecProvider.Local); +// confpred.addParameters(Arrays.asList("-dbname ported_db", "-dbpath /data/UNIREFdb/")); +// +// SyncExecutor sexec = Configurator.getSyncEngine(confpred); +// sexec.executeJob(); +// ConfiguredExecutable al = sexec.waitForResult(); +// assertNotNull(al.getResults()); +// +// // Save run configuration +// assertTrue(confpred.saveRunConfiguration()); +// +// // See if loaded configuration is the same as saved +// RunConfiguration loadedRun = RunConfiguration.load(new FileInputStream(new File(confpred.getWorkDirectory(), RunConfiguration.rconfigFile))); +// assertEquals(((ConfExecutable) confpred).getRunConfiguration(),loadedRun); +// +// // Load run configuration as ConfExecutable +// ConfiguredExecutable jpred2 = (ConfiguredExecutable) confpred.loadRunConfiguration(new FileInputStream(new File(confpred.getWorkDirectory(), RunConfiguration.rconfigFile))); +// assertNotNull(jpred2); +// assertEquals(jpred2.getExecutable().getInput(), test_input); +// assertEquals(jpred2.getExecutable().getError(), "errrr.txt"); +// assertEquals(jpred2.getExecutable().getOutput(), "outtt.txt"); +// +// // See in details whether executables are the same +// assertEquals(jpred2.getExecutable(), jpred); +// ConfiguredExecutable resjpred2 = Configurator.configureExecutable(jpred2.getExecutable(), Executable.ExecProvider.Local); +// +// sexec = Configurator.getSyncEngine(resjpred2, Executable.ExecProvider.Local); +// sexec.executeJob(); +// al = sexec.waitForResult(); +// assertNotNull(al); +// } catch (JobSubmissionException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } catch (JobExecutionException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } catch (IOException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } catch (ResultNotAvailableException e) { +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) +// public void ConfigurationLoading() { +// try { +// RunnerConfig jpredConfig = ConfExecutable.getRunnerOptions(Jpred.class); +// assertNotNull(jpredConfig); +// assertTrue(jpredConfig.getArguments().size() > 0); +// +// PresetManager jpredPreset = ConfExecutable.getRunnerPresets(Jpred.class); +// assertNotNull(jpredPreset); +// +// LimitsManager jpredLimits = ConfExecutable.getRunnerLimits(Jpred.class); +// assertNotNull(jpredLimits); +// assertTrue(jpredLimits.getLimits().size() > 0); +// jpredLimits.validate(jpredPreset); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } catch (IOException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } catch (ValidationException e) { +// e.printStackTrace(); +// fail(e.getLocalizedMessage()); +// } +// } +// +//} diff --git a/webservices/compbio/data/msa/Category.java b/webservices/compbio/data/msa/Category.java index 8694d16..1e0305a 100644 --- a/webservices/compbio/data/msa/Category.java +++ b/webservices/compbio/data/msa/Category.java @@ -81,7 +81,7 @@ public class Category { Category conservation = new Category(CATEGORY_CONSERVATION, conservation_services); Set prediction_services = new HashSet(); - prediction_services.add(Services.JpredWS); +// prediction_services.add(Services.JpredWS); prediction_services.add(Services.RNAalifoldWS); Category prediction = new Category(CATEGORY_PREDICTION, prediction_services); diff --git a/webservices/compbio/ws/client/Jws2Client.java b/webservices/compbio/ws/client/Jws2Client.java index daeb8fa..ded0516 100644 --- a/webservices/compbio/ws/client/Jws2Client.java +++ b/webservices/compbio/ws/client/Jws2Client.java @@ -50,7 +50,7 @@ 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.JpredAlignment; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.ScoreManager; import compbio.data.sequence.SequenceUtil; @@ -176,20 +176,23 @@ public class Jws2Client { writer.close(); } else if (service.getServiceType() == MsaWS.class) { Alignment alignment = align(infile, (MsaWS) thews, preset, customOptions); - if (serviceName.equalsIgnoreCase("JpredWS")) { - writer.close(); - JpredAlignment jpred = (JpredAlignment)alignment; - if (outfile != null) { - FileOutputStream fout = new FileOutputStream(outfile); - SequenceUtil.writeFastaKeepTheStream(fout, jpred.getJpredSequences(), 60); - fout.close(); - } else { - SequenceUtil.writeFasta(System.out, jpred.getJpredSequences()); - } - } else { - IOHelper.writeOut(writer, alignment); - writer.close(); - } +// if (serviceName.equalsIgnoreCase("JpredWS")) { +// writer.close(); +// JpredAlignment jpred = (JpredAlignment)alignment; +// if (outfile != null) { +// FileOutputStream fout = new FileOutputStream(outfile); +// SequenceUtil.writeFastaKeepTheStream(fout, jpred.getJpredSequences(), 60); +// fout.close(); +// } else { +// SequenceUtil.writeFasta(System.out, jpred.getJpredSequences()); +// } +// } else { +// IOHelper.writeOut(writer, alignment); +// writer.close(); +// } + + IOHelper.writeOut(writer, alignment); + writer.close(); AlignmentMetadata md = alignment.getMetadata(); System.out.println("Output has been prepared with " + md.getProgram()); } @@ -546,7 +549,7 @@ public class Jws2Client { System.exit(1); } if (args.length < 2) { - System.err.println("Host (-h=, e.g. -h=http://www.compbio.dundee.ac.uk/jabaws) and service (-s=, e.g. -s=Jpred) are required!"); + System.err.println("Host (-h=, e.g. -h=http://www.compbio.dundee.ac.uk/jabaws) and service (-s=, e.g. -s=MafftWS) are required!"); System.out.println(Constraints.help_text); System.exit(1); } diff --git a/webservices/compbio/ws/client/Services.java b/webservices/compbio/ws/client/Services.java index cf978f8..8ffaa05 100644 --- a/webservices/compbio/ws/client/Services.java +++ b/webservices/compbio/ws/client/Services.java @@ -42,7 +42,7 @@ public enum Services { MafftWS, MuscleWS, ClustalWS, ClustalOWS, TcoffeeWS, ProbconsWS, MSAprobsWS, GLprobsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS, IUPredWS, - JpredWS, +// JpredWS, RNAalifoldWS; public static Services getService(String servName) { @@ -87,7 +87,7 @@ public enum Services { case IUPredWS : case RNAalifoldWS : return SequenceAnnotation.class; - case JpredWS : +// case JpredWS : case ClustalWS : case ClustalOWS : case MafftWS : @@ -113,7 +113,7 @@ public enum Services { case IUPredWS : case MSAprobsWS : case GLprobsWS : - case JpredWS : +// case JpredWS : case ClustalOWS : return JABAService.V2_SERVICE_NAMESPACE; case ClustalWS : @@ -138,8 +138,8 @@ public enum Services { switch (this) { case AAConWS : return AACON_INFO.toString(); - case JpredWS : - return JPRED_INFO.toString(); +// case JpredWS : +// return JPRED_INFO.toString(); case ClustalOWS : return CLUSTAL_OMEGA_INFO.toString(); case ClustalWS : @@ -175,8 +175,8 @@ public enum Services { switch (this) { case AAConWS : return AACON_INFO.getReference(); - case JpredWS : - return JPRED_INFO.getReference(); +// case JpredWS : +// return JPRED_INFO.getReference(); case ClustalOWS : return CLUSTAL_OMEGA_INFO.getReference(); case ClustalWS : @@ -212,8 +212,8 @@ public enum Services { switch (this) { case AAConWS : return AACON_INFO.getVersion(); - case JpredWS : - return JPRED_INFO.getVersion(); +// case JpredWS : +// return JPRED_INFO.getVersion(); case ClustalOWS : return CLUSTAL_OMEGA_INFO.getVersion(); case ClustalWS : @@ -249,8 +249,8 @@ public enum Services { switch (this) { case AAConWS : return "annotation"; - case JpredWS : - return "annotation"; +// case JpredWS : +// return "annotation"; case ClustalOWS : return "alignment"; case ClustalWS : @@ -285,11 +285,11 @@ public enum Services { static ServiceInfo AACON_INFO = new ServiceInfo(AAConWS, "in preparation", "1.0", "http://www.compbio.dundee.ac.uk/aacon"); - static ServiceInfo JPRED_INFO = new ServiceInfo(JpredWS, - "Cole C, Barber JD, Barton GJ,\r\n" + - "\"The Jpred 3 secondary structure prediction server\"\r\n" + - "Nucl. Acids Res. 36 (suppl 2):W197 (2008)", - "3.0.3", "http://www.compbio.dundee.ac.uk/www-jpred"); +// static ServiceInfo JPRED_INFO = new ServiceInfo(JpredWS, +// "Cole C, Barber JD, Barton GJ,\r\n" + +// "\"The Jpred 3 secondary structure prediction server\"\r\n" + +// "Nucl. Acids Res. 36 (suppl 2):W197 (2008)", +// "3.0.3", "http://www.compbio.dundee.ac.uk/www-jpred"); static ServiceInfo CLUSTAL_INFO = new ServiceInfo(ClustalWS, "Larkin MA, Blackshields G, Brown NP, Chenna R, McGettigan PA, McWilliam H, Valentin F, Wallace IM, Wilm A, Lopez R, Thompson JD, Gibson TJ, Higgins DG,\r\n" + diff --git a/webservices/compbio/ws/client/ServicesUtil.java b/webservices/compbio/ws/client/ServicesUtil.java index 8f9bcdc..0e862d4 100644 --- a/webservices/compbio/ws/client/ServicesUtil.java +++ b/webservices/compbio/ws/client/ServicesUtil.java @@ -5,7 +5,7 @@ import java.io.File; import compbio.engine.client.ConfExecutable; import compbio.engine.client.Executable; import compbio.runner.conservation.AACon; -import compbio.runner.predictors.Jpred; +//import compbio.runner.predictors.Jpred; import compbio.runner.disorder.Disembl; import compbio.runner.disorder.GlobPlot; import compbio.runner.disorder.IUPred; @@ -37,8 +37,8 @@ public class ServicesUtil { switch (service) { case AAConWS : return AACon.class; - case JpredWS : - return Jpred.class; +// case JpredWS : +// return Jpred.class; case ClustalOWS : return ClustalO.class; case ClustalWS : diff --git a/webservices/compbio/ws/client/WSTester.java b/webservices/compbio/ws/client/WSTester.java index 5450a1d..1008bea 100644 --- a/webservices/compbio/ws/client/WSTester.java +++ b/webservices/compbio/ws/client/WSTester.java @@ -370,11 +370,12 @@ public class WSTester { boolean succeed = false; String taskId; - if (service == Services.JpredWS) { - taskId = msaws.align(loadAlignment()); - } else { - taskId = msaws.align(loadSeqs(2)); - } +// if (service == Services.JpredWS) { +// taskId = msaws.align(loadAlignment()); +// } else { +// taskId = msaws.align(loadSeqs(2)); +// } + taskId = msaws.align(loadSeqs(2)); writer.print("\nQuerying job status..."); JobStatus status = msaws.getJobStatus(taskId); while (status != JobStatus.FINISHED) { diff --git a/webservices/compbio/ws/server/JpredWS.java b/webservices/compbio/ws/server/JpredWS.java index df9bba4..382ef37 100644 --- a/webservices/compbio/ws/server/JpredWS.java +++ b/webservices/compbio/ws/server/JpredWS.java @@ -16,154 +16,154 @@ * must include this copyright and license notice. */ -package compbio.ws.server; - -import java.io.File; -import java.util.List; - -import javax.jws.WebService; - -import org.apache.log4j.Logger; - -import compbio.data.msa.JABAService; -import compbio.data.msa.MsaWS; -import compbio.data.sequence.Alignment; -import compbio.data.sequence.JpredAlignment; -import compbio.data.sequence.FastaSequence; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.SkeletalExecutable; -import compbio.engine.client.EngineUtil; -import compbio.metadata.ChunkHolder; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Limit; -import compbio.metadata.LimitsManager; -import compbio.metadata.Option; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.metadata.WrongParameterException; -import compbio.runner.RunnerUtil; -import compbio.runner.predictors.Jpred; - -@WebService(endpointInterface = "compbio.data.msa.MsaWS", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "JpredWS") -public class JpredWS implements MsaWS { - - private static Logger log = Logger.getLogger(JpredWS.class); - - private static final RunnerConfig jpredOptions = RunnerUtil.getSupportedOptions(Jpred.class); - private static final PresetManager jpredPresets = RunnerUtil.getPresets(Jpred.class); - private static final LimitsManager limitMan = EngineUtil.getLimits(new Jpred().getType()); - - @Override - public String align(List sequences) - throws JobSubmissionException { - WSUtil.validateFastaInput(sequences); - ConfiguredExecutable confClust = init(sequences); - return WSUtil.align(sequences, confClust, log, "align", getLimit("")); - } - - ConfiguredExecutable init(List dataSet) - throws JobSubmissionException { - Jpred jpred = new Jpred(); - jpred.setInput(SkeletalExecutable.INPUT); - jpred.setOutput(SkeletalExecutable.OUTPUT); - jpred.setError(SkeletalExecutable.ERROR); - ConfiguredExecutable confJpred = Configurator.configureExecutable(jpred, dataSet); - // Set the number of threads for the cluster execution from conf file - if (confJpred.getExecProvider() == Executable.ExecProvider.Cluster) { - int clusterCpuNum = SkeletalExecutable.getClusterCpuNum(jpred.getType()); - if (clusterCpuNum != 0) { - jpred.setNCore(clusterCpuNum); - } - } - return confJpred; - } - - @Override - public String presetAlign(List sequences, - Preset preset) throws JobSubmissionException, - WrongParameterException { - WSUtil.validateFastaInput(sequences); - if (preset == null) { - throw new WrongParameterException("Preset must be provided!"); - } - Limit limit = getLimit(preset.getName()); - ConfiguredExecutable confClust = init(sequences); - confClust.addParameters(preset.getOptions()); - return WSUtil.align(sequences, confClust, log, "presetAlign", limit); - } - - @Override - public String customAlign(List sequences, - List> options) throws JobSubmissionException, - WrongParameterException { - WSUtil.validateFastaInput(sequences); - ConfiguredExecutable confClust = init(sequences); - List params = WSUtil.getCommands(options, Jpred.KEY_VALUE_SEPARATOR); - confClust.addParameters(params); - log.info("Setting parameters: " + params); - return WSUtil.align(sequences, confClust, log, "customAlign", getLimit("")); - } - - @Override - public RunnerConfig getRunnerOptions() { - return jpredOptions; - } - - @SuppressWarnings("unchecked") - @Override - public Alignment getResult(String jobId) throws ResultNotAvailableException { - WSUtil.validateJobId(jobId); - AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); - ConfiguredExecutable jpred = (ConfiguredExecutable) asyncEngine.getResults(jobId); - return (Alignment)jpred.getResults(); - } - - @Override - public Limit getLimit(String presetName) { - if (limitMan == null) { - // No limit is configured - return null; - } - Limit limit = limitMan.getLimitByName(presetName); - return limit; - } - - @Override - public LimitsManager getLimits() { - return limitMan; - } - - @Override - public boolean cancelJob(String jobId) { - WSUtil.validateJobId(jobId); - boolean result = WSUtil.cancelJob(jobId); - return result; - } - - @Override - public JobStatus getJobStatus(String jobId) { - WSUtil.validateJobId(jobId); - JobStatus status = WSUtil.getJobStatus(jobId); - return status; - } - - @Override - public PresetManager getPresets() { - return jpredPresets; - } - - @Override - public ChunkHolder pullExecStatistics(String jobId, long position) { - WSUtil.validateJobId(jobId); - String file = Configurator.getWorkDirectory(jobId) + File.separator + Jpred.getStatFile(); - ChunkHolder cholder = WSUtil.pullFile(file, position); - return cholder; - } - -} +//package compbio.ws.server; +// +//import java.io.File; +//import java.util.List; +// +//import javax.jws.WebService; +// +//import org.apache.log4j.Logger; +// +//import compbio.data.msa.JABAService; +//import compbio.data.msa.MsaWS; +//import compbio.data.sequence.Alignment; +//import compbio.data.sequence.JpredAlignment; +//import compbio.data.sequence.FastaSequence; +//import compbio.engine.AsyncExecutor; +//import compbio.engine.Configurator; +//import compbio.engine.client.ConfiguredExecutable; +//import compbio.engine.client.Executable; +//import compbio.engine.client.SkeletalExecutable; +//import compbio.engine.client.EngineUtil; +//import compbio.metadata.ChunkHolder; +//import compbio.metadata.JobStatus; +//import compbio.metadata.JobSubmissionException; +//import compbio.metadata.Limit; +//import compbio.metadata.LimitsManager; +//import compbio.metadata.Option; +//import compbio.metadata.Preset; +//import compbio.metadata.PresetManager; +//import compbio.metadata.ResultNotAvailableException; +//import compbio.metadata.RunnerConfig; +//import compbio.metadata.WrongParameterException; +//import compbio.runner.RunnerUtil; +//import compbio.runner.predictors.Jpred; +// +//@WebService(endpointInterface = "compbio.data.msa.MsaWS", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "JpredWS") +//public class JpredWS implements MsaWS { +// +// private static Logger log = Logger.getLogger(JpredWS.class); +// +// private static final RunnerConfig jpredOptions = RunnerUtil.getSupportedOptions(Jpred.class); +// private static final PresetManager jpredPresets = RunnerUtil.getPresets(Jpred.class); +// private static final LimitsManager limitMan = EngineUtil.getLimits(new Jpred().getType()); +// +// @Override +// public String align(List sequences) +// throws JobSubmissionException { +// WSUtil.validateFastaInput(sequences); +// ConfiguredExecutable confClust = init(sequences); +// return WSUtil.align(sequences, confClust, log, "align", getLimit("")); +// } +// +// ConfiguredExecutable init(List dataSet) +// throws JobSubmissionException { +// Jpred jpred = new Jpred(); +// jpred.setInput(SkeletalExecutable.INPUT); +// jpred.setOutput(SkeletalExecutable.OUTPUT); +// jpred.setError(SkeletalExecutable.ERROR); +// ConfiguredExecutable confJpred = Configurator.configureExecutable(jpred, dataSet); +// // Set the number of threads for the cluster execution from conf file +// if (confJpred.getExecProvider() == Executable.ExecProvider.Cluster) { +// int clusterCpuNum = SkeletalExecutable.getClusterCpuNum(jpred.getType()); +// if (clusterCpuNum != 0) { +// jpred.setNCore(clusterCpuNum); +// } +// } +// return confJpred; +// } +// +// @Override +// public String presetAlign(List sequences, +// Preset preset) throws JobSubmissionException, +// WrongParameterException { +// WSUtil.validateFastaInput(sequences); +// if (preset == null) { +// throw new WrongParameterException("Preset must be provided!"); +// } +// Limit limit = getLimit(preset.getName()); +// ConfiguredExecutable confClust = init(sequences); +// confClust.addParameters(preset.getOptions()); +// return WSUtil.align(sequences, confClust, log, "presetAlign", limit); +// } +// +// @Override +// public String customAlign(List sequences, +// List> options) throws JobSubmissionException, +// WrongParameterException { +// WSUtil.validateFastaInput(sequences); +// ConfiguredExecutable confClust = init(sequences); +// List params = WSUtil.getCommands(options, Jpred.KEY_VALUE_SEPARATOR); +// confClust.addParameters(params); +// log.info("Setting parameters: " + params); +// return WSUtil.align(sequences, confClust, log, "customAlign", getLimit("")); +// } +// +// @Override +// public RunnerConfig getRunnerOptions() { +// return jpredOptions; +// } +// +// @SuppressWarnings("unchecked") +// @Override +// public Alignment getResult(String jobId) throws ResultNotAvailableException { +// WSUtil.validateJobId(jobId); +// AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); +// ConfiguredExecutable jpred = (ConfiguredExecutable) asyncEngine.getResults(jobId); +// return (Alignment)jpred.getResults(); +// } +// +// @Override +// public Limit getLimit(String presetName) { +// if (limitMan == null) { +// // No limit is configured +// return null; +// } +// Limit limit = limitMan.getLimitByName(presetName); +// return limit; +// } +// +// @Override +// public LimitsManager getLimits() { +// return limitMan; +// } +// +// @Override +// public boolean cancelJob(String jobId) { +// WSUtil.validateJobId(jobId); +// boolean result = WSUtil.cancelJob(jobId); +// return result; +// } +// +// @Override +// public JobStatus getJobStatus(String jobId) { +// WSUtil.validateJobId(jobId); +// JobStatus status = WSUtil.getJobStatus(jobId); +// return status; +// } +// +// @Override +// public PresetManager getPresets() { +// return jpredPresets; +// } +// +// @Override +// public ChunkHolder pullExecStatistics(String jobId, long position) { +// WSUtil.validateJobId(jobId); +// String file = Configurator.getWorkDirectory(jobId) + File.separator + Jpred.getStatFile(); +// ChunkHolder cholder = WSUtil.pullFile(file, position); +// return cholder; +// } +// +//} diff --git a/webservices/compbio/ws/server/WSUtil.java b/webservices/compbio/ws/server/WSUtil.java index 89c7375..19dd631 100644 --- a/webservices/compbio/ws/server/WSUtil.java +++ b/webservices/compbio/ws/server/WSUtil.java @@ -177,24 +177,24 @@ public final class WSUtil { } } - public static void validateJpredInput(List sequences) - throws JobSubmissionException { - validateFastaInput(sequences); - int len = 0; - for (FastaSequence fs : sequences) { - if (len == 0) { - len = fs.getLength(); - continue; - } - if (fs.getLength() != len) { - System.out.println("FASTA rec: id = " + fs.getId() + ": seq = " + fs.getSequence()); - throw new JobSubmissionException( - "All sequences must be of the same length. Please align the sequences " + - " prior to submission! The first sequence length is : " + len + - " but the sequence '" + fs.getId() + "' length is " + fs.getLength()); - } - } - } +// public static void validateJpredInput(List sequences) +// throws JobSubmissionException { +// validateFastaInput(sequences); +// int len = 0; +// for (FastaSequence fs : sequences) { +// if (len == 0) { +// len = fs.getLength(); +// continue; +// } +// if (fs.getLength() != len) { +// System.out.println("FASTA rec: id = " + fs.getId() + ": seq = " + fs.getSequence()); +// throw new JobSubmissionException( +// "All sequences must be of the same length. Please align the sequences " + +// " prior to submission! The first sequence length is : " + len + +// " but the sequence '" + fs.getId() + "' length is " + fs.getLength()); +// } +// } +// } public static ScoreManager getAnnotation(String jobId, Logger log) throws ResultNotAvailableException {