public enum GenotypeAssignmentMethod { /** * set all of the genotype GT values to NO_CALL */ SET_TO_NO_CALL, /** * set all of the genotype GT values to NO_CALL and remove annotations */ SET_TO_NO_CALL_NO_ANNOTATIONS, /** * Use the subsetted PLs to greedily assigned genotypes */ USE_PLS_TO_ASSIGN, /** * Try to match the original GT calls, if at all possible * * Suppose I have 3 alleles: A/B/C and the following samples: * * original_GT best_match to A/B best_match to A/C * S1 => A/A A/A A/A * S2 => A/B A/B A/A * S3 => B/B B/B A/A * S4 => B/C A/B A/C * S5 => C/C A/A C/C * * Basically, all alleles not in the subset map to ref. It means that het-alt genotypes
final String vcSourceName = "Comp" + compCount + "Allele" + alleleCount; final VariantContext candidateEventToAdd = new VariantContextBuilder(compVC).alleles(alleleSet).source(vcSourceName).make(); boolean alreadyExists = false; for( final VariantContext eventToTest : eventsAtThisLoc ) {
@DataProvider(name = "SitesAndGenotypesVC") public Object[][] MakeSitesAndGenotypesVCs() { Genotype g1 = GenotypeBuilder.create("AA", Arrays.asList(Aref, Aref)); Genotype g2 = GenotypeBuilder.create("AT", Arrays.asList(Aref, T)); Genotype g3 = GenotypeBuilder.create("TT", Arrays.asList(T, T)); VariantContext sites = new VariantContextBuilder("sites", snpLoc, snpLocStart, snpLocStop, Arrays.asList(Aref, T)).make(); VariantContext genotypes = new VariantContextBuilder(sites).source("genotypes").genotypes(g1, g2, g3).make(); List<Object[]> tests = new ArrayList<>(); tests.add(new Object[]{new SitesAndGenotypesVC("sites", sites)}); tests.add(new Object[]{new SitesAndGenotypesVC("genotypes", genotypes)}); return tests.toArray(new Object[][]{}); }
builder.source(testName); builder.attribute(AF, .2); resultBuilder.source(testName); resultBuilder.attribute(AF, .8); tests.add(new Object[]{builder.make(), resultBuilder.make()}); builder.source(testName); builder.attribute(AF, "."); resultBuilder.source(testName); resultBuilder.attribute(AF, "."); tests.add(new Object[]{builder.make(), resultBuilder.make()}); builder.source(testName); builder.attribute(AF, 1); resultBuilder.source(testName); resultBuilder.attribute(AF, 0D); tests.add(new Object[]{builder.make(), resultBuilder.make()}); builder.source(testName); builder.attribute(MAX_AF, 1); resultBuilder.source(testName); tests.add(new Object[]{builder.make(), resultBuilder.make()}); builder.source(testName); builder.attribute("AF_MAX_shouldnt_be_dropped", 1);
@Test public void testReverseComplementFailureDoesNotErrorOut() { final VariantContextBuilder builder = new VariantContextBuilder().source("test").loc("chr1", 1, 4); final Allele originalRef = Allele.create("CCCC", true); final Allele originalAlt = Allele.create("C", false); builder.alleles(Arrays.asList(originalRef, originalAlt)); final Interval interval = new Interval("chr1", 1, 4, true, "test "); final String reference = "ATGATGATGA"; final ReferenceSequence refSeq = new ReferenceSequence("chr1", 10, reference.getBytes()); // we don't actually care what the results are here -- we just want to make sure that it doesn't fail final VariantContextBuilder result = LiftoverUtils.reverseComplementVariantContext(builder.make(), interval, refSeq); }
@Test public void TestMergeIntoMNPvalidationDiffContigs() { final String contig = new String("2"); final VariantContext vc = new VariantContextBuilder().chr(contig).id("id1").source("TC").start(start+1).stop(start+1).alleles(alleleList2).genotypes(genotype2).make(); Assert.assertFalse(PhasingUtils.mergeIntoMNPvalidationCheck(genomeLocParser, vc1, vc)); }
private void generateAllLocationsAndVariantContextCombinations(final String[] chrs, final int[] eventSizes, final int[] eventStarts, final GenomeLoc[] locs, final VariantContext[] events) { int nextIndex = 0; for (final String chr : chrs ) for (final int size : eventSizes ) for (final int starts : eventStarts ) { locs[nextIndex] = genomeLocParser.createGenomeLoc(chr,starts,starts + Math.max(0,size)); events[nextIndex++] = new VariantContextBuilder().source("test").loc(chr,starts,starts + Math.max(0,size)).alleles(Arrays.asList( Allele.create(randomBases(size <= 0 ? 1 : size + 1, true), true), Allele.create(randomBases(size < 0 ? -size + 1 : 1, false), false))).make(); } locs[nextIndex++] = GenomeLoc.UNMAPPED; }
builder.source(getName());
@Test public void TestAllGenotypesAreUnfilteredAndCalled(){ final VariantContext vc = new VariantContextBuilder().chr(contig).id("id1").source("TC").start(start).stop(start).alleles(alleleList1).genotypes(genotype1).make(); Assert.assertTrue(PhasingUtils.allGenotypesAreUnfilteredAndCalled(vc)); }
@Test public void TestMergeIntoMNPvalidationCheckLocBefore() { final VariantContext vc1before = new VariantContextBuilder().chr(contig).id("id1").source("TC").start(start+1).stop(start+1).alleles(alleleList1).make(); final VariantContext vc2after = new VariantContextBuilder().chr(contig).id("id2").source("GA").start(start).stop(start).alleles(alleleList2).make(); Assert.assertFalse(PhasingUtils.mergeIntoMNPvalidationCheck(genomeLocParser, vc1before, vc2after)); }
@Test public void TestMergeIntoMNPvalidationFilterNoCall() { final List<String> filters = Arrays.asList("filter"); final List<Allele> alleleList = Arrays.asList(Allele.create("T", true), Allele.create(".", false)); final Genotype genotype = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-1", "10-2"}).alleles(alleleList).filters(filters).make(); final VariantContext vc = new VariantContextBuilder().chr(contig).id("id1").source("TC").start(start).stop(start).alleles(alleleList1).genotypes(genotype).make(); Assert.assertFalse(PhasingUtils.mergeIntoMNPvalidationCheck(genomeLocParser, vc, vc2)); }
@Test public void TestMergeIntoMNPvalidationFiltered() { final List<String> filters = Arrays.asList("filter"); final Genotype genotype = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-1", "10-2"}).alleles(alleleList1).filters(filters).make(); final VariantContext vc = new VariantContextBuilder().chr(contig).id("id1").source("TC").start(start).stop(start).alleles(alleleList1).genotypes(genotype).make(); Assert.assertFalse(PhasingUtils.mergeIntoMNPvalidationCheck(genomeLocParser, vc, vc2)); }
@Test public void TestSomeSampleHasDoubleNonReferenceAlleleTrue(){ Genotype genotype = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-1", "10-2"}).alleles(alleleList2).make(); VariantContext vc = new VariantContextBuilder().chr(contig).id("id2").source("GA").start(start+1).stop(start+1).alleles(alleleList2).genotypes(genotype).make(); Assert.assertTrue(PhasingUtils.someSampleHasDoubleNonReferenceAllele(vc1, vc)); }
@Test public void TestMergeIntoMNPvalidationDiffSampleNames() { final Genotype genotype = new GenotypeBuilder().name("sample1").attribute("HP", new String[]{"10-1", "10-2"}).alleles(alleleList1).make(); final VariantContext vc = new VariantContextBuilder().chr(contig).id("id1").source("TC").start(start).stop(start).alleles(alleleList1).genotypes(genotype).make(); Assert.assertFalse(PhasingUtils.mergeIntoMNPvalidationCheck(genomeLocParser, vc, vc2)); }
@Test public void TestDoubleAllelesSegregatePerfectlyAmongSamples(){ final Genotype genotype = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-1", "10-2"}).alleles(alleleList2).make(); final VariantContext vc = new VariantContextBuilder().chr(contig).id("id2").source("GA").start(start+1).stop(start+1).alleles(alleleList2).genotypes(genotype).make(); Assert.assertTrue(PhasingUtils.doubleAllelesSegregatePerfectlyAmongSamples(vc1, vc)); }
@Test public void TestReallyMergeIntoMNP( ){ final VariantContext vc = PhasingUtils.reallyMergeIntoMNP(vc1, vc2, referenceFile); final List<Allele> alleleList = Arrays.asList(Allele.create("TG", true), Allele.create("TA", false), Allele.create("CG", false)); final Map<String,Object> attributes = new HashMap<String,Object>(){{ put("AC", new ArrayList<Integer>(Arrays.asList(1, 1))); put("AF", new ArrayList<Double>(Arrays.asList(0.5, 0.5))); put("AN", 2); }}; final Map<String, Object> extendedAttributes = new HashMap<String, Object>(){{ put("PQ", 100.0); put("HP", new String[]{"10-1", "10-2"}); }}; final List<Allele> alleleListMeged = Arrays.asList(Allele.create("TA"), Allele.create("CG")); final Genotype genotype = new GenotypeBuilder().name("sample").attributes(extendedAttributes).alleles(alleleListMeged).make(); final VariantContext vcExpected = new VariantContextBuilder().chr(contig).id("id1;id2").source("TC_GA").start(start).stop(start+1).alleles(alleleList).genotypes(genotype).attributes(attributes).make(); Assert.assertTrue(genotype.sameGenotype(vcExpected.getGenotypes().get("sample"))); Assert.assertTrue(vcExpected.hasSameAllelesAs(vc)); Assert.assertEquals(vcExpected.getChr(), vc.getChr()); Assert.assertEquals(vcExpected.getStart(), vc.getStart()); Assert.assertEquals(vcExpected.getEnd(), vc.getEnd()); Assert.assertEquals(vcExpected.getID(), vc.getID()); Assert.assertEquals(vcExpected.getSource(), vc.getSource()); Assert.assertEquals(vcExpected.isFiltered(), vc.isFiltered()); Assert.assertEquals(vcExpected.getPhredScaledQual(), vc.getPhredScaledQual()); Assert.assertEquals(vcExpected.getAttribute("PQ"), vc.getAttribute("PQ")); Assert.assertEquals(vcExpected.getAttribute("HP"), vc.getAttribute("HP")); }
@BeforeSuite public void init() throws FileNotFoundException { referenceFile = new CachingIndexedFastaSequenceFile(new File(b37KGReference)); genomeLocParser = new GenomeLocParser(referenceFile); alleleList1 = Arrays.asList(Allele.create("T", true), Allele.create("C", false)); alleleList2 = Arrays.asList(Allele.create("G", true), Allele.create("A", false)); genotype1 = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-1", "10-2"}).attribute("PQ", 100.0).alleles(alleleList1).make(); genotype2 = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-2", "10-1"}).attribute("PQ", 200.0).alleles(alleleList2).make(); contig = new String("1"); vc1 = new VariantContextBuilder().chr(contig).id("id1").source("TC").start(start).stop(start).alleles(alleleList1).genotypes(genotype1).make(); vc2 = new VariantContextBuilder().chr(contig).id("id2").source("GA").start(start+1).stop(start+1).alleles(alleleList2).genotypes(genotype2).make(); }
@Test public void TestMergeIntoMNP(){ final AlwaysTrueMergeRule alleleMergeRule = new AlwaysTrueMergeRule(); final VariantContext vc = PhasingUtils.mergeIntoMNP(genomeLocParser, vc1, vc2, referenceFile, alleleMergeRule); final List<Allele> alleleList = Arrays.asList(Allele.create("TG", true), Allele.create("TA", false), Allele.create("CG", false)); final Map<String,Object> attributes = new HashMap<String,Object>(){{ put("AC", new ArrayList<Integer>(Arrays.asList(1, 1))); put("AF", new ArrayList<Double>(Arrays.asList(0.5, 0.5))); put("AN", 2); }}; final Map<String, Object> extendedAttributes = new HashMap<String, Object>(){{ put("PQ", 100.0); put("HP", new String[]{"10-1", "10-2"}); }}; final List<Allele> alleleListMeged = Arrays.asList(Allele.create("TA"), Allele.create("CG")); final Genotype genotype = new GenotypeBuilder().name("sample").attributes(extendedAttributes).alleles(alleleListMeged).make(); final VariantContext vcExpected = new VariantContextBuilder().chr(contig).id("id1;id2").source("TC_GA").start(start).stop(start+1).alleles(alleleList).genotypes(genotype).attributes(attributes).make(); Assert.assertTrue(genotype.sameGenotype(vcExpected.getGenotypes().get("sample"))); Assert.assertTrue(vcExpected.hasSameAllelesAs(vc)); Assert.assertEquals(vcExpected.getChr(), vc.getChr()); Assert.assertEquals(vcExpected.getStart(), vc.getStart()); Assert.assertEquals(vcExpected.getEnd(), vc.getEnd()); Assert.assertEquals(vcExpected.getID(), vc.getID()); Assert.assertEquals(vcExpected.getSource(), vc.getSource()); Assert.assertEquals(vcExpected.isFiltered(), vc.isFiltered()); Assert.assertEquals(vcExpected.getPhredScaledQual(), vc.getPhredScaledQual()); Assert.assertEquals(vcExpected.getAttribute("PQ"), vc.getAttribute("PQ")); Assert.assertEquals(vcExpected.getAttribute("HP"), vc.getAttribute("HP")); }
final VariantContextBuilder builder = new VariantContextBuilder().source("test1").chr("chr1"); final GenotypeBuilder genotypeBuilder = new GenotypeBuilder("test1"); final GenotypeBuilder resultGenotypeBuilder = new GenotypeBuilder("test1"); final VariantContextBuilder result_builder = new VariantContextBuilder().source("test1").chr("chr1").attribute(LiftoverUtils.SWAPPED_ALLELES, true);
@DataProvider(name = "noCallAndSymbolicData") public Iterator<Object[]> noCallAndSymbolicData() { final VariantContextBuilder builder = new VariantContextBuilder().source("test1").chr("chr1"); final VariantContextBuilder result_builder = new VariantContextBuilder().source("test1").chr("chr1"); result_builder.attribute(LiftoverVcf.ORIGINAL_CONTIG, "chr1"); final GenotypeBuilder genotypeBuilder = new GenotypeBuilder("test1"); final LiftOver liftOverRC = new LiftOver(CHAIN_FILE); builder.source("test1"); int start = 10; builder.start(start).stop(start).alleles(CollectionUtil.makeList(CRef, T)); builder.source("test2"); builder.start(start).stop(start).alleles(CollectionUtil.makeList(CRef, T, DEL)); result_builder.start(start).stop(start).alleles(CollectionUtil.makeList(CRef, T, DEL)); builder.source("test3"); int offset = 3; start = CHAIN_SIZE - offset; builder.source("test4"); offset = 4; start = CHAIN_SIZE - offset;