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.PhyloXmlFile;
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 Jnet("JnetFile", "", false, false)
250 public AlignmentFileReaderI getReader(FileParse source)
253 JPredFile af = new JPredFile(source);
254 af.removeNonSequences();
259 public AlignmentFileWriterI getWriter(AlignmentI al)
261 return null; // todo is this called?
265 Features("GFF or Jalview features", "gff2,gff3", true, false)
268 public AlignmentFileReaderI getReader(FileParse source)
271 return new FeaturesFile(source);
275 public AlignmentFileWriterI getWriter(AlignmentI al)
277 return new FeaturesFile();
280 ScoreMatrix("Substitution matrix", "", false, false)
283 public AlignmentFileReaderI getReader(FileParse source)
286 return new ScoreMatrixFile(source);
290 public AlignmentFileWriterI getWriter(AlignmentI al)
295 PDB("PDB", "pdb,ent", true, false)
298 public AlignmentFileReaderI getReader(FileParse source)
301 boolean isParseWithJMOL = StructureImportSettings
302 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
305 return new JmolParser(source);
309 StructureImportSettings.setShowSeqFeatures(true);
310 return new MCview.PDBfile(
311 StructureImportSettings.isVisibleChainAnnotation(),
312 StructureImportSettings.isProcessSecondaryStructure(),
313 StructureImportSettings.isExternalSecondaryStructure(),
319 public AlignmentFileWriterI getWriter(AlignmentI al)
321 return new JmolParser(); // todo or null?
325 public boolean isStructureFile()
330 MMCif("mmCIF", "cif", true, false)
333 public AlignmentFileReaderI getReader(FileParse source)
336 return new JmolParser(source);
340 public AlignmentFileWriterI getWriter(AlignmentI al)
342 return new JmolParser(); // todo or null?
346 public boolean isStructureFile()
351 Jalview("Jalview", "jar,jvp", true, true)
354 public AlignmentFileReaderI getReader(FileParse source)
361 public AlignmentFileWriterI getWriter(AlignmentI al)
367 public boolean isTextFormat()
373 public boolean isIdentifiable()
378 // Nexus("Nexus", "nex,nexus,nx,tre", true, true)
382 // public AlignmentFileReaderI getReader(FileParse source)
383 // throws IOException
385 // return new NexusFile(source);
389 // public AlignmentFileWriterI getWriter(AlignmentI al)
391 // // handle within Aptx?
396 // public boolean isTextFormat()
402 // public boolean isTreeFile()
408 PhyloXML("PhyloXML", "phyloxml,phylo.xml,pxml", true, true)
412 public AlignmentFileReaderI getReader(FileParse source)
415 return new PhyloXmlFile(source);
419 public AlignmentFileWriterI getWriter(AlignmentI al)
421 // handle within Aptx?
426 public boolean isTextFormat()
432 public boolean isTreeFile()
438 private boolean writable;
440 private boolean readable;
442 private String extensions;
447 public boolean isComplexAlignFile()
453 public boolean isReadable()
459 public boolean isWritable()
469 * comma-separated list of file extensions associated with the format
473 private FileFormat(String shortName, String extensions,
474 boolean isReadable, boolean isWritable)
476 this.name = shortName;
477 this.extensions = extensions;
478 this.readable = isReadable;
479 this.writable = isWritable;
483 public String getExtensions()
489 * Answers the display name of the file format (as for example shown in menu
490 * options). This name should not be locale (language) dependent.
493 public String getName()
499 public boolean isTextFormat()
505 public boolean isStructureFile()
511 public boolean isTreeFile()
517 * By default, answers true, indicating the format is one that can be
518 * identified by IdentifyFile. Formats that cannot be identified should
519 * override this method to return false.
521 public boolean isIdentifiable()