Any character non aa or nucleotide is a space
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
index 1de01e6..2e4ddc4 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
@@ -20,9 +20,6 @@
 \r
     import jalview.datamodel.*;\r
 \r
-    import java.util.Vector;\r
-\r
-\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -38,8 +35,8 @@
         };\r
 \r
         public static final String [] WRITEABLE_FORMATS = new String[]\r
-            {\r
-            "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM"\r
+        {\r
+            "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM"  //, "AMSA"\r
         };\r
 \r
 \r
@@ -77,7 +74,7 @@
          *\r
          * @return DOCUMENT ME!\r
          */\r
-        public SequenceI[] readFile(String inFile, String type, String format)\r
+        public Alignment readFile(String inFile, String type, String format)\r
             throws java.io.IOException\r
         {\r
             this.inFile = inFile;\r
                 afile = new StockholmFile(inFile, type);\r
               }\r
 \r
+              Alignment al = new Alignment(afile.getSeqsAsArray());\r
+\r
+              afile.addAnnotations(al);\r
 \r
-              return afile.getSeqsAsArray();\r
+              return al;\r
             }\r
             catch (Exception e)\r
             {\r
                 try{\r
                   // Possible sequence is just residues with no label\r
                   afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");\r
-                  return afile.getSeqsAsArray();\r
+                  Alignment al = new Alignment(afile.getSeqsAsArray());\r
+                  afile.addAnnotations(al);\r
+                  return al;\r
+\r
                 }\r
                 catch(Exception ex)\r
                 {\r
          * @return DOCUMENT ME!\r
          */\r
         public String formatSequences(String format,\r
-                                      Vector seqs,\r
+                                      AlignmentI alignment,\r
                                       boolean jvsuffix)\r
         {\r
-            SequenceI[] s = new SequenceI[seqs.size()];\r
-\r
-            for (int i = 0; i < seqs.size(); i++)\r
-                s[i] = (SequenceI) seqs.elementAt(i);\r
-\r
             try\r
             {\r
                 AlignFile afile = null;\r
                 {\r
                   afile = new StockholmFile();\r
                 }\r
-\r
+                else if (format.equals("AMSA"))\r
+                {\r
+                  afile = new AMSAFile(alignment);\r
+                }\r
 \r
                 afile.addJVSuffix(jvsuffix);\r
 \r
-                afile.setSeqs(s);\r
+                afile.setSeqs( alignment.getSequencesArray() );\r
 \r
                 return afile.print();\r
             }\r