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 java.io.IOException;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.DBRefSource;
27 import jalview.datamodel.PDBEntry;
28 import jalview.ext.forester.io.PhyloXmlFile;
29 import jalview.ext.jmol.JmolParser;
30 import jalview.structure.StructureImportSettings;
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 GenBank("GenBank Flatfile", "gb, gbk", true, false)
251 public AlignmentFileReaderI getReader(FileParse source)
254 return new GenBankFile(source, "GenBank");
258 public AlignmentFileWriterI getWriter(AlignmentI al)
263 Embl("ENA Flatfile", "txt", true, false)
266 public AlignmentFileReaderI getReader(FileParse source)
269 // Always assume we import from EMBL for now
270 return new EmblFlatFile(source, DBRefSource.EMBL);
274 public AlignmentFileWriterI getWriter(AlignmentI al)
279 Jnet("JnetFile", "", false, false)
282 public AlignmentFileReaderI getReader(FileParse source)
285 JPredFile af = new JPredFile(source);
286 af.removeNonSequences();
291 public AlignmentFileWriterI getWriter(AlignmentI al)
293 return null; // todo is this called?
297 Features("GFF or Jalview features", "gff2,gff3", true, false)
300 public AlignmentFileReaderI getReader(FileParse source)
303 return new FeaturesFile(source);
307 public AlignmentFileWriterI getWriter(AlignmentI al)
309 return new FeaturesFile();
312 ScoreMatrix("Substitution matrix", "", false, false)
315 public AlignmentFileReaderI getReader(FileParse source)
318 return new ScoreMatrixFile(source);
322 public AlignmentFileWriterI getWriter(AlignmentI al)
327 PDB("PDB", "pdb,ent", true, false)
330 public AlignmentFileReaderI getReader(FileParse source)
333 boolean isParseWithJMOL = StructureImportSettings
334 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
337 return new JmolParser(source);
341 StructureImportSettings.setShowSeqFeatures(true);
342 return new mc_view.PDBfile(
343 StructureImportSettings.isVisibleChainAnnotation(),
344 StructureImportSettings.isProcessSecondaryStructure(),
345 StructureImportSettings.isExternalSecondaryStructure(),
351 public AlignmentFileWriterI getWriter(AlignmentI al)
353 return new JmolParser(); // todo or null?
357 public boolean isStructureFile()
362 MMCif("mmCIF", "cif", true, false)
365 public AlignmentFileReaderI getReader(FileParse source)
368 return new JmolParser(source);
372 public AlignmentFileWriterI getWriter(AlignmentI al)
374 return new JmolParser(); // todo or null?
378 public boolean isStructureFile()
383 Jalview("Jalview", "jvp, jar", true, true)
386 public AlignmentFileReaderI getReader(FileParse source)
393 public AlignmentFileWriterI getWriter(AlignmentI al)
399 public boolean isTextFormat()
405 public boolean isIdentifiable()
410 // Nexus("Nexus", "nex,nexus,nx,tre", true, true)
414 // public AlignmentFileReaderI getReader(FileParse source)
415 // throws IOException
417 // return new NexusFile(source);
421 // public AlignmentFileWriterI getWriter(AlignmentI al)
423 // // handle within Aptx?
428 // public boolean isTextFormat()
434 // public boolean isTreeFile()
440 PhyloXML("PhyloXML", "phyloxml,phylo.xml,pxml", true, false)
444 public AlignmentFileReaderI getReader(FileParse source)
447 return new PhyloXmlFile(source);
451 public AlignmentFileWriterI getWriter(AlignmentI al)
454 // handle within Aptx?
459 public boolean isTextFormat()
465 public boolean isTreeFile()
471 private boolean writable;
473 private boolean readable;
475 private String extensions;
480 public boolean isComplexAlignFile()
486 public boolean isReadable()
492 public boolean isWritable()
502 * comma-separated list of file extensions associated with the format
504 * - can be recognised by IdentifyFile and imported with the given
507 * - can be exported with the returned writer
509 private FileFormat(String shortName, String extensions,
510 boolean isReadable, boolean isWritable)
512 this.name = shortName;
513 this.extensions = extensions;
514 this.readable = isReadable;
515 this.writable = isWritable;
519 public String getExtensions()
525 * Answers the display name of the file format (as for example shown in menu
526 * options). This name should not be locale (language) dependent.
529 public String getName()
535 public boolean isTextFormat()
541 public boolean isStructureFile()
547 public boolean isTreeFile()
553 * By default, answers true, indicating the format is one that can be
554 * identified by IdentifyFile. Formats that cannot be identified should
555 * override this method to return false.
557 public boolean isIdentifiable()