Must repaint whole alignPanel
[jalview.git] / src / jalview / io / AlignFile.java
index d22dc12..0691d82 100755 (executable)
@@ -1,6 +1,6 @@
 /*\r
 * Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
 *\r
 * This program is free software; you can redistribute it and/or\r
 * modify it under the terms of the GNU General Public License\r
@@ -39,6 +39,7 @@ public abstract class AlignFile extends FileParse
     Vector headers;\r
     long start;\r
     long end;\r
+    boolean jvSuffix = true;\r
 \r
     /**\r
      * Creates a new AlignFile object.\r
@@ -47,24 +48,6 @@ public abstract class AlignFile extends FileParse
     {\r
     }\r
 \r
-    /**\r
-     * Creates a new AlignFile object.\r
-     *\r
-     * @param inStr DOCUMENT ME!\r
-     */\r
-    public AlignFile(String inStr)\r
-    {\r
-        initData();\r
-        System.out.println("is this ever called??");\r
-\r
-        try\r
-        {\r
-            parse();\r
-        }\r
-        catch (Exception ex)\r
-        {\r
-        }\r
-    }\r
 \r
     /**\r
      * Constructor which parses the data from a file of some specified type.\r
@@ -131,15 +114,17 @@ public abstract class AlignFile extends FileParse
     protected boolean isValidProteinSequence(String sequence)\r
     {\r
         for (int i = 0; i < sequence.length(); i++)\r
-            if (!jalview.schemes.ResidueProperties.aaHash.containsKey(\r
-                        String.valueOf(sequence.charAt(i))))\r
+            if (jalview.schemes.ResidueProperties.aaIndex[sequence.charAt(i)]==-1)\r
             {\r
+                invalidCharacter = sequence.charAt(i);\r
                 return false;\r
             }\r
 \r
         return true;\r
     }\r
 \r
+    char invalidCharacter;\r
+\r
     /**\r
      * This method must be implemented to parse the contents of the file.\r
      */\r
@@ -149,4 +134,45 @@ public abstract class AlignFile extends FileParse
      * Print out in alignment file format the Sequences in the seqs Vector.\r
      */\r
     public abstract String print();\r
+\r
+    public void addJVSuffix(boolean b)\r
+    {\r
+      jvSuffix = b;\r
+    }\r
+\r
+    /**\r
+     * A general parser for ids.\r
+     *\r
+     * @String id Id to be parsed\r
+     */\r
+    Sequence parseId(String id)\r
+    {\r
+      Sequence seq = null;\r
+      id = id.trim();\r
+      int space = id.indexOf(" ");\r
+      if(space>-1)\r
+      {\r
+        seq = new Sequence(id.substring(0, space),"");\r
+        seq.setDescription(id.substring(space+1));\r
+      }\r
+      else\r
+      {\r
+        seq = new Sequence(id, "");\r
+      }\r
+\r
+      return seq;\r
+    }\r
+\r
+    /**\r
+     * Creates the output id.\r
+     * Adds prefix Uniprot format source|id\r
+     * And suffix Jalview /start-end\r
+     *\r
+     * @String id Id to be parsed\r
+     */\r
+    String printId(SequenceI seq)\r
+    {\r
+     return seq.getDisplayId(jvSuffix);\r
+    }\r
+\r
 }\r