Further work on AAConWS
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Mon, 20 Dec 2010 13:56:37 +0000 (13:56 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Mon, 20 Dec 2010 13:56:37 +0000 (13:56 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3534 e3abac25-378b-4346-85de-24260fe3988d

datamodel/compbio/data/sequence/ConservationMethod.java [moved from datamodel/compbio/data/sequence/Method.java with 96% similarity]
datamodel/compbio/data/sequence/SMERFSConstraints.java [new file with mode: 0644]
datamodel/compbio/data/sequence/Score.java
datamodel/compbio/data/sequence/SequenceUtil.java
testsrc/compbio/runner/conservation/AAConTester.java
testsrc/compbio/ws/client/TestAAConWS.java
webservices/compbio/data/msa/Annotation.java
webservices/compbio/ws/client/Services.java
webservices/compbio/ws/server/AAConWS.java

@@ -21,10 +21,10 @@ package compbio.data.sequence;
  * 
  * @author Agnieszka Golicz & Peter Troshin
  */
-public enum Method {
+public enum ConservationMethod {
        KABAT, JORES, SCHNEIDER, SHENKIN, GERSTEIN, TAYLOR_GAPS, TAYLOR_NO_GAPS, ZVELIBIL, KARLIN, ARMON, THOMPSON, NOT_LANCET, MIRNY, WILLIAMSON, LANDGRAF, SANDER, VALDAR, SMERFS;
 
-       public static Method getMethod(String meth) {
+       public static ConservationMethod getMethod(String meth) {
                meth = meth.trim().toLowerCase();
                if (meth.equalsIgnoreCase(KABAT.toString())) {
                        return KABAT;
diff --git a/datamodel/compbio/data/sequence/SMERFSConstraints.java b/datamodel/compbio/data/sequence/SMERFSConstraints.java
new file mode 100644 (file)
index 0000000..ca8496e
--- /dev/null
@@ -0,0 +1,40 @@
+package compbio.data.sequence;\r
+\r
+/**\r
+ * Enumeration defining two constraints for SMERFS columns score calculation.\r
+ * MAX_SCORE gives the highest core of all the windows the column belongs to.\r
+ * MID_SCORE gives the window score to the column in the middle.\r
+ * \r
+ * @author Agnieszka Golicz & Peter Troshin\r
+ */\r
+public enum SMERFSConstraints {\r
+\r
+       MAX_SCORE, MID_SCORE;\r
+\r
+       /**\r
+        * Default column scoring schema\r
+        */\r
+       public static final SMERFSConstraints DEFAULT_COLUMN_SCORE = SMERFSConstraints.MID_SCORE;\r
+\r
+       /**\r
+        * Default window size value for SMERFS algorithm\r
+        */\r
+       public static final int DEFAULT_WINDOW_SIZE = 7;\r
+\r
+       /**\r
+        * Default gap threshold value for SMERFS algorithm\r
+        */\r
+       public static final double DEFAULT_GAP_THRESHOLD = 0.1;\r
+\r
+       public static SMERFSConstraints getSMERFSColumnScore(String score) {\r
+\r
+               score = score.trim().toLowerCase();\r
+               if (score.equalsIgnoreCase(SMERFSConstraints.MAX_SCORE.toString())) {\r
+                       return SMERFSConstraints.MAX_SCORE;\r
+               }\r
+               if (score.equalsIgnoreCase(SMERFSConstraints.MID_SCORE.toString())) {\r
+                       return SMERFSConstraints.MID_SCORE;\r
+               }\r
+               return null;\r
+       }\r
+}\r
index 3416e78..0e49a08 100644 (file)
@@ -12,7 +12,7 @@ import compbio.util.annotation.Immutable;
 @Immutable\r
 public class Score {\r
 \r
-       private Method method;\r
+       private ConservationMethod method;\r
 \r
        private List<Float> scores;\r
 \r
@@ -20,12 +20,12 @@ public class Score {
                // JaXB default constructor\r
        }\r
 \r
-       public Score(Method method, List<Float> scores) {\r
+       public Score(ConservationMethod method, List<Float> scores) {\r
                this.method = method;\r
                this.scores = scores;\r
        }\r
 \r
-       public Method getMethod() {\r
+       public ConservationMethod getMethod() {\r
                return method;\r
        }\r
 \r
index ddd1222..20628a1 100644 (file)
@@ -467,7 +467,7 @@ public final class SequenceUtil {
         * \r
         * @param results\r
         *            output file of AAConservation\r
-        * @return Map with keys {@link Method} -> float[]\r
+        * @return Map with keys {@link ConservationMethod} -> float[]\r
         */\r
        public static HashSet<Score> readAAConResults(InputStream results) {\r
                if (results == null) {\r
@@ -483,7 +483,7 @@ public final class SequenceUtil {
                        assert spacePos > 0 : "Space is expected as delimited between method "\r
                                        + "name and values!";\r
                        String methodLine = line.substring(0, spacePos);\r
-                       Method method = Method.getMethod(methodLine);\r
+                       ConservationMethod method = ConservationMethod.getMethod(methodLine);\r
                        assert method != null : "Method " + methodLine\r
                                        + " is not recognized! ";\r
                        Scanner valuesScanner = new Scanner(line.substring(spacePos));\r
index edf637b..fd3749b 100644 (file)
@@ -37,7 +37,7 @@ import org.ggf.drmaa.JobInfo;
 import org.testng.annotations.BeforeMethod;\r
 import org.testng.annotations.Test;\r
 \r
-import compbio.data.sequence.Method;\r
+import compbio.data.sequence.ConservationMethod;\r
 import compbio.data.sequence.MultiAnnotatedSequence;\r
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
@@ -188,7 +188,7 @@ public class AAConTester {
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       MultiAnnotatedSequence<Method> annotations = confAAcon.getResults();\r
+                       MultiAnnotatedSequence<ConservationMethod> annotations = confAAcon.getResults();\r
                        assertNotNull(annotations);\r
                        assertEquals(annotations.getAnnotations().size(), 1);\r
                        assertEquals(al1.getResults(), annotations);\r
@@ -219,7 +219,7 @@ public class AAConTester {
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       MultiAnnotatedSequence<Method> annotations = confAAcon.getResults();\r
+                       MultiAnnotatedSequence<ConservationMethod> annotations = confAAcon.getResults();\r
                        assertNotNull(annotations);\r
                        assertEquals(annotations.getAnnotations().size(), 13);\r
                        assertEquals(al1.getResults(), annotations);\r
@@ -252,7 +252,7 @@ public class AAConTester {
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       MultiAnnotatedSequence<Method> annotations = confAAcon.getResults();\r
+                       MultiAnnotatedSequence<ConservationMethod> annotations = confAAcon.getResults();\r
                        assertNotNull(annotations);\r
                        assertEquals(annotations.getAnnotations().size(), 3);\r
                        assertEquals(al1.getResults(), annotations);\r
index a6affb9..e0b002c 100644 (file)
@@ -8,21 +8,17 @@ import java.io.File;
 import java.io.FileInputStream;\r
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
-import java.net.MalformedURLException;\r
-import java.net.URL;\r
 import java.util.ArrayList;\r
 import java.util.HashSet;\r
 import java.util.List;\r
 \r
-import javax.xml.namespace.QName;\r
-import javax.xml.ws.Service;\r
-\r
 import org.testng.annotations.BeforeTest;\r
 import org.testng.annotations.Test;\r
 \r
 import compbio.data.msa.Annotation;\r
+import compbio.data.msa.JABAService;\r
 import compbio.data.sequence.FastaSequence;\r
-import compbio.data.sequence.Method;\r
+import compbio.data.sequence.ConservationMethod;\r
 import compbio.data.sequence.Score;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.metadata.JobSubmissionException;\r
@@ -41,18 +37,19 @@ public class TestAAConWS {
 \r
        @BeforeTest\r
        void initConnection() {\r
-               URL url = null;\r
-               try {\r
-                       url = new URL("http://localhost:8080/jabaws/AAConWS?wsdl");\r
-               } catch (MalformedURLException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getLocalizedMessage());\r
-               }\r
-               String namespace = "http://msa.data.compbio/01/12/2010/";\r
-               QName qname = new QName(namespace, "AAConWS");\r
-               Service serv = Service.create(url, qname);\r
-               msaws = serv.getPort(new QName(namespace, "AAConWSPort"),\r
-                               Annotation.class);\r
+               /*\r
+                * URL url = null; try { url = new\r
+                * URL("http://localhost:8080/jabaws/AAConWS?wsdl"); } catch\r
+                * (MalformedURLException e) { e.printStackTrace();\r
+                * fail(e.getLocalizedMessage()); } String namespace =\r
+                * "http://msa.data.compbio/01/12/2010/"; QName qname = new\r
+                * QName(namespace, "AAConWS"); Service serv = Service.create(url,\r
+                * qname); msaws = serv.getPort(new QName(namespace, "AAConWSPort"),\r
+                * Annotation.class);\r
+                */\r
+               JABAService client = Jws2Client.connect("http://localhost:8080/jabaws",\r
+                               Services.AAConWS);\r
+               msaws = (Annotation<AACon>) client;\r
        }\r
 \r
        @Test\r
@@ -83,7 +80,7 @@ public class TestAAConWS {
                        HashSet<Score> result = msaws.getAnnotation(jobId);\r
                        assertNotNull(result);\r
                        assertEquals(result.size(), 1);\r
-                       assertEquals(result.iterator().next().getMethod(), Method.SHENKIN);\r
+                       assertEquals(result.iterator().next().getMethod(), ConservationMethod.SHENKIN);\r
                        List<Float> scores = result.iterator().next().getScores();\r
                        assertNotNull(scores);\r
                        assertEquals(scores.size(), 568);\r
index 27a1d55..1de9f30 100644 (file)
@@ -9,6 +9,7 @@ import javax.jws.WebParam;
 import javax.jws.WebService;\r
 \r
 import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.SMERFSConstraints;\r
 import compbio.data.sequence.Score;\r
 import compbio.metadata.JobSubmissionException;\r
 import compbio.metadata.LimitExceededException;\r
@@ -163,6 +164,48 @@ public interface Annotation<T> extends JABAService, JManagement, Metadata<T> {
                        JobSubmissionException, WrongParameterException;\r
 \r
        /**\r
+        * \r
+        * Analyse the sequences. The actual analysis algorithm is defined by the\r
+        * type T.\r
+        * \r
+        * Any dataset containing a greater number of sequences or the average\r
+        * length of the sequences are greater then defined in the default Limit\r
+        * will not be accepted for an alignment operation and\r
+        * JobSubmissionException will be thrown.\r
+        * \r
+        * @param sequences\r
+        *            List of FastaSequence objects. The programme does not perform\r
+        *            any sequence validity checks. Nor does it checks whether the\r
+        *            sequences names are unique. It is responsibility of the caller\r
+        *            to validate this information\r
+        * @return jobId - unique identifier for the job\r
+        * @throws JobSubmissionException\r
+        *             is thrown when the job could not be submitted due to the\r
+        *             following reasons: 1) The number of sequences in the\r
+        *             submission or their average length is greater then defined by\r
+        *             the default Limit. 2) Any problems on the server side e.g. it\r
+        *             is misconfigured or malfunction, is reported via this\r
+        *             exception. In the first case the information on the limit\r
+        *             could be obtained from an exception.\r
+        * @throws InvalidParameterException\r
+        *             thrown if input list of fasta sequence is null or empty\r
+        * @throws UnsupportedRuntimeException\r
+        *             thrown if server OS does not support native executables for a\r
+        *             given web service, e.g. JABAWS is deployed on Windows and\r
+        *             Mafft service is called\r
+        * @throws LimitExceededException\r
+        *             is throw if the input sequences number or average length\r
+        *             exceeds what is defined by the limit\r
+        */\r
+       @WebMethod\r
+       String customSMERFS(\r
+                       @WebParam(name = "fastaSequences") List<FastaSequence> sequences,\r
+                       int windowWidth, SMERFSConstraints scoringMethod,\r
+                       float gapTreshold, boolean normalize)\r
+                       throws UnsupportedRuntimeException, LimitExceededException,\r
+                       JobSubmissionException;\r
+\r
+       /**\r
         * Return the result of the job.\r
         * \r
         * @param jobId\r
index 95a0a89..6734a36 100644 (file)
@@ -70,7 +70,6 @@ public enum Services {
 \r
                switch (this) {\r
                        case AAConWS :\r
-\r
                                return service.getPort(portName, Annotation.class);\r
 \r
                                // deliberate leaking\r
index a32533f..f9d8ce6 100644 (file)
@@ -13,6 +13,7 @@ import org.apache.log4j.Logger;
 \r
 import compbio.data.msa.Annotation;\r
 import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.SMERFSConstraints;\r
 import compbio.data.sequence.Score;\r
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
@@ -174,4 +175,13 @@ public class AAConWS implements Annotation<AACon> {
                return WSUtil.align(sequences, confAAcon, null, "presetAnalize", limit);\r
        }\r
 \r
+       @Override\r
+       public String customSMERFS(List<FastaSequence> sequences, int windowWidth,\r
+                       SMERFSConstraints scoringMethod, float gapTreshold,\r
+                       boolean normalize) throws UnsupportedRuntimeException,\r
+                       LimitExceededException, JobSubmissionException {\r
+               // TODO Auto-generated method stub\r
+               return null;\r
+       }\r
+\r
 }\r