Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:56:54 GMT
  2. Package jalview.datamodel

File MappedFeaturesTest.java

 

Code metrics

0
45
1
1
139
67
1
0.02
45
1
1

Classes

Class Line # Actions
MappedFeaturesTest 34 45 1
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.datamodel;
22   
23    import static org.testng.Assert.assertEquals;
24   
25    import jalview.util.MapList;
26   
27    import java.util.ArrayList;
28    import java.util.HashMap;
29    import java.util.List;
30    import java.util.Map;
31   
32    import org.testng.annotations.Test;
33   
 
34    public class MappedFeaturesTest
35    {
 
36  1 toggle @Test(groups = "Functional")
37    public void testFindProteinVariants()
38    {
39    /*
40    * scenario:
41    * dna/10-20 aCGTaGctGAa (codons CGT=R, GGA = G)
42    * mapping: 3:1 from [11-13,15,18-19] to peptide/1-2 RG
43    */
44  1 SequenceI from = new Sequence("dna/10-20", "acgTAGCTGAA");
45  1 SequenceI to = new Sequence("peptide", "RG");
46  1 MapList map = new MapList(new int[] { 11, 13, 15, 15, 18, 19 },
47    new int[]
48    { 1, 2 }, 3, 1);
49  1 Mapping mapping = new Mapping(to, map);
50   
51    /*
52    * variants
53    * C>T at dna11, consequence CGT>TGT=C
54    * T>C at dna13, consequence CGT>CGC synonymous
55    */
56  1 List<SequenceFeature> features = new ArrayList<>();
57  1 SequenceFeature sf1 = new SequenceFeature("sequence_variant", "C,T", 11,
58    11, null);
59  1 sf1.setValue("alleles", "C,T");
60  1 features.add(sf1);
61  1 SequenceFeature sf2 = new SequenceFeature("sequence_variant", "T,C", 13,
62    13, null);
63  1 sf2.setValue("alleles", "T,C");
64  1 features.add(sf2);
65   
66    /*
67    * missense variant in first codon
68    */
69  1 MappedFeatures mf = new MappedFeatures(mapping, from, 1, 'R', features);
70  1 String variant = mf.findProteinVariants(sf1);
71  1 assertEquals(variant, "p.Arg1Cys");
72   
73    /*
74    * more than one alternative allele
75    * C>G consequence is GGT=G
76    * peptide variants as a comma-separated list
77    */
78  1 sf1.setValue("alleles", "C,T,G");
79  1 variant = mf.findProteinVariants(sf1);
80  1 assertEquals(variant, "p.Arg1Cys,p.Arg1Gly");
81   
82    /*
83    * synonymous variant in first codon
84    * shown in HGVS notation on peptide
85    */
86  1 variant = mf.findProteinVariants(sf2);
87  1 assertEquals(variant, "c.13T>C(p.=)");
88   
89    /*
90    * CSQ:HGVSp value is used if present
91    * _and_ it contains "p." following a colon
92    */
93  1 Map<String, String> csq = new HashMap<>();
94  1 csq.put("HGVSp", "hello:world");
95  1 sf2.setValue("CSQ", csq);
96  1 variant = mf.findProteinVariants(sf2);
97  1 assertEquals(variant, "c.13T>C(p.=)");
98  1 csq.put("HGVSp", "p.HelloWorld");
99  1 variant = mf.findProteinVariants(sf2);
100  1 assertEquals(variant, "c.13T>C(p.=)");
101  1 csq.put("HGVSp", "try this:hellop.world");
102  1 variant = mf.findProteinVariants(sf2);
103  1 assertEquals(variant, "hellop.world");
104   
105    /*
106    * missense and indel variants in second codon
107    * - codon is GGA spliced from dna positions 15,18,19
108    * - SNP G>T in second position mutates GGA>G to GTA>V
109    * - indel variants are not computed or reported
110    */
111  1 mf = new MappedFeatures(mapping, from, 2, 'G', features);
112  1 features.clear();
113  1 SequenceFeature sf3 = new SequenceFeature("sequence_variant",
114    "G,-,CG,T", 18, 18, null);
115  1 sf3.setValue("alleles", "G,-,CG,T");
116  1 features.add(sf3);
117  1 variant = mf.findProteinVariants(sf3);
118  1 assertEquals(variant, "p.Gly2Val");
119   
120    /*
121    * G>T in first position gives TGA Stop
122    * shown with HGVS notation as 'Ter'
123    */
124  1 SequenceFeature sf4 = new SequenceFeature("sequence_variant", "G,T", 15,
125    15, null);
126  1 sf4.setValue("alleles", "G,-,CG,T");
127  1 features.add(sf4);
128  1 variant = mf.findProteinVariants(sf4);
129  1 assertEquals(variant, "p.Gly2Ter");
130   
131    /*
132    * feature must be one of those in MappedFeatures
133    */
134  1 SequenceFeature sf9 = new SequenceFeature("sequence_variant", "G,C", 15,
135    15, null);
136  1 variant = mf.findProteinVariants(sf9);
137  1 assertEquals(variant, "");
138    }
139    }