*/
package jalview.io;
+import java.io.IOException;
+
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
import jalview.ext.jmol.JmolParser;
import jalview.structure.StructureImportSettings;
-import java.io.IOException;
-
public enum FileFormat implements FileFormatI
{
Fasta("Fasta", "fa, fasta, mfa, fastq", true, true)
return new PhylipFile();
}
},
- GenBank("GenBank/ENA Flatfile","gb",false,false)
+ GenBank("GenBank Flatfile", "gb", true, false)
+ {
+ @Override
+ public AlignmentFileReaderI getReader(FileParse source)
+ throws IOException
+ {
+ return new GenBankFile(source, "GenBank");
+ }
+
+ @Override
+ public AlignmentFileWriterI getWriter(AlignmentI al)
+ {
+ return null;
+ }
+ },
+ Embl("ENA Flatfile", "txt", true, false)
{
@Override
public AlignmentFileReaderI getReader(FileParse source)
// Always assume we import from EMBL for now
return new EmblFlatFile(source, DBRefSource.EMBL);
}
+
@Override
public AlignmentFileWriterI getWriter(AlignmentI al)
{
return null;
}
- }
- ,
+ },
Jnet("JnetFile", "", false, false)
{
@Override
* using TreeMap gives CDS sequences in alphabetical, so readable, order
*/
cds = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ parse();
}
/**
reply = FileFormat.ScoreMatrix;
break;
}
+ if (data.startsWith("LOCUS"))
+ {
+ reply = FileFormat.GenBank;
+ break;
+ }
+ if (data.startsWith("ID "))
+ {
+ if (data.substring(2).trim().split(";").length == 7)
+ {
+ reply = FileFormat.Embl;
+ break;
+ }
+ }
if (data.startsWith("H ") && !aaIndexHeaderRead)
{
aaIndexHeaderRead = true;
File dataFile = new File("test/jalview/io/J03321.embl.txt");
FileParse fp = new FileParse(dataFile, DataSourceType.FILE);
EmblFlatFile parser = new EmblFlatFile(fp, "EmblTest");
- parser.parse();
List<SequenceI> seqs = parser.getSeqs();
assertEquals(seqs.size(), 1);
+ " ggatGcgtaa gttagacgaa attttgtctt tgcgcacaga 40\n";
FileParse fp = new FileParse(data, DataSourceType.PASTE);
EmblFlatFile parser = new EmblFlatFile(fp, "EmblTest");
- parser.parse();
List<SequenceI> seqs = parser.getSeqs();
assertEquals(seqs.size(), 1);
SequenceI seq = seqs.get(0);
FileParse fp = new FileParse(dataFile.getAbsolutePath(),
DataSourceType.FILE);
FlatFile parser = new GenBankFile(fp, "GenBankTest");
- parser.parse();
List<SequenceI> seqs = parser.getSeqs();
assertEquals(seqs.size(), 1);
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
-import jalview.gui.JvOptionPane;
-
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import jalview.gui.JvOptionPane;
+
public class IdentifyFileTest
{
{ "examples/testdata/test.html", FileFormat.Html },
{ "examples/testdata/test.pileup", FileFormat.Pileup },
{ "examples/testdata/test.blc", FileFormat.BLC },
+ { "test/jalview/io/J03321.embl.txt", FileFormat.Embl },
+ { "test/jalview/io/J03321.gb", FileFormat.GenBank },
{ "examples/exampleFeatures.txt", FileFormat.Features },
{ "examples/testdata/simpleGff3.gff", FileFormat.Features },
{ "examples/testdata/test.jvp", FileFormat.Jalview },