Switch JpredWS from SequenceAnnotation to MsaWS
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 6 Sep 2013 14:29:24 +0000 (15:29 +0100)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 6 Sep 2013 14:29:24 +0000 (15:29 +0100)
datamodel/compbio/data/sequence/Alignment.java
datamodel/compbio/data/sequence/JpredAlignment.java [new file with mode: 0644]
runner/compbio/runner/predictors/Jpred.java
testsrc/compbio/runner/predictors/JpredTester.java
webservices/compbio/ws/client/Services.java
webservices/compbio/ws/client/WSTester.java
webservices/compbio/ws/server/JpredWS.java

index 8fddd0b..3952d25 100644 (file)
@@ -42,12 +42,12 @@ import compbio.util.annotation.Immutable;
  */\r
 @XmlAccessorType(XmlAccessType.FIELD)\r
 @Immutable\r
-public final class Alignment {\r
+public class Alignment {\r
 \r
        private AlignmentMetadata metadata;\r
        private List<FastaSequence> sequences;\r
 \r
-       private Alignment() {\r
+       protected Alignment() {\r
                // This has to has a default constructor for JaxB\r
        }\r
 \r
diff --git a/datamodel/compbio/data/sequence/JpredAlignment.java b/datamodel/compbio/data/sequence/JpredAlignment.java
new file mode 100644 (file)
index 0000000..c7f612f
--- /dev/null
@@ -0,0 +1,237 @@
+/* Copyright (c) 2009 Peter Troshin\r
+ * Copyright (c) 2013 Alexander Sherstnev\r
+ *  \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0\r
+ * \r
+ *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
+ *  Apache License version 2 as published by the Apache Software Foundation\r
+ * \r
+ *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
+ *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
+ *  License for more details.\r
+ * \r
+ *  A copy of the license is in apache_license.txt. It is also available here:\r
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
+ * \r
+ * Any republication or derived work distributed in source code form\r
+ * must include this copyright and license notice.\r
+ */\r
+\r
+package compbio.data.sequence;\r
+\r
+import java.util.List;\r
+import java.util.ArrayList;\r
+\r
+import javax.xml.bind.annotation.XmlAccessType;\r
+import javax.xml.bind.annotation.XmlAccessorType;\r
+\r
+import compbio.util.annotation.Immutable;\r
+import compbio.data.sequence.Alignment;\r
+/**\r
+ * Multiple sequence alignment and Jpred prediction.\r
+ * \r
+ * Does not give any guarantees on the content of individual FastaSequece\r
+ * records. It does not guarantee neither the uniqueness of the names of\r
+ * sequences nor it guarantees the uniqueness of the sequences.\r
+ * \r
+ * @see FastaSequence\r
+ * @see AlignmentMetadata\r
+ * \r
+ * @author pvtroshin\r
+ * \r
+ * @version 1.0 September 2009\r
+ * \r
+ */\r
+@XmlAccessorType(XmlAccessType.FIELD)\r
+@Immutable\r
+public final class JpredAlignment extends Alignment{\r
+\r
+       private AlignmentMetadata metadata;\r
+       private List<FastaSequence> sequences;\r
+       \r
+       FastaSequence jnetpred;\r
+       FastaSequence JNETCONF;\r
+       FastaSequence JNETSOL25;\r
+       FastaSequence JNETSOL5;\r
+       FastaSequence JNETSOL0;\r
+       FastaSequence JNETHMM;\r
+       FastaSequence JNETPSSM;\r
+       FastaSequence JNETJURY;\r
+\r
+       private JpredAlignment() {\r
+               // This has to has a default constructor for JaxB\r
+       }\r
+\r
+       /**\r
+        * @param sequences\r
+        * @param program\r
+        * @param gapchar\r
+        */\r
+       public JpredAlignment(List<FastaSequence> sequences, Program program,\r
+                       char gapchar) {\r
+               DecomposeInitalJpredSeq(sequences);\r
+               this.metadata = new AlignmentMetadata(Program.CLUSTAL, gapchar);\r
+       }\r
+\r
+       /**\r
+        * \r
+        * @param sequences\r
+        * @param metadata\r
+        */\r
+       public JpredAlignment(List<FastaSequence> sequences, AlignmentMetadata metadata) {\r
+               DecomposeInitalJpredSeq(sequences);\r
+               this.metadata = metadata;\r
+       }\r
+\r
+       /**\r
+        * \r
+        * @param sequences\r
+        */\r
+       private void DecomposeInitalJpredSeq(List<FastaSequence> sequences) {\r
+               List<FastaSequence> realsequences = new ArrayList<FastaSequence>();\r
+               for (FastaSequence s : sequences) {\r
+                       if (s.getId().equals("jnetpred")) {\r
+                               this.jnetpred = s;\r
+                       } else if (s.getId().equals("JNETCONF")) {\r
+                               this.JNETCONF = s;\r
+                       } else if (s.getId().equals("JNETSOL25")) {\r
+                               this.JNETSOL25 = s;\r
+                       } else if (s.getId().equals("JNETSOL5")) {\r
+                               this.JNETSOL5 = s;\r
+                       } else if (s.getId().equals("JNETSOL0")) {\r
+                               this.JNETSOL0 = s;\r
+                       } else if (s.getId().equals("JNETHMM")) {\r
+                               this.JNETSOL0 = s;\r
+                       } else if (s.getId().equals("JNETHMM")) {\r
+                               this.JNETHMM = s;\r
+                       } else if (s.getId().equals("JNETSOL0")) {\r
+                               this.JNETPSSM = s;\r
+                       } else if (s.getId().equals("JNETHMM")) {\r
+                               this.JNETJURY = s;\r
+                       } else {\r
+                               realsequences.add(s);\r
+                       }\r
+               }\r
+               this.sequences = realsequences;\r
+       }\r
+\r
+       /**\r
+        * \r
+        * @return Jpred prediction \r
+        */\r
+       public String getJpredPrediction() {\r
+               return this.jnetpred.getSequence();\r
+       }\r
+\r
+       /**\r
+        * \r
+        * @return Jpred JNETSOL25 line\r
+        */\r
+       public String getJpredSOL25() {\r
+               return this.JNETSOL25.getSequence();\r
+       }\r
+\r
+       /**\r
+        * \r
+        * @return Jpred JNETSOL5 line\r
+        */\r
+       public String getJpredSOL5() {\r
+               return this.JNETSOL5.getSequence();\r
+       }\r
+       /**\r
+        * \r
+        * @return Jpred JNETSOL0 line\r
+        */\r
+       public String getJpredSOL0() {\r
+               return this.JNETSOL0.getSequence();\r
+       }\r
+       /**\r
+        * \r
+        * @return Jpred JNETCONF line\r
+        */\r
+       public String getJpredJNETCONF() {\r
+               return this.JNETCONF.getSequence();\r
+       }\r
+       /**\r
+        * \r
+        * @return list of FastaSequence records\r
+        */\r
+       public List<FastaSequence> getSequences() {\r
+               return sequences;\r
+       }\r
+\r
+       /**\r
+        * \r
+        * @return a number of sequence in the alignment\r
+        */\r
+       public int getSize() {\r
+               return this.sequences.size();\r
+       }\r
+\r
+       /**\r
+        * \r
+        * @return AlignmentMetadata object\r
+        */\r
+       public AlignmentMetadata getMetadata() {\r
+               return metadata;\r
+       }\r
+\r
+       @Override\r
+       public String toString() {\r
+               String sseq = "";\r
+               for (FastaSequence fs : getSequences()) {\r
+                       sseq += fs.toString() + "\n";\r
+               }\r
+               return sseq;\r
+       }\r
+\r
+       @Override\r
+       public int hashCode() {\r
+               final int prime = 31;\r
+               int result = 1;\r
+               result = prime * result\r
+                               + ((metadata == null) ? 0 : metadata.hashCode());\r
+               result = prime * result\r
+                               + ((sequences == null) ? 0 : sequences.hashCode());\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * Please note that this implementation does not take the order of sequences\r
+        * into account!\r
+        */\r
+       @Override\r
+       public boolean equals(Object obj) {\r
+               if (obj == null) {\r
+                       return false;\r
+               }\r
+               if (!(obj instanceof Alignment)) {\r
+                       return false;\r
+               }\r
+               Alignment al = (Alignment) obj;\r
+               if (this.getSize() != al.getSize()) {\r
+                       return false;\r
+               }\r
+               if (!this.getMetadata().equals(al.getMetadata())) {\r
+                       return false;\r
+               }\r
+               int outerCounter = 0;\r
+               int matchCounter = 0;\r
+               for (FastaSequence fs : getSequences()) {\r
+                       outerCounter++;\r
+                       for (FastaSequence fs1 : al.getSequences()) {\r
+                               if (fs.equals(fs1)) {\r
+                                       matchCounter++;\r
+                                       continue;\r
+                               }\r
+                       }\r
+                       // Match for at lease one element was not found!\r
+                       if (outerCounter != matchCounter) {\r
+                               return false;\r
+                       }\r
+               }\r
+\r
+               return true;\r
+       }\r
+\r
+}\r
index 7c27a37..12f9487 100644 (file)
@@ -28,16 +28,14 @@ import java.util.List;
 \r
 import org.apache.log4j.Logger;\r
 \r
-import compbio.data.sequence.Alignment;\r
+import compbio.data.sequence.JpredAlignment;\r
 import compbio.data.sequence.AlignmentMetadata;\r
 import compbio.data.sequence.Program;\r
-import compbio.data.sequence.ScoreManager;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.engine.client.CommandBuilder;\r
 import compbio.engine.client.Executable;\r
 import compbio.engine.client.SkeletalExecutable;\r
 import compbio.metadata.ResultNotAvailableException;\r
-import compbio.runner.Util;\r
 \r
 /**\r
  * Command line\r
@@ -62,16 +60,18 @@ public class Jpred extends SkeletalExecutable<Jpred> {
 \r
        public Jpred() {\r
                addParameters(Arrays.asList("-logfile " + STAT_FILE));\r
+               addParameters(Arrays.asList("-jabaws"));\r
        }\r
 \r
        // HashMap<Method, float[]>\r
+       @SuppressWarnings("unchecked")\r
        @Override\r
-       public Alignment getResults(String workDirectory)\r
+       public JpredAlignment getResults(String workDirectory)\r
                        throws ResultNotAvailableException {\r
-               Alignment annotations = null;\r
+               JpredAlignment annotations = null;\r
                try {\r
                        InputStream inStream = new FileInputStream(new File(workDirectory, getOutput()));\r
-                       annotations = new Alignment(SequenceUtil.readJpredFile(inStream), new AlignmentMetadata(Program.Jpred, '-'));\r
+                       annotations = new JpredAlignment(SequenceUtil.readJpredFile(inStream), new AlignmentMetadata(Program.Jpred, '-'));\r
                } catch (FileNotFoundException e) {\r
                        log.error(e.getMessage(), e.getCause());\r
                        throw new ResultNotAvailableException(e);\r
index 6eb6f6f..b1b991f 100644 (file)
@@ -38,7 +38,7 @@ import org.ggf.drmaa.JobInfo;
 import org.testng.annotations.BeforeMethod;\r
 import org.testng.annotations.Test;\r
 \r
-import compbio.data.sequence.Alignment;\r
+import compbio.data.sequence.JpredAlignment;\r
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.FilePuller;\r
@@ -174,10 +174,10 @@ public class JpredTester {
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       Alignment annotations = confpred.getResults();\r
-                       assertNotNull(annotations);\r
-                       assertEquals(annotations.getSize(), 19);\r
-                       assertEquals(al1.getResults(), annotations);\r
+                       JpredAlignment totalign = (JpredAlignment) confpred.getResults();\r
+                       assertNotNull(totalign);\r
+                       assertEquals(totalign.getSize(), 14);\r
+                       assertEquals(al1.getResults(), totalign);\r
                } catch (JobSubmissionException e) {\r
                        e.printStackTrace();\r
                        fail(e.getLocalizedMessage());\r
@@ -190,7 +190,7 @@ public class JpredTester {
                }\r
        }\r
 \r
-       @Test(groups = {AllTestSuit.test_group_runner})\r
+       @Test(enabled=false,groups = {AllTestSuit.test_group_runner})\r
        public void RunLocallyWithPreset() {\r
                try {\r
                        ConfiguredExecutable<Jpred> confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Local);\r
@@ -204,10 +204,10 @@ public class JpredTester {
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       Alignment annotations = confpred.getResults();\r
-                       assertNotNull(annotations);\r
-                       assertEquals(annotations.getSize(), 19);\r
-                       assertEquals(al1.getResults(), annotations);\r
+                       JpredAlignment totalign = (JpredAlignment) confpred.getResults();\r
+                       assertNotNull(totalign);\r
+                       assertEquals(totalign.getSize(), 19);\r
+                       assertEquals(al1.getResults(), totalign);\r
                } catch (JobSubmissionException e) {\r
                        e.printStackTrace();\r
                        fail(e.getLocalizedMessage());\r
@@ -220,7 +220,7 @@ public class JpredTester {
                }\r
        }\r
        \r
-       @Test(groups = {AllTestSuit.test_group_runner})\r
+       @Test(enabled=false,groups = {AllTestSuit.test_group_runner})\r
        public void readStatistics() {\r
                try {\r
                        Jpred jpred = new Jpred();\r
@@ -275,7 +275,7 @@ public class JpredTester {
                }\r
        }\r
 \r
-       @Test(groups = {AllTestSuit.test_group_runner})\r
+       @Test(enabled=false,groups = {AllTestSuit.test_group_runner})\r
        public void Persistance() {\r
                try {\r
                        Jpred jpred = new Jpred();\r
@@ -333,7 +333,7 @@ public class JpredTester {
                }\r
        }\r
 \r
-       @Test(groups = {AllTestSuit.test_group_runner})\r
+       @Test(enabled=false,groups = {AllTestSuit.test_group_runner})\r
        public void ConfigurationLoading() {\r
                try {\r
                        RunnerConfig<Jpred> jpredConfig = ConfExecutable.getRunnerOptions(Jpred.class);\r
index 8a392d7..2720eb7 100644 (file)
@@ -72,12 +72,12 @@ public enum Services {
        Class<? extends JABAService> getServiceType() {\r
                switch (this) {\r
                        case AAConWS :\r
-                       case JpredWS :\r
                        case JronnWS :\r
                        case DisemblWS :\r
                        case GlobPlotWS :\r
                        case IUPredWS :\r
                                return SequenceAnnotation.class;\r
+                       case JpredWS :\r
                        case ClustalWS :\r
                        case ClustalOWS :\r
                        case MafftWS :\r
index 2f33cb1..bae843b 100644 (file)
@@ -1,6 +1,7 @@
 /* Copyright (c) 2011 Peter Troshin\r
+ * Copyright (c) 2013 Alexander Sherstnev\r
  *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0\r
  * \r
  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
  *  Apache License version 2 as published by the Apache Software Foundation\r
@@ -56,32 +57,27 @@ import compbio.util.Util;
  * \r
  * @author pvtroshin\r
  * \r
- * @version 1.0 February 2010\r
+ * @version 1.5 February 2013\r
  */\r
 public class WSTester {\r
 \r
        /**\r
-        * Sequences to be used as input for all WS\r
+        * Test sequences to be used as input for WS\r
         */\r
-       public static final String fastaInput2records = ">Foo\n"\r
-                       + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV"\r
-                       + "\n>Bar\n"\r
-                       + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVA\n";\r
-       public static final String fastaInput1record = ">Foo\n"\r
-                       + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV"\r
-                       + "\n";\r
-\r
-       public static final String fastaAlignment = ">Foo\n"\r
-                       + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV--------\n"\r
-                       + ">Bar\n"\r
-                       + "ASDAAPEH------------PGIALWLHALE-DAGQAEAAA---AYTRAHQLLPEEPYITAQLLNAVA\n"\r
-                       + "";\r
-\r
-       static final List<FastaSequence> seqs = loadSeqs(2);\r
+       public static final String fastaInput2records = \r
+                       ">Foo\nMTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV\n"\r
+               +   ">Bar\nASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVA\n";\r
+       public static final String fastaInput1record = \r
+                       ">Foo\nMTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV\n";\r
+       public static final String fastaAlignment = \r
+                       ">Foo\nMTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV--------\n"\r
+               +   ">Bar\nASDAAPEH------------PGIALWLHALE-DAGQAEAAA---AYTRAHQLLPEEPYITAQLLNAVA\n";\r
 \r
+       /**\r
+        * Status strings\r
+        */\r
        private static final String FAILED = "FAILED";\r
        private static final String OK = "OK";\r
-\r
        private static final String UNSUPPORTED = "UNSUPPORTED";\r
 \r
        /**\r
@@ -173,7 +169,7 @@ public class WSTester {
                        writer.print("Aligning with preset '" + preset.getName() + "'... ");\r
                        Alignment al = null;\r
                        try {\r
-                               String taskId = msaws.presetAlign(seqs, preset);\r
+                               String taskId = msaws.presetAlign(loadSeqs(2), preset);\r
                                al = msaws.getResult(taskId);\r
                                if (al != null) {\r
                                        writer.println(OK);\r
@@ -194,10 +190,10 @@ public class WSTester {
                return succeed;\r
        }\r
 \r
-       private <T> boolean testMsaWS(MsaWS<T> msaws) throws Exception {\r
+       private <T> boolean testMsaWS(MsaWS<T> msaws, Services service) throws Exception {\r
                assert msaws != null;\r
 \r
-               boolean succeed = testDefaultAlignment(msaws);\r
+               boolean succeed = testDefaultAlignment(msaws, service);\r
                // If exception above is thrown than the tests below is not run\r
 \r
                PresetManager<T> pmanager = msaws.getPresets();\r
@@ -228,7 +224,7 @@ public class WSTester {
                        }\r
 \r
                        if (wservice instanceof MsaWS) {\r
-                               return testMsaWS((MsaWS<T>) wservice);\r
+                               return testMsaWS((MsaWS<T>) wservice, service);\r
                        } else if (wservice instanceof SequenceAnnotation) {\r
                                return testSequenceAnnotationWS(\r
                                                (SequenceAnnotation<T>) wservice, service);\r
@@ -249,9 +245,6 @@ public class WSTester {
                if (service == Services.AAConWS) {\r
                        input = loadAlignment();\r
                }\r
-               if (service == Services.JpredWS) {\r
-                       input = loadSeqs(1);\r
-               }\r
                boolean success = testDefaultAnalyse(input, wservice, null, null);\r
 \r
                PresetManager<T> presetman = wservice.getPresets();\r
@@ -343,12 +336,17 @@ public class WSTester {
         * @param msaws\r
         * @throws UnsupportedRuntimeException\r
         */\r
-       private <T> boolean testDefaultAlignment(MsaWS<T> msaws) throws Exception {\r
+       private <T> boolean testDefaultAlignment(MsaWS<T> msaws, Services service) throws Exception {\r
                writer.print("Testing alignment with default parameters:");\r
                Alignment al = null;\r
                boolean succeed = false;\r
+               String taskId;\r
 \r
-               String taskId = msaws.align(seqs);\r
+               if (service == Services.JpredWS) {\r
+                       taskId = msaws.align(loadSeqs(1));\r
+               } else {\r
+                       taskId = msaws.align(loadSeqs(2));\r
+               }\r
                writer.print("\nQuerying job status...");\r
                JobStatus status = msaws.getJobStatus(taskId);\r
                while (status != JobStatus.FINISHED) {\r
index b0aa158..eebc96f 100644 (file)
@@ -1,8 +1,6 @@
 /* Copyright (c) 2011 Peter Troshin\r
- * Copyright (c) 2013 Alexander Sherstnev\r
  *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS)\r
- *  @version: 2.5     \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
  * \r
  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
  *  Apache License version 2 as published by the Apache Software Foundation\r
@@ -17,6 +15,7 @@
  * Any republication or derived work distributed in source code form\r
  * must include this copyright and license notice.\r
  */\r
+\r
 package compbio.ws.server;\r
 \r
 import java.io.File;\r
@@ -27,61 +26,145 @@ import javax.jws.WebService;
 import org.apache.log4j.Logger;\r
 \r
 import compbio.data.msa.JABAService;\r
-import compbio.data.msa.SequenceAnnotation;\r
+import compbio.data.msa.MsaWS;\r
+import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.FastaSequence;\r
+import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.Executable;\r
+import compbio.engine.client.SkeletalExecutable;\r
 import compbio.metadata.ChunkHolder;\r
+import compbio.metadata.JobStatus;\r
 import compbio.metadata.JobSubmissionException;\r
-import compbio.metadata.LimitExceededException;\r
+import compbio.metadata.Limit;\r
+import compbio.metadata.LimitsManager;\r
 import compbio.metadata.Option;\r
 import compbio.metadata.Preset;\r
-import compbio.metadata.UnsupportedRuntimeException;\r
+import compbio.metadata.PresetManager;\r
+import compbio.metadata.ResultNotAvailableException;\r
+import compbio.metadata.RunnerConfig;\r
 import compbio.metadata.WrongParameterException;\r
+import compbio.runner.Util;\r
 import compbio.runner.predictors.Jpred;\r
 \r
-@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "JpredWS")\r
-public class JpredWS extends SequenceAnnotationService<Jpred>\r
-               implements SequenceAnnotation<Jpred> {\r
+@WebService(endpointInterface = "compbio.data.msa.MsaWS", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "JpredWS")\r
+public class JpredWS implements MsaWS<Jpred> {\r
 \r
        private static Logger log = Logger.getLogger(JpredWS.class);\r
 \r
-       public JpredWS() {\r
-               super(new Jpred(), log);\r
+       private static final RunnerConfig<Jpred> jpredOptions = Util.getSupportedOptions(Jpred.class);\r
+\r
+       private static final PresetManager<Jpred> jpredPresets = Util.getPresets(Jpred.class);\r
+\r
+       private static final LimitsManager<Jpred> limitMan = compbio.engine.client.Util.getLimits(new Jpred().getType());\r
+\r
+       @Override\r
+       public String align(List<FastaSequence> sequences)\r
+                       throws JobSubmissionException {\r
+\r
+               WSUtil.validateFastaInput(sequences);\r
+               ConfiguredExecutable<Jpred> confClust = init(sequences);\r
+               return WSUtil.align(sequences, confClust, log, "align", getLimit(""));\r
+       }\r
+\r
+       ConfiguredExecutable<Jpred> init(List<FastaSequence> dataSet)\r
+                       throws JobSubmissionException {\r
+               Jpred jpred = new Jpred();\r
+               jpred.setInput(SkeletalExecutable.INPUT);\r
+               jpred.setOutput(SkeletalExecutable.OUTPUT);\r
+               jpred.setError(SkeletalExecutable.ERROR);\r
+               ConfiguredExecutable<Jpred> confClust = Configurator.configureExecutable(jpred, dataSet);\r
+               // Set the number of threads for the cluster execution from conf file\r
+               if (confClust.getExecProvider() == Executable.ExecProvider.Cluster) {\r
+                       int clusterCpuNum = SkeletalExecutable.getClusterCpuNum(jpred.getType());\r
+                       if (clusterCpuNum != 0) {\r
+                               jpred.setNCore(clusterCpuNum);\r
+                       }\r
+               }\r
+               return confClust;\r
        }\r
 \r
        @Override\r
-       public String analize(List<FastaSequence> sequences)\r
-                       throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException {\r
-               WSUtil.validateJpredInput(sequences);\r
-               ConfiguredExecutable<Jpred> confpred = init(sequences);\r
-\r
-               // set default conservation method to fastest - SHENKIN\r
-               // TODO: This violates encapsulation, should be moved to the runners\r
-               // level.\r
-               //confpred.addParameters(Arrays.asList("-m=SHENKIN"));\r
-               return WSUtil.analize(sequences, confpred, log, "JpredWS analize", getLimit(""));\r
+       public String presetAlign(List<FastaSequence> sequences,\r
+                       Preset<Jpred> preset) throws JobSubmissionException,\r
+                       WrongParameterException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               if (preset == null) {\r
+                       throw new WrongParameterException("Preset must be provided!");\r
+               }\r
+               Limit<Jpred> limit = getLimit(preset.getName());\r
+               ConfiguredExecutable<Jpred> confClust = init(sequences);\r
+               confClust.addParameters(preset.getOptions());\r
+               return WSUtil.align(sequences, confClust, log, "presetAlign", limit);\r
        }\r
 \r
        @Override\r
-       public String customAnalize(List<FastaSequence> sequences, List<Option<Jpred>> options) \r
-                                       throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException {\r
-               WSUtil.validateJpredInput(sequences);\r
-               return super.customAnalize(sequences, options);\r
+       public String customAlign(List<FastaSequence> sequences,\r
+                       List<Option<Jpred>> options) throws JobSubmissionException,\r
+                       WrongParameterException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               ConfiguredExecutable<Jpred> confClust = init(sequences);\r
+               List<String> params = WSUtil.getCommands(options, Jpred.KEY_VALUE_SEPARATOR);\r
+               confClust.addParameters(params);\r
+               log.info("Setting parameters: " + params);\r
+               return WSUtil.align(sequences, confClust, log, "customAlign", getLimit(""));\r
+       }\r
+\r
+       @Override\r
+       public RunnerConfig<Jpred> getRunnerOptions() {\r
+               return jpredOptions;\r
+       }\r
+\r
+       @SuppressWarnings("unchecked")\r
+       @Override\r
+       public Alignment getResult(String jobId) throws ResultNotAvailableException {\r
+               WSUtil.validateJobId(jobId);\r
+               AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);\r
+               ConfiguredExecutable<Jpred> jpred = (ConfiguredExecutable<Jpred>) asyncEngine.getResults(jobId);\r
+               return jpred.getResults();\r
+       }\r
+\r
+       @Override\r
+       public Limit<Jpred> getLimit(String presetName) {\r
+               if (limitMan == null) {\r
+                       // No limit is configured\r
+                       return null;\r
+               }\r
+               Limit<Jpred> limit = limitMan.getLimitByName(presetName);\r
+               return limit;\r
+       }\r
+\r
+       @Override\r
+       public LimitsManager<Jpred> getLimits() {\r
+               return limitMan;\r
+       }\r
+\r
+       @Override\r
+       public boolean cancelJob(String jobId) {\r
+               WSUtil.validateJobId(jobId);\r
+               boolean result = WSUtil.cancelJob(jobId);\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public JobStatus getJobStatus(String jobId) {\r
+               WSUtil.validateJobId(jobId);\r
+               JobStatus status = WSUtil.getJobStatus(jobId);\r
+               return status;\r
        }\r
 \r
        @Override\r
-       public String presetAnalize(List<FastaSequence> sequences, Preset<Jpred> preset)\r
-                       throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException {\r
-               WSUtil.validateJpredInput(sequences);\r
-               return super.presetAnalize(sequences, preset);\r
+       public PresetManager<Jpred> getPresets() {\r
+               return jpredPresets;\r
        }\r
 \r
        @Override\r
        public ChunkHolder pullExecStatistics(String jobId, long position) {\r
                WSUtil.validateJobId(jobId);\r
                String file = Configurator.getWorkDirectory(jobId) + File.separator + Jpred.getStatFile();\r
-               return WSUtil.pullFile(file, position);\r
+               ChunkHolder cholder = WSUtil.pullFile(file, position);\r
+               return cholder;\r
        }\r
 \r
 }\r