--- /dev/null
+package jalview.io;
+
+import jalview.ext.jmol.JmolParser;
+import jalview.structure.StructureImportSettings;
+
+import java.io.IOException;
+
+public enum FileFormat implements FileFormatI
+{
+ Fasta
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new FastaFile(inFile, sourceType);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new FastaFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new FastaFile();
+ }
+ },
+ Pfam
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new PfamFile(inFile, sourceType);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new PfamFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new PfamFile();
+ }
+ },
+ Stockholm
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new StockholmFile(inFile, sourceType);
+ }
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new StockholmFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new StockholmFile();
+ }
+
+ },
+ SimpleBlast
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new SimpleBlastFile(inFile, sourceType);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new SimpleBlastFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new SimpleBlastFile();
+ }
+ },
+
+ PIR
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new PIRFile(inFile, sourceType);
+ }
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new PIRFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new PIRFile();
+ }
+ },
+ BLC
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new BLCFile(inFile, sourceType);
+ } @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new BLCFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new BLCFile();
+ }
+
+ },
+ Html
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new HtmlFile(inFile, sourceType);
+ } @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new HtmlFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new HtmlFile();
+ }
+
+ @Override
+ public boolean isComplexAlignFile()
+ {
+ return true;
+ }
+
+ },
+ Rnaml
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new RnamlFile(inFile, sourceType);
+ } @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new RnamlFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new RnamlFile();
+ }
+
+ },
+ Json
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new JSONFile(inFile, sourceType);
+ } @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new JSONFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new JSONFile();
+ }
+
+ @Override
+ public boolean isComplexAlignFile()
+ {
+ return true;
+ }
+
+ },
+ Pileup
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new PileUpfile(inFile, sourceType);
+ } @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new PileUpfile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new PileUpfile();
+ }
+
+ },
+ MSF
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new MSFfile(inFile, sourceType);
+ } @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new MSFfile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new MSFfile();
+ }
+
+ },
+ Clustal
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new ClustalFile(inFile, sourceType);
+ } @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new ClustalFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new ClustalFile();
+ }
+
+ },
+ Phylip
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new PhylipFile(inFile, sourceType);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new PhylipFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new PhylipFile();
+ }
+
+ },
+ Jnet
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ JPredFile af = new JPredFile(inFile, sourceType);
+ af.removeNonSequences();
+ return af;
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ JPredFile af = new JPredFile(source);
+ af.removeNonSequences();
+ return af;
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return null; // todo is this called?
+ }
+
+ },
+ Features
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new FeaturesFile(true, inFile, sourceType);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new FeaturesFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new FeaturesFile();
+ }
+ },
+ PDB
+ {
+
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ // TODO obtain config value from preference settings.
+ // Set value to 'true' to test PDB processing with Jmol: JAL-1213
+ boolean isParseWithJMOL = !StructureImportSettings
+ .getCurrentDefaultFormat().equalsIgnoreCase("PDB");
+ if (isParseWithJMOL)
+ {
+ return new JmolParser(
+ StructureImportSettings.isVisibleChainAnnotation(),
+ StructureImportSettings.isPredictSecondaryStructure(),
+ StructureImportSettings.isExternalSecondaryStructure(),
+ inFile,
+ sourceType);
+ }
+ else
+ {
+ StructureImportSettings.setShowSeqFeatures(true);
+ return new MCview.PDBfile(
+ StructureImportSettings.isVisibleChainAnnotation(),
+ StructureImportSettings.isPredictSecondaryStructure(),
+ StructureImportSettings.isExternalSecondaryStructure(),
+ inFile,
+ sourceType);
+ }
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ boolean isParseWithJMOL = !StructureImportSettings
+ .getCurrentDefaultFormat().equalsIgnoreCase("PDB");
+ if (isParseWithJMOL)
+ {
+ return new JmolParser(
+ StructureImportSettings.isVisibleChainAnnotation(),
+ StructureImportSettings.isPredictSecondaryStructure(),
+ StructureImportSettings.isExternalSecondaryStructure(),
+ source);
+ }
+ else
+ {
+ StructureImportSettings.setShowSeqFeatures(true);
+ return new MCview.PDBfile(
+ StructureImportSettings.isVisibleChainAnnotation(),
+ StructureImportSettings.isPredictSecondaryStructure(),
+ StructureImportSettings.isExternalSecondaryStructure(),
+ source);
+ }
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new JmolParser(); // todo or null?
+ }
+
+ },
+ MMCif
+ {
+
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new JmolParser(
+ StructureImportSettings.isVisibleChainAnnotation(),
+ StructureImportSettings.isPredictSecondaryStructure(),
+ StructureImportSettings.isExternalSecondaryStructure(),
+ inFile, sourceType);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new JmolParser(
+ StructureImportSettings.isVisibleChainAnnotation(),
+ StructureImportSettings.isPredictSecondaryStructure(),
+ StructureImportSettings.isExternalSecondaryStructure(),
+ source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return new JmolParser(); // todo or null?
+ }
+ },
+ Jalview
+ {
+
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return null;
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return null;
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return null;
+ }
+ };
+
+ @Override
+ public boolean isComplexAlignFile()
+ {
+ return false;
+ }
+
+ @Override
+ public String getShortDescription()
+ {
+ return toString();
+ }
+}