Warn if URL not found
[jalview.git] / src / jalview / io / JPredFile.java
index 9ecb54a..b2226db 100755 (executable)
@@ -18,6 +18,23 @@ public class JPredFile
   Vector conf;
   Hashtable Scores; // Hash of names and score vectors
   Hashtable Symscores; // indexes of symbol annotation properties in sequenceI vector
+  private int QuerySeqPosition;
+  public void setQuerySeqPosition(int QuerySeqPosition)
+  {
+    this.QuerySeqPosition = QuerySeqPosition;
+  }
+
+  public int getQuerySeqPosition()
+  {
+    return QuerySeqPosition;
+  }
+  public Hashtable getScores() {
+    return Scores;
+  }
+  public Hashtable getSymscores() {
+    return Symscores;
+  }
+
   public JPredFile(String inStr)
   {
     super(inStr);
@@ -28,6 +45,8 @@ public class JPredFile
 
     super.initData();
     Scores = new Hashtable();
+    ids = null;
+    conf = null;
   }
 
   public JPredFile(String inFile, String type)
@@ -40,13 +59,12 @@ public class JPredFile
   /**
    * parse a JPred concise file into a sequence-alignment like object.
    */
-
   public void parse()
       throws IOException
   {
-
+    // JBPNote log.System.out.println("all read in ");
     String line;
-
+    QuerySeqPosition = -1;
     noSeqs = 0;
     Vector seq_entries = new Vector();
     Vector ids = new Vector();
@@ -56,7 +74,6 @@ public class JPredFile
       // Concise format allows no comments or non comma-formatted data
       StringTokenizer str = new StringTokenizer(line, ":");
       String id = "";
-      String seq = "";
       if (!str.hasMoreTokens())
       {
         continue;
@@ -96,6 +113,7 @@ public class JPredFile
             Float score = new Float(ascore);
             scores.addElement( (Object) score);
           }
+          Scores.put(id, scores);
         }
         catch (Exception e)
         {
@@ -115,9 +133,10 @@ public class JPredFile
           }
           Scores.put(id, scores);
         }
-      } else
-      if (id.equals("jnetconf"))
+      }
+      else if (id.equals("jnetconf"))
       {
+        // log.debug System.out.println("here");
         id = "Prediction Confidence";
         this.conf = new Vector(numSymbols);
         for (int i = 0; i < numSymbols; i++)
@@ -128,13 +147,13 @@ public class JPredFile
       else
         {
           // Sequence or a prediction string (rendered as sequence)
-          
+
           StringBuffer newseq = new StringBuffer();
-          
+
           for (int i = 0; i < numSymbols; i++) {
             newseq.append(symbols.nextToken());
           }
-          
+
           if (id.indexOf(";") > -1) {
             seq_entries.addElement(newseq);
             int i=1;
@@ -143,6 +162,7 @@ public class JPredFile
               name = id.substring(id.indexOf(";")+1)+"_"+1;
             }
             ids.addElement(name);
+
             noSeqs++;
           }
           else
@@ -186,6 +206,10 @@ public class JPredFile
                               ids.elementAt(i).toString()
                               + ") has an unexpected number of columns");
       }
+      if (newSeq.getName().startsWith("QUERY") && QuerySeqPosition==-1) {
+        QuerySeqPosition = seqs.size();
+      }
+
       seqs.addElement(newSeq);
 
     }
@@ -217,7 +241,7 @@ public class JPredFile
       }
       catch (java.io.IOException e)
       {
-        System.out.println("Exception " + e);
+        System.err.println("Exception " + e);
         e.printStackTrace();
       }
     }