3 import jalview.ext.jmol.JmolParser;
4 import jalview.structure.StructureImportSettings;
6 import java.io.IOException;
7 import java.util.HashMap;
10 public enum FileFormat implements FileFormatI
12 Fasta("FASTA", "fa, fasta, mfa, fastq", true, true)
15 public AlignmentFileI getAlignmentFile(String inFile,
16 DataSourceType sourceType) throws IOException
18 return new FastaFile(inFile, sourceType);
22 public AlignmentFileI getAlignmentFile(FileParse source)
25 return new FastaFile(source);
29 public AlignmentFileI getAlignmentFile()
31 return new FastaFile();
34 Pfam("PFAM", "pfam", true, true)
37 public AlignmentFileI getAlignmentFile(String inFile,
38 DataSourceType sourceType) throws IOException
40 return new PfamFile(inFile, sourceType);
44 public AlignmentFileI getAlignmentFile(FileParse source)
47 return new PfamFile(source);
51 public AlignmentFileI getAlignmentFile()
53 return new PfamFile();
56 Stockholm("STH", "sto,stk", true, true)
59 public AlignmentFileI getAlignmentFile(String inFile,
60 DataSourceType sourceType) throws IOException
62 return new StockholmFile(inFile, sourceType);
65 public AlignmentFileI getAlignmentFile(FileParse source)
68 return new StockholmFile(source);
72 public AlignmentFileI getAlignmentFile()
74 return new StockholmFile();
79 PIR("PIR", "pir", true, true)
82 public AlignmentFileI getAlignmentFile(String inFile,
83 DataSourceType sourceType) throws IOException
85 return new PIRFile(inFile, sourceType);
88 public AlignmentFileI getAlignmentFile(FileParse source)
91 return new PIRFile(source);
95 public AlignmentFileI getAlignmentFile()
100 BLC("BLC", "BLC", true, true)
103 public AlignmentFileI getAlignmentFile(String inFile,
104 DataSourceType sourceType) throws IOException
106 return new BLCFile(inFile, sourceType);
108 public AlignmentFileI getAlignmentFile(FileParse source)
111 return new BLCFile(source);
115 public AlignmentFileI getAlignmentFile()
117 return new BLCFile();
120 Html("HTML", "html", true, false)
123 public AlignmentFileI getAlignmentFile(String inFile,
124 DataSourceType sourceType) throws IOException
126 return new HtmlFile(inFile, sourceType);
128 public AlignmentFileI getAlignmentFile(FileParse source)
131 return new HtmlFile(source);
135 public AlignmentFileI getAlignmentFile()
137 return new HtmlFile();
141 public boolean isComplexAlignFile()
147 Rnaml("RNAML", "xml,rnaml", true, false)
150 public AlignmentFileI getAlignmentFile(String inFile,
151 DataSourceType sourceType) throws IOException
153 return new RnamlFile(inFile, sourceType);
155 public AlignmentFileI getAlignmentFile(FileParse source)
158 return new RnamlFile(source);
162 public AlignmentFileI getAlignmentFile()
164 return new RnamlFile();
168 Json("JSON","json", true, true)
171 public AlignmentFileI getAlignmentFile(String inFile,
172 DataSourceType sourceType) throws IOException
174 return new JSONFile(inFile, sourceType);
176 public AlignmentFileI getAlignmentFile(FileParse source)
179 return new JSONFile(source);
183 public AlignmentFileI getAlignmentFile()
185 return new JSONFile();
189 public boolean isComplexAlignFile()
195 Pileup("PileUp", "?", false, false)
198 public AlignmentFileI getAlignmentFile(String inFile,
199 DataSourceType sourceType) throws IOException
201 return new PileUpfile(inFile, sourceType);
203 public AlignmentFileI getAlignmentFile(FileParse source)
206 return new PileUpfile(source);
210 public AlignmentFileI getAlignmentFile()
212 return new PileUpfile();
216 MSF("MSF", "msf", true, true)
219 public AlignmentFileI getAlignmentFile(String inFile,
220 DataSourceType sourceType) throws IOException
222 return new MSFfile(inFile, sourceType);
224 public AlignmentFileI getAlignmentFile(FileParse source)
227 return new MSFfile(source);
231 public AlignmentFileI getAlignmentFile()
233 return new MSFfile();
237 Clustal("CLUSTAL", "aln", true, true)
240 public AlignmentFileI getAlignmentFile(String inFile,
241 DataSourceType sourceType) throws IOException
243 return new ClustalFile(inFile, sourceType);
245 public AlignmentFileI getAlignmentFile(FileParse source)
248 return new ClustalFile(source);
252 public AlignmentFileI getAlignmentFile()
254 return new ClustalFile();
257 Phylip("PHYLIP", "phy", true, true)
260 public AlignmentFileI getAlignmentFile(String inFile,
261 DataSourceType sourceType) throws IOException
263 return new PhylipFile(inFile, sourceType);
267 public AlignmentFileI getAlignmentFile(FileParse source)
270 return new PhylipFile(source);
274 public AlignmentFileI getAlignmentFile()
276 return new PhylipFile();
279 Jnet("JnetFile", "", false, false)
282 public AlignmentFileI getAlignmentFile(String inFile,
283 DataSourceType sourceType) throws IOException
285 JPredFile af = new JPredFile(inFile, sourceType);
286 af.removeNonSequences();
291 public AlignmentFileI getAlignmentFile(FileParse source)
294 JPredFile af = new JPredFile(source);
295 af.removeNonSequences();
300 public AlignmentFileI getAlignmentFile()
302 return null; // todo is this called?
306 Features("GFF or Jalview features", "gff2,gff3", false, false)
309 public AlignmentFileI getAlignmentFile(String inFile,
310 DataSourceType sourceType) throws IOException
312 return new FeaturesFile(true, inFile, sourceType);
316 public AlignmentFileI getAlignmentFile(FileParse source)
319 return new FeaturesFile(source);
323 public AlignmentFileI getAlignmentFile()
325 return new FeaturesFile();
328 PDB("PDB", "", false, false)
332 public AlignmentFileI getAlignmentFile(String inFile,
333 DataSourceType sourceType) throws IOException
335 // TODO obtain config value from preference settings.
336 // Set value to 'true' to test PDB processing with Jmol: JAL-1213
337 boolean isParseWithJMOL = !StructureImportSettings
338 .getCurrentDefaultFormat().equalsIgnoreCase("PDB");
341 return new JmolParser(
342 StructureImportSettings.isVisibleChainAnnotation(),
343 StructureImportSettings.isPredictSecondaryStructure(),
344 StructureImportSettings.isExternalSecondaryStructure(),
350 StructureImportSettings.setShowSeqFeatures(true);
351 return new MCview.PDBfile(
352 StructureImportSettings.isVisibleChainAnnotation(),
353 StructureImportSettings.isPredictSecondaryStructure(),
354 StructureImportSettings.isExternalSecondaryStructure(),
361 public AlignmentFileI getAlignmentFile(FileParse source)
364 boolean isParseWithJMOL = !StructureImportSettings
365 .getCurrentDefaultFormat().equalsIgnoreCase("PDB");
368 return new JmolParser(
369 StructureImportSettings.isVisibleChainAnnotation(),
370 StructureImportSettings.isPredictSecondaryStructure(),
371 StructureImportSettings.isExternalSecondaryStructure(),
376 StructureImportSettings.setShowSeqFeatures(true);
377 return new MCview.PDBfile(
378 StructureImportSettings.isVisibleChainAnnotation(),
379 StructureImportSettings.isPredictSecondaryStructure(),
380 StructureImportSettings.isExternalSecondaryStructure(),
386 public AlignmentFileI getAlignmentFile()
388 return new JmolParser(); // todo or null?
391 MMCif("mmCIF", "cif", false, false)
395 public AlignmentFileI getAlignmentFile(String inFile,
396 DataSourceType sourceType) throws IOException
398 return new JmolParser(
399 StructureImportSettings.isVisibleChainAnnotation(),
400 StructureImportSettings.isPredictSecondaryStructure(),
401 StructureImportSettings.isExternalSecondaryStructure(),
406 public AlignmentFileI getAlignmentFile(FileParse source)
409 return new JmolParser(
410 StructureImportSettings.isVisibleChainAnnotation(),
411 StructureImportSettings.isPredictSecondaryStructure(),
412 StructureImportSettings.isExternalSecondaryStructure(),
417 public AlignmentFileI getAlignmentFile()
419 return new JmolParser(); // todo or null?
422 Jalview("Jalview", "jar,jvp", true, false)
426 public AlignmentFileI getAlignmentFile(String inFile,
427 DataSourceType sourceType) throws IOException
433 public AlignmentFileI getAlignmentFile(FileParse source)
440 public AlignmentFileI getAlignmentFile()
447 * A lookup map of enums by upper-cased name
449 private static Map<String, FileFormat> names;
452 names = new HashMap<String, FileFormat>();
453 for (FileFormat format : FileFormat.values())
455 names.put(format.toString().toUpperCase(), format);
459 private boolean writable;
461 private boolean readable;
463 private String extensions;
468 public boolean isComplexAlignFile()
474 public String getShortDescription()
480 * Returns the file format with the given name, or null if format is null or
481 * invalid. Unlike valueOf(), this is not case-sensitive, to be kind to
482 * writers of javascript.
487 public static FileFormatI forName(String format)
489 // or could store format.getShortDescription().toUpperCase()
490 // in order to decouple 'given name' from enum name
491 return format == null ? null : names.get(format.toUpperCase());
495 public boolean isReadable()
501 public boolean isWritable()
511 * comma-separated list of file extensions associated with the format
515 private FileFormat(String shortName, String extensions,
516 boolean isReadable, boolean isWritable)
518 this.name = shortName;
519 this.extensions = extensions;
520 this.readable = isReadable;
521 this.writable = isWritable;
525 public String getExtensions()