From a5ad4f49249c216517d76303c731a8ca0d1f0c55 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 16 May 2017 10:25:28 +0100 Subject: [PATCH] JAL-2505 additional tests/asserts prior to refactoring --- test/jalview/io/gff/Gff3HelperTest.java | 46 +++++++++++++++++++++++ test/jalview/io/gff/InterProScanHelperTest.java | 12 ++++++ 2 files changed, 58 insertions(+) diff --git a/test/jalview/io/gff/Gff3HelperTest.java b/test/jalview/io/gff/Gff3HelperTest.java index bf038ac..cd5a0d8 100644 --- a/test/jalview/io/gff/Gff3HelperTest.java +++ b/test/jalview/io/gff/Gff3HelperTest.java @@ -37,7 +37,9 @@ import jalview.gui.JvOptionPane; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -231,4 +233,48 @@ public class Gff3HelperTest .getToRanges().get(0)); } + @Test(groups = "Functional") + public void testGetDescription() + { + Gff3Helper testee = new Gff3Helper(); + SequenceFeature sf = new SequenceFeature("type", "desc", 10, 20, 3f, + "group"); + Map> attributes = new HashMap>(); + assertNull(testee.getDescription(sf, attributes)); + + // ID if any is a fall-back for description + sf.setValue("ID", "Patrick"); + assertEquals("Patrick", testee.getDescription(sf, attributes)); + + // Target is set by Exonerate + sf.setValue("Target", "Destination Moon"); + assertEquals("Destination", testee.getDescription(sf, attributes)); + + // Ensembl variant feature - extract "alleles" value + // may be sequence_variant or a sub-type in the sequence ontology + sf = new SequenceFeature("feature_variant", "desc", 10, 20, 3f, "group"); + List atts = new ArrayList(); + atts.add("A"); + atts.add("C"); + atts.add("T"); + attributes.put("alleles", atts); + assertEquals("A,C,T", testee.getDescription(sf, attributes)); + + // Ensembl transcript or exon feature - extract Name + List atts2 = new ArrayList(); + atts2.add("ENSE00001871077"); + attributes.put("Name", atts2); + sf = new SequenceFeature("transcript", "desc", 10, 20, 3f, "group"); + assertEquals("ENSE00001871077", testee.getDescription(sf, attributes)); + // transcript sub-type in SO + sf = new SequenceFeature("mRNA", "desc", 10, 20, 3f, "group"); + assertEquals("ENSE00001871077", testee.getDescription(sf, attributes)); + // special usage of feature by Ensembl + sf = new SequenceFeature("NMD_transcript_variant", "desc", 10, 20, 3f, + "group"); + assertEquals("ENSE00001871077", testee.getDescription(sf, attributes)); + // exon feature + sf = new SequenceFeature("exon", "desc", 10, 20, 3f, "group"); + assertEquals("ENSE00001871077", testee.getDescription(sf, attributes)); + } } diff --git a/test/jalview/io/gff/InterProScanHelperTest.java b/test/jalview/io/gff/InterProScanHelperTest.java index bcccf35..59935dd 100644 --- a/test/jalview/io/gff/InterProScanHelperTest.java +++ b/test/jalview/io/gff/InterProScanHelperTest.java @@ -21,6 +21,7 @@ package jalview.io.gff; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; @@ -30,6 +31,7 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceDummy; +import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.gui.JvOptionPane; @@ -76,6 +78,16 @@ public class InterProScanHelperTest assertEquals(1, newseqs.size()); assertTrue(newseqs.get(0) instanceof SequenceDummy); assertEquals("match$17_5_30", newseqs.get(0).getName()); + + assertNotNull(newseqs.get(0).getSequenceFeatures()); + assertEquals(1, newseqs.get(0).getSequenceFeatures().length); + SequenceFeature sf = newseqs.get(0).getSequenceFeatures()[0]; + assertEquals(1, sf.getBegin()); + assertEquals(26, sf.getEnd()); + assertEquals("Pfam", sf.getType()); + assertEquals("4Fe-4S dicluster domain", sf.getDescription()); + assertEquals("InterProScan", sf.getFeatureGroup()); + assertEquals(1, align.getCodonFrames().size()); AlignedCodonFrame mapping = align.getCodonFrames().iterator().next(); -- 1.7.10.2