package jalview.io;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.PDBEntry;
import jalview.ext.jmol.JmolParser;
import jalview.structure.StructureImportSettings;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
public enum FileFormat implements FileFormatI
{
- Fasta("FASTA", "fa, fasta, mfa, fastq", true, true)
+ Fasta("Fasta", "fa, fasta, mfa, fastq", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new FastaFile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new PfamFile();
}
},
- Stockholm("STH", "sto,stk", true, true)
+ Stockholm("Stockholm", "sto,stk", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
- return new StockholmFile();
+ return new StockholmFile(al);
}
},
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new PIRFile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new BLCFile();
}
},
+ AMSA("AMSA", "amsa", true, true)
+ {
+ @Override
+ public AlignmentFileI getAlignmentFile(String inFile,
+ DataSourceType sourceType) throws IOException
+ {
+ return new AMSAFile(inFile, sourceType);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(FileParse source)
+ throws IOException
+ {
+ return new AMSAFile(source);
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
+ {
+ return new AMSAFile(al);
+ }
+ },
Html("HTML", "html", true, false)
{
@Override
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new HtmlFile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new RnamlFile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new JSONFile();
}
}
},
- Pileup("PileUp", "?", false, false)
+ Pileup("PileUp", "pileup", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new PileUpfile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new MSFfile();
}
},
- Clustal("CLUSTAL", "aln", true, true)
+ Clustal("Clustal", "aln", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new ClustalFile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new PhylipFile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return null; // todo is this called?
}
},
- Features("GFF or Jalview features", "gff2,gff3", false, false)
+ Features("GFF or Jalview features", "gff2,gff3", true, false)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new FeaturesFile();
}
},
- PDB("PDB", "", false, false)
+ PDB("PDB", "pdb,ent", true, false)
{
@Override
{
// 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");
+ boolean isParseWithJMOL = StructureImportSettings
+ .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
if (isParseWithJMOL)
{
- return new JmolParser(
- StructureImportSettings.isVisibleChainAnnotation(),
- StructureImportSettings.isPredictSecondaryStructure(),
- StructureImportSettings.isExternalSecondaryStructure(),
- inFile,
- sourceType);
+ return new JmolParser(inFile, sourceType);
}
else
{
StructureImportSettings.setShowSeqFeatures(true);
return new MCview.PDBfile(
StructureImportSettings.isVisibleChainAnnotation(),
- StructureImportSettings.isPredictSecondaryStructure(),
+ StructureImportSettings.isProcessSecondaryStructure(),
StructureImportSettings.isExternalSecondaryStructure(),
inFile,
sourceType);
public AlignmentFileI getAlignmentFile(FileParse source)
throws IOException
{
- boolean isParseWithJMOL = !StructureImportSettings
- .getCurrentDefaultFormat().equalsIgnoreCase("PDB");
+ boolean isParseWithJMOL = StructureImportSettings
+ .getDefaultStructureFileFormat() != PDBEntry.Type.PDB;
if (isParseWithJMOL)
{
- return new JmolParser(
- StructureImportSettings.isVisibleChainAnnotation(),
- StructureImportSettings.isPredictSecondaryStructure(),
- StructureImportSettings.isExternalSecondaryStructure(),
- source);
+ return new JmolParser(source);
}
else
{
StructureImportSettings.setShowSeqFeatures(true);
return new MCview.PDBfile(
StructureImportSettings.isVisibleChainAnnotation(),
- StructureImportSettings.isPredictSecondaryStructure(),
+ StructureImportSettings.isProcessSecondaryStructure(),
StructureImportSettings.isExternalSecondaryStructure(),
source);
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new JmolParser(); // todo or null?
}
+
+ @Override
+ public boolean isStructureFile()
+ {
+ return true;
+ }
},
- MMCif("mmCIF", "cif", false, false)
+ MMCif("mmCIF", "cif", true, false)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
DataSourceType sourceType) throws IOException
{
- return new JmolParser(
- StructureImportSettings.isVisibleChainAnnotation(),
- StructureImportSettings.isPredictSecondaryStructure(),
- StructureImportSettings.isExternalSecondaryStructure(),
- inFile, sourceType);
+ return new JmolParser(inFile, sourceType);
}
@Override
public AlignmentFileI getAlignmentFile(FileParse source)
throws IOException
{
- return new JmolParser(
- StructureImportSettings.isVisibleChainAnnotation(),
- StructureImportSettings.isPredictSecondaryStructure(),
- StructureImportSettings.isExternalSecondaryStructure(),
- source);
+ return new JmolParser(source);
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new JmolParser(); // todo or null?
}
+
+ @Override
+ public boolean isStructureFile()
+ {
+ return true;
+ }
},
- Jalview("Jalview", "jar,jvp", true, false)
+ Jalview("Jalview", "jar,jvp", true, true)
{
@Override
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return null;
}
+
+ @Override
+ public boolean isTextFormat()
+ {
+ return false;
+ }
};
/**
private String name;
- @Override
- public boolean isComplexAlignFile()
+ /**
+ * Answers a list of writeable file formats (as string, corresponding to the
+ * toString() and forName() methods)
+ *
+ * @return
+ */
+ public static List<String> getWritableFormats(boolean textOnly)
{
- return false;
+ List<String> l = new ArrayList<String>();
+ for (FileFormatI ff : values())
+ {
+ if (ff.isWritable() && (!textOnly || ff.isTextFormat()))
+ {
+ l.add(ff.toString());
+ }
+ }
+ return l;
+ }
+
+ /**
+ * Answers a list of readable file formats (as string, corresponding to the
+ * toString() and forName() methods)
+ *
+ * @return
+ */
+ public static List<String> getReadableFormats()
+ {
+ List<String> l = new ArrayList<String>();
+ for (FileFormatI ff : values())
+ {
+ if (ff.isReadable())
+ {
+ l.add(ff.toString());
+ }
+ }
+ return l;
}
@Override
- public String getShortDescription()
+ public boolean isComplexAlignFile()
{
- return toString();
+ return false;
}
/**
{
return extensions;
}
+
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return getAlignmentFile((AlignmentI) null);
+ }
+
+ @Override
+ public boolean isTextFormat()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isStructureFile()
+ {
+ return false;
+ }
}