merge from 2_4_Release branch
[jalview.git] / src / jalview / io / FeaturesFile.java
index 03a7a83..462ee22 100755 (executable)
@@ -1,17 +1,17 @@
 /*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
+ * Copyright (C) 2008 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
  * as published by the Free Software Foundation; either version 2\r
  * of the License, or (at your option) any later version.\r
- *\r
+ * \r
  * This program is distributed in the hope that it will be useful,\r
  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
  * GNU General Public License for more details.\r
- *\r
+ * \r
  * You should have received a copy of the GNU General Public License\r
  * along with this program; if not, write to the Free Software\r
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
@@ -148,7 +148,7 @@ public class FeaturesFile extends AlignFile
           }\r
           continue;\r
         }\r
-\r
+        String seqId = "";\r
         while (st.hasMoreElements())\r
         {\r
 \r
@@ -156,8 +156,8 @@ public class FeaturesFile extends AlignFile
           {\r
             // Still possible this is an old Jalview file,\r
             // which does not have type colours at the beginning\r
-            token = st.nextToken();\r
-            seq = align.findName(token, true);\r
+            seqId = token = st.nextToken();\r
+            seq = align.findName(seqId, true);\r
             if (seq != null)\r
             {\r
               desc = st.nextToken();\r
@@ -205,7 +205,10 @@ public class FeaturesFile extends AlignFile
               }\r
 \r
               seq.addSequenceFeature(sf);\r
-\r
+              while ((seq = align.findName(seq, seqId, true)) != null)\r
+              {\r
+                seq.addSequenceFeature(new SequenceFeature(sf));\r
+              }\r
               break;\r
             }\r
           }\r
@@ -231,11 +234,12 @@ public class FeaturesFile extends AlignFile
 \r
           if (!token.equals("ID_NOT_SPECIFIED"))\r
           {\r
-            seq = align.findName(token, true);\r
+            seq = align.findName(seqId = token, true);\r
             st.nextToken();\r
           }\r
           else\r
           {\r
+            seqId = null;\r
             try\r
             {\r
               index = Integer.parseInt(st.nextToken());\r
@@ -266,8 +270,6 @@ public class FeaturesFile extends AlignFile
 \r
           sf = new SequenceFeature(type, desc, "", start, end, featureGroup);\r
 \r
-          seq.addSequenceFeature(sf);\r
-\r
           if (groupLink != null && removeHTML)\r
           {\r
             sf.addLink(groupLink);\r
@@ -281,6 +283,13 @@ public class FeaturesFile extends AlignFile
 \r
           parseDescriptionHTML(sf, removeHTML);\r
 \r
+          seq.addSequenceFeature(sf);\r
+\r
+          while (seqId != null\r
+                  && (seq = align.findName(seq, seqId, false)) != null)\r
+          {\r
+            seq.addSequenceFeature(new SequenceFeature(sf));\r
+          }\r
           // If we got here, its not a GFFFile\r
           GFFFile = false;\r
         }\r
@@ -371,12 +380,15 @@ public class FeaturesFile extends AlignFile
 \r
   }\r
 \r
-/**\r
- * generate a features file for seqs\r
- * @param seqs source of sequence features\r
- * @param visible hash of feature types and colours \r
- * @return features file contents\r
- */\r
+  /**\r
+   * generate a features file for seqs\r
+   * \r
+   * @param seqs\r
+   *                source of sequence features\r
+   * @param visible\r
+   *                hash of feature types and colours\r
+   * @return features file contents\r
+   */\r
   public String printJalviewFormat(SequenceI[] seqs, Hashtable visible)\r
   {\r
     return printJalviewFormat(seqs, visible, true);\r
@@ -384,9 +396,13 @@ public class FeaturesFile extends AlignFile
 \r
   /**\r
    * generate a features file for seqs with colours from visible (if any)\r
-   * @param seqs        source of features\r
-   * @param visible     hash of Colours for each feature type\r
-   * @param visOnly     when true only feature types in 'visible' will be output\r
+   * \r
+   * @param seqs\r
+   *                source of features\r
+   * @param visible\r
+   *                hash of Colours for each feature type\r
+   * @param visOnly\r
+   *                when true only feature types in 'visible' will be output\r
    * @return features file contents\r
    */\r
   public String printJalviewFormat(SequenceI[] seqs, Hashtable visible,\r
@@ -401,7 +417,8 @@ public class FeaturesFile extends AlignFile
     }\r
     if (visible != null && visOnly)\r
     {\r
-      // write feature colours only if we're given them and we are generating viewed features\r
+      // write feature colours only if we're given them and we are generating\r
+      // viewed features\r
       Enumeration en = visible.keys();\r
       String type;\r
       int color;\r