GPL license added
[jalview.git] / src / jalview / io / JPredFile.java
index 92d9819..38addf7 100755 (executable)
@@ -1,8 +1,28 @@
+/*
+* Jalview - A Sequence Alignment Editor and Viewer
+* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+*/
+
 /**
  * PredFile.java
  * JalviewX / Vamsas Project
  * JPred.seq.concise reader
  */
+
 package jalview.io;
 
 import jalview.datamodel.*;
@@ -18,6 +38,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 +65,8 @@ public class JPredFile
 
     super.initData();
     Scores = new Hashtable();
+    ids = null;
+    conf = null;
   }
 
   public JPredFile(String inFile, String type)
@@ -40,13 +79,12 @@ public class JPredFile
   /**
    * parse a JPred concise file into a sequence-alignment like object.
    */
-
   public void parse()
       throws IOException
   {
-System.out.println("all read in ");
+    // JBPNote log.System.out.println("all read in ");
     String line;
-
+    QuerySeqPosition = -1;
     noSeqs = 0;
     Vector seq_entries = new Vector();
     Vector ids = new Vector();
@@ -118,7 +156,7 @@ System.out.println("all read in ");
       }
       else if (id.equals("jnetconf"))
       {
-        System.out.println("here");
+        // log.debug System.out.println("here");
         id = "Prediction Confidence";
         this.conf = new Vector(numSymbols);
         for (int i = 0; i < numSymbols; i++)
@@ -144,6 +182,7 @@ System.out.println("all read in ");
               name = id.substring(id.indexOf(";")+1)+"_"+1;
             }
             ids.addElement(name);
+
             noSeqs++;
           }
           else
@@ -187,6 +226,10 @@ System.out.println("all read in ");
                               ids.elementAt(i).toString()
                               + ") has an unexpected number of columns");
       }
+      if (newSeq.getName().startsWith("QUERY") && QuerySeqPosition==-1) {
+        QuerySeqPosition = seqs.size();
+      }
+
       seqs.addElement(newSeq);
 
     }
@@ -218,7 +261,7 @@ System.out.println("all read in ");
       }
       catch (java.io.IOException e)
       {
-        System.out.println("Exception " + e);
+        System.err.println("Exception " + e);
         e.printStackTrace();
       }
     }