Clover icon

Coverage Report

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

File EnsemblSeqProxyTest.java

 

Code metrics

0
34
8
1
220
169
8
0.24
4.25
8
1

Classes

Class Line # Actions
EnsemblSeqProxyTest 42 34 8
0.690476269%
 

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.ensembl;
22   
23    import static org.testng.AssertJUnit.assertEquals;
24   
25    import jalview.datamodel.AlignmentI;
26    import jalview.datamodel.SequenceFeature;
27    import jalview.datamodel.SequenceI;
28    import jalview.gui.JvOptionPane;
29    import jalview.io.DataSourceType;
30    import jalview.io.FastaFile;
31    import jalview.io.gff.SequenceOntologyFactory;
32    import jalview.io.gff.SequenceOntologyLite;
33   
34    import java.lang.reflect.Method;
35   
36    import org.testng.Assert;
37    import org.testng.annotations.AfterClass;
38    import org.testng.annotations.BeforeClass;
39    import org.testng.annotations.DataProvider;
40    import org.testng.annotations.Test;
41   
 
42    public class EnsemblSeqProxyTest
43    {
44   
 
45  1 toggle @BeforeClass(alwaysRun = true)
46    public void setUpJvOptionPane()
47    {
48  1 JvOptionPane.setInteractiveMode(false);
49  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
50    }
51   
52    private static final Object[][] allSeqs = new Object[][] { {
53    new EnsemblProtein(), "CCDS5863.1",
54    ">CCDS5863.1\n"
55    + "MAALSGGGGGGAEPGQALFNGDMEPEAGAGAGAAASSAADPAIPEEVWNIKQMIKLTQEH\n"
56    + "IEALLDKFGGEHNPPSIYLEAYEEYTSKLDALQQREQQLLESLGNGTDFSVSSSASMDTV\n"
57    + "TSSSSSSLSVLPSSLSVFQNPTDVARSNPKSPQKPIVRVFLPNKQRTVVPARCGVTVRDS\n"
58    + "LKKALMMRGLIPECCAVYRIQDGEKKPIGWDTDISWLTGEELHVEVLENVPLTTHNFVRK\n"
59    + "TFFTLAFCDFCRKLLFQGFRCQTCGYKFHQRCSTEVPLMCVNYDQLDLLFVSKFFEHHPI\n"
60    + "PQEEASLAETALTSGSSPSAPASDSIGPQILTSPSPSKSIPIPQPFRPADEDHRNQFGQR\n"
61    + "DRSSSAPNVHINTIEPVNIDDLIRDQGFRGDGGSTTGLSATPPASLPGSLTNVKALQKSP\n"
62    + "GPQRERKSSSSSEDRNRMKTLGRRDSSDDWEIPDGQITVGQRIGSGSFGTVYKGKWHGDV\n"
63    + "AVKMLNVTAPTPQQLQAFKNEVGVLRKTRHVNILLFMGYSTKPQLAIVTQWCEGSSLYHH\n"
64    + "LHIIETKFEMIKLIDIARQTAQGMDYLHAKSIIHRDLKSNNIFLHEDLTVKIGDFGLATV\n"
65    + "KSRWSGSHQFEQLSGSILWMAPEVIRMQDKNPYSFQSDVYAFGIVLYELMTGQLPYSNIN\n"
66    + "NRDQIIFMVGRGYLSPDLSKVRSNCPKAMKRLMAECLKKKRDERPLFPQILASIELLARS\n"
67    + "LPKIHRSASEPSLNRAGFQTEDFSLYACASPKTPIQAGGYGAFPVH\n" },
68    { new EnsemblCdna(), "CCDS5863.1", ">CCDS5863.1\n"
69    + "ATGGCGGCGCTGAGCGGTGGCGGTGGTGGCGGCGCGGAGCCGGGCCAGGCTCTGTTCAAC\n"
70    + "GGGGACATGGAGCCCGAGGCCGGCGCCGGCGCCGGCGCCGCGGCCTCTTCGGCTGCGGAC\n"
71    + "CCTGCCATTCCGGAGGAGGTGTGGAATATCAAACAAATGATTAAGTTGACACAGGAACAT\n"
72    + "ATAGAGGCCCTATTGGACAAATTTGGTGGGGAGCATAATCCACCATCAATATATCTGGAG\n"
73    + "GCCTATGAAGAATACACCAGCAAGCTAGATGCACTCCAACAAAGAGAACAACAGTTATTG\n"
74    + "GAATCTCTGGGGAACGGAACTGATTTTTCTGTTTCTAGCTCTGCATCAATGGATACCGTT\n"
75    + "ACATCTTCTTCCTCTTCTAGCCTTTCAGTGCTACCTTCATCTCTTTCAGTTTTTCAAAAT\n"
76    + "CCCACAGATGTGGCACGGAGCAACCCCAAGTCACCACAAAAACCTATCGTTAGAGTCTTC\n"
77    + "CTGCCCAACAAACAGAGGACAGTGGTACCTGCAAGGTGTGGAGTTACAGTCCGAGACAGT\n"
78    + "CTAAAGAAAGCACTGATGATGAGAGGTCTAATCCCAGAGTGCTGTGCTGTTTACAGAATT\n"
79    + "CAGGATGGAGAGAAGAAACCAATTGGTTGGGACACTGATATTTCCTGGCTTACTGGAGAA\n"
80    + "GAATTGCATGTGGAAGTGTTGGAGAATGTTCCACTTACAACACACAACTTTGTACGAAAA\n"
81    + "ACGTTTTTCACCTTAGCATTTTGTGACTTTTGTCGAAAGCTGCTTTTCCAGGGTTTCCGC\n"
82    + "TGTCAAACATGTGGTTATAAATTTCACCAGCGTTGTAGTACAGAAGTTCCACTGATGTGT\n"
83    + "GTTAATTATGACCAACTTGATTTGCTGTTTGTCTCCAAGTTCTTTGAACACCACCCAATA\n"
84    + "CCACAGGAAGAGGCGTCCTTAGCAGAGACTGCCCTAACATCTGGATCATCCCCTTCCGCA\n"
85    + "CCCGCCTCGGACTCTATTGGGCCCCAAATTCTCACCAGTCCGTCTCCTTCAAAATCCATT\n"
86    + "CCAATTCCACAGCCCTTCCGACCAGCAGATGAAGATCATCGAAATCAATTTGGGCAACGA\n"
87    + "GACCGATCCTCATCAGCTCCCAATGTGCATATAAACACAATAGAACCTGTCAATATTGAT\n"
88    + "GACTTGATTAGAGACCAAGGATTTCGTGGTGATGGAGGATCAACCACAGGTTTGTCTGCT\n"
89    + "ACCCCCCCTGCCTCATTACCTGGCTCACTAACTAACGTGAAAGCCTTACAGAAATCTCCA\n"
90    + "GGACCTCAGCGAGAAAGGAAGTCATCTTCATCCTCAGAAGACAGGAATCGAATGAAAACA\n"
91    + "CTTGGTAGACGGGACTCGAGTGATGATTGGGAGATTCCTGATGGGCAGATTACAGTGGGA\n"
92    + "CAAAGAATTGGATCTGGATCATTTGGAACAGTCTACAAGGGAAAGTGGCATGGTGATGTG\n"
93    + "GCAGTGAAAATGTTGAATGTGACAGCACCTACACCTCAGCAGTTACAAGCCTTCAAAAAT\n"
94    + "GAAGTAGGAGTACTCAGGAAAACACGACATGTGAATATCCTACTCTTCATGGGCTATTCC\n"
95    + "ACAAAGCCACAACTGGCTATTGTTACCCAGTGGTGTGAGGGCTCCAGCTTGTATCACCAT\n"
96    + "CTCCATATCATTGAGACCAAATTTGAGATGATCAAACTTATAGATATTGCACGACAGACT\n"
97    + "GCACAGGGCATGGATTACTTACACGCCAAGTCAATCATCCACAGAGACCTCAAGAGTAAT\n"
98    + "AATATATTTCTTCATGAAGACCTCACAGTAAAAATAGGTGATTTTGGTCTAGCTACAGTG\n"
99    + "AAATCTCGATGGAGTGGGTCCCATCAGTTTGAACAGTTGTCTGGATCCATTTTGTGGATG\n"
100    + "GCACCAGAAGTCATCAGAATGCAAGATAAAAATCCATACAGCTTTCAGTCAGATGTATAT\n"
101    + "GCATTTGGAATTGTTCTGTATGAATTGATGACTGGACAGTTACCTTATTCAAACATCAAC\n"
102    + "AACAGGGACCAGATAATTTTTATGGTGGGACGAGGATACCTGTCTCCAGATCTCAGTAAG\n"
103    + "GTACGGAGTAACTGTCCAAAAGCCATGAAGAGATTAATGGCAGAGTGCCTCAAAAAGAAA\n"
104    + "AGAGATGAGAGACCACTCTTTCCCCAAATTCTCGCCTCTATTGAGCTGCTGGCCCGCTCA\n"
105    + "TTGCCAAAAATTCACCGCAGTGCATCAGAACCCTCCTTGAATCGGGCTGGTTTCCAAACA\n"
106    + "GAGGATTTTAGTCTATATGCTTGTGCTTCTCCAAAAACACCCATCCAGGCAGGGGGATAT\n"
107    + "GGTGCGTTTCCTGTCCACTGA\n" },
108    { new EnsemblProtein(), "ENSP00000288602", ">ENSP00000288602\n"
109    + "MAALSGGGGGGAEPGQALFNGDMEPEAGAGAGAAASSAADPAIPEEVWNIKQMIKLTQEH\n"
110    + "IEALLDKFGGEHNPPSIYLEAYEEYTSKLDALQQREQQLLESLGNGTDFSVSSSASMDTV\n"
111    + "TSSSSSSLSVLPSSLSVFQNPTDVARSNPKSPQKPIVRVFLPNKQRTVVPARCGVTVRDS\n"
112    + "LKKALMMRGLIPECCAVYRIQDGEKKPIGWDTDISWLTGEELHVEVLENVPLTTHNFVRK\n"
113    + "TFFTLAFCDFCRKLLFQGFRCQTCGYKFHQRCSTEVPLMCVNYDQLDLLFVSKFFEHHPI\n"
114    + "PQEEASLAETALTSGSSPSAPASDSIGPQILTSPSPSKSIPIPQPFRPADEDHRNQFGQR\n"
115    + "DRSSSAPNVHINTIEPVNIDDLIRDQGFRGDG\n"
116    // ? insertion added in ENSP00000288602.11, not in P15056
117    + "APLNQLMRCLRKYQSRTPSPLLHSVPSEIVFDFEPGPVFR\n"
118    // end insertion
119    + "GSTTGLSATPPASLPGSLTNVKALQKSP\n"
120    + "GPQRERKSSSSSEDRNRMKTLGRRDSSDDWEIPDGQITVGQRIGSGSFGTVYKGKWHGDV\n"
121    + "AVKMLNVTAPTPQQLQAFKNEVGVLRKTRHVNILLFMGYSTKPQLAIVTQWCEGSSLYHH\n"
122    + "LHIIETKFEMIKLIDIARQTAQGMDYLHAKSIIHRDLKSNNIFLHEDLTVKIGDFGLATV\n"
123    + "KSRWSGSHQFEQLSGSILWMAPEVIRMQDKNPYSFQSDVYAFGIVLYELMTGQLPYSNIN\n"
124    + "NRDQIIFMVGRGYLSPDLSKVRSNCPKAMKRLMAECLKKKRDERPLFPQILASIELLARS\n"
125    + "LPKIHRSASEPSLNRAGFQTEDFSLYACASPKTPIQAGGYGAFPVH" } };
126   
 
127  1 toggle @BeforeClass(alwaysRun = true)
128    public void setUp()
129    {
130  1 SequenceOntologyFactory.setInstance(new SequenceOntologyLite());
131    }
132   
 
133  1 toggle @AfterClass(alwaysRun = true)
134    public void tearDown()
135    {
136  1 SequenceOntologyFactory.setInstance(null);
137    }
138   
 
139  0 toggle @DataProvider(name = "ens_seqs")
140    public Object[][] createData(Method m)
141    {
142  0 System.out.println(m.getName());
143  0 return allSeqs;
144    }
145   
 
146  0 toggle @Test(dataProvider = "ens_seqs", suiteName = "live")
147    public void testGetSequenceRecords(EnsemblSeqProxy proxy, String sq,
148    String fastasq) throws Exception
149    {
150  0 FastaFile trueRes = new FastaFile(fastasq, DataSourceType.PASTE);
151  0 SequenceI[] expected = trueRes.getSeqsAsArray();
152  0 AlignmentI retrieved = proxy.getSequenceRecords(sq);
153   
154  0 Assert.assertEquals(retrieved.getHeight(), expected.length,
155    "Different number of sequences retrieved for query " + sq);
156   
157  0 for (SequenceI tr : expected)
158    {
159  0 SequenceI[] rseq;
160  0 Assert.assertNotNull(rseq = retrieved.findSequenceMatch(tr.getName()),
161    "Couldn't find sequences matching expected sequence "
162    + tr.getName());
163  0 Assert.assertEquals(rseq.length, 1,
164    "Expected only one sequence for sequence ID " + tr.getName());
165  0 Assert.assertEquals(rseq[0].getSequenceAsString(),
166    tr.getSequenceAsString(),
167    "Sequences differ for " + tr.getName() + "\n" + "Exp:"
168    + tr.getSequenceAsString() + "\n" + "Got:"
169    + rseq[0].getSequenceAsString());
170    }
171    }
172   
 
173  1 toggle @Test(groups = "Functional")
174    public void getGenomicRangesFromFeatures()
175    {
176   
177    }
178   
179    /**
180    * Test the method that appends a single allele's reverse complement to a
181    * string buffer
182    */
 
183  1 toggle @Test(groups = "Functional")
184    public void testReverseComplementAllele()
185    {
186  1 StringBuilder sb = new StringBuilder();
187  1 EnsemblSeqProxy.reverseComplementAllele(sb, "G"); // comp=C
188  1 EnsemblSeqProxy.reverseComplementAllele(sb, "g"); // comp=c
189  1 EnsemblSeqProxy.reverseComplementAllele(sb, "C"); // comp=G
190  1 EnsemblSeqProxy.reverseComplementAllele(sb, "T"); // comp=A
191  1 EnsemblSeqProxy.reverseComplementAllele(sb, "A"); // comp=T
192  1 assertEquals("C,c,G,A,T", sb.toString());
193   
194  1 sb = new StringBuilder();
195  1 EnsemblSeqProxy.reverseComplementAllele(sb, "-GATt"); // revcomp=aATC-
196  1 EnsemblSeqProxy.reverseComplementAllele(sb, "hgmd_mutation");
197  1 EnsemblSeqProxy.reverseComplementAllele(sb, "PhenCode_variation");
198  1 assertEquals("aATC-,hgmd_mutation,PhenCode_variation", sb.toString());
199    }
200   
201    /**
202    * Test the method that computes the reverse complement of the alleles in a
203    * sequence_variant feature
204    */
 
205  1 toggle @Test(groups = "Functional")
206    public void testReverseComplementAlleles()
207    {
208  1 String alleles = "C,G,-TAC,HGMD_MUTATION,gac";
209  1 SequenceFeature sf = new SequenceFeature("sequence_variant", alleles, 1,
210    2, 0f, null);
211  1 sf.setValue("alleles", alleles);
212   
213  1 EnsemblSeqProxy.reverseComplementAlleles(sf);
214  1 String revcomp = "G,C,GTA-,HGMD_MUTATION,gtc";
215    // verify description is updated with reverse complement
216  1 assertEquals(revcomp, sf.getDescription());
217    // verify alleles attribute is updated with reverse complement
218  1 assertEquals(revcomp, sf.getValue("alleles"));
219    }
220    }