SequenceMapping updated
[jalview.git] / src / jalview / io / FeaturesFile.java
index 9431011..7046f88 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
@@ -40,15 +40,6 @@ public class FeaturesFile extends AlignFile
     {\r
     }\r
 \r
-    /**\r
-     * Creates a new FeaturesFile object.\r
-     *\r
-     * @param inStr DOCUMENT ME!\r
-     */\r
-    public FeaturesFile(String inStr)\r
-    {\r
-        super(inStr);\r
-    }\r
 \r
     /**\r
      * Creates a new FeaturesFile object.\r
@@ -165,7 +156,7 @@ public class FeaturesFile extends AlignFile
                 end = Integer.parseInt(st.nextToken());\r
                 try\r
                 {\r
-                  score = Float.parseFloat(st.nextToken());\r
+                  score =  new Float(st.nextToken()).floatValue();\r
                 }\r
                 catch (NumberFormatException ex)\r
                 {\r
@@ -182,7 +173,17 @@ public class FeaturesFile extends AlignFile
                 catch (Exception ex)\r
                 {}\r
 \r
-                seq.getDatasetSequence().addSequenceFeature(sf);\r
+                if(st.hasMoreTokens())\r
+                {\r
+                  StringBuffer attributes = new StringBuffer();\r
+                  while (st.hasMoreTokens())\r
+                  {\r
+                    attributes.append("\t"+st.nextElement());\r
+                  }\r
+                  sf.setValue("ATTRIBUTES", attributes.toString());\r
+                }\r
+\r
+                seq.addSequenceFeature(sf);\r
 \r
                 break;\r
               }\r
@@ -382,7 +383,29 @@ public class FeaturesFile extends AlignFile
                 if(next[j].description==null || next[j].description.equals(""))\r
                   out.append(next[j].type+"\t");\r
                 else\r
-                  out.append(next[j].description + "\t");\r
+                {\r
+                  out.append(next[j].description+" ");\r
+                  if(next[j].links!=null)\r
+                    {\r
+                      for(int l=0; l<next[j].links.size(); l++)\r
+                      {\r
+                        String label = next[j].links.elementAt(l).toString();\r
+                        String href = label.substring(label.indexOf("|")+1);\r
+                        label = label.substring(0, label.indexOf("|"));\r
+\r
+                        if(next[j].description.indexOf(href)==-1)\r
+                        {\r
+                          out.append("<a href=\""\r
+                                     + href\r
+                                     + "\">"\r
+                                     + label\r
+                                     + "</a>");\r
+                        }\r
+                      }\r
+                    }\r
+                   out.append("\t");\r
+                }\r
+\r
 \r
                 out.append(  seqs[i].getName() + "\t-1\t"\r
                            + next[j].begin + "\t"\r
@@ -412,6 +435,7 @@ public class FeaturesFile extends AlignFile
     {\r
       StringBuffer out = new StringBuffer();\r
       SequenceFeature [] next;\r
+      String source;\r
 \r
       for(int i=0; i<seqs.length; i++)\r
       {\r
@@ -423,8 +447,12 @@ public class FeaturesFile extends AlignFile
             if(!visible.containsKey(next[j].type))\r
               continue;\r
 \r
+            source = next[j].featureGroup;\r
+            if(source==null)\r
+              source = next[j].getDescription();\r
+\r
             out.append(seqs[i].getName() + "\t"\r
-                       + next[j].description + "\t"\r
+                       + source + "\t"\r
                        + next[j].type  + "\t"\r
                        + next[j].begin + "\t"\r
                        + next[j].end   + "\t"\r
@@ -435,10 +463,16 @@ public class FeaturesFile extends AlignFile
               out.append(next[j].getValue("STRAND")+"\t");\r
             else\r
               out.append(".\t");\r
+\r
             if(next[j].getValue("FRAME")!=null)\r
-              out.append(next[j].getValue("FRAME")+"\n");\r
+              out.append(next[j].getValue("FRAME"));\r
             else\r
-              out.append(".\n");\r
+              out.append(".");\r
+\r
+            if(next[j].getValue("ATTRIBUTES")!=null)\r
+              out.append(next[j].getValue("ATTRIBUTES"));\r
+\r
+            out.append("\n");\r
 \r
           }\r
         }\r