X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fio%2Fvcf%2FVCFLoaderTest.java;h=246337d6e8f9dfcf784e0e401b95ad8c649267b0;hb=0a680b4ff1aaad7580d3b10941233307e2190be4;hp=4a254d29f334dd63101e2078d783db1198ff5d5c;hpb=353109c11d706b29ae5bc9606f0e12223aa45a98;p=jalview.git diff --git a/test/jalview/io/vcf/VCFLoaderTest.java b/test/jalview/io/vcf/VCFLoaderTest.java index 4a254d2..246337d 100644 --- a/test/jalview/io/vcf/VCFLoaderTest.java +++ b/test/jalview/io/vcf/VCFLoaderTest.java @@ -1,8 +1,8 @@ package jalview.io.vcf; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import jalview.bin.Cache; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.Mapping; @@ -21,7 +21,9 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.List; +import java.util.Map; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class VCFLoaderTest @@ -55,7 +57,7 @@ public class VCFLoaderTest private static final String[] VCF = { "##fileformat=VCFv4.2", "##INFO=", - "##reference=GRCh38", + "##reference=Homo_sapiens/GRCh38", "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO", // A/T,C variants in position 2 of gene sequence (precedes transcript) // should create 2 variant features with respective scores @@ -64,6 +66,17 @@ public class VCFLoaderTest // insertion G/GA is transferred to nucleotide but not to peptide "17\t45051613\t.\tG\tGA,C\t1666.64\tRF\tAC=15;AF=3.0e-03,2.0e-03" }; + @BeforeClass + public void setUp() + { + /* + * configure to capture all available VCF and VEP (CSQ) fields + */ + Cache.loadProperties("test/jalview/io/testProps.jvprops"); + Cache.setProperty("VCF_FIELDS", ".*"); + Cache.setProperty("VEP_FIELDS", ".*"); + } + @Test(groups = "Functional") public void testDoLoad() throws IOException { @@ -191,7 +204,8 @@ public class VCFLoaderTest SequenceI gene1 = alignment.findName("gene1"); int[] to = new int[] { 45051610, 45051634 }; int[] from = new int[] { gene1.getStart(), gene1.getEnd() }; - gene1.setGeneLoci("human", "GRCh38", "17", new MapList(from, to, 1, 1)); + gene1.setGeneLoci("homo_sapiens", "GRCh38", "17", new MapList(from, to, + 1, 1)); /* * map 'transcript1' to chromosome via 'gene1' @@ -201,7 +215,8 @@ public class VCFLoaderTest to = new int[] { 45051612, 45051619, 45051624, 45051633 }; SequenceI transcript1 = alignment.findName("transcript1"); from = new int[] { transcript1.getStart(), transcript1.getEnd() }; - transcript1.setGeneLoci("human", "GRCh38", "17", new MapList(from, to, + transcript1.setGeneLoci("homo_sapiens", "GRCh38", "17", new MapList( + from, to, 1, 1)); /* @@ -210,7 +225,8 @@ public class VCFLoaderTest SequenceI gene2 = alignment.findName("gene2"); to = new int[] { 45051634, 45051610 }; from = new int[] { gene2.getStart(), gene2.getEnd() }; - gene2.setGeneLoci("human", "GRCh38", "17", new MapList(from, to, 1, 1)); + gene2.setGeneLoci("homo_sapiens", "GRCh38", "17", new MapList(from, to, + 1, 1)); /* * map 'transcript2' to chromosome via 'gene2' @@ -220,7 +236,8 @@ public class VCFLoaderTest to = new int[] { 45051633, 45051624, 45051619, 45051612 }; SequenceI transcript2 = alignment.findName("transcript2"); from = new int[] { transcript2.getStart(), transcript2.getEnd() }; - transcript2.setGeneLoci("human", "GRCh38", "17", new MapList(from, to, + transcript2.setGeneLoci("homo_sapiens", "GRCh38", "17", new MapList( + from, to, 1, 1)); /* @@ -248,7 +265,8 @@ public class VCFLoaderTest SequenceI gene3 = alignment.findName("gene3"); to = new int[] { 45051610, 45051634 }; from = new int[] { gene3.getStart(), gene3.getEnd() }; - gene3.setGeneLoci("human", "GRCh38", "5", new MapList(from, to, 1, 1)); + gene3.setGeneLoci("homo_sapiens", "GRCh38", "5", new MapList(from, to, + 1, 1)); /* * map 'transcript3' to chromosome @@ -256,7 +274,8 @@ public class VCFLoaderTest SequenceI transcript3 = alignment.findName("transcript3"); to = new int[] { 45051612, 45051619, 45051624, 45051633 }; from = new int[] { transcript3.getStart(), transcript3.getEnd() }; - transcript3.setGeneLoci("human", "GRCh38", "5", new MapList(from, to, + transcript3.setGeneLoci("homo_sapiens", "GRCh38", "5", new MapList( + from, to, 1, 1)); /* @@ -266,7 +285,8 @@ public class VCFLoaderTest to = new int[] { 45051615, 45051617, 45051619, 45051632, 45051634, 45051634 }; from = new int[] { transcript4.getStart(), transcript4.getEnd() }; - transcript4.setGeneLoci("human", "GRCh38", "5", new MapList(from, to, + transcript4.setGeneLoci("homo_sapiens", "GRCh38", "5", new MapList( + from, to, 1, 1)); /* @@ -425,49 +445,56 @@ public class VCFLoaderTest assertEquals(sf.getScore(), 0.1f, DELTA); assertEquals(sf.getValue("alleles"), "C,A"); // gene features include Consequence for all transcripts - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2); + Map map = (Map) sf.getValue("CSQ"); + assertEquals(map.size(), 9); sf = geneFeatures.get(1); assertEquals(sf.getBegin(), 5); assertEquals(sf.getEnd(), 5); assertEquals(sf.getScore(), 0.2f, DELTA); assertEquals(sf.getValue("alleles"), "C,T"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2); + map = (Map) sf.getValue("CSQ"); + assertEquals(map.size(), 9); sf = geneFeatures.get(2); assertEquals(sf.getBegin(), 9); assertEquals(sf.getEnd(), 11); // deletion over 3 positions assertEquals(sf.getScore(), 0.3f, DELTA); assertEquals(sf.getValue("alleles"), "CGG,C"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2); + map = (Map) sf.getValue("CSQ"); + assertEquals(map.size(), 9); sf = geneFeatures.get(3); assertEquals(sf.getBegin(), 13); assertEquals(sf.getEnd(), 13); assertEquals(sf.getScore(), 0.5f, DELTA); assertEquals(sf.getValue("alleles"), "C,T"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2); + map = (Map) sf.getValue("CSQ"); + assertEquals(map.size(), 9); sf = geneFeatures.get(4); assertEquals(sf.getBegin(), 13); assertEquals(sf.getEnd(), 13); assertEquals(sf.getScore(), 0.4f, DELTA); assertEquals(sf.getValue("alleles"), "C,G"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2); + map = (Map) sf.getValue("CSQ"); + assertEquals(map.size(), 9); sf = geneFeatures.get(5); assertEquals(sf.getBegin(), 17); assertEquals(sf.getEnd(), 17); assertEquals(sf.getScore(), 0.7f, DELTA); assertEquals(sf.getValue("alleles"), "A,G"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2); + map = (Map) sf.getValue("CSQ"); + assertEquals(map.size(), 9); sf = geneFeatures.get(6); assertEquals(sf.getBegin(), 17); assertEquals(sf.getEnd(), 17); // insertion assertEquals(sf.getScore(), 0.6f, DELTA); assertEquals(sf.getValue("alleles"), "A,AC"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 2); + map = (Map) sf.getValue("CSQ"); + assertEquals(map.size(), 9); /* * verify variant feature(s) added to transcript3 @@ -485,24 +512,25 @@ public class VCFLoaderTest assertEquals(sf.getScore(), 0.2f, DELTA); assertEquals(sf.getValue("alleles"), "C,T"); // transcript features only have Consequence for that transcripts - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1); - assertTrue(sf.getValue("CSQ").toString().contains("transcript3")); + map = (Map) sf.getValue("CSQ"); + assertEquals(map.size(), 9); + assertEquals(sf.getValueAsString("CSQ", "Feature"), "transcript3"); sf = transcriptFeatures.get(1); assertEquals(sf.getBegin(), 11); assertEquals(sf.getEnd(), 11); assertEquals(sf.getScore(), 0.7f, DELTA); assertEquals(sf.getValue("alleles"), "A,G"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1); - assertTrue(sf.getValue("CSQ").toString().contains("transcript3")); + assertEquals(map.size(), 9); + assertEquals(sf.getValueAsString("CSQ", "Feature"), "transcript3"); sf = transcriptFeatures.get(2); assertEquals(sf.getBegin(), 11); assertEquals(sf.getEnd(), 11); assertEquals(sf.getScore(), 0.6f, DELTA); assertEquals(sf.getValue("alleles"), "A,AC"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1); - assertTrue(sf.getValue("CSQ").toString().contains("transcript3")); + assertEquals(map.size(), 9); + assertEquals(sf.getValueAsString("CSQ", "Feature"), "transcript3"); /* * verify variants computed on protein product for transcript3 @@ -541,31 +569,31 @@ public class VCFLoaderTest assertEquals(sf.getEnd(), 7); assertEquals(sf.getScore(), 0.5f, DELTA); assertEquals(sf.getValue("alleles"), "C,T"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1); - assertTrue(sf.getValue("CSQ").toString().contains("transcript4")); + assertEquals(map.size(), 9); + assertEquals(sf.getValueAsString("CSQ", "Feature"), "transcript4"); sf = transcriptFeatures.get(1); assertEquals(sf.getBegin(), 7); assertEquals(sf.getEnd(), 7); assertEquals(sf.getScore(), 0.4f, DELTA); assertEquals(sf.getValue("alleles"), "C,G"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1); - assertTrue(sf.getValue("CSQ").toString().contains("transcript4")); + assertEquals(map.size(), 9); + assertEquals(sf.getValueAsString("CSQ", "Feature"), "transcript4"); sf = transcriptFeatures.get(2); assertEquals(sf.getBegin(), 11); assertEquals(sf.getEnd(), 11); assertEquals(sf.getScore(), 0.7f, DELTA); assertEquals(sf.getValue("alleles"), "A,G"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1); - assertTrue(sf.getValue("CSQ").toString().contains("transcript4")); + assertEquals(map.size(), 9); + assertEquals(sf.getValueAsString("CSQ", "Feature"), "transcript4"); sf = transcriptFeatures.get(3); assertEquals(sf.getBegin(), 11); assertEquals(sf.getEnd(), 11); assertEquals(sf.getScore(), 0.6f, DELTA); assertEquals(sf.getValue("alleles"), "A,AC"); - assertEquals(((String) sf.getValue("CSQ")).split(",").length, 1); - assertTrue(sf.getValue("CSQ").toString().contains("transcript4")); + assertEquals(map.size(), 9); + assertEquals(sf.getValueAsString("CSQ", "Feature"), "transcript4"); } }