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 FeatureSettings("Jalview Feature Settings File", "fc", false, false)
314 public AlignmentFileReaderI getReader(FileParse source)
321 public AlignmentFileWriterI getWriter(AlignmentI al)
326 ScoreMatrix("Substitution matrix", "", false, false)
329 public AlignmentFileReaderI getReader(FileParse source)
332 return new ScoreMatrixFile(source);
336 public AlignmentFileWriterI getWriter(AlignmentI al)
341 PDB("PDB", "pdb,ent", true, false)
344 public AlignmentFileReaderI getReader(FileParse source)
347 boolean isParseWithJMOL = StructureImportSettings
348 .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
351 return new JmolParser(source);
355 StructureImportSettings.setShowSeqFeatures(true);
356 return new mc_view.PDBfile(
357 StructureImportSettings.isVisibleChainAnnotation(),
358 StructureImportSettings.isProcessSecondaryStructure(),
359 StructureImportSettings.isExternalSecondaryStructure(),
365 public AlignmentFileWriterI getWriter(AlignmentI al)
367 return new JmolParser(); // todo or null?
371 public boolean isStructureFile()
376 MMCif("mmCIF", "cif", true, false)
379 public AlignmentFileReaderI getReader(FileParse source)
382 return new JmolParser(source);
386 public AlignmentFileWriterI getWriter(AlignmentI al)
388 return new JmolParser(); // todo or null?
392 public boolean isStructureFile()
397 Jalview("Jalview", "jvp,jar", true, true)
400 public AlignmentFileReaderI getReader(FileParse source)
407 public AlignmentFileWriterI getWriter(AlignmentI al)
413 public boolean isTextFormat()
419 public boolean isIdentifiable()
425 private boolean writable;
427 private boolean readable;
429 private String extensions;
434 public boolean isComplexAlignFile()
440 public boolean isReadable()
446 public boolean isWritable()
456 * comma-separated list of file extensions associated with the format
458 * - can be recognised by IdentifyFile and imported with the given
461 * - can be exported with the returned writer
463 private FileFormat(String shortName, String extensions,
464 boolean isReadable, boolean isWritable)
466 this.name = shortName;
467 this.extensions = extensions;
468 this.readable = isReadable;
469 this.writable = isWritable;
473 public String getExtensions()
479 * Answers the display name of the file format (as for example shown in menu
480 * options). This name should not be locale (language) dependent.
483 public String getName()
489 public boolean isTextFormat()
495 public boolean isStructureFile()
501 * By default, answers true, indicating the format is one that can be
502 * identified by IdentifyFile. Formats that cannot be identified should
503 * override this method to return false.
505 public boolean isIdentifiable()