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.jmol.JmolParser;
26 import jalview.structure.StructureImportSettings;
28 import java.io.IOException;
30 public enum FileFormat implements FileFormatI
32 BSML("BSML", "bbb", true, false)
35 public AlignmentFileReaderI getReader(FileParse source)
38 return new BSMLFile(source);
42 public AlignmentFileWriterI getWriter(AlignmentI al)
47 Fasta("Fasta", "fa, fasta, mfa, fastq", true, true)
50 public AlignmentFileReaderI getReader(FileParse source)
53 return new FastaFile(source);
57 public AlignmentFileWriterI getWriter(AlignmentI al)
59 return new FastaFile();
62 Pfam("PFAM", "pfam", true, true)
65 public AlignmentFileReaderI getReader(FileParse source)
68 return new PfamFile(source);
72 public AlignmentFileWriterI getWriter(AlignmentI al)
74 return new PfamFile();
77 Stockholm("Stockholm", "sto,stk", true, true)
80 public AlignmentFileReaderI getReader(FileParse source)
83 return new StockholmFile(source);
87 public AlignmentFileWriterI getWriter(AlignmentI al)
89 return new StockholmFile(al);
94 PIR("PIR", "pir", true, true)
97 public AlignmentFileReaderI getReader(FileParse source)
100 return new PIRFile(source);
104 public AlignmentFileWriterI getWriter(AlignmentI al)
106 return new PIRFile();
109 BLC("BLC", "BLC", true, true)
112 public AlignmentFileReaderI getReader(FileParse source)
115 return new BLCFile(source);
119 public AlignmentFileWriterI getWriter(AlignmentI al)
121 return new BLCFile();
124 AMSA("AMSA", "amsa", true, true)
127 public AlignmentFileReaderI getReader(FileParse source)
130 return new AMSAFile(source);
134 public AlignmentFileWriterI getWriter(AlignmentI al)
136 return new AMSAFile(al);
139 Html("HTML", "html", true, false)
142 public AlignmentFileReaderI getReader(FileParse source)
145 return new HtmlFile(source);
149 public AlignmentFileWriterI getWriter(AlignmentI al)
151 return new HtmlFile();
155 public boolean isComplexAlignFile()
161 Rnaml("RNAML", "xml,rnaml", true, false)
164 public AlignmentFileReaderI getReader(FileParse source)
167 return new RnamlFile(source);
171 public AlignmentFileWriterI getWriter(AlignmentI al)
173 return new RnamlFile();
177 Json("JSON", "json", true, true)
180 public AlignmentFileReaderI getReader(FileParse source)
183 return new JSONFile(source);
187 public AlignmentFileWriterI getWriter(AlignmentI al)
189 return new JSONFile();
193 public boolean isComplexAlignFile()
199 Pileup("PileUp", "pileup", true, true)
202 public AlignmentFileReaderI getReader(FileParse source)
205 return new PileUpfile(source);
209 public AlignmentFileWriterI getWriter(AlignmentI al)
211 return new PileUpfile();
215 MSF("MSF", "msf", true, true)
218 public AlignmentFileReaderI getReader(FileParse source)
221 return new MSFfile(source);
225 public AlignmentFileWriterI getWriter(AlignmentI al)
227 return new MSFfile();
231 Clustal("Clustal", "aln", true, true)
234 public AlignmentFileReaderI getReader(FileParse source)
237 return new ClustalFile(source);
241 public AlignmentFileWriterI getWriter(AlignmentI al)
243 return new ClustalFile();
246 Phylip("PHYLIP", "phy", true, true)
249 public AlignmentFileReaderI getReader(FileParse source)
252 return new PhylipFile(source);
256 public AlignmentFileWriterI getWriter(AlignmentI al)
258 return new PhylipFile();
261 Jnet("JnetFile", "", false, false)
264 public AlignmentFileReaderI getReader(FileParse source)
267 JPredFile af = new JPredFile(source);
268 af.removeNonSequences();
273 public AlignmentFileWriterI getWriter(AlignmentI al)
275 return null; // todo is this called?
279 Features("GFF or Jalview features", "gff2,gff3", true, false)
282 public AlignmentFileReaderI getReader(FileParse source)
285 return new FeaturesFile(source);
289 public AlignmentFileWriterI getWriter(AlignmentI al)
291 return new FeaturesFile();
294 ScoreMatrix("Substitution matrix", "", false, false)
297 public AlignmentFileReaderI getReader(FileParse source)
300 return new ScoreMatrixFile(source);
304 public AlignmentFileWriterI getWriter(AlignmentI al)
309 PDB("PDB", "pdb,ent", true, false)
312 public AlignmentFileReaderI getReader(FileParse source)
315 boolean isParseWithJMOL = StructureImportSettings
316 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
319 return new JmolParser(source);
323 StructureImportSettings.setShowSeqFeatures(true);
324 return new mc_view.PDBfile(
325 StructureImportSettings.isVisibleChainAnnotation(),
326 StructureImportSettings.isProcessSecondaryStructure(),
327 StructureImportSettings.isExternalSecondaryStructure(),
333 public AlignmentFileWriterI getWriter(AlignmentI al)
335 return new JmolParser(); // todo or null?
339 public boolean isStructureFile()
344 MMCif("mmCIF", "cif", true, false)
347 public AlignmentFileReaderI getReader(FileParse source)
350 return new JmolParser(source);
354 public AlignmentFileWriterI getWriter(AlignmentI al)
356 return new JmolParser(); // todo or null?
360 public boolean isStructureFile()
365 Jalview("Jalview", "jvp, jar", true, true)
368 public AlignmentFileReaderI getReader(FileParse source)
375 public AlignmentFileWriterI getWriter(AlignmentI al)
381 public boolean isTextFormat()
387 public boolean isIdentifiable()
393 private boolean writable;
395 private boolean readable;
397 private String extensions;
402 public boolean isComplexAlignFile()
408 public boolean isReadable()
414 public boolean isWritable()
424 * comma-separated list of file extensions associated with the format
428 private FileFormat(String shortName, String extensions,
429 boolean isReadable, boolean isWritable)
431 this.name = shortName;
432 this.extensions = extensions;
433 this.readable = isReadable;
434 this.writable = isWritable;
438 public String getExtensions()
444 * Answers the display name of the file format (as for example shown in menu
445 * options). This name should not be locale (language) dependent.
448 public String getName()
454 public boolean isTextFormat()
460 public boolean isStructureFile()
466 * By default, answers true, indicating the format is one that can be
467 * identified by IdentifyFile. Formats that cannot be identified should
468 * override this method to return false.
470 public boolean isIdentifiable()