X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FFeaturesFileTest.java;h=385e049bbc7122d931c70a490fd3a21de5effc37;hb=a6626e6ecada2984ba9f11de957a14244d34be14;hp=506ee91dcf1248a9506fe6592a3a3e799a8ec9e4;hpb=0900cfda915f917ce29ced5401b7118ff2a5372a;p=jalview.git diff --git a/test/jalview/io/FeaturesFileTest.java b/test/jalview/io/FeaturesFileTest.java index 506ee91..385e049 100644 --- a/test/jalview/io/FeaturesFileTest.java +++ b/test/jalview/io/FeaturesFileTest.java @@ -24,14 +24,10 @@ import static org.testng.AssertJUnit.assertEquals; 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; @@ -42,9 +38,7 @@ import jalview.schemes.GraduatedColor; 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; @@ -167,7 +161,7 @@ public class FeaturesFileTest .getSequenceFeatures(); assertEquals(1, sfs.length); SequenceFeature sf = sfs[0]; - assertEquals("Iron-sulfur; 2Fe-2S", sf.description); + assertEquals("Iron-sulfur,2Fe-2S", sf.description); assertEquals(44, sf.begin); assertEquals(45, sf.end); assertEquals("uniprot", sf.featureGroup); @@ -256,7 +250,7 @@ public class FeaturesFileTest 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", @@ -268,7 +262,7 @@ public class FeaturesFileTest assertEquals(1, sfs.length); SequenceFeature sf = sfs[0]; // description parsed from Note attribute - assertEquals("Iron-sulfur (2Fe-2S); another note", sf.description); + assertEquals("Iron-sulfur (2Fe-2S),another note", sf.description); assertEquals(39, sf.begin); assertEquals(39, sf.end); assertEquals("uniprot", sf.featureGroup); @@ -281,7 +275,8 @@ public class FeaturesFileTest sfs = al.getSequenceAt(2).getDatasetSequence().getSequenceFeatures(); assertEquals(1, sfs.length); sf = sfs[0]; - assertEquals("uniprot", sf.description); + // ID used for description if available + assertEquals("$23", sf.description); assertEquals(55, sf.begin); assertEquals(130, sf.end); assertEquals("uniprot", sf.featureGroup); @@ -339,8 +334,8 @@ public class FeaturesFileTest 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( @@ -402,8 +397,7 @@ public class FeaturesFileTest 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" }) @@ -418,64 +412,4 @@ public class FeaturesFileTest parseResult); checkDatasetfromSimpleGff3(dataset); } - - /** - * Tests loading exonerate GFF2 output, including 'similarity' alignment - * feature, on to sequences - */ - @Test(groups = { "Functional" }) - public void testExonerateImport() - { - FileLoader loader = new FileLoader(false); - AlignFrame af = loader.LoadFileWaitTillLoaded( - "examples/testdata/exonerateseqs.fa", - FormatAdapter.FILE); - - af.loadJalviewDataFile("examples/testdata/exonerateoutput.gff", - FormatAdapter.FILE, null, null); - - /* - * verify one mapping to a dummy sequence, one to a real one - */ - Set mappings = af - .getViewport().getAlignment().getDataset().getCodonFrames(); - assertEquals(2, mappings.size()); - Iterator iter = mappings.iterator(); - - // first mapping is to dummy sequence - AlignedCodonFrame mapping = iter.next(); - Mapping[] mapList = mapping.getProtMappings(); - assertEquals(1, mapList.length); - assertTrue(mapList[0].getTo() instanceof SequenceDummy); - assertEquals("DDB_G0269124", mapList[0].getTo().getName()); - - // second mapping is to a sequence in the alignment - mapping = iter.next(); - mapList = mapping.getProtMappings(); - assertEquals(1, mapList.length); - SequenceI proteinSeq = af.getViewport().getAlignment() - .findName("DDB_G0280897"); - assertSame(proteinSeq.getDatasetSequence(), mapList[0].getTo()); - assertEquals(1, mapping.getdnaToProt().length); - - // 143 in protein should map to codon [11270, 11269, 11268] in dna - int[] mappedRegion = mapList[0].getMap().locateInFrom(143, 143); - assertArrayEquals(new int[] { 11270, 11268 }, mappedRegion); - - // 182 in protein should map to codon [11153, 11152, 11151] in dna - mappedRegion = mapList[0].getMap().locateInFrom(182, 182); - assertArrayEquals(new int[] { 11153, 11151 }, mappedRegion); - - // and the reverse mapping: - mappedRegion = mapList[0].getMap().locateInTo(11151, 11153); - assertArrayEquals(new int[] { 182, 182 }, mappedRegion); - - // 11150 in dna should _not_ map to protein - mappedRegion = mapList[0].getMap().locateInTo(11150, 11150); - assertNull(mappedRegion); - - // similarly 183 in protein should _not_ map to dna - mappedRegion = mapList[0].getMap().locateInFrom(183, 183); - assertNull(mappedRegion); - } }