refactored code for creating JNet annotations
authorjprocter <Jim Procter>
Wed, 17 May 2006 16:51:29 +0000 (16:51 +0000)
committerjprocter <Jim Procter>
Wed, 17 May 2006 16:51:29 +0000 (16:51 +0000)
src/jalview/ws/JPredClient.java

index 2d49ac6..08d7271 100755 (executable)
@@ -27,6 +27,7 @@ import jalview.analysis.*;
 import jalview.datamodel.*;\r
 import jalview.gui.*;\r
 import jalview.io.FormatAdapter;\r
+import jalview.io.*;\r
 \r
 public class JPredClient\r
     extends WSClient\r
@@ -127,6 +128,8 @@ public class JPredClient
     {\r
       this.server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set from properties\r
       ( (JpredSoapBindingStub)this.server).setTimeout(60000); // one minute stub\r
+      //((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C, Boolean.TRUE);\r
+\r
     }\r
     catch (Exception ex)\r
     {\r
@@ -238,6 +241,7 @@ public class JPredClient
         catch (Exception ex)\r
         {\r
           allowedServerExceptions--;\r
+\r
           wsInfo.appendProgressText("\nJPredWS Server exception!\n" +\r
                                     ex.getMessage());\r
 \r
@@ -441,110 +445,13 @@ public class JPredClient
 \r
         al.setDataset(null);\r
 \r
-        AlignmentAnnotation annot;\r
-        Annotation[] annotations = null;\r
-        int i = 0;\r
-        int width = preds[0].getSequence().length();\r
-\r
-        int[] gapmap = al.getSequenceAt(FirstSeq).gapMap();\r
-\r
-        if (gapmap.length != width)\r
-        {\r
-          throw (new Exception(\r
-              "Jnet Client Error\nNumber of residues in supposed query sequence :\n" +\r
-              al.getSequenceAt(FirstSeq).getName() + "\n" +\r
-              al.getSequenceAt(FirstSeq).getSequence() +\r
-              "\nDiffer from number of prediction sites in \n" +\r
-              result.getPredfile() + "\n"));\r
+        try {\r
+          jalview.io.JnetAnnotationMaker.add_annotation(prediction, al, FirstSeq,\r
+              noMsa);\r
         }\r
-\r
-        // JBPNote Should also rename the query sequence sometime...\r
-        i = 0;\r
-\r
-        SequenceI seqRef = al.getSequenceAt(FirstSeq);\r
-\r
-        while (i < preds.length)\r
-        {\r
-          String id = preds[i].getName().toUpperCase();\r
-\r
-          if (id.startsWith("LUPAS") || id.startsWith("JNET") ||\r
-              id.startsWith("JPRED"))\r
-          {\r
-            annotations = new Annotation[al.getWidth()];\r
-\r
-            if (id.equals("JNETPRED") || id.equals("JNETPSSM") ||\r
-                id.equals("JNETFREQ") || id.equals("JNETHMM") ||\r
-                id.equals("JNETALIGN") || id.equals("JPRED"))\r
-            {\r
-              for (int j = 0; j < width; j++)\r
-              {\r
-                annotations[gapmap[j]] = new Annotation("", "",\r
-                    preds[i].getCharAt(j), 0);\r
-              }\r
-            }\r
-            else if (id.equals("JNETCONF"))\r
-            {\r
-              for (int j = 0; j < width; j++)\r
-              {\r
-                float value = Float.parseFloat(preds[i].getCharAt(\r
-                    j) + "");\r
-                annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(\r
-                    j) + "", "", preds[i].getCharAt(j),\r
-                    value);\r
-              }\r
-            }\r
-            else\r
-            {\r
-              for (int j = 0; j < width; j++)\r
-              {\r
-                annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(\r
-                    j) + "", "", ' ', 0);\r
-              }\r
-            }\r
-\r
-            if (id.equals("JNETCONF"))\r
-            {\r
-              annot = new AlignmentAnnotation(preds[i].getName(),\r
-                                              "JNet Output", annotations, 0f,\r
-                                              10f,\r
-                                              AlignmentAnnotation.BAR_GRAPH);\r
-            }\r
-            else\r
-            {\r
-              annot = new AlignmentAnnotation(preds[i].getName(),\r
-                                              "JNet Output", annotations);\r
-            }\r
-\r
-            if (seqRef != null)\r
-            {\r
-              annot.createSequenceMapping(seqRef, 0);\r
-              seqRef.addAlignmentAnnotation(annot);\r
-            }\r
-\r
-            al.addAnnotation(annot);\r
-\r
-\r
-            if (noMsa)\r
-            {\r
-              al.deleteSequence(preds[i]);\r
-            }\r
-          }\r
-\r
-          i++;\r
+        catch (Exception e) {\r
+          jalview.bin.Cache.log.error("JNet Client: JPred Annotation Parse Error", e);\r
         }\r
-\r
-        //Hashtable scores = prediction.getScores();\r
-\r
-        /*  addFloatAnnotations(al, gapmap,  (Vector)scores.get("JNETPROPH"),\r
-                              "JnetpropH", "Jnet Helix Propensity", 0f,1f,1);\r
-\r
-          addFloatAnnotations(al, gapmap,  (Vector)scores.get("JNETPROPB"),\r
-         "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1);\r
-\r
-          addFloatAnnotations(al, gapmap,  (Vector)scores.get("JNETPROPC"),\r
-                              "JnetpropC", "Jnet Coil Propensity", 0f,1f,1);\r
-         */\r
-\r
         wsInfo.setProgressText(OutputHeader);\r
         jalview.bin.Cache.log.debug("Finished parsing output.");\r
         AlignFrame af = new AlignFrame(al);\r