FileFormatI further tweaks, clean compile
[jalview.git] / src / jalview / io / FileFormat.java
index a7113f6..770f762 100644 (file)
@@ -5,12 +5,14 @@ import jalview.ext.jmol.JmolParser;
 import jalview.structure.StructureImportSettings;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 public enum FileFormat implements FileFormatI
 {
-  Fasta("FASTA", "fa, fasta, mfa, fastq", true, true)
+  Fasta("Fasta", "fa, fasta, mfa, fastq", true, true)
   {
     @Override
     public AlignmentFileI getAlignmentFile(String inFile,
@@ -54,7 +56,7 @@ public enum FileFormat implements FileFormatI
       return new PfamFile();
     }
   },
-  Stockholm("STH", "sto,stk", true, true)
+  Stockholm("Stockholm", "sto,stk", true, true)
   {
     @Override
     public AlignmentFileI getAlignmentFile(String inFile,
@@ -118,6 +120,28 @@ public enum FileFormat implements FileFormatI
       return new BLCFile();
     }
   },
+  AMSA("AMSA", "amsa", true, true)
+  {
+    @Override
+    public AlignmentFileI getAlignmentFile(String inFile,
+            DataSourceType sourceType) throws IOException
+    {
+      return new AMSAFile(inFile, sourceType);
+    }
+
+    @Override
+    public AlignmentFileI getAlignmentFile(FileParse source)
+            throws IOException
+    {
+      return new AMSAFile(source);
+    }
+
+    @Override
+    public AlignmentFileI getAlignmentFile()
+    {
+      return new BLCFile();
+    }
+  },
   Html("HTML", "html", true, false)
   {
     @Override
@@ -193,7 +217,7 @@ public enum FileFormat implements FileFormatI
     }
 
   },
-  Pileup("PileUp", "?", false, false)
+  Pileup("PileUp", "pileup", false, true)
   {
     @Override
     public AlignmentFileI getAlignmentFile(String inFile,
@@ -235,7 +259,7 @@ public enum FileFormat implements FileFormatI
     }
 
   },
-  Clustal("CLUSTAL", "aln", true, true)
+  Clustal("Clustal", "aln", true, true)
   {
     @Override
     public AlignmentFileI getAlignmentFile(String inFile,
@@ -465,6 +489,44 @@ public enum FileFormat implements FileFormatI
 
   private String name;
 
+  /**
+   * Answers a list of writeable file formats (as string, corresponding to the
+   * toString() and forName() methods)
+   * 
+   * @return
+   */
+  public static List<String> getWritableFormats()
+  {
+    List<String> l = new ArrayList<String>();
+    for (FileFormatI ff : values())
+    {
+      if (ff.isWritable())
+      {
+        l.add(ff.toString());
+      }
+    }
+    return l;
+  }
+
+  /**
+   * Answers a list of readable file formats (as string, corresponding to the
+   * toString() and forName() methods)
+   * 
+   * @return
+   */
+  public static List<String> getReadableFormats()
+  {
+    List<String> l = new ArrayList<String>();
+    for (FileFormatI ff : values())
+    {
+      if (ff.isReadable())
+      {
+        l.add(ff.toString());
+      }
+    }
+    return l;
+  }
+
   @Override
   public boolean isComplexAlignFile()
   {
@@ -527,4 +589,10 @@ public enum FileFormat implements FileFormatI
   {
     return extensions;
   }
+
+  @Override
+  public String toString()
+  {
+    return name;
+  }
 }