Clover icon

Coverage Report

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

File MappedFeaturesTest.java

 

Code metrics

0
45
1
1
120
68
1
0.02
45
1
1

Classes

Class Line # Actions
MappedFeaturesTest 14 45 1
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

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