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.PDBEntry;
25 import jalview.ext.forester.io.NexusFile;
26 import jalview.ext.forester.io.PhyloXmlFile;
27 import jalview.ext.jmol.JmolParser;
28 import jalview.structure.StructureImportSettings;
30 import java.io.IOException;
32 public enum FileFormat implements FileFormatI
34 Fasta("Fasta", "fa, fasta, mfa, fastq", true, true)
37 public AlignmentFileReaderI getReader(FileParse source)
40 return new FastaFile(source);
44 public AlignmentFileWriterI getWriter(AlignmentI al)
46 return new FastaFile();
49 Pfam("PFAM", "pfam", true, true)
52 public AlignmentFileReaderI getReader(FileParse source)
55 return new PfamFile(source);
59 public AlignmentFileWriterI getWriter(AlignmentI al)
61 return new PfamFile();
64 Stockholm("Stockholm", "sto,stk", true, true)
67 public AlignmentFileReaderI getReader(FileParse source)
70 return new StockholmFile(source);
74 public AlignmentFileWriterI getWriter(AlignmentI al)
76 return new StockholmFile(al);
81 PIR("PIR", "pir", true, true)
84 public AlignmentFileReaderI getReader(FileParse source)
87 return new PIRFile(source);
91 public AlignmentFileWriterI getWriter(AlignmentI al)
96 BLC("BLC", "BLC", true, true)
99 public AlignmentFileReaderI getReader(FileParse source)
102 return new BLCFile(source);
106 public AlignmentFileWriterI getWriter(AlignmentI al)
108 return new BLCFile();
111 AMSA("AMSA", "amsa", true, true)
114 public AlignmentFileReaderI getReader(FileParse source)
117 return new AMSAFile(source);
121 public AlignmentFileWriterI getWriter(AlignmentI al)
123 return new AMSAFile(al);
126 Html("HTML", "html", true, false)
129 public AlignmentFileReaderI getReader(FileParse source)
132 return new HtmlFile(source);
136 public AlignmentFileWriterI getWriter(AlignmentI al)
138 return new HtmlFile();
142 public boolean isComplexAlignFile()
148 Rnaml("RNAML", "xml,rnaml", true, false)
151 public AlignmentFileReaderI getReader(FileParse source)
154 return new RnamlFile(source);
158 public AlignmentFileWriterI getWriter(AlignmentI al)
160 return new RnamlFile();
164 Json("JSON", "json", true, true)
167 public AlignmentFileReaderI getReader(FileParse source)
170 return new JSONFile(source);
174 public AlignmentFileWriterI getWriter(AlignmentI al)
176 return new JSONFile();
180 public boolean isComplexAlignFile()
186 Pileup("PileUp", "pileup", true, true)
189 public AlignmentFileReaderI getReader(FileParse source)
192 return new PileUpfile(source);
196 public AlignmentFileWriterI getWriter(AlignmentI al)
198 return new PileUpfile();
202 MSF("MSF", "msf", true, true)
205 public AlignmentFileReaderI getReader(FileParse source)
208 return new MSFfile(source);
212 public AlignmentFileWriterI getWriter(AlignmentI al)
214 return new MSFfile();
218 Clustal("Clustal", "aln", true, true)
221 public AlignmentFileReaderI getReader(FileParse source)
224 return new ClustalFile(source);
228 public AlignmentFileWriterI getWriter(AlignmentI al)
230 return new ClustalFile();
233 Phylip("PHYLIP", "phy", true, true)
236 public AlignmentFileReaderI getReader(FileParse source)
239 return new PhylipFile(source);
243 public AlignmentFileWriterI getWriter(AlignmentI al)
245 return new PhylipFile();
248 Jnet("JnetFile", "", false, false)
251 public AlignmentFileReaderI getReader(FileParse source)
254 JPredFile af = new JPredFile(source);
255 af.removeNonSequences();
260 public AlignmentFileWriterI getWriter(AlignmentI al)
262 return null; // todo is this called?
266 Features("GFF or Jalview features", "gff2,gff3", true, false)
269 public AlignmentFileReaderI getReader(FileParse source)
272 return new FeaturesFile(source);
276 public AlignmentFileWriterI getWriter(AlignmentI al)
278 return new FeaturesFile();
281 ScoreMatrix("Substitution matrix", "", false, false)
284 public AlignmentFileReaderI getReader(FileParse source)
287 return new ScoreMatrixFile(source);
291 public AlignmentFileWriterI getWriter(AlignmentI al)
296 PDB("PDB", "pdb,ent", true, false)
299 public AlignmentFileReaderI getReader(FileParse source)
302 boolean isParseWithJMOL = StructureImportSettings
303 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
306 return new JmolParser(source);
310 StructureImportSettings.setShowSeqFeatures(true);
311 return new MCview.PDBfile(
312 StructureImportSettings.isVisibleChainAnnotation(),
313 StructureImportSettings.isProcessSecondaryStructure(),
314 StructureImportSettings.isExternalSecondaryStructure(),
320 public AlignmentFileWriterI getWriter(AlignmentI al)
322 return new JmolParser(); // todo or null?
326 public boolean isStructureFile()
331 MMCif("mmCIF", "cif", true, false)
334 public AlignmentFileReaderI getReader(FileParse source)
337 return new JmolParser(source);
341 public AlignmentFileWriterI getWriter(AlignmentI al)
343 return new JmolParser(); // todo or null?
347 public boolean isStructureFile()
352 Jalview("Jalview", "jar,jvp", true, true)
355 public AlignmentFileReaderI getReader(FileParse source)
362 public AlignmentFileWriterI getWriter(AlignmentI al)
368 public boolean isTextFormat()
374 public boolean isIdentifiable()
379 Nexus("Nexus", "nex,nexus,nx,tre", true, true)
383 public AlignmentFileReaderI getReader(FileParse source)
386 return new NexusFile(source);
390 public AlignmentFileWriterI getWriter(AlignmentI al)
392 // handle within Aptx?
397 public boolean isTextFormat()
403 PhyloXML("PhyloXML", "phyloxml,phylo.xml,pxml", true, true)
407 public AlignmentFileReaderI getReader(FileParse source)
410 return new PhyloXmlFile(source);
414 public AlignmentFileWriterI getWriter(AlignmentI al)
416 // handle within Aptx?
421 public boolean isTextFormat()
427 private boolean writable;
429 private boolean readable;
431 private String extensions;
436 public boolean isComplexAlignFile()
442 public boolean isReadable()
448 public boolean isWritable()
458 * comma-separated list of file extensions associated with the format
462 private FileFormat(String shortName, String extensions,
463 boolean isReadable, boolean isWritable)
465 this.name = shortName;
466 this.extensions = extensions;
467 this.readable = isReadable;
468 this.writable = isWritable;
472 public String getExtensions()
478 * Answers the display name of the file format (as for example shown in menu
479 * options). This name should not be locale (language) dependent.
482 public String getName()
488 public boolean isTextFormat()
494 public boolean isStructureFile()
500 * By default, answers true, indicating the format is one that can be
501 * identified by IdentifyFile. Formats that cannot be identified should
502 * override this method to return false.
504 public boolean isIdentifiable()