DisEMBL and GlobProt web services further work
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 9 Feb 2011 14:51:20 +0000 (14:51 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 9 Feb 2011 14:51:20 +0000 (14:51 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3727 e3abac25-378b-4346-85de-24260fe3988d

datamodel/compbio/data/sequence/SequenceUtil.java
runner/compbio/runner/disorder/Disembl.java
runner/compbio/runner/disorder/GlobPlot.java
testsrc/compbio/data/sequence/SequenceUtilTester.java
testsrc/testdata/disembl.out
webservices/compbio/ws/client/Jws2Client.java
webservices/compbio/ws/client/Services.java
webservices/compbio/ws/server/DisemblWS.java

index 754cf5f..3990f8f 100644 (file)
@@ -30,7 +30,6 @@ import java.util.HashSet;
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.Scanner;\r
-import java.util.Set;\r
 import java.util.SortedSet;\r
 import java.util.TreeSet;\r
 import java.util.logging.Level;\r
@@ -365,7 +364,7 @@ public final class SequenceUtil {
                infasta.close();\r
                return seqs;\r
        }\r
-               \r
+\r
        private static float[] convertToNumber(String[] annotValues)\r
                        throws UnknownFileFormatException {\r
                float[] annotation = new float[annotValues.length];\r
@@ -431,7 +430,7 @@ public final class SequenceUtil {
         * @throws IOException\r
         * @throws UnknownFileFormatException\r
         */\r
-       public static Map<FastaSequence, Set<Score>> readDisembl(\r
+       public static HashMap<FastaSequence, HashSet<Score>> readDisembl(\r
                        final InputStream input) throws IOException,\r
                        UnknownFileFormatException {\r
                Scanner scan = new Scanner(input);\r
@@ -443,7 +442,7 @@ public final class SequenceUtil {
                                                        + " No such line was found!");\r
                }\r
 \r
-               Map<FastaSequence, Set<Score>> results = new HashMap<FastaSequence, Set<Score>>();\r
+               HashMap<FastaSequence, HashSet<Score>> results = new HashMap<FastaSequence, HashSet<Score>>();\r
                int seqCounter = 0;\r
                while (scan.hasNext()) {\r
                        seqCounter++;\r
@@ -478,7 +477,7 @@ public final class SequenceUtil {
                        }\r
                        FastaSequence fs = new FastaSequence(sequenceName,\r
                                        seqbuffer.toString());\r
-                       Set<Score> scores = new HashSet<Score>();\r
+                       HashSet<Score> scores = new HashSet<Score>();\r
                        scores.add(new Score(DisemblResult.COILS, coils, coilsR));\r
                        scores.add(new Score(DisemblResult.HOTLOOPS, hotloops, rem465R));\r
                        scores.add(new Score(DisemblResult.REM465, rem, loopsR));\r
@@ -486,7 +485,7 @@ public final class SequenceUtil {
 \r
                        scansingle.close();\r
                }\r
-\r
+               scan.close();\r
                input.close();\r
                return results;\r
        }\r
@@ -506,10 +505,12 @@ public final class SequenceUtil {
         */\r
        private static SortedSet<Range> parseRanges(Enum resultType, String lines) {\r
                SortedSet<Range> ranges = new TreeSet<Range>();\r
+\r
                Scanner scan = new Scanner(lines);\r
 \r
                assert scan.hasNext();\r
-               assert "#".equals(scan.next()); // pass delimiter #\r
+               String del = scan.next();\r
+               assert "#".equals(del); // pass delimiter #\r
                String type = scan.next(); // pass enum name e.g. COILS\r
                assert resultType.toString().equalsIgnoreCase(type) : "Unknown result type: "\r
                                + resultType.toString();\r
@@ -525,10 +526,10 @@ public final class SequenceUtil {
                return ranges;\r
        }\r
 \r
-       public static Map<String, Set<Score>> removeSequences(\r
-                       Map<FastaSequence, Set<Score>> disemblResults) {\r
-               Map<String, Set<Score>> seqNameScores = new HashMap<String, Set<Score>>();\r
-               for (Map.Entry<FastaSequence, Set<Score>> dres : disemblResults\r
+       public static HashMap<String, HashSet<Score>> removeSequences(\r
+                       HashMap<FastaSequence, HashSet<Score>> disemblResults) {\r
+               HashMap<String, HashSet<Score>> seqNameScores = new HashMap<String, HashSet<Score>>();\r
+               for (Map.Entry<FastaSequence, HashSet<Score>> dres : disemblResults\r
                                .entrySet()) {\r
                        seqNameScores.put(dres.getKey().getId(), dres.getValue());\r
                }\r
@@ -559,7 +560,7 @@ public final class SequenceUtil {
         * @throws IOException\r
         * @throws UnknownFileFormatException\r
         */\r
-       public static Map<FastaSequence, Set<Score>> readGlobPlot(\r
+       public static HashMap<FastaSequence, HashSet<Score>> readGlobPlot(\r
                        final InputStream input) throws IOException,\r
                        UnknownFileFormatException {\r
                Scanner scan = new Scanner(input);\r
@@ -571,7 +572,7 @@ public final class SequenceUtil {
                                                        + " No such line was found!");\r
                }\r
 \r
-               Map<FastaSequence, Set<Score>> results = new HashMap<FastaSequence, Set<Score>>();\r
+               HashMap<FastaSequence, HashSet<Score>> results = new HashMap<FastaSequence, HashSet<Score>>();\r
                int seqCounter = 0;\r
                while (scan.hasNext()) {\r
                        seqCounter++;\r
@@ -604,7 +605,7 @@ public final class SequenceUtil {
                        }\r
                        FastaSequence fs = new FastaSequence(sequenceName,\r
                                        seqbuffer.toString());\r
-                       Set<Score> scores = new HashSet<Score>();\r
+                       HashSet<Score> scores = new HashSet<Score>();\r
                        scores.add(new Score(GlobProtResult.Disorder, disorderR));\r
                        scores.add(new Score(GlobProtResult.GlobDoms, domsR));\r
                        scores.add(new Score(GlobProtResult.Dydx, dydxScore));\r
@@ -614,7 +615,7 @@ public final class SequenceUtil {
 \r
                        scansingle.close();\r
                }\r
-\r
+               scan.close();\r
                input.close();\r
                return results;\r
        }\r
index 83ca5d3..616b552 100644 (file)
@@ -19,8 +19,8 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
-import java.util.Map;\r
-import java.util.Set;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
@@ -84,12 +84,13 @@ public class Disembl extends SkeletalExecutable<Disembl>
        }\r
 \r
        @SuppressWarnings("unchecked")\r
-       public Map<String, Set<Score>> getResults(String workDirectory)\r
+       @Override\r
+       public HashMap<String, HashSet<Score>> getResults(String workDirectory)\r
                        throws ResultNotAvailableException {\r
 \r
                InputStream inStream = null;\r
-               Map<String, Set<Score>> results = null;\r
-               // How about getting ranges?\r
+               HashMap<String, HashSet<Score>> results = null;\r
+\r
                try {\r
                        inStream = new FileInputStream(new File(workDirectory, getOutput()));\r
                        results = SequenceUtil.removeSequences(SequenceUtil\r
@@ -108,7 +109,7 @@ public class Disembl extends SkeletalExecutable<Disembl>
                        log.error(e.getMessage(), e.getCause());\r
                        throw new ResultNotAvailableException(e);\r
                }\r
-\r
+               log.trace("DRESULTS: " + results);\r
                return results;\r
        }\r
 \r
index 2284671..99420f5 100644 (file)
@@ -19,8 +19,8 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
-import java.util.Map;\r
-import java.util.Set;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
@@ -70,11 +70,11 @@ public class GlobPlot extends SkeletalExecutable<GlobPlot>
        }\r
 \r
        @SuppressWarnings("unchecked")\r
-       public Map<String, Set<Score>> getResults(String workDirectory)\r
+       public HashMap<String, HashSet<Score>> getResults(String workDirectory)\r
                        throws ResultNotAvailableException {\r
 \r
                InputStream inStream = null;\r
-               Map<String, Set<Score>> results = null;\r
+               HashMap<String, HashSet<Score>> results = null;\r
                // How about getting ranges?\r
                try {\r
                        inStream = new FileInputStream(new File(workDirectory, getOutput()));\r
index 7f45855..a4bf4c9 100644 (file)
@@ -24,6 +24,7 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
+import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.List;\r
 import java.util.Map;\r
@@ -164,11 +165,11 @@ public class SequenceUtilTester {
                try {\r
                        fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH\r
                                        + "disembl.out");\r
-                       Map<FastaSequence, Set<Score>> aseqs = SequenceUtil\r
+                       Map<FastaSequence, HashSet<Score>> aseqs = SequenceUtil\r
                                        .readDisembl(fio);\r
                        assertNotNull(aseqs);\r
                        assertEquals(aseqs.size(), 3);\r
-                       System.out.println(aseqs);\r
+                       // System.out.println(aseqs);\r
                        for (FastaSequence fs : aseqs.keySet()) {\r
                                assertTrue(" Foobar_dundeefriends Foobar dundeefriends "\r
                                                .contains(fs.getId()));\r
@@ -217,7 +218,7 @@ public class SequenceUtilTester {
                try {\r
                        fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH\r
                                        + "globplot.out");\r
-                       Map<FastaSequence, Set<Score>> aseqs = SequenceUtil\r
+                       HashMap<FastaSequence, HashSet<Score>> aseqs = SequenceUtil\r
                                        .readGlobPlot(fio);\r
                        assertNotNull(aseqs);\r
                        assertEquals(aseqs.size(), 3);\r
@@ -232,12 +233,12 @@ public class SequenceUtilTester {
                                assertEquals(scores.size(), 5);\r
                        }\r
                        for (Score score : scores) {\r
-                               \r
+\r
                                if (score.getMethod() == (Enum<?>) GlobProtResult.Disorder) {\r
                                        assertEquals(score.getRanges().size(), 7);\r
                                        assertTrue(score.getScores().isEmpty());\r
                                }\r
-                               if (score.getMethod() == (Enum<?>)GlobProtResult.Dydx) {\r
+                               if (score.getMethod() == (Enum<?>) GlobProtResult.Dydx) {\r
                                        assertFalse(score.getScores().isEmpty());\r
                                        assertTrue(score.getRanges().isEmpty());\r
                                }\r
index cb9301d..eaa316d 100644 (file)
@@ -1,7 +1,7 @@
 > Foobar_dundeefriends
 # COILS 34-41, 50-58, 83-91, 118-127, 160-169, 191-220, 243-252, 287-343, 350-391, 429-485, 497-506, 539-547
 # REM465 355-368
-# HOTLOOPS 
+# HOTLOOPS 190-204
 # RESIDUE COILS REM465 HOTLOOPS
 M      0.86010 0.88512 0.37094
 T      0.79983 0.85864 0.44331
index 62aa383..1fc2a68 100644 (file)
@@ -37,6 +37,7 @@ import java.io.OutputStream;
 import java.net.MalformedURLException;\r
 import java.net.URL;\r
 import java.util.Arrays;\r
+import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.List;\r
 import java.util.Map;\r
@@ -160,17 +161,17 @@ public class Jws2Client {
                                // std.out will not be\r
                                outStream = System.out;\r
                        }\r
-                       if (service == Services.AAConWS) {\r
+                       if (service.getServiceType() == SequenceAnnotation.class) {\r
                                Map<String, HashSet<Score>> result = analize(inputFile,\r
                                                ((SequenceAnnotation<T>) msaws), preset, customOptions);\r
+                               assert result != null && !result.values().isEmpty() : "No Result reported!";\r
                                IOHelper.writeOut(outStream, result);\r
                        } else {\r
                                alignment = align(inputFile, (MsaWS<T>) msaws, preset,\r
                                                customOptions);\r
                                IOHelper.writeOut(outStream, alignment);\r
                        }\r
-\r
-                       // stream is closed in the method no need to close it here\r
+                       outStream.close();\r
                }\r
 \r
                boolean listParameters = CmdHelper.listParameters(cmd);\r
@@ -203,12 +204,12 @@ public class Jws2Client {
         * @return Set<Score> the conservation scores\r
         * @throws UnknownFileFormatException\r
         */\r
-       <T> Map<String, HashSet<Score>> analize(File file,\r
+       <T> HashMap<String, HashSet<Score>> analize(File file,\r
                        SequenceAnnotation<T> wsproxy, Preset<T> preset,\r
                        List<Option<T>> customOptions) {\r
 \r
                List<FastaSequence> fastalist = null;\r
-               Map<String, HashSet<Score>> scores = null;\r
+               HashMap<String, HashSet<Score>> scores = null;\r
                try {\r
                        fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());\r
 \r
@@ -224,8 +225,9 @@ public class Jws2Client {
                        } else {\r
                                jobId = wsproxy.analize(fastalist);\r
                        }\r
-                       Thread.sleep(1000);\r
+                       Thread.sleep(2000);\r
                        scores = wsproxy.getAnnotation(jobId);\r
+                       assert scores != null && !scores.values().isEmpty() : "Scores are NULL";\r
 \r
                } catch (IOException e) {\r
                        System.err\r
@@ -289,6 +291,10 @@ public class Jws2Client {
                                serv = service.getService(url, V2_QUALIFIED_SERVICE_NAME);\r
                        }\r
                }\r
+               if (serv == null) {\r
+                       System.err.println("Could not connect to " + url);\r
+                       // FIXME\r
+               }\r
                JABAService serviceIF = service.getInterface(serv);\r
                log.log(Level.FINE, "Connected successfully!");\r
 \r
@@ -428,7 +434,7 @@ public class Jws2Client {
 \r
        /**\r
         * Starts command line client, if no parameter are supported print help. Two\r
-        * parameters are required for successfull call the JWS2 host name and a\r
+        * parameters are required for successful call the JWS2 host name and a\r
         * service name.\r
         * \r
         * @param args\r
index f18eadf..a0c1f56 100644 (file)
@@ -32,7 +32,7 @@ import compbio.data.msa.SequenceAnnotation;
  * \r
  */\r
 public enum Services {\r
-       MafftWS, MuscleWS, ClustalWS, TcoffeeWS, ProbconsWS, AAConWS;\r
+       MafftWS, MuscleWS, ClustalWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS;\r
 \r
        public static Services getService(String servName) {\r
                servName = servName.trim().toLowerCase();\r
@@ -54,6 +54,15 @@ public enum Services {
                if (servName.equalsIgnoreCase(AAConWS.toString())) {\r
                        return AAConWS;\r
                }\r
+               if (servName.equalsIgnoreCase(JronnWS.toString())) {\r
+                       return JronnWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(DisemblWS.toString())) {\r
+                       return DisemblWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(GlobPlotWS.toString())) {\r
+                       return GlobPlotWS;\r
+               }\r
                return null;\r
        }\r
 \r
@@ -62,15 +71,15 @@ public enum Services {
                return Service.create(url, qname);\r
        }\r
 \r
-       JABAService getInterface(Service service) {\r
-               assert service != null;\r
-\r
-               QName portName = new QName(service.getServiceName().getNamespaceURI(),\r
-                               this.toString() + "Port");\r
-\r
+       Class<? extends JABAService> getServiceType() {\r
                switch (this) {\r
+                       // deliberate leaking\r
                        case AAConWS :\r
-                               return service.getPort(portName, SequenceAnnotation.class);\r
+                       case JronnWS :\r
+                       case DisemblWS :\r
+                       case GlobPlotWS :\r
+\r
+                               return SequenceAnnotation.class;\r
 \r
                                // deliberate leaking\r
                        case ClustalWS :\r
@@ -78,13 +87,19 @@ public enum Services {
                        case MuscleWS :\r
                        case ProbconsWS :\r
                        case TcoffeeWS :\r
-                               // TODO remove\r
-                               System.out.println("Qname from serv: " + portName);\r
-\r
-                               return service.getPort(portName, MsaWS.class);\r
 \r
+                               return MsaWS.class;\r
                        default :\r
-                               throw new RuntimeException("Should never happened!");\r
+                               throw new RuntimeException("Unrecognised Web Service Type "\r
+                                               + this + " - Should never happened!");\r
                }\r
        }\r
+\r
+       JABAService getInterface(Service service) {\r
+               assert service != null;\r
+\r
+               QName portName = new QName(service.getServiceName().getNamespaceURI(),\r
+                               this.toString() + "Port");\r
+               return service.getPort(portName, this.getServiceType());\r
+       }\r
 }
\ No newline at end of file
index 00f3f69..061f9a6 100644 (file)
@@ -61,10 +61,10 @@ public class DisemblWS implements SequenceAnnotation<Disembl> {
                        throws ResultNotAvailableException {\r
                WSUtil.validateJobId(jobId);\r
                AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);\r
-               ConfiguredExecutable<Disembl> aacon = (ConfiguredExecutable<Disembl>) asyncEngine\r
+               ConfiguredExecutable<Disembl> disembl = (ConfiguredExecutable<Disembl>) asyncEngine\r
                                .getResults(jobId);\r
-               HashMap<String, HashSet<Score>> mas = aacon.getResults();\r
-               log.trace(jobId + " getConservation : " + mas);\r
+               HashMap<String, HashSet<Score>> mas = disembl.getResults();\r
+               log.trace(jobId + " getDisorder : " + mas);\r
                return mas;\r
        }\r
 \r