Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package jalview.io.gff

File GffTests.java

 

Code metrics

0
27
2
1
116
60
2
0.07
13.5
2
1

Classes

Class Line # Actions
GffTests 50 27 2
0.00%
 

Contributing tests

No tests hitting this source file were found.

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.assertSame;
25    import static org.testng.AssertJUnit.assertTrue;
26    import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
27   
28    import jalview.datamodel.AlignedCodonFrame;
29    import jalview.datamodel.Alignment;
30    import jalview.datamodel.AlignmentI;
31    import jalview.datamodel.Mapping;
32    import jalview.datamodel.Sequence;
33    import jalview.datamodel.SequenceDummy;
34    import jalview.datamodel.SequenceI;
35    import jalview.gui.AlignFrame;
36    import jalview.gui.JvOptionPane;
37    import jalview.io.DataSourceType;
38    import jalview.io.FileLoader;
39   
40    import java.util.List;
41   
42    import org.testng.annotations.BeforeClass;
43    import org.testng.annotations.Test;
44   
45    /**
46    * Tests of use cases that include parsing GFF (version 2 or 3) features that
47    * describe mappings between protein and cDNA. The format of the GFF varies
48    * depending on which tool generated it.
49    */
 
50    public class GffTests
51    {
52   
 
53  0 toggle @BeforeClass(alwaysRun = true)
54    public void setUpJvOptionPane()
55    {
56  0 JvOptionPane.setInteractiveMode(false);
57  0 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
58    }
59   
60    /**
61    * Test the case where we load a protein ('query') sequence, then exonerateGff
62    * describing its mapping to cDNA, and then a DNA sequence including the
63    * mapped region
64    */
 
65  0 toggle @Test(groups = "Functional")
66    public void testResolveExonerateGff()
67    {
68  0 String proteinSeq = ">prot1/10-16\nYCWRSGA";
69  0 AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(proteinSeq,
70    DataSourceType.PASTE);
71   
72    /*
73    * exonerate GFF output mapping residues 11-15 (CWRSG)
74    * to bases 24-10 in sequence 'dna1' (reverse strand)
75    */
76  0 String exonerateGff = "##gff-version 2\n"
77    + "prot1\tprotein2genome\tsimilarity\t11\t15\t99\t-\t.\talignment_id 0 ; Target dna1 ; Align 11 24 5";
78  0 af.loadJalviewDataFile(exonerateGff, DataSourceType.PASTE, null, null);
79   
80    /*
81    * check we have a mapping from prot1 to SequenceDummy 'dna1'
82    */
83  0 AlignmentI dataset = af.getViewport().getAlignment().getDataset();
84  0 assertEquals(1, dataset.getSequences().size());
85  0 assertEquals("prot1", dataset.getSequenceAt(0).getName());
86  0 assertEquals("YCWRSGA", dataset.getSequenceAt(0).getSequenceAsString());
87  0 List<AlignedCodonFrame> mappings = dataset.getCodonFrames();
88  0 assertEquals(1, mappings.size());
89  0 AlignedCodonFrame mapping = mappings.iterator().next();
90  0 SequenceI mappedDna = mapping.getDnaForAaSeq(dataset.getSequenceAt(0));
91  0 assertTrue(mappedDna instanceof SequenceDummy);
92  0 assertEquals("dna1", mappedDna.getName());
93  0 Mapping[] mapList = mapping.getProtMappings();
94  0 assertEquals(1, mapList.length);
95    // 11 in protein should map to codon [24, 23, 22] in dna
96  0 int[] mappedRegion = mapList[0].getMap().locateInFrom(11, 11);
97  0 assertArrayEquals(new int[] { 24, 22 }, mappedRegion);
98    // 15 in protein should map to codon [12, 11, 10] in dna
99  0 mappedRegion = mapList[0].getMap().locateInFrom(15, 15);
100  0 assertArrayEquals(new int[] { 12, 10 }, mappedRegion);
101   
102  0 SequenceI dna1 = new Sequence("dna1", "AAACCCGGGTTTAAACCCGGGTTT");
103  0 AlignmentI al = new Alignment(new SequenceI[] { dna1 });
104  0 al.setDataset(null);
105   
106    /*
107    * Now 'realise' the virtual mapping to the real DNA sequence;
108    * interactively this could be by a drag or fetch of the sequence data
109    * on to the alignment
110    */
111  0 mapping.realiseWith(dna1);
112    // verify the mapping is now from the real, not the dummy sequence
113  0 assertSame(dna1.getDatasetSequence(),
114    mapping.getDnaForAaSeq(dataset.getSequenceAt(0)));
115    }
116    }