added unofficial support for concise output parsing from the JNet server to extract...
authorjprocter <Jim Procter>
Wed, 17 May 2006 16:52:58 +0000 (16:52 +0000)
committerjprocter <Jim Procter>
Wed, 17 May 2006 16:52:58 +0000 (16:52 +0000)
src/jalview/io/AppletFormatAdapter.java
src/jalview/io/IdentifyFile.java
src/jalview/io/JPredFile.java

index 5f73898..5f228fb 100755 (executable)
                 {\r
                     afile = new PfamFile(inFile, type);\r
                 }\r
-\r
+                else if (format.equals("JnetFile"))\r
+                {\r
+                  afile = new JPredFile(inFile, type);\r
+                  ((JPredFile)afile).removeNonSequences();\r
+                }\r
 \r
                 return afile.getSeqsAsArray();\r
             }\r
index 2040769..6b32fe1 100755 (executable)
@@ -126,6 +126,12 @@ public class IdentifyFile
 \r
                     break;\r
                 }\r
+                else if (data.indexOf(":")<data.indexOf(",")) //  && data.indexOf(",")<data.indexOf(",", data.indexOf(",")))\r
+                {\r
+                  // file looks like a concise JNet file\r
+                  reply="JnetFile";\r
+                  break;\r
+                }\r
             }\r
 \r
             reader.close();\r
index f5ba7d6..0ee41b8 100755 (executable)
  */\r
 package jalview.io;\r
 \r
-import jalview.datamodel.*;\r
-\r
 import java.io.*;\r
-\r
 import java.util.*;\r
 \r
+import jalview.datamodel.*;\r
+\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -264,12 +263,12 @@ public class JPredFile extends AlignFile
                 }\r
             }\r
         }\r
-\r
+        /* leave it to the parser user to actually check this.\r
         if (noSeqs < 1)\r
         {\r
             throw new IOException(\r
                 "JpredFile Parser: No sequence in the prediction!");\r
-        }\r
+        }*/\r
 \r
         maxLength = seq_entries.elementAt(0).toString().length();\r
 \r
@@ -339,6 +338,34 @@ public class JPredFile extends AlignFile
             e.printStackTrace();\r
         }\r
     }\r
+    Vector annotSeqs=null;\r
+  /**\r
+   * removeNonSequences\r
+   */\r
+  public void removeNonSequences()\r
+  {\r
+    if (annotSeqs!=null)\r
+      return;\r
+    annotSeqs = new Vector();\r
+    Vector newseqs = new Vector();\r
+    int i=0;\r
+    int j=seqs.size();\r
+    for (; i<QuerySeqPosition; i++)\r
+        annotSeqs.add(seqs.get(i));\r
+      // check that no stray annotations have been added at the end.\r
+      {\r
+        SequenceI sq = (SequenceI) seqs.get(j-1);\r
+        if (sq.getName().toUpperCase().startsWith("JPRED")) {\r
+          annotSeqs.add(sq);\r
+          seqs.remove(--j);\r
+        }\r
+      }\r
+    for (; i<j; i++)\r
+        newseqs.add(seqs.get(i));\r
+\r
+    seqs.clear();\r
+    seqs = newseqs;\r
+  }\r
 }\r
 \r
 \r