Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package jalview.io.gff

File InterProScanHelperTest.java

 

Code metrics

0
32
2
1
112
66
2
0.06
16
2
1

Classes

Class Line # Actions
InterProScanHelperTest 46 32 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.assertEquals;
24    import static org.testng.AssertJUnit.assertNotNull;
25    import static org.testng.AssertJUnit.assertSame;
26    import static org.testng.AssertJUnit.assertTrue;
27    import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
28   
29    import jalview.datamodel.AlignedCodonFrame;
30    import jalview.datamodel.Alignment;
31    import jalview.datamodel.AlignmentI;
32    import jalview.datamodel.Sequence;
33    import jalview.datamodel.SequenceDummy;
34    import jalview.datamodel.SequenceFeature;
35    import jalview.datamodel.SequenceI;
36    import jalview.gui.JvOptionPane;
37   
38    import java.io.IOException;
39    import java.util.ArrayList;
40    import java.util.List;
41    import java.util.Map;
42   
43    import org.testng.annotations.BeforeClass;
44    import org.testng.annotations.Test;
45   
 
46    public class InterProScanHelperTest
47    {
48   
 
49  1 toggle @BeforeClass(alwaysRun = true)
50    public void setUpJvOptionPane()
51    {
52  1 JvOptionPane.setInteractiveMode(false);
53  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
54    }
55   
56    /**
57    * Test processing one InterProScan GFF line
58    *
59    * @throws IOException
60    */
 
61  1 toggle @Test(groups = "Functional")
62    public void testProcessProteinMatch() throws IOException
63    {
64  1 InterProScanHelper testee = new InterProScanHelper();
65  1 List<SequenceI> newseqs = new ArrayList<SequenceI>();
66  1 String[] gff = "Submitted\tPfam\tprotein_match\t5\t30\t0\t+\t.\tName=PF12838;Target=Submitted 5 30;signature_desc=4Fe-4S dicluster domain;ID=match$17_5_30"
67    .split("\\t");
68  1 SequenceI seq = new Sequence("Prot1", "PQRASTGKEEDVMIWCHQN");
69  1 seq.createDatasetSequence();
70  1 AlignmentI align = new Alignment(new SequenceI[] {});
71  1 Map<String, List<String>> set = Gff3Helper.parseNameValuePairs(gff[8]);
72   
73    /*
74    * this should create a mapping from Prot1/5-30 to virtual sequence
75    * match$17_5_30 (added to newseqs) positions 1-26
76    */
77  1 testee.processProteinMatch(set, seq, gff, align, newseqs, false);
78  1 assertEquals(1, newseqs.size());
79  1 assertTrue(newseqs.get(0) instanceof SequenceDummy);
80  1 assertEquals("match$17_5_30", newseqs.get(0).getName());
81   
82  1 assertNotNull(newseqs.get(0).getSequenceFeatures());
83  1 assertEquals(1, newseqs.get(0).getSequenceFeatures().size());
84  1 SequenceFeature sf = newseqs.get(0).getSequenceFeatures().get(0);
85  1 assertEquals(1, sf.getBegin());
86  1 assertEquals(26, sf.getEnd());
87  1 assertEquals("Pfam", sf.getType());
88  1 assertEquals("4Fe-4S dicluster domain", sf.getDescription());
89  1 assertEquals("InterProScan", sf.getFeatureGroup());
90   
91  1 assertEquals(1, align.getCodonFrames().size());
92  1 AlignedCodonFrame mapping = align.getCodonFrames().iterator().next();
93   
94    /*
95    * 'dnaseqs' (map from) is here [Prot1]
96    * 'aaseqs' (map to) is here [match$17_5_30]
97    */
98    // TODO use more suitable naming in AlignedCodonFrame
99  1 assertEquals(1, mapping.getAaSeqs().length);
100  1 assertSame(seq.getDatasetSequence(), mapping.getdnaSeqs()[0]);
101  1 assertEquals(1, mapping.getdnaSeqs().length);
102  1 assertSame(newseqs.get(0), mapping.getAaSeqs()[0]);
103  1 assertEquals(1, mapping.getdnaToProt().length);
104  1 assertEquals(1, mapping.getdnaToProt()[0].getFromRanges().size());
105  1 assertArrayEquals(new int[] { 5, 30 }, mapping.getdnaToProt()[0]
106    .getFromRanges().get(0));
107  1 assertEquals(1, mapping.getdnaToProt()[0].getToRanges().size());
108  1 assertArrayEquals(new int[] { 1, 26 }, mapping.getdnaToProt()[0]
109    .getToRanges().get(0));
110    }
111   
112    }