Search in sources :

Example 56 with VariantContextBuilder

use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.

the class ReadThreadingAssemblerUnitTest method testAssembleRefAndDeletion.

@Test(dataProvider = "AssembleIntervalsWithVariantData")
public void testAssembleRefAndDeletion(final ReadThreadingAssembler assembler, final SimpleInterval loc, final int nReadsToUse, final int variantSite) {
    final byte[] refBases = seq.getSubsequenceAt(loc.getContig(), loc.getStart(), loc.getEnd()).getBases();
    for (int deletionLength = 1; deletionLength < 10; deletionLength++) {
        final Allele refBase = Allele.create(new String(refBases).substring(variantSite, variantSite + deletionLength + 1), true);
        final Allele altBase = Allele.create(refBase.getBases()[0], false);
        final VariantContextBuilder vcb = new VariantContextBuilder("x", loc.getContig(), variantSite, variantSite + deletionLength, Arrays.asList(refBase, altBase));
        testAssemblyWithVariant(assembler, refBases, loc, nReadsToUse, vcb.make());
    }
}
Also used : Allele(htsjdk.variant.variantcontext.Allele) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 57 with VariantContextBuilder

use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.

the class SelectVariantsUnitTest method maxIndelSizeTest.

@Test(dataProvider = "MaxMinIndelSize")
public void maxIndelSizeTest(final int size, final int otherSize, final int max, final int min, final String op) {
    final byte[] largerAllele = Utils.dupBytes((byte) 'A', size + 1);
    final byte[] smallerAllele = Utils.dupBytes((byte) 'A', 1);
    final List<Allele> alleles = new ArrayList<>(2);
    final Allele ref = Allele.create(op.equals("I") ? smallerAllele : largerAllele, true);
    final Allele alt = Allele.create(op.equals("D") ? smallerAllele : largerAllele, false);
    alleles.add(ref);
    alleles.add(alt);
    final VariantContext vc = new VariantContextBuilder("test", "1", 10, 10 + ref.length() - 1, alleles).make();
    final boolean hasIndelTooLargeOrSmall = SelectVariants.containsIndelLargerOrSmallerThan(vc, max, min);
    Assert.assertEquals(hasIndelTooLargeOrSmall, size > max || size < min);
}
Also used : Allele(htsjdk.variant.variantcontext.Allele) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContext(htsjdk.variant.variantcontext.VariantContext) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)57 VariantContext (htsjdk.variant.variantcontext.VariantContext)40 Test (org.testng.annotations.Test)26 Allele (htsjdk.variant.variantcontext.Allele)25 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)21 Genotype (htsjdk.variant.variantcontext.Genotype)12 ReferenceContext (org.broadinstitute.hellbender.engine.ReferenceContext)8 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)7 GenotypeBuilder (htsjdk.variant.variantcontext.GenotypeBuilder)6 GenotypesContext (htsjdk.variant.variantcontext.GenotypesContext)6 File (java.io.File)6 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)5 VCFHeader (htsjdk.variant.vcf.VCFHeader)5 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)5 BeforeTest (org.testng.annotations.BeforeTest)5 SAMSequenceRecord (htsjdk.samtools.SAMSequenceRecord)4 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)4 VCFHeaderLine (htsjdk.variant.vcf.VCFHeaderLine)3 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3