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.jmol.JmolParser;
29 import jalview.structure.StructureImportSettings;
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 GenBank("GenBank Flatfile", "gb, gbk", true, false)
250 public AlignmentFileReaderI getReader(FileParse source)
253 return new GenBankFile(source, "GenBank");
257 public AlignmentFileWriterI getWriter(AlignmentI al)
262 Embl("ENA Flatfile", "txt", true, false)
265 public AlignmentFileReaderI getReader(FileParse source)
268 // Always assume we import from EMBL for now
269 return new EmblFlatFile(source, DBRefSource.EMBL);
273 public AlignmentFileWriterI getWriter(AlignmentI al)
278 Jnet("JnetFile", "", false, false)
281 public AlignmentFileReaderI getReader(FileParse source)
284 JPredFile af = new JPredFile(source);
285 af.removeNonSequences();
290 public AlignmentFileWriterI getWriter(AlignmentI al)
292 return null; // todo is this called?
296 Features("GFF or Jalview features", "gff2,gff3", true, false)
299 public AlignmentFileReaderI getReader(FileParse source)
302 return new FeaturesFile(source);
306 public AlignmentFileWriterI getWriter(AlignmentI al)
308 return new FeaturesFile();
311 ScoreMatrix("Substitution matrix", "", false, false)
314 public AlignmentFileReaderI getReader(FileParse source)
317 return new ScoreMatrixFile(source);
321 public AlignmentFileWriterI getWriter(AlignmentI al)
326 PDB("PDB", "pdb,ent", true, false)
329 public AlignmentFileReaderI getReader(FileParse source)
332 boolean isParseWithJMOL = StructureImportSettings
333 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
336 return new JmolParser(source);
340 StructureImportSettings.setShowSeqFeatures(true);
341 return new mc_view.PDBfile(
342 StructureImportSettings.isVisibleChainAnnotation(),
343 StructureImportSettings.isProcessSecondaryStructure(),
344 StructureImportSettings.isExternalSecondaryStructure(),
350 public AlignmentFileWriterI getWriter(AlignmentI al)
352 return new JmolParser(); // todo or null?
356 public boolean isStructureFile()
361 MMCif("mmCIF", "cif", true, false)
364 public AlignmentFileReaderI getReader(FileParse source)
367 return new JmolParser(source);
371 public AlignmentFileWriterI getWriter(AlignmentI al)
373 return new JmolParser(); // todo or null?
377 public boolean isStructureFile()
382 Jalview("Jalview", "jvp, jar", true, true)
385 public AlignmentFileReaderI getReader(FileParse source)
392 public AlignmentFileWriterI getWriter(AlignmentI al)
398 public boolean isTextFormat()
404 public boolean isIdentifiable()
410 private boolean writable;
412 private boolean readable;
414 private String extensions;
419 public boolean isComplexAlignFile()
425 public boolean isReadable()
431 public boolean isWritable()
441 * comma-separated list of file extensions associated with the format
442 * @param isReadable - can be recognised by IdentifyFile and imported with the given reader
443 * @param isWritable - can be exported with the returned writer
445 private FileFormat(String shortName, String extensions,
446 boolean isReadable, boolean isWritable)
448 this.name = shortName;
449 this.extensions = extensions;
450 this.readable = isReadable;
451 this.writable = isWritable;
455 public String getExtensions()
461 * Answers the display name of the file format (as for example shown in menu
462 * options). This name should not be locale (language) dependent.
465 public String getName()
471 public boolean isTextFormat()
477 public boolean isStructureFile()
483 * By default, answers true, indicating the format is one that can be
484 * identified by IdentifyFile. Formats that cannot be identified should
485 * override this method to return false.
487 public boolean isIdentifiable()