Search in sources :

Example 11 with VariantContextBuilder

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

the class MappingQualityZeroUnitTest method makeVC.

private VariantContext makeVC() {
    final GenotypesContext testGC = GenotypesContext.create(2);
    final Allele refAllele = Allele.create("A", true);
    final Allele altAllele = Allele.create("T");
    return (new VariantContextBuilder()).alleles(Arrays.asList(refAllele, altAllele)).chr("1").start(15L).stop(15L).genotypes(testGC).make();
}
Also used : Allele(htsjdk.variant.variantcontext.Allele) GenotypesContext(htsjdk.variant.variantcontext.GenotypesContext) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder)

Example 12 with VariantContextBuilder

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

the class ReadThreadingAssemblerUnitTest method testAssembleRefAndSNP.

@Test(dataProvider = "AssembleIntervalsWithVariantData")
public void testAssembleRefAndSNP(final ReadThreadingAssembler assembler, final SimpleInterval loc, final int nReadsToUse, final int variantSite) {
    final byte[] refBases = seq.getSubsequenceAt(loc.getContig(), loc.getStart(), loc.getEnd()).getBases();
    final Allele refBase = Allele.create(refBases[variantSite], true);
    final Allele altBase = Allele.create((byte) (refBase.getBases()[0] == 'A' ? 'C' : 'A'), false);
    final VariantContextBuilder vcb = new VariantContextBuilder("x", loc.getContig(), variantSite, variantSite, 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 13 with VariantContextBuilder

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

the class SVVariantConsensusDiscovery method discoverVariantsFromConsensus.

// TODO: 12/12/16 does not handle translocation yet
/**
     * Produces a VC from a {@link NovelAdjacencyReferenceLocations} (consensus among different assemblies if they all point to the same breakpoint).
     *
     * @param breakpointPairAndItsEvidence      consensus among different assemblies if they all point to the same breakpoint
     * @param broadcastReference                broadcasted reference
     * @throws IOException                      due to read operations on the reference
     */
public static VariantContext discoverVariantsFromConsensus(final Tuple2<NovelAdjacencyReferenceLocations, Iterable<ChimericAlignment>> breakpointPairAndItsEvidence, final Broadcast<ReferenceMultiSource> broadcastReference) throws IOException {
    final NovelAdjacencyReferenceLocations novelAdjacencyReferenceLocations = breakpointPairAndItsEvidence._1;
    final Iterable<ChimericAlignment> evidence = breakpointPairAndItsEvidence._2();
    final String contig = novelAdjacencyReferenceLocations.leftJustifiedLeftRefLoc.getContig();
    final int start = novelAdjacencyReferenceLocations.leftJustifiedLeftRefLoc.getEnd();
    final int end = novelAdjacencyReferenceLocations.leftJustifiedRightRefLoc.getStart();
    Utils.validateArg(start <= end, "An identified breakpoint pair has left breakpoint positioned to the right of right breakpoint: " + novelAdjacencyReferenceLocations.toString());
    final SvType variant = getType(novelAdjacencyReferenceLocations);
    final VariantContextBuilder vcBuilder = new VariantContextBuilder().chr(contig).start(start).stop(end).alleles(produceAlleles(novelAdjacencyReferenceLocations, broadcastReference.getValue(), variant)).id(variant.getVariantId()).attribute(VCFConstants.END_KEY, end).attribute(GATKSVVCFHeaderLines.SVTYPE, variant.toString()).attribute(GATKSVVCFHeaderLines.SVLEN, variant.getSVLength());
    variant.getTypeSpecificAttributes().forEach(vcBuilder::attribute);
    parseComplicationsAndMakeThemAttributeMap(novelAdjacencyReferenceLocations).forEach(vcBuilder::attribute);
    getEvidenceRelatedAnnotations(evidence).forEach(vcBuilder::attribute);
    return vcBuilder.make();
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder)

Example 14 with VariantContextBuilder

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

the class GenotypingEngineUnitTest method init.

@BeforeTest
public void init() {
    genotypingEngine = getGenotypingEngine();
    final int deletionSize = refAllele.length() - altT.length();
    final int start = 1;
    final VariantContext deletionVC = new VariantContextBuilder("testDeletion", "1", start, start + deletionSize, allelesDel).make();
    genotypingEngine.recordDeletion(deletionSize, deletionVC);
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContext(htsjdk.variant.variantcontext.VariantContext) BeforeTest(org.testng.annotations.BeforeTest)

Example 15 with VariantContextBuilder

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

the class FilterMutectCalls method onTraversalSuccess.

@Override
public Object onTraversalSuccess() {
    final String tumorSample = getHeaderForVariants().getMetaDataLine(Mutect2Engine.TUMOR_SAMPLE_KEY_IN_VCF_HEADER).getValue();
    final Mutect2FilteringEngine filteringEngine = new Mutect2FilteringEngine(MTFAC, tumorSample);
    // TODO: implement sophisticated filtering
    for (final VariantContext vc : unfilteredCalls) {
        final VariantContextBuilder vcb = new VariantContextBuilder(vc);
        vcb.filters(filteringEngine.calculateFilters(MTFAC, vc));
        vcfWriter.add(vcb.make());
    }
    return "SUCCESS";
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContext(htsjdk.variant.variantcontext.VariantContext)

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