parses jpredfile into new alignment annotation
authoramwaterhouse <Andrew Waterhouse>
Fri, 1 Apr 2005 16:44:57 +0000 (16:44 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 1 Apr 2005 16:44:57 +0000 (16:44 +0000)
src/jalview/io/JPredClient.java

index c3415ee..7c2675d 100755 (executable)
@@ -154,30 +154,107 @@ public class JPredClient
     {\r
       output.setText(OutputHeader + result.getOutput());\r
       try {\r
+        // JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt", "File");\r
         JPredFile prediction=new JPredFile(result.getOutput(), "Paste");\r
         SequenceI[] preds = prediction.getSeqsAsArray();\r
-        int i=0;\r
+        Alignment al = new Alignment(preds);\r
+\r
+        AlignmentAnnotation annot;\r
+        Annotation [] annotations = null;\r
+        int i = 0;\r
         // Rename the query sequence\r
-        while (i<preds.length && !preds[i].getName().equals("QUERY")) {\r
+        while (i < preds.length)\r
+        {\r
+          String id = preds[i].getName().toUpperCase();\r
+          if(id.startsWith("LUPAS") || id.startsWith("JNET"))\r
+          {\r
+            annotations = new Annotation[al.getWidth()];\r
+\r
+            if(id.equals("JNETPRED")\r
+               || id.equals("JNETPSSM")\r
+               || id.equals("JNETFREQ")\r
+               || id.equals("JNETHMM")\r
+               || id.equals("JNETALIGN"))\r
+            {\r
+              for (int j = 0; j < al.getWidth(); j++)\r
+                annotations[j] = new Annotation("", "", preds[i].getCharAt(j), 0);\r
+            }\r
+            else if(id.equals("JNETCONF"))\r
+            {\r
+              for (int j = 0; j < al.getWidth(); j++)\r
+              {\r
+                float value = Float.parseFloat(preds[i].getCharAt(j)+"");\r
+                annotations[j] = new Annotation(preds[i].getCharAt(j)+"", "",preds[i].getCharAt(j),value);\r
+              }\r
+            }\r
+            else\r
+            {\r
+              for (int j = 0; j < al.getWidth(); j++)\r
+                annotations[j] = new Annotation(preds[i].getCharAt(j)+"", "", ' ', 0);\r
+            }\r
+\r
+            if(id.equals("JNETCONF"))\r
+              annot = new AlignmentAnnotation(preds[i].getName(),\r
+                                           "Jpred Output",\r
+                                           annotations,0f,10f,1);\r
+\r
+            else   annot = new AlignmentAnnotation(preds[i].getName(),\r
+                                            "Jpred Output",\r
+                                            annotations);\r
+            al.addAnnotation(annot);\r
+            al.deleteSequence(preds[i]);\r
+          }\r
           i++;\r
         }\r
-        if (i<preds.length) {\r
-          preds[i].setName(sequence.getId());\r
+\r
+        Hashtable scores = prediction.Scores;\r
+\r
+        Vector values = (Vector)scores.get("JNETPROPH");\r
+        annotations = new Annotation[al.getWidth()];\r
+        for (int j = 0; j < al.getWidth(); j++)\r
+        {\r
+          float value = Float.parseFloat(values.get(j).toString());\r
+          annotations[j] = new Annotation("", value+"",' ',value);\r
         }\r
-        AlignFrame af = new AlignFrame(new Alignment(preds));\r
+        annot = new AlignmentAnnotation("Jnetproph", "Jpred Output", annotations, 0f,1f,1);\r
+        al.addAnnotation(annot);\r
+\r
+        values = (Vector)scores.get("JNETPROPB");\r
+             annotations = new Annotation[al.getWidth()];\r
+             for (int j = 0; j < al.getWidth(); j++)\r
+             {\r
+               float value = Float.parseFloat(values.get(j).toString());\r
+               annotations[j] = new Annotation("", value+"",' ',value);\r
+             }\r
+             annot = new AlignmentAnnotation("JnetpropB", "Jpred Output", annotations, 0f,1f,1);\r
+             al.addAnnotation(annot);\r
+\r
+             values = (Vector)scores.get("JNETPROPC");\r
+                  annotations = new Annotation[al.getWidth()];\r
+                  for (int j = 0; j < al.getWidth(); j++)\r
+                  {\r
+                    float value = Float.parseFloat(values.get(j).toString());\r
+                    annotations[j] = new Annotation("", value+"",' ',value);\r
+                  }\r
+                  annot = new AlignmentAnnotation("JnetpropC", "Jpred Output", annotations, 0f,1f,1);\r
+                  al.addAnnotation(annot);\r
+\r
+\r
+\r
+        AlignFrame af = new AlignFrame(al);\r
+\r
+\r
         /*  JBPNote - need to set correct style of display for the secstrpred alignment object.\r
             af.clustalColour.setSelected(true);\r
             af.clustalColour_actionPerformed(null);\r
          */\r
-        Desktop.addInternalFrame(af, "JNet Prediction for sequence "+sequence.getId(),\r
+        Desktop.addInternalFrame(af,\r
+                                 "JNet Prediction for sequence ",\r
                                  700, 500);\r
-      }\r
-      catch (Exception e) {\r
-        output.setText(output.getText()+"\nError! File did not parse correctly\n"+e.getMessage()+"\n");\r
-        e.printStackTrace();\r
-      }\r
+      }catch(Exception ex){ex.printStackTrace();}\r
 \r
     }\r
 \r
   }\r
 }\r
+\r