viewport.setColumnSelection(cs);
isAnnotation = true;
}
- else if (IdentifyFile.FeaturesFile.equals(format))
+ // else if (IdentifyFile.FeaturesFile.equals(format))
+ else if (format == FileFormat.Features)
{
if (parseFeaturesFile(file, sourceType))
{
{
String title = MessageManager.formatMessage(
"label.input_cut_paste_params",
- new String[] { format.getShortDescription() });
+ new String[] { format.toString() });
FeatureSettingsModelI proxyColourScheme = source
.getFeatureColourScheme();
import jalview.bin.Cache;
import jalview.gui.Help.HelpId;
import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.FileFormatI;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.jbgui.GPreferences;
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
- chooser
- .getSelectedFormat().toString());
+ FileFormatI format = chooser.getSelectedFormat();
+ if (format != null)
+ {
+ Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
+ format.toString());
+ }
startupFileTextfield.setText(chooser.getSelectedFile()
.getAbsolutePath());
}
/**
* Properties to be added to generated alignment object
*/
- protected Hashtable properties;
+ private Hashtable properties;
long start;
{
try
{
- AlignmentFileI afile = format.getAlignmentFile();
+ AlignmentFileI afile = format.getAlignmentFile(alignment);
afile.setNewlineString(newline);
afile.setExportSettings(exportSettings);
package jalview.io;
+import jalview.datamodel.AlignmentI;
import jalview.datamodel.PDBEntry;
import jalview.ext.jmol.JmolParser;
import jalview.structure.StructureImportSettings;
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new FastaFile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new PfamFile();
}
}
@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();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
- return new BLCFile();
+ return new AMSAFile(al);
}
},
Html("HTML", "html", true, false)
}
@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();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new PileUpfile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new MSFfile();
}
}
@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?
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new FeaturesFile();
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new JmolParser(); // todo or null?
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return new JmolParser(); // todo or null?
}
}
@Override
- public AlignmentFileI getAlignmentFile()
+ public AlignmentFileI getAlignmentFile(AlignmentI al)
{
return null;
}
return false;
}
- @Override
- public String getShortDescription()
- {
- return toString();
- }
-
/**
* Returns the file format with the given name, or null if format is null or
* invalid. Unlike valueOf(), this is not case-sensitive, to be kind to
{
return name;
}
+
+ @Override
+ public AlignmentFileI getAlignmentFile()
+ {
+ return getAlignmentFile((AlignmentI) null);
+ }
}
package jalview.io;
+import jalview.datamodel.AlignmentI;
+
import java.io.IOException;
public interface FileFormatI
AlignmentFileI getAlignmentFile(FileParse source) throws IOException;
+ AlignmentFileI getAlignmentFile(AlignmentI al);
+
AlignmentFileI getAlignmentFile();
boolean isComplexAlignFile();
- String getShortDescription();
-
/**
* Returns a comma-separated list of file extensions associated with the
* format
//
// try
// {
- boolean withSuffix = getCacheSuffixDefault(format);
+ boolean withSuffix = getCacheSuffixDefault(format);
return format.getAlignmentFile().print(seqs, withSuffix);
// null;
//
*/
public class IdentifyFile
{
- public static final String FeaturesFile = "GFF or Jalview features";
-
/**
* Identify a datasource's file content.
*
if (format.isReadable())
{
extensions.add(format.getExtensions());
- descs.add(format.getShortDescription());
+ descs.add(format.toString());
}
}
return new JalviewFileChooser(directory,
if (format.isWritable())
{
extensions.add(format.getExtensions());
- descs.add(format.getShortDescription());
+ descs.add(format.toString());
}
}
return new JalviewFileChooser(directory,
}
}
+ /**
+ * Returns the selected file format, or null if none selected
+ *
+ * @return
+ */
public FileFormatI getSelectedFormat()
{
if (getFileFilter() == null)
return null;
}
+ /*
+ * logic here depends on option description being formatted as
+ * formatName (extension, extension...)
+ * or the 'no option selected' value
+ * All Files
+ * @see JalviewFileFilter.getDescription
+ */
String format = getFileFilter().getDescription();
- format = format.substring(0, format.indexOf("(") - 1);
- return FileFormat.valueOf(format);
+ int parenPos = format.indexOf("(");
+ if (parenPos > 0)
+ {
+ format = format.substring(0, parenPos).trim();
+ try
+ {
+ return FileFormat.valueOf(format);
+ } catch (IllegalArgumentException e)
+ {
+ System.err.println("Unexpected format: " + format);
+ }
+ }
+ return null;
}
@Override
*/
package jalview.io;
-import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.Assert;
{
@Test(groups = { "Functional" }, dataProvider = "identifyFiles")
- public void testIdentify(String data, String expectedFileType)
+ public void testIdentify(String data, FileFormatI expectedFileType)
throws FileFormatException
{
DataSourceType protocol = DataSourceType.FILE;
IdentifyFile ider = new IdentifyFile();
- String actualFiletype = ider.identify(data, protocol).toString();
- Assert.assertEquals(actualFiletype, expectedFileType,
+ FileFormatI actualFiletype = ider.identify(data, protocol);
+ Assert.assertSame(actualFiletype, expectedFileType,
"File identification Failed!");
}
*/
String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
- assertEquals(IdentifyFile.FeaturesFile,
+ assertSame(FileFormat.Features,
ider.identify(data, DataSourceType.PASTE));
/*
*/
data = "METAL\tcc9900\n" + "GFF\n"
+ "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n";
- assertEquals(IdentifyFile.FeaturesFile,
+ assertSame(FileFormat.Features,
ider.identify(data, DataSourceType.PASTE));
/*
* Feature with '<' in the name (JAL-2098)
*/
data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n";
- assertEquals(IdentifyFile.FeaturesFile,
+ assertSame(FileFormat.Features,
ider.identify(data, DataSourceType.PASTE));
}
public Object[][] IdentifyFileDP()
{
return new Object[][] {
- { "examples/example.json", "JSON" },
- { "examples/plantfdx.fa", "FASTA" },
- { "examples/dna_interleaved.phy", "PHYLIP" },
- { "examples/2GIS.pdb", "PDB" },
- { "examples/rf00031_folded.stk", "STH" },
- { "examples/testdata/test.rnaml", "RNAML" },
- { "examples/testdata/test.aln", "CLUSTAL" },
- { "examples/testdata/test.pfam", "PFAM" },
- { "examples/testdata/test.msf", "MSF" },
- { "examples/testdata/test.pir", "PIR" },
- { "examples/testdata/test.html", "HTML" },
- { "examples/testdata/test.pileup", "PileUp" },
- { "examples/testdata/test.blc", "BLC" },
- { "examples/exampleFeatures.txt", IdentifyFile.FeaturesFile },
- { "examples/testdata/simpleGff3.gff", IdentifyFile.FeaturesFile },
- { "examples/testdata/test.jvp", "Jalview" },
- { "examples/testdata/test.cif", "mmCIF" },
+ { "examples/example.json", FileFormat.Json },
+ { "examples/plantfdx.fa", FileFormat.Fasta },
+ { "examples/dna_interleaved.phy", FileFormat.Phylip },
+ { "examples/2GIS.pdb", FileFormat.PDB },
+ { "examples/rf00031_folded.stk", FileFormat.Stockholm },
+ { "examples/testdata/test.rnaml", FileFormat.Rnaml },
+ { "examples/testdata/test.aln", FileFormat.Clustal },
+ { "examples/testdata/test.pfam", FileFormat.Pfam },
+ { "examples/testdata/test.msf", FileFormat.MSF },
+ { "examples/testdata/test.pir", FileFormat.PIR },
+ { "examples/testdata/test.html", FileFormat.Html },
+ { "examples/testdata/test.pileup", FileFormat.Pileup },
+ { "examples/testdata/test.blc", FileFormat.BLC },
+ { "examples/exampleFeatures.txt", FileFormat.Features },
+ { "examples/testdata/simpleGff3.gff", FileFormat.Features },
+ { "examples/testdata/test.jvp", FileFormat.Jalview },
+ { "examples/testdata/test.cif", FileFormat.MMCif },
{
"examples/testdata/cullpdb_pc25_res3.0_R0.3_d150729_chains9361.fasta.15316",
- "FASTA" },
+ FileFormat.Fasta },
// { "examples/testdata/test.amsa", "AMSA" },
// { "examples/test.jnet", "JnetFile" },