X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileFormat.java;h=d0ce86e23421c6800c3d701d9cab104b81cb35b9;hb=781218e12641a89d5dd99906369d5b9807c1d203;hp=a7113f637bd2ca03625026c2c8328e30050c8a86;hpb=8b27085fa7fc5f2877e078421284c2636b85b8c6;p=jalview.git diff --git a/src/jalview/io/FileFormat.java b/src/jalview/io/FileFormat.java index a7113f6..d0ce86e 100644 --- a/src/jalview/io/FileFormat.java +++ b/src/jalview/io/FileFormat.java @@ -1,16 +1,19 @@ package jalview.io; +import jalview.datamodel.AlignmentI; import jalview.datamodel.PDBEntry; 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, @@ -27,7 +30,7 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new FastaFile(); } @@ -49,12 +52,12 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new PfamFile(); } }, - Stockholm("STH", "sto,stk", true, true) + Stockholm("Stockholm", "sto,stk", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -70,9 +73,9 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { - return new StockholmFile(); + return new StockholmFile(al); } }, @@ -93,7 +96,7 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new PIRFile(); } @@ -113,11 +116,33 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { 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(AlignmentI al) + { + return new AMSAFile(al); + } + }, Html("HTML", "html", true, false) { @Override @@ -133,7 +158,7 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new HtmlFile(); } @@ -160,7 +185,7 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new RnamlFile(); } @@ -181,7 +206,7 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new JSONFile(); } @@ -193,7 +218,7 @@ public enum FileFormat implements FileFormatI } }, - Pileup("PileUp", "?", false, false) + Pileup("PileUp", "pileup", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -208,7 +233,7 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new PileUpfile(); } @@ -229,13 +254,13 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new MSFfile(); } }, - Clustal("CLUSTAL", "aln", true, true) + Clustal("Clustal", "aln", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -250,7 +275,7 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new ClustalFile(); } @@ -272,7 +297,7 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new PhylipFile(); } @@ -298,13 +323,13 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return null; // todo is this called? } }, - Features("GFF or Jalview features", "gff2,gff3", false, false) + Features("GFF or Jalview features", "gff2,gff3", true, false) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -321,12 +346,12 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new FeaturesFile(); } }, - PDB("PDB", "", false, false) + PDB("PDB", "pdb,ent", true, false) { @Override @@ -384,12 +409,12 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new JmolParser(); // todo or null? } }, - MMCif("mmCIF", "cif", false, false) + MMCif("mmCIF", "cif", true, false) { @Override @@ -415,12 +440,12 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return new JmolParser(); // todo or null? } }, - Jalview("Jalview", "jar,jvp", true, false) + Jalview("Jalview", "jar,jvp", true, true) { @Override @@ -438,10 +463,16 @@ public enum FileFormat implements FileFormatI } @Override - public AlignmentFileI getAlignmentFile() + public AlignmentFileI getAlignmentFile(AlignmentI al) { return null; } + + @Override + public boolean isTextFormat() + { + return false; + } }; /** @@ -465,16 +496,48 @@ public enum FileFormat implements FileFormatI private String name; - @Override - public boolean isComplexAlignFile() + /** + * Answers a list of writeable file formats (as string, corresponding to the + * toString() and forName() methods) + * + * @return + */ + public static List getWritableFormats(boolean textOnly) { - return false; + List l = new ArrayList(); + for (FileFormatI ff : values()) + { + if (ff.isWritable() && (!textOnly || ff.isTextFormat())) + { + 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 getReadableFormats() + { + List l = new ArrayList(); + for (FileFormatI ff : values()) + { + if (ff.isReadable()) + { + l.add(ff.toString()); + } + } + return l; } @Override - public String getShortDescription() + public boolean isComplexAlignFile() { - return toString(); + return false; } /** @@ -527,4 +590,22 @@ public enum FileFormat implements FileFormatI { return extensions; } + + @Override + public String toString() + { + return name; + } + + @Override + public AlignmentFileI getAlignmentFile() + { + return getAlignmentFile((AlignmentI) null); + } + + @Override + public boolean isTextFormat() + { + return true; + } }