3 import jalview.datamodel.PDBEntry;
4 import jalview.ext.jmol.JmolParser;
5 import jalview.structure.StructureImportSettings;
7 import java.io.IOException;
8 import java.util.HashMap;
11 public enum FileFormat implements FileFormatI
13 Fasta("FASTA", "fa, fasta, mfa, fastq", true, true)
16 public AlignmentFileI getAlignmentFile(String inFile,
17 DataSourceType sourceType) throws IOException
19 return new FastaFile(inFile, sourceType);
23 public AlignmentFileI getAlignmentFile(FileParse source)
26 return new FastaFile(source);
30 public AlignmentFileI getAlignmentFile()
32 return new FastaFile();
35 Pfam("PFAM", "pfam", true, true)
38 public AlignmentFileI getAlignmentFile(String inFile,
39 DataSourceType sourceType) throws IOException
41 return new PfamFile(inFile, sourceType);
45 public AlignmentFileI getAlignmentFile(FileParse source)
48 return new PfamFile(source);
52 public AlignmentFileI getAlignmentFile()
54 return new PfamFile();
57 Stockholm("STH", "sto,stk", true, true)
60 public AlignmentFileI getAlignmentFile(String inFile,
61 DataSourceType sourceType) throws IOException
63 return new StockholmFile(inFile, sourceType);
66 public AlignmentFileI getAlignmentFile(FileParse source)
69 return new StockholmFile(source);
73 public AlignmentFileI getAlignmentFile()
75 return new StockholmFile();
80 PIR("PIR", "pir", true, true)
83 public AlignmentFileI getAlignmentFile(String inFile,
84 DataSourceType sourceType) throws IOException
86 return new PIRFile(inFile, sourceType);
89 public AlignmentFileI getAlignmentFile(FileParse source)
92 return new PIRFile(source);
96 public AlignmentFileI getAlignmentFile()
101 BLC("BLC", "BLC", true, true)
104 public AlignmentFileI getAlignmentFile(String inFile,
105 DataSourceType sourceType) throws IOException
107 return new BLCFile(inFile, sourceType);
109 public AlignmentFileI getAlignmentFile(FileParse source)
112 return new BLCFile(source);
116 public AlignmentFileI getAlignmentFile()
118 return new BLCFile();
121 Html("HTML", "html", true, false)
124 public AlignmentFileI getAlignmentFile(String inFile,
125 DataSourceType sourceType) throws IOException
127 return new HtmlFile(inFile, sourceType);
129 public AlignmentFileI getAlignmentFile(FileParse source)
132 return new HtmlFile(source);
136 public AlignmentFileI getAlignmentFile()
138 return new HtmlFile();
142 public boolean isComplexAlignFile()
148 Rnaml("RNAML", "xml,rnaml", true, false)
151 public AlignmentFileI getAlignmentFile(String inFile,
152 DataSourceType sourceType) throws IOException
154 return new RnamlFile(inFile, sourceType);
156 public AlignmentFileI getAlignmentFile(FileParse source)
159 return new RnamlFile(source);
163 public AlignmentFileI getAlignmentFile()
165 return new RnamlFile();
169 Json("JSON","json", true, true)
172 public AlignmentFileI getAlignmentFile(String inFile,
173 DataSourceType sourceType) throws IOException
175 return new JSONFile(inFile, sourceType);
177 public AlignmentFileI getAlignmentFile(FileParse source)
180 return new JSONFile(source);
184 public AlignmentFileI getAlignmentFile()
186 return new JSONFile();
190 public boolean isComplexAlignFile()
196 Pileup("PileUp", "?", false, false)
199 public AlignmentFileI getAlignmentFile(String inFile,
200 DataSourceType sourceType) throws IOException
202 return new PileUpfile(inFile, sourceType);
204 public AlignmentFileI getAlignmentFile(FileParse source)
207 return new PileUpfile(source);
211 public AlignmentFileI getAlignmentFile()
213 return new PileUpfile();
217 MSF("MSF", "msf", true, true)
220 public AlignmentFileI getAlignmentFile(String inFile,
221 DataSourceType sourceType) throws IOException
223 return new MSFfile(inFile, sourceType);
225 public AlignmentFileI getAlignmentFile(FileParse source)
228 return new MSFfile(source);
232 public AlignmentFileI getAlignmentFile()
234 return new MSFfile();
238 Clustal("CLUSTAL", "aln", true, true)
241 public AlignmentFileI getAlignmentFile(String inFile,
242 DataSourceType sourceType) throws IOException
244 return new ClustalFile(inFile, sourceType);
246 public AlignmentFileI getAlignmentFile(FileParse source)
249 return new ClustalFile(source);
253 public AlignmentFileI getAlignmentFile()
255 return new ClustalFile();
258 Phylip("PHYLIP", "phy", true, true)
261 public AlignmentFileI getAlignmentFile(String inFile,
262 DataSourceType sourceType) throws IOException
264 return new PhylipFile(inFile, sourceType);
268 public AlignmentFileI getAlignmentFile(FileParse source)
271 return new PhylipFile(source);
275 public AlignmentFileI getAlignmentFile()
277 return new PhylipFile();
280 Jnet("JnetFile", "", false, false)
283 public AlignmentFileI getAlignmentFile(String inFile,
284 DataSourceType sourceType) throws IOException
286 JPredFile af = new JPredFile(inFile, sourceType);
287 af.removeNonSequences();
292 public AlignmentFileI getAlignmentFile(FileParse source)
295 JPredFile af = new JPredFile(source);
296 af.removeNonSequences();
301 public AlignmentFileI getAlignmentFile()
303 return null; // todo is this called?
307 Features("GFF or Jalview features", "gff2,gff3", false, false)
310 public AlignmentFileI getAlignmentFile(String inFile,
311 DataSourceType sourceType) throws IOException
313 return new FeaturesFile(true, inFile, sourceType);
317 public AlignmentFileI getAlignmentFile(FileParse source)
320 return new FeaturesFile(source);
324 public AlignmentFileI getAlignmentFile()
326 return new FeaturesFile();
329 PDB("PDB", "", false, false)
333 public AlignmentFileI getAlignmentFile(String inFile,
334 DataSourceType sourceType) throws IOException
336 // TODO obtain config value from preference settings.
337 // Set value to 'true' to test PDB processing with Jmol: JAL-1213
338 boolean isParseWithJMOL = StructureImportSettings
339 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
342 return new JmolParser(
343 StructureImportSettings.isVisibleChainAnnotation(),
344 StructureImportSettings.isProcessSecondaryStructure(),
345 StructureImportSettings.isExternalSecondaryStructure(),
351 StructureImportSettings.setShowSeqFeatures(true);
352 return new MCview.PDBfile(
353 StructureImportSettings.isVisibleChainAnnotation(),
354 StructureImportSettings.isProcessSecondaryStructure(),
355 StructureImportSettings.isExternalSecondaryStructure(),
362 public AlignmentFileI getAlignmentFile(FileParse source)
365 boolean isParseWithJMOL = StructureImportSettings
366 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
369 return new JmolParser(
370 StructureImportSettings.isVisibleChainAnnotation(),
371 StructureImportSettings.isProcessSecondaryStructure(),
372 StructureImportSettings.isExternalSecondaryStructure(),
377 StructureImportSettings.setShowSeqFeatures(true);
378 return new MCview.PDBfile(
379 StructureImportSettings.isVisibleChainAnnotation(),
380 StructureImportSettings.isProcessSecondaryStructure(),
381 StructureImportSettings.isExternalSecondaryStructure(),
387 public AlignmentFileI getAlignmentFile()
389 return new JmolParser(); // todo or null?
392 MMCif("mmCIF", "cif", false, false)
396 public AlignmentFileI getAlignmentFile(String inFile,
397 DataSourceType sourceType) throws IOException
399 return new JmolParser(
400 StructureImportSettings.isVisibleChainAnnotation(),
401 StructureImportSettings.isProcessSecondaryStructure(),
402 StructureImportSettings.isExternalSecondaryStructure(),
407 public AlignmentFileI getAlignmentFile(FileParse source)
410 return new JmolParser(
411 StructureImportSettings.isVisibleChainAnnotation(),
412 StructureImportSettings.isProcessSecondaryStructure(),
413 StructureImportSettings.isExternalSecondaryStructure(),
418 public AlignmentFileI getAlignmentFile()
420 return new JmolParser(); // todo or null?
423 Jalview("Jalview", "jar,jvp", true, false)
427 public AlignmentFileI getAlignmentFile(String inFile,
428 DataSourceType sourceType) throws IOException
434 public AlignmentFileI getAlignmentFile(FileParse source)
441 public AlignmentFileI getAlignmentFile()
448 * A lookup map of enums by upper-cased name
450 private static Map<String, FileFormat> names;
453 names = new HashMap<String, FileFormat>();
454 for (FileFormat format : FileFormat.values())
456 names.put(format.toString().toUpperCase(), format);
460 private boolean writable;
462 private boolean readable;
464 private String extensions;
469 public boolean isComplexAlignFile()
475 public String getShortDescription()
481 * Returns the file format with the given name, or null if format is null or
482 * invalid. Unlike valueOf(), this is not case-sensitive, to be kind to
483 * writers of javascript.
488 public static FileFormatI forName(String format)
490 // or could store format.getShortDescription().toUpperCase()
491 // in order to decouple 'given name' from enum name
492 return format == null ? null : names.get(format.toUpperCase());
496 public boolean isReadable()
502 public boolean isWritable()
512 * comma-separated list of file extensions associated with the format
516 private FileFormat(String shortName, String extensions,
517 boolean isReadable, boolean isWritable)
519 this.name = shortName;
520 this.extensions = extensions;
521 this.readable = isReadable;
522 this.writable = isWritable;
526 public String getExtensions()