Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 17:27:16 GMT
  2. Package jalview.ext.so

File SequenceOntologyTest.java

 

Code metrics

0
53
5
1
135
89
6
0.11
10.6
5
1.2

Classes

Class Line # Actions
SequenceOntologyTest 32 53 6
0.965517296.6%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.ext.so;
22   
23    import static org.testng.AssertJUnit.assertFalse;
24    import static org.testng.AssertJUnit.assertTrue;
25   
26    import jalview.gui.JvOptionPane;
27    import jalview.io.gff.SequenceOntologyI;
28   
29    import org.testng.annotations.BeforeClass;
30    import org.testng.annotations.Test;
31   
 
32    public class SequenceOntologyTest
33    {
34   
 
35  1 toggle @BeforeClass(alwaysRun = true)
36    public void setUpJvOptionPane()
37    {
38  1 JvOptionPane.setInteractiveMode(false);
39  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
40    }
41   
42    private SequenceOntologyI so;
43   
 
44  1 toggle @BeforeClass(alwaysRun = true)
45    public void setUp()
46    {
47  1 long now = System.currentTimeMillis();
48  1 try
49    {
50  1 so = new SequenceOntology();
51    } catch (Throwable t)
52    {
53  0 System.out.println("SOTest error ");
54  0 t.printStackTrace(System.err);
55    }
56  1 long elapsed = System.currentTimeMillis() - now;
57  1 System.out.println(
58    "Load and cache of Sequence Ontology took " + elapsed + "ms");
59    }
60   
 
61  1 toggle @Test(groups = "Functional")
62    public void testIsA()
63    {
64  1 assertFalse(so.isA(null, null));
65  1 assertFalse(so.isA(null, "SO:0000087"));
66  1 assertFalse(so.isA("SO:0000087", null));
67  1 assertFalse(so.isA("complete", "garbage"));
68   
69  1 assertTrue(so.isA("SO:0000087", "SO:0000704"));
70  1 assertFalse(so.isA("SO:0000704", "SO:0000087"));
71  1 assertTrue(so.isA("SO:0000736", "SO:0000735"));
72   
73    // same thing:
74  1 assertTrue(so.isA("micronuclear_sequence", "micronuclear_sequence"));
75    // direct parent:
76  1 assertTrue(so.isA("micronuclear_sequence", "organelle_sequence"));
77    // grandparent:
78  1 assertTrue(so.isA("micronuclear_sequence", "sequence_location"));
79    // great-grandparent:
80  1 assertTrue(so.isA("micronuclear_sequence", "sequence_attribute"));
81   
82    // same thing by name / description:
83  1 assertTrue(so.isA("micronuclear_sequence", "SO:0000084"));
84  1 assertTrue(so.isA("SO:0000084", "micronuclear_sequence"));
85  1 assertTrue(so.isA("SO:0000084", "SO:0000084"));
86   
87    // SO name to description:
88  1 assertTrue(so.isA("SO:0000084", "organelle_sequence"));
89  1 assertTrue(so.isA("SO:0000084", "sequence_location"));
90  1 assertTrue(so.isA("SO:0000084", "sequence_attribute"));
91   
92    // description to SO name:
93  1 assertTrue(so.isA("micronuclear_sequence", "SO:0000736"));
94  1 assertTrue(so.isA("micronuclear_sequence", "SO:0000735"));
95  1 assertTrue(so.isA("micronuclear_sequence", "SO:0000400"));
96    }
97   
 
98  1 toggle @Test(groups = "Functional")
99    public void testIsCDS()
100    {
101  1 assertTrue(so.isA("CDS", "CDS"));
102  1 assertTrue(so.isA("CDS_predicted", "CDS"));
103  1 assertTrue(so.isA("transposable_element_CDS", "CDS"));
104  1 assertTrue(so.isA("edited_CDS", "CDS"));
105  1 assertTrue(so.isA("CDS_independently_known", "CDS"));
106  1 assertTrue(so.isA("CDS_fragment", "CDS"));
107  1 assertFalse(so.isA("CDS_region", "CDS"));// part_of
108  1 assertFalse(so.isA("polypeptide", "CDS")); // derives_from
109    }
110   
 
111  1 toggle @Test(groups = "Functional")
112    public void testIsSequenceVariant()
113    {
114  1 assertFalse(so.isA("CDS", "sequence_variant"));
115  1 assertTrue(so.isA("sequence_variant", "sequence_variant"));
116   
117    /*
118    * these should all be sub-types of sequence_variant
119    */
120  1 assertTrue(so.isA("structural_variant", "sequence_variant"));
121  1 assertTrue(so.isA("feature_variant", "sequence_variant"));
122  1 assertTrue(so.isA("gene_variant", "sequence_variant"));
123  1 assertTrue(so.isA("transcript_variant", "sequence_variant"));
124  1 assertTrue(so.isA("NMD_transcript_variant", "sequence_variant"));
125  1 assertTrue(so.isA("missense_variant", "sequence_variant"));
126  1 assertTrue(so.isA("synonymous_variant", "sequence_variant"));
127  1 assertTrue(so.isA("frameshift_variant", "sequence_variant"));
128  1 assertTrue(so.isA("5_prime_UTR_variant", "sequence_variant"));
129  1 assertTrue(so.isA("3_prime_UTR_variant", "sequence_variant"));
130  1 assertTrue(so.isA("stop_gained", "sequence_variant"));
131  1 assertTrue(so.isA("stop_lost", "sequence_variant"));
132  1 assertTrue(so.isA("inframe_deletion", "sequence_variant"));
133  1 assertTrue(so.isA("inframe_insertion", "sequence_variant"));
134    }
135    }