Search in sources :

Example 1 with ReadsContext

use of org.broadinstitute.hellbender.engine.ReadsContext in project gatk-protected by broadinstitute.

the class AnnotateVcfWithExpectedAlleleFraction method apply.

@Override
public void apply(final VariantContext vc, final ReadsContext readsContext, final ReferenceContext refContext, final FeatureContext fc) {
    final double[] weights = vc.getGenotypes().stream().mapToDouble(g -> weight(g)).toArray();
    final double expectedAlleleFraction = MathUtils.sum(MathArrays.ebeMultiply(weights, mixingFractionsInSampleOrder));
    vcfWriter.add(new VariantContextBuilder(vc).attribute(EXPECTED_ALLELE_FRACTION_NAME, expectedAlleleFraction).make());
}
Also used : Genotype(htsjdk.variant.variantcontext.Genotype) VCFHeaderLine(htsjdk.variant.vcf.VCFHeaderLine) DocumentedFeature(org.broadinstitute.barclay.help.DocumentedFeature) CommandLineProgramProperties(org.broadinstitute.barclay.argparser.CommandLineProgramProperties) VCFHeader(htsjdk.variant.vcf.VCFHeader) MathArrays(org.apache.commons.math3.util.MathArrays) Argument(org.broadinstitute.barclay.argparser.Argument) StandardArgumentDefinitions(org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions) VariantProgramGroup(org.broadinstitute.hellbender.cmdline.programgroups.VariantProgramGroup) HashSet(java.util.HashSet) Map(java.util.Map) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) FeatureContext(org.broadinstitute.hellbender.engine.FeatureContext) VCFHeaderLineType(htsjdk.variant.vcf.VCFHeaderLineType) VariantWalker(org.broadinstitute.hellbender.engine.VariantWalker) Set(java.util.Set) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) MathUtils(org.broadinstitute.hellbender.utils.MathUtils) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine) VariantContext(htsjdk.variant.variantcontext.VariantContext) ReadsContext(org.broadinstitute.hellbender.engine.ReadsContext) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder)

Example 2 with ReadsContext

use of org.broadinstitute.hellbender.engine.ReadsContext in project gatk by broadinstitute.

the class AnnotateVcfWithExpectedAlleleFraction method apply.

@Override
public void apply(final VariantContext vc, final ReadsContext readsContext, final ReferenceContext refContext, final FeatureContext fc) {
    final double[] weights = vc.getGenotypes().stream().mapToDouble(g -> weight(g)).toArray();
    final double expectedAlleleFraction = MathUtils.sum(MathArrays.ebeMultiply(weights, mixingFractionsInSampleOrder));
    vcfWriter.add(new VariantContextBuilder(vc).attribute(EXPECTED_ALLELE_FRACTION_NAME, expectedAlleleFraction).make());
}
Also used : Genotype(htsjdk.variant.variantcontext.Genotype) VCFHeaderLine(htsjdk.variant.vcf.VCFHeaderLine) DocumentedFeature(org.broadinstitute.barclay.help.DocumentedFeature) CommandLineProgramProperties(org.broadinstitute.barclay.argparser.CommandLineProgramProperties) VCFHeader(htsjdk.variant.vcf.VCFHeader) MathArrays(org.apache.commons.math3.util.MathArrays) Argument(org.broadinstitute.barclay.argparser.Argument) StandardArgumentDefinitions(org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions) VariantProgramGroup(org.broadinstitute.hellbender.cmdline.programgroups.VariantProgramGroup) HashSet(java.util.HashSet) Map(java.util.Map) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) FeatureContext(org.broadinstitute.hellbender.engine.FeatureContext) VCFHeaderLineType(htsjdk.variant.vcf.VCFHeaderLineType) VariantWalker(org.broadinstitute.hellbender.engine.VariantWalker) Set(java.util.Set) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) MathUtils(org.broadinstitute.hellbender.utils.MathUtils) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine) VariantContext(htsjdk.variant.variantcontext.VariantContext) ReadsContext(org.broadinstitute.hellbender.engine.ReadsContext) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder)

Aggregations

Genotype (htsjdk.variant.variantcontext.Genotype)2 VariantContext (htsjdk.variant.variantcontext.VariantContext)2 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)2 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)2 VCFHeader (htsjdk.variant.vcf.VCFHeader)2 VCFHeaderLine (htsjdk.variant.vcf.VCFHeaderLine)2 VCFHeaderLineType (htsjdk.variant.vcf.VCFHeaderLineType)2 VCFInfoHeaderLine (htsjdk.variant.vcf.VCFInfoHeaderLine)2 File (java.io.File)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 MathArrays (org.apache.commons.math3.util.MathArrays)2 Argument (org.broadinstitute.barclay.argparser.Argument)2 CommandLineProgramProperties (org.broadinstitute.barclay.argparser.CommandLineProgramProperties)2 DocumentedFeature (org.broadinstitute.barclay.help.DocumentedFeature)2 StandardArgumentDefinitions (org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions)2 VariantProgramGroup (org.broadinstitute.hellbender.cmdline.programgroups.VariantProgramGroup)2