JAL-1191 SequenceOntology wrapping/caching SO.OBO via BioJava library
[jalview.git] / test / jalview / io / gff / SequenceOntologyTest.java
1 package jalview.io.gff;
2
3 import static org.testng.AssertJUnit.assertFalse;
4 import static org.testng.AssertJUnit.assertTrue;
5
6 import org.testng.annotations.BeforeMethod;
7 import org.testng.annotations.Test;
8
9 public class SequenceOntologyTest
10 {
11   private SequenceOntology so;
12
13   @BeforeMethod
14   public void setUp() {
15     so = SequenceOntology.getInstance();
16   }
17
18   @Test(groups = "Functional")
19   public void testTermIsA()
20   {
21     assertTrue(so.isA("SO:0000087", "SO:0000704"));
22     assertFalse(so.isA("SO:0000704", "SO:0000087"));
23     assertTrue(so.isA("SO:0000736", "SO:0000735"));
24
25     // direct parent:
26     assertTrue(so.isA("micronuclear_sequence", "organelle_sequence"));
27     // grandparent:
28     assertTrue(so.isA("micronuclear_sequence", "sequence_location"));
29     // great-grandparent:
30     assertTrue(so.isA("micronuclear_sequence", "sequence_attribute"));
31
32     // same thing:
33     assertTrue(so.isA("micronuclear_sequence", "SO:0000084"));
34   }
35
36   @Test(groups = "Functional")
37   public void testIsProteinMatch()
38   {
39     assertTrue(so.isProteinMatch("protein_match"));
40     assertTrue(so.isProteinMatch("protein_hmm_match"));
41     assertFalse(so.isProteinMatch("Protein_match")); // case-sensitive
42   }
43
44   @Test(groups = "Functional")
45   public void testIsNucleotideMatch()
46   {
47     assertTrue(so.isNucleotideMatch("nucleotide_match"));
48     assertTrue(so.isNucleotideMatch("primer_match"));
49     assertTrue(so.isNucleotideMatch("cross_genome_match"));
50     assertTrue(so.isNucleotideMatch("expressed_sequence_match"));
51     assertTrue(so.isNucleotideMatch("translated_nucleotide_match"));
52     assertTrue(so.isNucleotideMatch("UST_match"));
53     assertTrue(so.isNucleotideMatch("RST_match"));
54     assertTrue(so.isNucleotideMatch("cDNA_match"));
55     assertTrue(so.isNucleotideMatch("EST_match"));
56     assertFalse(so.isNucleotideMatch("match")); // parent
57   }
58
59   @Test(groups = "Functional")
60   public void testIsCDS()
61   {
62     assertTrue(so.isA("CDS", "CDS"));
63     assertTrue(so.isA("CDS_predicted", "CDS"));
64     assertTrue(so.isA("transposable_element_CDS", "CDS"));
65     assertTrue(so.isA("edited_CDS", "CDS"));
66     assertTrue(so.isA("CDS_independently_known", "CDS"));
67     assertTrue(so.isA("CDS_fragment", "CDS"));
68     assertFalse(so.isA("CDS_region", "CDS"));// part_of
69     assertFalse(so.isA("polypeptide", "CDS")); // derives_from
70   }
71 }