1 package jalview.datamodel;
3 import static org.testng.Assert.assertEquals;
5 import jalview.util.MapList;
7 import java.util.ArrayList;
8 import java.util.HashMap;
12 import org.testng.annotations.Test;
14 public class MappedFeaturesTest
17 public void testFindProteinVariants()
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
24 SequenceI from = new Sequence("dna/10-20", "ACGTAGCTGAA");
25 SequenceI to = new Sequence("peptide", "RG");
26 MapList map = new MapList(new int[] { 11, 13, 15, 15, 18, 19 },
29 Mapping mapping = new Mapping(to, map);
33 * C>T at dna11, consequence CGT>TGT=C
34 * T>C at dna13, consequence CGT>CGC synonymous
36 List<SequenceFeature> features = new ArrayList<>();
37 SequenceFeature sf1 = new SequenceFeature("sequence_variant", "C,T",
39 sf1.setValue("alleles", "C,T");
41 SequenceFeature sf2 = new SequenceFeature("sequence_variant", "T,C", 13,
43 sf2.setValue("alleles", "T,C");
47 * missense variant in first codon
49 MappedFeatures mf = new MappedFeatures(mapping, from, 1, 'R',
51 String variant = mf.findProteinVariants(sf1);
52 assertEquals(variant, "p.Arg1Cys");
55 * more than one alternative allele
56 * C>G consequence is GGT=G
57 * peptide variants as a comma-separated list
59 sf1.setValue("alleles", "C,T,G");
60 variant = mf.findProteinVariants(sf1);
61 assertEquals(variant, "p.Arg1Cys,p.Arg1Gly");
64 * synonymous variant in first codon
65 * shown in HGVS notation on peptide
67 variant = mf.findProteinVariants(sf2);
68 assertEquals(variant, "c.13T>C(p.=)");
71 * CSQ:HGVSp value is used if present
73 Map<String, String> csq = new HashMap<>();
74 csq.put("HGVSp", "hello:world");
75 sf2.setValue("CSQ", csq);
76 variant = mf.findProteinVariants(sf2);
77 assertEquals(variant, "world");
80 * missense and indel variants in second codon
81 * - codon is GGA spliced from dna positions 15,18,19
82 * - SNP G>T in second position mutates GGA>G to GTA>V
83 * - indel variants are not computed or reported
85 mf = new MappedFeatures(mapping, from, 2, 'G', features);
87 SequenceFeature sf3 = new SequenceFeature("sequence_variant",
88 "G,-,CG,T", 18, 18, null);
89 sf3.setValue("alleles", "G,-,CG,T");
91 variant = mf.findProteinVariants(sf3);
92 assertEquals(variant, "p.Gly2Val");
95 * G>T in first position gives TGA Stop
96 * shown with HGVS notation as 'Ter'
98 SequenceFeature sf4 = new SequenceFeature("sequence_variant", "G,T", 15,
100 sf4.setValue("alleles", "G,-,CG,T");
102 variant = mf.findProteinVariants(sf4);
103 assertEquals(variant, "p.Gly2Ter");
106 * feature must be one of those in MappedFeatures
108 SequenceFeature sf9 = new SequenceFeature("sequence_variant", "G,C", 15,
110 variant = mf.findProteinVariants(sf9);
111 assertEquals(variant, "");