Search in sources :

Example 1 with MafCalculator

use of com.github.lindenb.jvarkit.tools.burden.MafCalculator in project jvarkit by lindenb.

the class AFBySexChartFactory method visit.

@Override
public void visit(final VariantContext ctx) {
    for (final Allele alt : ctx.getAlternateAlleles()) {
        final MafCalculator[] mafCalculators = new MafCalculator[PedFile.Sex.values().length];
        for (int i = 0; i < mafCalculators.length; ++i) {
            mafCalculators[i] = new MafCalculator(alt, ctx.getContig());
        }
        for (final Genotype gt : ctx.getGenotypes()) {
            final PedFile.Sample sample = getPedigree().get(gt.getSampleName());
            if (sample == null) {
                mafCalculators[PedFile.Sex.Unknown.ordinal()].add(gt, false);
            } else {
                mafCalculators[sample.getSex().ordinal()].add(gt, sample.isMale());
            }
        }
        for (int i = 0; i < mafCalculators.length; ++i) {
            if (mafCalculators[i].isEmpty())
                continue;
            final Total total = popcount.get(i);
            total.num_maf++;
            total.sum += mafCalculators[i].getMaf();
        }
    }
}
Also used : Allele(htsjdk.variant.variantcontext.Allele) PedFile(com.github.lindenb.jvarkit.tools.vcfviewgui.PedFile) MafCalculator(com.github.lindenb.jvarkit.tools.burden.MafCalculator) Genotype(htsjdk.variant.variantcontext.Genotype)

Example 2 with MafCalculator

use of com.github.lindenb.jvarkit.tools.burden.MafCalculator in project jvarkit by lindenb.

the class AFByPopulationChartFactory method visit.

@Override
public void visit(final VariantContext ctx) {
    for (final Allele alt : ctx.getAlternateAlleles()) {
        final MafCalculator[] mafCalculators = new MafCalculator[PedFile.Status.values().length];
        for (int i = 0; i < mafCalculators.length; ++i) {
            mafCalculators[i] = new MafCalculator(alt, ctx.getContig());
        }
        for (final Genotype gt : ctx.getGenotypes()) {
            final PedFile.Sample sample = getPedigree().get(gt.getSampleName());
            if (sample == null) {
                mafCalculators[PedFile.Status.Unknown.ordinal()].add(gt, false);
            } else {
                mafCalculators[sample.getStatus().ordinal()].add(gt, sample.isMale());
            }
        }
        for (int i = 0; i < mafCalculators.length; ++i) {
            if (mafCalculators[i].isEmpty())
                continue;
            final Total total = popcount.get(i);
            total.num_maf++;
            total.sum += mafCalculators[i].getMaf();
        }
    }
}
Also used : Allele(htsjdk.variant.variantcontext.Allele) PedFile(com.github.lindenb.jvarkit.tools.vcfviewgui.PedFile) MafCalculator(com.github.lindenb.jvarkit.tools.burden.MafCalculator) Genotype(htsjdk.variant.variantcontext.Genotype)

Aggregations

MafCalculator (com.github.lindenb.jvarkit.tools.burden.MafCalculator)2 PedFile (com.github.lindenb.jvarkit.tools.vcfviewgui.PedFile)2 Allele (htsjdk.variant.variantcontext.Allele)2 Genotype (htsjdk.variant.variantcontext.Genotype)2