2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.io.gff;
23 import static org.testng.AssertJUnit.assertNull;
24 import static org.testng.AssertJUnit.assertSame;
25 import static org.testng.AssertJUnit.assertTrue;
27 import jalview.gui.JvOptionPane;
29 import org.testng.annotations.BeforeClass;
30 import org.testng.annotations.Test;
32 public class GffHelperFactoryTest
35 @BeforeClass(alwaysRun = true)
36 public void setUpJvOptionPane()
38 JvOptionPane.setInteractiveMode(false);
39 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
42 @Test(groups = "Functional")
43 public void testGetHelper()
45 assertNull(GffHelperFactory.getHelper(null));
47 String tabRegex = "\\t";
50 * column 3 = 'similarity' indicates exonerate GFF alignment data
52 String gff = "submitted\taffine:local\tsimilarity\t20\t30\t99\t+\t.\t";
53 // no attributes (column 9 data):
54 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof Gff2Helper);
56 // attributes set but unhandled featureGroup - get generic handler
57 gff = "submitted\taffine:local\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
58 assertSame(GffHelperFactory.getHelper(gff.split(tabRegex)).getClass(),
61 // handled featureGroup (exonerate model) values
62 gff = "submitted\texonerate:protein2dna:local\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
63 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
65 gff = "submitted\tprotein2genome\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
66 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
68 gff = "submitted\tcoding2coding\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
69 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
71 gff = "submitted\tcoding2genome\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
72 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
74 gff = "submitted\tcdna2genome\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
75 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
77 gff = "submitted\tgenome2genome\tsimilarity\t20\t30\t99\t+\t.\tID=$1";
78 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
80 // not case-sensitive:
81 gff = "submitted\tgenome2genome\tSIMILARITY\t20\t30\t99\t+\t.\tID=$1";
82 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof ExonerateHelper);
85 * InterProScan has 'protein_match' in column 3
87 gff = "Submitted\tPANTHER\tprotein_match\t1\t1174\t0.0\t+\t.\tName=PTHR32154";
88 assertTrue(GffHelperFactory.getHelper(gff.split(tabRegex)) instanceof InterProScanHelper);
91 * nothing specific - return the generic GFF3 class if Name=Value is present in col9
93 gff = "nothing\tinteresting\there\t20\t30\t99\t+\t.\tID=1";
94 GffHelperI helper = GffHelperFactory.getHelper(gff.split(tabRegex));
95 assertSame(helper.getClass(), Gff3Helper.class);
97 // return the generic GFF2 class if "Name Value" is present in col9
98 gff = "nothing\tinteresting\there\t20\t30\t99\t+\t.\tID 1";
99 helper = GffHelperFactory.getHelper(gff.split(tabRegex));
100 assertSame(helper.getClass(), Gff2Helper.class);