X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2Fgff%2FGff3HelperTest.java;h=cd5a0d8853e8571d75a9992a241f39790e1aa20f;hb=136c0793b90b72b928c4d77dc109dd5c644e00d3;hp=4355e40ec67af11eeac5073e70a455b723feffc6;hpb=604cbee405a837565ba1a74aa9bddd62aed685ab;p=jalview.git diff --git a/test/jalview/io/gff/Gff3HelperTest.java b/test/jalview/io/gff/Gff3HelperTest.java index 4355e40..cd5a0d8 100644 --- a/test/jalview/io/gff/Gff3HelperTest.java +++ b/test/jalview/io/gff/Gff3HelperTest.java @@ -33,16 +33,27 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceDummy; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; +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; public class Gff3HelperTest { + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + /** * Test processing one PASA GFF line giving a match from forward strand to * forward strand @@ -222,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)); + } }