JAL-1793 spike branch updated to latest
[jalview.git] / test / jalview / io / vcf / VCFLoaderTest.java
1 package jalview.io.vcf;
2
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertTrue;
5
6 import jalview.datamodel.AlignmentI;
7 import jalview.datamodel.DBRefEntry;
8 import jalview.datamodel.Mapping;
9 import jalview.datamodel.Sequence;
10 import jalview.datamodel.SequenceFeature;
11 import jalview.datamodel.SequenceI;
12 import jalview.datamodel.features.SequenceFeatures;
13 import jalview.gui.AlignFrame;
14 import jalview.io.DataSourceType;
15 import jalview.io.FileLoader;
16 import jalview.io.gff.Gff3Helper;
17 import jalview.io.gff.SequenceOntologyI;
18 import jalview.util.MapList;
19
20 import java.io.File;
21 import java.io.IOException;
22 import java.io.PrintWriter;
23 import java.util.List;
24
25 import org.testng.annotations.Test;
26
27 public class VCFLoaderTest
28 {
29   private static final float DELTA = 0.00001f;
30
31   // columns 9717- of gene P30419 from Ensembl (much modified)
32   private static final String FASTA = ""
33           +
34           /*
35            * forward strand 'gene' and 'transcript' with two exons
36            */
37           ">gene1/1-25 chromosome:GRCh38:17:45051610:45051634:1\n"
38           + "CAAGCTGGCGGACGAGAGTGTGACA\n"
39           + ">transcript1/1-18\n--AGCTGGCG----AGAGTGTGAC-\n"
40
41           /*
42            * reverse strand gene and transcript (reverse complement alleles!)
43            */
44           + ">gene2/1-25 chromosome:GRCh38:17:45051610:45051634:-1\n"
45           + "TGTCACACTCTCGTCCGCCAGCTTG\n"
46           + ">transcript2/1-18\n" + "-GTCACACTCT----CGCCAGCT--\n"
47
48           /*
49            * 'gene' on chromosome 5 with two transcripts
50            */
51           + ">gene3/1-25 chromosome:GRCh38:5:45051610:45051634:1\n"
52           + "CAAGCTGGCGGACGAGAGTGTGACA\n"
53           + ">transcript3/1-18\n--AGCTGGCG----AGAGTGTGAC-\n"
54           + ">transcript4/1-18\n-----TGG-GGACGAGAGTGTGA-A\n";
55
56   private static final String[] VCF = { "##fileformat=VCFv4.2",
57       "##INFO=<ID=AF,Number=A,Type=Float,Description=\"Allele Frequency, for each ALT allele, in the same order as listed\">",
58       "##reference=Homo_sapiens/GRCh38",
59       "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO",
60       // A/T,C variants in position 2 of gene sequence (precedes transcript)
61       // should create 2 variant features with respective scores
62       "17\t45051611\t.\tA\tT,C\t1666.64\tRF\tAC=15;AF=5.0e-03,4.0e-03",
63       // SNP G/C in position 4 of gene sequence, position 2 of transcript
64       // insertion G/GA is transferred to nucleotide but not to peptide
65       "17\t45051613\t.\tG\tGA,C\t1666.64\tRF\tAC=15;AF=3.0e-03,2.0e-03" };
66
67   @Test(groups = "Functional")
68   public void testDoLoad() throws IOException
69   {
70     AlignmentI al = buildAlignment();
71     VCFLoader loader = new VCFLoader(al);
72
73     File f = makeVcf();
74
75     loader.doLoad(f.getPath(), null);
76
77     /*
78      * verify variant feature(s) added to gene
79      * NB alleles at a locus may not be processed, and features added,
80      * in the order in which they appear in the VCF record as method
81      * VariantContext.getAlternateAlleles() does not guarantee order
82      * - order of assertions here matches what we find (is not important) 
83      */
84     List<SequenceFeature> geneFeatures = al.getSequenceAt(0)
85             .getSequenceFeatures();
86     SequenceFeatures.sortFeatures(geneFeatures, true);
87     assertEquals(geneFeatures.size(), 4);
88     SequenceFeature sf = geneFeatures.get(0);
89     assertEquals(sf.getFeatureGroup(), "VCF");
90     assertEquals(sf.getBegin(), 2);
91     assertEquals(sf.getEnd(), 2);
92     assertEquals(sf.getScore(), 4.0e-03, DELTA);
93     assertEquals(sf.getValue(Gff3Helper.ALLELES), "A,C");
94     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
95     sf = geneFeatures.get(1);
96     assertEquals(sf.getFeatureGroup(), "VCF");
97     assertEquals(sf.getBegin(), 2);
98     assertEquals(sf.getEnd(), 2);
99     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
100     assertEquals(sf.getScore(), 5.0e-03, DELTA);
101     assertEquals(sf.getValue(Gff3Helper.ALLELES), "A,T");
102
103     sf = geneFeatures.get(2);
104     assertEquals(sf.getFeatureGroup(), "VCF");
105     assertEquals(sf.getBegin(), 4);
106     assertEquals(sf.getEnd(), 4);
107     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
108     assertEquals(sf.getScore(), 2.0e-03, DELTA);
109     assertEquals(sf.getValue(Gff3Helper.ALLELES), "G,C");
110
111     sf = geneFeatures.get(3);
112     assertEquals(sf.getFeatureGroup(), "VCF");
113     assertEquals(sf.getBegin(), 4);
114     assertEquals(sf.getEnd(), 4);
115     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
116     assertEquals(sf.getScore(), 3.0e-03, DELTA);
117     assertEquals(sf.getValue(Gff3Helper.ALLELES), "G,GA");
118
119     /*
120      * verify variant feature(s) added to transcript
121      */
122     List<SequenceFeature> transcriptFeatures = al.getSequenceAt(1)
123             .getSequenceFeatures();
124     assertEquals(transcriptFeatures.size(), 2);
125     sf = transcriptFeatures.get(0);
126     assertEquals(sf.getFeatureGroup(), "VCF");
127     assertEquals(sf.getBegin(), 2);
128     assertEquals(sf.getEnd(), 2);
129     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
130     assertEquals(sf.getScore(), 2.0e-03, DELTA);
131     assertEquals(sf.getValue(Gff3Helper.ALLELES), "G,C");
132     sf = transcriptFeatures.get(1);
133     assertEquals(sf.getFeatureGroup(), "VCF");
134     assertEquals(sf.getBegin(), 2);
135     assertEquals(sf.getEnd(), 2);
136     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
137     assertEquals(sf.getScore(), 3.0e-03, DELTA);
138     assertEquals(sf.getValue(Gff3Helper.ALLELES), "G,GA");
139
140     /*
141      * verify SNP variant feature(s) computed and added to protein
142      * first codon AGC varies to ACC giving S/T
143      */
144     DBRefEntry[] dbRefs = al.getSequenceAt(1).getDBRefs();
145     SequenceI peptide = null;
146     for (DBRefEntry dbref : dbRefs)
147     {
148       if (dbref.getMap().getMap().getFromRatio() == 3)
149       {
150         peptide = dbref.getMap().getTo();
151       }
152     }
153     List<SequenceFeature> proteinFeatures = peptide.getSequenceFeatures();
154     assertEquals(proteinFeatures.size(), 1);
155     sf = proteinFeatures.get(0);
156     assertEquals(sf.getFeatureGroup(), "VCF");
157     assertEquals(sf.getBegin(), 1);
158     assertEquals(sf.getEnd(), 1);
159     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
160     assertEquals(sf.getDescription(), "p.Ser1Thr");
161   }
162
163   private File makeVcf() throws IOException
164   {
165     File f = File.createTempFile("Test", ".vcf");
166     f.deleteOnExit();
167     PrintWriter pw = new PrintWriter(f);
168     for (String vcfLine : VCF)
169     {
170       pw.println(vcfLine);
171     }
172     pw.close();
173     return f;
174   }
175
176   /**
177    * Make a simple alignment with one 'gene' and one 'transcript'
178    * 
179    * @return
180    */
181   private AlignmentI buildAlignment()
182   {
183     AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(FASTA,
184             DataSourceType.PASTE);
185
186     /*
187      * map gene1 sequence to chromosome (normally done when the sequence is fetched
188      * from Ensembl and transcripts computed)
189      */
190     AlignmentI alignment = af.getViewport().getAlignment();
191     SequenceI gene1 = alignment.findName("gene1");
192     int[] to = new int[] { 45051610, 45051634 };
193     int[] from = new int[] { gene1.getStart(), gene1.getEnd() };
194     gene1.setGeneLoci("homo_sapiens", "GRCh38", "17", new MapList(from, to,
195             1, 1));
196
197     /*
198      * map 'transcript1' to chromosome via 'gene1'
199      * transcript1/1-18 is gene1/3-10,15-24
200      * which is chromosome 45051612-45051619,45051624-45051633
201      */
202     to = new int[] { 45051612, 45051619, 45051624, 45051633 };
203     SequenceI transcript1 = alignment.findName("transcript1");
204     from = new int[] { transcript1.getStart(), transcript1.getEnd() };
205     transcript1.setGeneLoci("homo_sapiens", "GRCh38", "17", new MapList(
206             from, to,
207             1, 1));
208
209     /*
210      * map gene2 to chromosome reverse strand
211      */
212     SequenceI gene2 = alignment.findName("gene2");
213     to = new int[] { 45051634, 45051610 };
214     from = new int[] { gene2.getStart(), gene2.getEnd() };
215     gene2.setGeneLoci("homo_sapiens", "GRCh38", "17", new MapList(from, to,
216             1, 1));
217
218     /*
219      * map 'transcript2' to chromosome via 'gene2'
220      * transcript2/1-18 is gene2/2-11,16-23
221      * which is chromosome 45051633-45051624,45051619-45051612
222      */
223     to = new int[] { 45051633, 45051624, 45051619, 45051612 };
224     SequenceI transcript2 = alignment.findName("transcript2");
225     from = new int[] { transcript2.getStart(), transcript2.getEnd() };
226     transcript2.setGeneLoci("homo_sapiens", "GRCh38", "17", new MapList(
227             from, to,
228             1, 1));
229
230     /*
231      * add a protein product as a DBRef on transcript1
232      */
233     SequenceI peptide1 = new Sequence("ENSP001", "SWRECD");
234     MapList mapList = new MapList(new int[] { 1, 18 }, new int[] { 1, 6 },
235             3, 1);
236     Mapping map = new Mapping(peptide1, mapList);
237     DBRefEntry product = new DBRefEntry("", "", "ENSP001", map);
238     transcript1.addDBRef(product);
239
240     /*
241      * add a protein product as a DBRef on transcript2
242      */
243     SequenceI peptide2 = new Sequence("ENSP002", "VTLSPA");
244     mapList = new MapList(new int[] { 1, 18 }, new int[] { 1, 6 }, 3, 1);
245     map = new Mapping(peptide2, mapList);
246     product = new DBRefEntry("", "", "ENSP002", map);
247     transcript2.addDBRef(product);
248
249     /*
250      * map gene3 to chromosome 
251      */
252     SequenceI gene3 = alignment.findName("gene3");
253     to = new int[] { 45051610, 45051634 };
254     from = new int[] { gene3.getStart(), gene3.getEnd() };
255     gene3.setGeneLoci("homo_sapiens", "GRCh38", "5", new MapList(from, to,
256             1, 1));
257
258     /*
259      * map 'transcript3' to chromosome
260      */
261     SequenceI transcript3 = alignment.findName("transcript3");
262     to = new int[] { 45051612, 45051619, 45051624, 45051633 };
263     from = new int[] { transcript3.getStart(), transcript3.getEnd() };
264     transcript3.setGeneLoci("homo_sapiens", "GRCh38", "5", new MapList(
265             from, to,
266             1, 1));
267
268     /*
269      * map 'transcript4' to chromosome
270      */
271     SequenceI transcript4 = alignment.findName("transcript4");
272     to = new int[] { 45051615, 45051617, 45051619, 45051632, 45051634,
273         45051634 };
274     from = new int[] { transcript4.getStart(), transcript4.getEnd() };
275     transcript4.setGeneLoci("homo_sapiens", "GRCh38", "5", new MapList(
276             from, to,
277             1, 1));
278
279     /*
280      * add a protein product as a DBRef on transcript3
281      */
282     SequenceI peptide3 = new Sequence("ENSP003", "SWRECD");
283     mapList = new MapList(new int[] { 1, 18 }, new int[] { 1, 6 }, 3, 1);
284     map = new Mapping(peptide3, mapList);
285     product = new DBRefEntry("", "", "ENSP003", map);
286     transcript3.addDBRef(product);
287
288     return alignment;
289   }
290
291   /**
292    * Test with 'gene' and 'transcript' mapped to the reverse strand of the
293    * chromosome. The VCF variant positions (in forward coordinates) should get
294    * correctly located on sequence positions.
295    * 
296    * @throws IOException
297    */
298   @Test(groups = "Functional")
299   public void testDoLoad_reverseStrand() throws IOException
300   {
301     AlignmentI al = buildAlignment();
302
303     VCFLoader loader = new VCFLoader(al);
304
305     File f = makeVcf();
306
307     loader.doLoad(f.getPath(), null);
308
309     /*
310      * verify variant feature(s) added to gene2
311      * gene/1-25 maps to chromosome 45051634- reverse strand
312      * variants A/T, A/C at 45051611 and G/GA,G/C at 45051613 map to
313      * T/A, T/G and C/TC,C/G at gene positions 24 and 22 respectively
314      */
315     List<SequenceFeature> geneFeatures = al.getSequenceAt(2)
316             .getSequenceFeatures();
317     SequenceFeatures.sortFeatures(geneFeatures, true);
318     assertEquals(geneFeatures.size(), 4);
319     SequenceFeature sf = geneFeatures.get(0);
320     assertEquals(sf.getFeatureGroup(), "VCF");
321     assertEquals(sf.getBegin(), 22);
322     assertEquals(sf.getEnd(), 22);
323     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
324     assertEquals(sf.getScore(), 2.0e-03, DELTA);
325     assertEquals("C,G", sf.getValue(Gff3Helper.ALLELES));
326
327     sf = geneFeatures.get(1);
328     assertEquals(sf.getFeatureGroup(), "VCF");
329     assertEquals(sf.getBegin(), 22);
330     assertEquals(sf.getEnd(), 22);
331     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
332     assertEquals(sf.getScore(), 3.0e-03, DELTA);
333     assertEquals("C,TC", sf.getValue(Gff3Helper.ALLELES));
334
335     sf = geneFeatures.get(2);
336     assertEquals(sf.getFeatureGroup(), "VCF");
337     assertEquals(sf.getBegin(), 24);
338     assertEquals(sf.getEnd(), 24);
339     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
340     assertEquals(sf.getScore(), 4.0e-03, DELTA);
341     assertEquals("T,G", sf.getValue(Gff3Helper.ALLELES));
342
343     sf = geneFeatures.get(3);
344     assertEquals(sf.getFeatureGroup(), "VCF");
345     assertEquals(sf.getBegin(), 24);
346     assertEquals(sf.getEnd(), 24);
347     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
348     assertEquals(sf.getScore(), 5.0e-03, DELTA);
349     assertEquals("T,A", sf.getValue(Gff3Helper.ALLELES));
350
351     /*
352      * verify variant feature(s) added to transcript2
353      * variants G/GA,G/C at position 22 of gene overlap and map to
354      * C/TC,C/G at position 17 of transcript
355      */
356     List<SequenceFeature> transcriptFeatures = al.getSequenceAt(3)
357             .getSequenceFeatures();
358     assertEquals(transcriptFeatures.size(), 2);
359     sf = transcriptFeatures.get(0);
360     assertEquals(sf.getFeatureGroup(), "VCF");
361     assertEquals(sf.getBegin(), 17);
362     assertEquals(sf.getEnd(), 17);
363     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
364     assertEquals(sf.getScore(), 2.0e-03, DELTA);
365     assertEquals("C,G", sf.getValue(Gff3Helper.ALLELES));
366
367     sf = transcriptFeatures.get(1);
368     assertEquals(sf.getFeatureGroup(), "VCF");
369     assertEquals(sf.getBegin(), 17);
370     assertEquals(sf.getEnd(), 17);
371     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
372     assertEquals(sf.getScore(), 3.0e-03, DELTA);
373     assertEquals("C,TC", sf.getValue(Gff3Helper.ALLELES));
374
375     /*
376      * verify variant feature(s) computed and added to protein
377      * last codon GCT varies to GGT giving A/G in the last peptide position
378      */
379     DBRefEntry[] dbRefs = al.getSequenceAt(3).getDBRefs();
380     SequenceI peptide = null;
381     for (DBRefEntry dbref : dbRefs)
382     {
383       if (dbref.getMap().getMap().getFromRatio() == 3)
384       {
385         peptide = dbref.getMap().getTo();
386       }
387     }
388     List<SequenceFeature> proteinFeatures = peptide.getSequenceFeatures();
389     assertEquals(proteinFeatures.size(), 1);
390     sf = proteinFeatures.get(0);
391     assertEquals(sf.getFeatureGroup(), "VCF");
392     assertEquals(sf.getBegin(), 6);
393     assertEquals(sf.getEnd(), 6);
394     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
395     assertEquals(sf.getDescription(), "p.Ala6Gly");
396   }
397
398   /**
399    * Tests that if VEP consequence (CSQ) data is present in the VCF data, then
400    * it is added to the variant feature, but restricted where possible to the
401    * consequences for a specific transcript
402    * 
403    * @throws IOException
404    */
405   @Test(groups = "Functional")
406   public void testDoLoad_vepCsq() throws IOException
407   {
408     AlignmentI al = buildAlignment();
409
410     VCFLoader loader = new VCFLoader(al);
411
412     /*
413      * VCF data file with variants at gene3 positions
414      * 1 C/A
415      * 5 C/T
416      * 9 CGT/C (deletion)
417      * 13 C/G, C/T
418      * 17 A/AC (insertion), A/G
419      */
420     loader.doLoad("test/jalview/io/vcf/testVcf.dat", null);
421
422     /*
423      * verify variant feature(s) added to gene3
424      */
425     List<SequenceFeature> geneFeatures = al.findName("gene3")
426             .getSequenceFeatures();
427     SequenceFeatures.sortFeatures(geneFeatures, true);
428     assertEquals(geneFeatures.size(), 7);
429     SequenceFeature sf = geneFeatures.get(0);
430     assertEquals(sf.getBegin(), 1);
431     assertEquals(sf.getEnd(), 1);
432     assertEquals(sf.getScore(), 0.1f, DELTA);
433     assertEquals(sf.getValue("alleles"), "C,A");
434     // gene features include Consequence for all transcripts
435     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2);
436
437     sf = geneFeatures.get(1);
438     assertEquals(sf.getBegin(), 5);
439     assertEquals(sf.getEnd(), 5);
440     assertEquals(sf.getScore(), 0.2f, DELTA);
441     assertEquals(sf.getValue("alleles"), "C,T");
442     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2);
443
444     sf = geneFeatures.get(2);
445     assertEquals(sf.getBegin(), 9);
446     assertEquals(sf.getEnd(), 11); // deletion over 3 positions
447     assertEquals(sf.getScore(), 0.3f, DELTA);
448     assertEquals(sf.getValue("alleles"), "CGG,C");
449     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2);
450
451     sf = geneFeatures.get(3);
452     assertEquals(sf.getBegin(), 13);
453     assertEquals(sf.getEnd(), 13);
454     assertEquals(sf.getScore(), 0.5f, DELTA);
455     assertEquals(sf.getValue("alleles"), "C,T");
456     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2);
457
458     sf = geneFeatures.get(4);
459     assertEquals(sf.getBegin(), 13);
460     assertEquals(sf.getEnd(), 13);
461     assertEquals(sf.getScore(), 0.4f, DELTA);
462     assertEquals(sf.getValue("alleles"), "C,G");
463     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2);
464
465     sf = geneFeatures.get(5);
466     assertEquals(sf.getBegin(), 17);
467     assertEquals(sf.getEnd(), 17);
468     assertEquals(sf.getScore(), 0.7f, DELTA);
469     assertEquals(sf.getValue("alleles"), "A,G");
470     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2);
471
472     sf = geneFeatures.get(6);
473     assertEquals(sf.getBegin(), 17);
474     assertEquals(sf.getEnd(), 17); // insertion
475     assertEquals(sf.getScore(), 0.6f, DELTA);
476     assertEquals(sf.getValue("alleles"), "A,AC");
477     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2);
478
479     /*
480      * verify variant feature(s) added to transcript3
481      * at columns 5 (1), 17 (2), positions 3, 11
482      * note the deletion at columns 9-11 is not transferred since col 11
483      * has no mapping to transcript 3 
484      */
485     List<SequenceFeature> transcriptFeatures = al.findName("transcript3")
486             .getSequenceFeatures();
487     SequenceFeatures.sortFeatures(transcriptFeatures, true);
488     assertEquals(transcriptFeatures.size(), 3);
489     sf = transcriptFeatures.get(0);
490     assertEquals(sf.getBegin(), 3);
491     assertEquals(sf.getEnd(), 3);
492     assertEquals(sf.getScore(), 0.2f, DELTA);
493     assertEquals(sf.getValue("alleles"), "C,T");
494     // transcript features only have Consequence for that transcripts
495     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1);
496     assertTrue(sf.getValue("CSQ").toString().contains("transcript3"));
497
498     sf = transcriptFeatures.get(1);
499     assertEquals(sf.getBegin(), 11);
500     assertEquals(sf.getEnd(), 11);
501     assertEquals(sf.getScore(), 0.7f, DELTA);
502     assertEquals(sf.getValue("alleles"), "A,G");
503     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1);
504     assertTrue(sf.getValue("CSQ").toString().contains("transcript3"));
505
506     sf = transcriptFeatures.get(2);
507     assertEquals(sf.getBegin(), 11);
508     assertEquals(sf.getEnd(), 11);
509     assertEquals(sf.getScore(), 0.6f, DELTA);
510     assertEquals(sf.getValue("alleles"), "A,AC");
511     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1);
512     assertTrue(sf.getValue("CSQ").toString().contains("transcript3"));
513
514     /*
515      * verify variants computed on protein product for transcript3
516      * peptide is SWRECD
517      * codon variants are AGC/AGT position 1 which is synonymous
518      * and GAG/GGG which is E/G in position 4
519      * the insertion variant is not transferred to the peptide
520      */
521     DBRefEntry[] dbRefs = al.findName("transcript3").getDBRefs();
522     SequenceI peptide = null;
523     for (DBRefEntry dbref : dbRefs)
524     {
525       if (dbref.getMap().getMap().getFromRatio() == 3)
526       {
527         peptide = dbref.getMap().getTo();
528       }
529     }
530     List<SequenceFeature> proteinFeatures = peptide.getSequenceFeatures();
531     assertEquals(proteinFeatures.size(), 1);
532     sf = proteinFeatures.get(0);
533     assertEquals(sf.getFeatureGroup(), "VCF");
534     assertEquals(sf.getBegin(), 4);
535     assertEquals(sf.getEnd(), 4);
536     assertEquals(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT);
537     assertEquals(sf.getDescription(), "p.Glu4Gly");
538
539     /*
540      * verify variant feature(s) added to transcript4
541      * at columns 13 (2) and 17 (2), positions 7 and 11
542      */
543     transcriptFeatures = al.findName("transcript4").getSequenceFeatures();
544     SequenceFeatures.sortFeatures(transcriptFeatures, true);
545     assertEquals(transcriptFeatures.size(), 4);
546     sf = transcriptFeatures.get(0);
547     assertEquals(sf.getBegin(), 7);
548     assertEquals(sf.getEnd(), 7);
549     assertEquals(sf.getScore(), 0.5f, DELTA);
550     assertEquals(sf.getValue("alleles"), "C,T");
551     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1);
552     assertTrue(sf.getValue("CSQ").toString().contains("transcript4"));
553
554     sf = transcriptFeatures.get(1);
555     assertEquals(sf.getBegin(), 7);
556     assertEquals(sf.getEnd(), 7);
557     assertEquals(sf.getScore(), 0.4f, DELTA);
558     assertEquals(sf.getValue("alleles"), "C,G");
559     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1);
560     assertTrue(sf.getValue("CSQ").toString().contains("transcript4"));
561
562     sf = transcriptFeatures.get(2);
563     assertEquals(sf.getBegin(), 11);
564     assertEquals(sf.getEnd(), 11);
565     assertEquals(sf.getScore(), 0.7f, DELTA);
566     assertEquals(sf.getValue("alleles"), "A,G");
567     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1);
568     assertTrue(sf.getValue("CSQ").toString().contains("transcript4"));
569
570     sf = transcriptFeatures.get(3);
571     assertEquals(sf.getBegin(), 11);
572     assertEquals(sf.getEnd(), 11);
573     assertEquals(sf.getScore(), 0.6f, DELTA);
574     assertEquals(sf.getValue("alleles"), "A,AC");
575     assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1);
576     assertTrue(sf.getValue("CSQ").toString().contains("transcript4"));
577   }
578 }