Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.io.gff

File GffHelperFactoryTest.java

 

Code metrics

0
30
2
1
111
58
2
0.07
15
2
1

Classes

Class Line # Actions
GffHelperFactoryTest 32 30 2
1.0100%
 

Contributing tests

This file is covered by 1 test. .

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.io.gff;
22   
23    import static org.testng.AssertJUnit.assertNull;
24    import static org.testng.AssertJUnit.assertSame;
25    import static org.testng.AssertJUnit.assertTrue;
26   
27    import jalview.gui.JvOptionPane;
28   
29    import org.testng.annotations.BeforeClass;
30    import org.testng.annotations.Test;
31   
 
32    public class GffHelperFactoryTest
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  1 toggle @Test(groups = "Functional")
43    public void testGetHelper()
44    {
45  1 assertNull(GffHelperFactory.getHelper(null));
46   
47  1 String tabRegex = "\\t";
48   
49    /*
50    * column 3 = 'similarity' indicates exonerate GFF alignment data
51    */
52  1 String gff = "submitted\taffine:local\tsimilarity\t20\t30\t99\t+\t.\t";
53    // no attributes (column 9 data):
54  1 assertTrue(GffHelperFactory
55    .getHelper(gff.split(tabRegex)) instanceof Gff2Helper);
56   
57    // attributes set but unhandled featureGroup - get generic handler
58  1 gff = "submitted\taffine:local\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
59  1 assertSame(GffHelperFactory.getHelper(gff.split(tabRegex)).getClass(),
60    Gff3Helper.class);
61   
62    // handled featureGroup (exonerate model) values
63  1 gff = "submitted\texonerate:protein2dna:local\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
64  1 assertTrue(GffHelperFactory
65    .getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
66   
67  1 gff = "submitted\tprotein2genome\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
68  1 assertTrue(GffHelperFactory
69    .getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
70   
71  1 gff = "submitted\tcoding2coding\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
72  1 assertTrue(GffHelperFactory
73    .getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
74   
75  1 gff = "submitted\tcoding2genome\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
76  1 assertTrue(GffHelperFactory
77    .getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
78   
79  1 gff = "submitted\tcdna2genome\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
80  1 assertTrue(GffHelperFactory
81    .getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
82   
83  1 gff = "submitted\tgenome2genome\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
84  1 assertTrue(GffHelperFactory
85    .getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
86   
87    // not case-sensitive:
88  1 gff = "submitted\tgenome2genome\tSIMILARITY\t20\t30\t99\t+\t.\tID=$1";
89  1 assertTrue(GffHelperFactory
90    .getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
91   
92    /*
93    * InterProScan has 'protein_match' in column 3
94    */
95  1 gff = "Submitted\tPANTHER\tprotein_match\t1\t1174\t0.0\t+\t.\tName=PTHR32154";
96  1 assertTrue(GffHelperFactory
97    .getHelper(gff.split(tabRegex)) instanceof InterProScanHelper);
98   
99    /*
100    * nothing specific - return the generic GFF3 class if Name=Value is present in col9
101    */
102  1 gff = "nothing\tinteresting\there\t20\t30\t99\t+\t.\tID=1";
103  1 GffHelperI helper = GffHelperFactory.getHelper(gff.split(tabRegex));
104  1 assertSame(helper.getClass(), Gff3Helper.class);
105   
106    // return the generic GFF2 class if "Name Value" is present in col9
107  1 gff = "nothing\tinteresting\there\t20\t30\t99\t+\t.\tID 1";
108  1 helper = GffHelperFactory.getHelper(gff.split(tabRegex));
109  1 assertSame(helper.getClass(), Gff2Helper.class);
110    }
111    }