2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.datamodel.AlignmentI;
24 import jalview.datamodel.DBRefSource;
25 import jalview.datamodel.PDBEntry;
26 import jalview.ext.jmol.JmolParser;
27 import jalview.structure.StructureImportSettings;
29 import java.io.IOException;
31 public enum FileFormat implements FileFormatI
33 Fasta("Fasta", "fa, fasta, mfa, fastq", true, true)
36 public AlignmentFileReaderI getReader(FileParse source)
39 return new FastaFile(source);
43 public AlignmentFileWriterI getWriter(AlignmentI al)
45 return new FastaFile();
48 Pfam("PFAM", "pfam", true, true)
51 public AlignmentFileReaderI getReader(FileParse source)
54 return new PfamFile(source);
58 public AlignmentFileWriterI getWriter(AlignmentI al)
60 return new PfamFile();
63 Stockholm("Stockholm", "sto,stk", true, true)
66 public AlignmentFileReaderI getReader(FileParse source)
69 return new StockholmFile(source);
73 public AlignmentFileWriterI getWriter(AlignmentI al)
75 return new StockholmFile(al);
80 PIR("PIR", "pir", true, true)
83 public AlignmentFileReaderI getReader(FileParse source)
86 return new PIRFile(source);
90 public AlignmentFileWriterI getWriter(AlignmentI al)
95 BLC("BLC", "BLC", true, true)
98 public AlignmentFileReaderI getReader(FileParse source)
101 return new BLCFile(source);
105 public AlignmentFileWriterI getWriter(AlignmentI al)
107 return new BLCFile();
110 AMSA("AMSA", "amsa", true, true)
113 public AlignmentFileReaderI getReader(FileParse source)
116 return new AMSAFile(source);
120 public AlignmentFileWriterI getWriter(AlignmentI al)
122 return new AMSAFile(al);
125 Html("HTML", "html", true, false)
128 public AlignmentFileReaderI getReader(FileParse source)
131 return new HtmlFile(source);
135 public AlignmentFileWriterI getWriter(AlignmentI al)
137 return new HtmlFile();
141 public boolean isComplexAlignFile()
147 Rnaml("RNAML", "xml,rnaml", true, false)
150 public AlignmentFileReaderI getReader(FileParse source)
153 return new RnamlFile(source);
157 public AlignmentFileWriterI getWriter(AlignmentI al)
159 return new RnamlFile();
163 Json("JSON", "json", true, true)
166 public AlignmentFileReaderI getReader(FileParse source)
169 return new JSONFile(source);
173 public AlignmentFileWriterI getWriter(AlignmentI al)
175 return new JSONFile();
179 public boolean isComplexAlignFile()
185 Pileup("PileUp", "pileup", true, true)
188 public AlignmentFileReaderI getReader(FileParse source)
191 return new PileUpfile(source);
195 public AlignmentFileWriterI getWriter(AlignmentI al)
197 return new PileUpfile();
201 MSF("MSF", "msf", true, true)
204 public AlignmentFileReaderI getReader(FileParse source)
207 return new MSFfile(source);
211 public AlignmentFileWriterI getWriter(AlignmentI al)
213 return new MSFfile();
217 Clustal("Clustal", "aln", true, true)
220 public AlignmentFileReaderI getReader(FileParse source)
223 return new ClustalFile(source);
227 public AlignmentFileWriterI getWriter(AlignmentI al)
229 return new ClustalFile();
232 Phylip("PHYLIP", "phy", true, true)
235 public AlignmentFileReaderI getReader(FileParse source)
238 return new PhylipFile(source);
242 public AlignmentFileWriterI getWriter(AlignmentI al)
244 return new PhylipFile();
247 GenBank("GenBank/ENA Flatfile","gb",false,false)
250 public AlignmentFileReaderI getReader(FileParse source)
253 // Always assume we import from EMBL for now
254 return new EmblFlatFile(source, DBRefSource.EMBL);
257 public AlignmentFileWriterI getWriter(AlignmentI al)
263 Jnet("JnetFile", "", false, false)
266 public AlignmentFileReaderI getReader(FileParse source)
269 JPredFile af = new JPredFile(source);
270 af.removeNonSequences();
275 public AlignmentFileWriterI getWriter(AlignmentI al)
277 return null; // todo is this called?
281 Features("GFF or Jalview features", "gff2,gff3", true, false)
284 public AlignmentFileReaderI getReader(FileParse source)
287 return new FeaturesFile(source);
291 public AlignmentFileWriterI getWriter(AlignmentI al)
293 return new FeaturesFile();
296 ScoreMatrix("Substitution matrix", "", false, false)
299 public AlignmentFileReaderI getReader(FileParse source)
302 return new ScoreMatrixFile(source);
306 public AlignmentFileWriterI getWriter(AlignmentI al)
311 PDB("PDB", "pdb,ent", true, false)
314 public AlignmentFileReaderI getReader(FileParse source)
317 boolean isParseWithJMOL = StructureImportSettings
318 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
321 return new JmolParser(source);
325 StructureImportSettings.setShowSeqFeatures(true);
326 return new MCview.PDBfile(
327 StructureImportSettings.isVisibleChainAnnotation(),
328 StructureImportSettings.isProcessSecondaryStructure(),
329 StructureImportSettings.isExternalSecondaryStructure(),
335 public AlignmentFileWriterI getWriter(AlignmentI al)
337 return new JmolParser(); // todo or null?
341 public boolean isStructureFile()
346 MMCif("mmCIF", "cif", true, false)
349 public AlignmentFileReaderI getReader(FileParse source)
352 return new JmolParser(source);
356 public AlignmentFileWriterI getWriter(AlignmentI al)
358 return new JmolParser(); // todo or null?
362 public boolean isStructureFile()
367 Jalview("Jalview", "jvp, jar", true, true)
370 public AlignmentFileReaderI getReader(FileParse source)
377 public AlignmentFileWriterI getWriter(AlignmentI al)
383 public boolean isTextFormat()
389 public boolean isIdentifiable()
395 private boolean writable;
397 private boolean readable;
399 private String extensions;
404 public boolean isComplexAlignFile()
410 public boolean isReadable()
416 public boolean isWritable()
426 * comma-separated list of file extensions associated with the format
427 * @param isReadable - can be recognised by IdentifyFile and imported with the given reader
428 * @param isWritable - can be exported with the returned writer
430 private FileFormat(String shortName, String extensions,
431 boolean isReadable, boolean isWritable)
433 this.name = shortName;
434 this.extensions = extensions;
435 this.readable = isReadable;
436 this.writable = isWritable;
440 public String getExtensions()
446 * Answers the display name of the file format (as for example shown in menu
447 * options). This name should not be locale (language) dependent.
450 public String getName()
456 public boolean isTextFormat()
462 public boolean isStructureFile()
468 * By default, answers true, indicating the format is one that can be
469 * identified by IdentifyFile. Formats that cannot be identified should
470 * override this method to return false.
472 public boolean isIdentifiable()