import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Mapping;
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import org.testng.annotations.Test;
public class FeaturesFileTest
{
- private static String exonerateSeqs = "examples/testdata/exonerateseqs.fa",
- exonerateOutput = "examples/testdata/exonerateoutput.gff",
- simpleGffFile = "examples/testdata/simpleGff3.gff";
+ private static String simpleGffFile = "examples/testdata/simpleGff3.gff";
@Test(groups = { "Functional" })
public void testParse() throws Exception
AlignFrame af = new AlignFrame(al, 500, 500);
Map<String, Object> colours = af.getFeatureRenderer()
.getFeatureColours();
+ // GFF2 uses space as name/value separator in column 9
String gffData = "METAL\tcc9900\n" + "GFF\n"
- + "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n"
+ + "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\tNote Iron-sulfur; Note 2Fe-2S\n"
+ "FER1_SOLLC\tuniprot\tPfam\t55\t130\t2.0\t.\t.";
FeaturesFile featuresFile = new FeaturesFile(gffData,
FormatAdapter.PASTE);
.getSequenceFeatures();
assertEquals(1, sfs.length);
SequenceFeature sf = sfs[0];
- assertEquals("uniprot", sf.description);
+ assertEquals("Iron-sulfur; 2Fe-2S", sf.description);
assertEquals(44, sf.begin);
assertEquals(45, sf.end);
assertEquals("uniprot", sf.featureGroup);
* @throws Exception
*/
@Test(groups = { "Functional" })
- public void testParse_pureGff() throws Exception
+ public void testParse_pureGff3() throws Exception
{
File f = new File("examples/uniref50.fa");
AlignmentI al = readAlignmentFile(f);
AlignFrame af = new AlignFrame(al, 500, 500);
Map<String, Object> colours = af.getFeatureRenderer()
.getFeatureColours();
- String gffData = "##gff-version 2\n"
+ // GFF3 uses '=' separator for name/value pairs in colum 9
+ String gffData = "##gff-version 3\n"
+ "FER_CAPAA\tuniprot\tMETAL\t39\t39\t0.0\t.\t.\t"
+ "Note=Iron-sulfur (2Fe-2S);Note=another note;evidence=ECO:0000255|PROSITE-ProRule:PRU00465\n"
- + "FER1_SOLLC\tuniprot\tPfam\t55\t130\t3.0\t.\t.";
+ + "FER1_SOLLC\tuniprot\tPfam\t55\t130\t3.0\t.\t.\tID=$23";
FeaturesFile featuresFile = new FeaturesFile(gffData,
FormatAdapter.PASTE);
assertTrue("Failed to parse features file",
assertEquals("no sequences extracted from GFF3 file", 2,
dataset.getHeight());
- SequenceI seq1 = dataset.findName("seq1"), seq2 = dataset
- .findName("seq2");
+ SequenceI seq1 = dataset.findName("seq1");
+ SequenceI seq2 = dataset.findName("seq2");
assertNotNull(seq1);
assertNotNull(seq2);
assertFalse(
}
@Test(groups = { "Functional" })
- public void simpleGff3FileIdentify()
- {
- assertEquals("Didn't recognise file correctly.",
- IdentifyFile.FeaturesFile,
- new IdentifyFile().identify(simpleGffFile, FormatAdapter.FILE));
- }
-
- @Test(groups = { "Functional" })
public void simpleGff3FileLoader() throws IOException
{
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
assertTrue(
"Didn't read the alignment into an alignframe from Gff3 File",
af != null);
- // FIXME codon mappings are on the alignment but not on the dataset
- checkDatasetfromSimpleGff3(af.getViewport().getAlignment()/* .getDataset() */);
+ checkDatasetfromSimpleGff3(af.getViewport().getAlignment());
}
@Test(groups = { "Functional" })
parseResult);
checkDatasetfromSimpleGff3(dataset);
}
-
- @Test(groups = { "Functional" })
- public void testExonerateImport()
- {
- // exonerate does not tag sequences after features, so we have a more
- // conventional annotation import test here
-
- FileLoader loader = new FileLoader(false);
-
- AlignFrame af = loader.LoadFileWaitTillLoaded(exonerateSeqs,
- FormatAdapter.FILE);
-
- assertEquals("Unexpected number of DNA protein associations", 0, af
- .getViewport().getAlignment().getCodonFrames().size());
-
- af.loadJalviewDataFile(exonerateOutput, FormatAdapter.FILE, null, null);
-
- assertTrue("Expected at least one DNA protein association", 0 != af
- .getViewport().getAlignment().getDataset().getCodonFrames()
- .size());
- }
}