From: gmungoc Date: Thu, 16 Nov 2017 09:03:49 +0000 (+0000) Subject: JAL-2835 update test for CSQ data held as a Map X-Git-Tag: Release_2_11_0~124 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=779411693812e6e3ad6c547e44f1e58124263ffd;p=jalview.git JAL-2835 update test for CSQ data held as a Map --- diff --git a/test/jalview/io/vcf/VCFLoaderTest.java b/test/jalview/io/vcf/VCFLoaderTest.java index 5607b4b..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 @@ -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 { @@ -432,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 @@ -492,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 @@ -548,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"); } }