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 Fasta("Fasta", "fa, fasta, mfa, fastq", true, true)
35 public AlignmentFileReaderI getReader(FileParse source)
38 return new FastaFile(source);
42 public AlignmentFileWriterI getWriter(AlignmentI al)
44 return new FastaFile();
47 Pfam("PFAM", "pfam", true, true)
50 public AlignmentFileReaderI getReader(FileParse source)
53 return new PfamFile(source);
57 public AlignmentFileWriterI getWriter(AlignmentI al)
59 return new PfamFile();
62 Stockholm("Stockholm", "sto,stk", true, true)
65 public AlignmentFileReaderI getReader(FileParse source)
68 return new StockholmFile(source);
72 public AlignmentFileWriterI getWriter(AlignmentI al)
74 return new StockholmFile(al);
79 PIR("PIR", "pir", true, true)
82 public AlignmentFileReaderI getReader(FileParse source)
85 return new PIRFile(source);
89 public AlignmentFileWriterI getWriter(AlignmentI al)
94 BLC("BLC", "BLC", true, true)
97 public AlignmentFileReaderI getReader(FileParse source)
100 return new BLCFile(source);
104 public AlignmentFileWriterI getWriter(AlignmentI al)
106 return new BLCFile();
109 AMSA("AMSA", "amsa", true, true)
112 public AlignmentFileReaderI getReader(FileParse source)
115 return new AMSAFile(source);
119 public AlignmentFileWriterI getWriter(AlignmentI al)
121 return new AMSAFile(al);
124 Html("HTML", "html", true, false)
127 public AlignmentFileReaderI getReader(FileParse source)
130 return new HtmlFile(source);
134 public AlignmentFileWriterI getWriter(AlignmentI al)
136 return new HtmlFile();
140 public boolean isComplexAlignFile()
146 Rnaml("RNAML", "xml,rnaml", true, false)
149 public AlignmentFileReaderI getReader(FileParse source)
152 return new RnamlFile(source);
156 public AlignmentFileWriterI getWriter(AlignmentI al)
158 return new RnamlFile();
162 Json("JSON", "json", true, true)
165 public AlignmentFileReaderI getReader(FileParse source)
168 return new JSONFile(source);
172 public AlignmentFileWriterI getWriter(AlignmentI al)
174 return new JSONFile();
178 public boolean isComplexAlignFile()
184 Pileup("PileUp", "pileup", true, true)
187 public AlignmentFileReaderI getReader(FileParse source)
190 return new PileUpfile(source);
194 public AlignmentFileWriterI getWriter(AlignmentI al)
196 return new PileUpfile();
200 MSF("MSF", "msf", true, true)
203 public AlignmentFileReaderI getReader(FileParse source)
206 return new MSFfile(source);
210 public AlignmentFileWriterI getWriter(AlignmentI al)
212 return new MSFfile();
216 Clustal("Clustal", "aln", true, true)
219 public AlignmentFileReaderI getReader(FileParse source)
222 return new ClustalFile(source);
226 public AlignmentFileWriterI getWriter(AlignmentI al)
228 return new ClustalFile();
231 Phylip("PHYLIP", "phy", true, true)
234 public AlignmentFileReaderI getReader(FileParse source)
237 return new PhylipFile(source);
241 public AlignmentFileWriterI getWriter(AlignmentI al)
243 return new PhylipFile();
246 Jnet("JnetFile", "", false, false)
249 public AlignmentFileReaderI getReader(FileParse source)
252 JPredFile af = new JPredFile(source);
253 af.removeNonSequences();
258 public AlignmentFileWriterI getWriter(AlignmentI al)
260 return null; // todo is this called?
264 Features("GFF or Jalview features", "gff2,gff3", true, false)
267 public AlignmentFileReaderI getReader(FileParse source)
270 return new FeaturesFile(source);
274 public AlignmentFileWriterI getWriter(AlignmentI al)
276 return new FeaturesFile();
279 ScoreMatrix("Substitution matrix", "", false, false)
282 public AlignmentFileReaderI getReader(FileParse source)
285 return new ScoreMatrixFile(source);
289 public AlignmentFileWriterI getWriter(AlignmentI al)
294 PDB("PDB", "pdb,ent", true, false)
297 public AlignmentFileReaderI getReader(FileParse source)
300 boolean isParseWithJMOL = StructureImportSettings
301 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
304 return new JmolParser(source);
308 StructureImportSettings.setShowSeqFeatures(true);
309 return new MCview.PDBfile(
310 StructureImportSettings.isVisibleChainAnnotation(),
311 StructureImportSettings.isProcessSecondaryStructure(),
312 StructureImportSettings.isExternalSecondaryStructure(),
318 public AlignmentFileWriterI getWriter(AlignmentI al)
320 return new JmolParser(); // todo or null?
324 public boolean isStructureFile()
329 MMCif("mmCIF", "cif", true, false)
332 public AlignmentFileReaderI getReader(FileParse source)
335 return new JmolParser(source);
339 public AlignmentFileWriterI getWriter(AlignmentI al)
341 return new JmolParser(); // todo or null?
345 public boolean isStructureFile()
350 Jalview("Jalview", "jar,jvp", true, true)
353 public AlignmentFileReaderI getReader(FileParse source)
360 public AlignmentFileWriterI getWriter(AlignmentI al)
366 public boolean isTextFormat()
372 public boolean isIdentifiable()
378 private boolean writable;
380 private boolean readable;
382 private String extensions;
387 public boolean isComplexAlignFile()
393 public boolean isReadable()
399 public boolean isWritable()
409 * comma-separated list of file extensions associated with the format
413 private FileFormat(String shortName, String extensions,
414 boolean isReadable, boolean isWritable)
416 this.name = shortName;
417 this.extensions = extensions;
418 this.readable = isReadable;
419 this.writable = isWritable;
423 public String getExtensions()
429 * Answers the display name of the file format (as for example shown in menu
430 * options). This name should not be locale (language) dependent.
433 public String getName()
439 public boolean isTextFormat()
445 public boolean isStructureFile()
451 * By default, answers true, indicating the format is one that can be
452 * identified by IdentifyFile. Formats that cannot be identified should
453 * override this method to return false.
455 public boolean isIdentifiable()