Package org.broadinstitute.gatk.utils

Examples of org.broadinstitute.gatk.utils.GenomeLoc


        return consensusIndelStrings;
    }

    private List<Allele> consensusCountsToAlleles(final ReferenceContext ref,
                                                  final Map<String, Integer> consensusIndelStrings) {
        final GenomeLoc loc = ref.getLocus();
        final Collection<VariantContext> vcs = new ArrayList<VariantContext>();
        int maxAlleleCnt = 0;
        Allele refAllele, altAllele;

        for (final Map.Entry<String, Integer> elt : consensusIndelStrings.entrySet()) {
            final String s = elt.getKey();
            final int curCnt = elt.getValue();
            int stop = 0;

            // if observed count if above minimum threshold, we will genotype this allele
            if (curCnt < minIndelCountForGenotyping)
                continue;

            if (s.startsWith("D")) {
                // get deletion length
                final int dLen = Integer.valueOf(s.substring(1));
                // get ref bases of accurate deletion
                final int startIdxInReference = 1 + loc.getStart() - ref.getWindow().getStart();
                stop = loc.getStart() + dLen;
                final byte[] refBases = Arrays.copyOfRange(ref.getBases(), startIdxInReference - 1, startIdxInReference + dLen);   // add reference padding

                if (Allele.acceptableAlleleBases(refBases, false)) {
                    refAllele = Allele.create(refBases, true);
                    altAllele = Allele.create(ref.getBase(), false);
                }
                else continue; // don't go on with this allele if refBases are non-standard
            } else {
                // insertion case
                final String insertionBases = (char)ref.getBase() + s;  // add reference padding
                if (Allele.acceptableAlleleBases(insertionBases, false)) { // don't allow N's in insertions
                    refAllele = Allele.create(ref.getBase(), true);
                    altAllele = Allele.create(insertionBases, false);
                    stop = loc.getStart();
                }
                else continue; // go on to next allele if consensus insertion has any non-standard base.
            }


            final VariantContextBuilder builder = new VariantContextBuilder().source("");
            builder.loc(loc.getContig(), loc.getStart(), stop);
            builder.alleles(Arrays.asList(refAllele, altAllele));
            builder.noGenotypes();
            if (doMultiAllelicCalls) {
                vcs.add(builder.make());
                if (vcs.size() >= GenotypeLikelihoods.MAX_ALT_ALLELES_THAT_CAN_BE_GENOTYPED)
View Full Code Here


        final int variantStepSize = 1;
        final int nReadsToUse = 5;

        for ( int startI = start; startI < end; startI += stepSize) {
            final int endI = startI + windowSize;
            final GenomeLoc refLoc = genomeLocParser.createGenomeLoc(contig, startI, endI);
            for ( int variantStart = windowSize / 2 - 10; variantStart < windowSize / 2 + 10; variantStart += variantStepSize ) {
                tests.add(new Object[]{new ReadThreadingAssembler(), refLoc, nReadsToUse, variantStart});
            }
        }
View Full Code Here

        final int end        = start + windowSize;

        final int excludeVariantsWithinXbp = 25; // TODO -- decrease to zero when the edge calling problem is fixed

        final String ref = new String(seq.getSubsequenceAt(contig, start, end).getBases());
        final GenomeLoc refLoc = genomeLocParser.createGenomeLoc(contig, start, end);

            for ( int snpPos = 0; snpPos < windowSize; snpPos++) {
                if ( snpPos > excludeVariantsWithinXbp && (windowSize - snpPos) >= excludeVariantsWithinXbp ) {
                    final byte[] altBases = ref.getBytes();
                    altBases[snpPos] = altBases[snpPos] == 'A' ? (byte)'C' : (byte)'A';
View Full Code Here

        loadAllPlugins(thresholds);
    }

    @Override
    public Long map(final RefMetaDataTracker tracker, final ReferenceContext ref, final AlignmentContext context) {
        GenomeLoc refLocus = ref.getLocus();

        // process and remove any intervals in the map that are don't overlap the current locus anymore
        // and add all new intervals that may overlap this reference locus
        addNewOverlappingIntervals(refLocus);
        outputFinishedIntervals(refLocus, ref.getBase());
View Full Code Here

    @Override
    public void onTraversalDone(final Long result) {
        for (GenomeLoc interval : intervalMap.keySet())
            outputStatsToVCF(intervalMap.get(interval), UNCOVERED_ALLELE);

        GenomeLoc interval = intervalListIterator.peek();
        while (interval != null) {
            outputStatsToVCF(createIntervalStatistic(interval), UNCOVERED_ALLELE);
            intervalListIterator.next();
            interval = intervalListIterator.peek();
        }
View Full Code Here

     * Adds all intervals that overlap the current reference locus to the intervalMap
     *
     * @param refLocus the current reference locus
     */
    private void addNewOverlappingIntervals(final GenomeLoc refLocus) {
        GenomeLoc interval = intervalListIterator.peek();
        while (interval != null && !interval.isPast(refLocus)) {
            intervalMap.put(interval, createIntervalStatistic(interval));
            intervalListIterator.next();
            interval = intervalListIterator.peek();
        }
    }
View Full Code Here

     *
     * @param stats     The statistics of the interval
     * @param refAllele the reference allele
     */
    private void outputStatsToVCF(final IntervalStratification stats, final Allele refAllele) {
        GenomeLoc interval = stats.getInterval();

        final List<Allele> alleles = new ArrayList<Allele>();
        final Map<String, Object> attributes = new HashMap<String, Object>();
        final ArrayList<Genotype> genotypes = new ArrayList<Genotype>();

        for (String sample : samples) {
            final GenotypeBuilder gb = new GenotypeBuilder(sample);

            SampleStratification sampleStat = stats.getSampleStatistics(sample);
            gb.attribute(AVG_INTERVAL_DP_KEY, sampleStat.averageCoverage(interval.size()));
            gb.attribute(LOW_COVERAGE_LOCI, sampleStat.getNLowCoveredLoci());
            gb.attribute(ZERO_COVERAGE_LOCI, sampleStat.getNUncoveredLoci());
            gb.filters(statusToStrings(stats.getSampleStatistics(sample).callableStatuses(), false));

            genotypes.add(gb.make());
        }
        alleles.add(refAllele);
        alleles.add(SYMBOLIC_ALLELE);
        VariantContextBuilder vcb = new VariantContextBuilder("DiagnoseTargets", interval.getContig(), interval.getStart(), interval.getStop(), alleles);

        vcb = vcb.log10PError(VariantContext.NO_LOG10_PERROR);
        vcb.filters(new LinkedHashSet<String>(statusToStrings(stats.callableStatuses(), true)));

        attributes.put(VCFConstants.END_KEY, interval.getStop());
        attributes.put(AVG_INTERVAL_DP_KEY, stats.averageCoverage(interval.size()));
        attributes.put(GC_CONTENT_KEY, stats.gcContent());

        vcb = vcb.attributes(attributes);
        vcb = vcb.genotypes(genotypes);

View Full Code Here

    private boolean hasMissingLoci(final IntervalStratification stats) {
        return thresholds.missingTargets != null && hasMissingStatuses(stats);
    }

    private void outputMissingInterval(final IntervalStratification stats) {
        final GenomeLoc interval = stats.getInterval();
        final boolean missing[] = new boolean[interval.size()];
        Arrays.fill(missing, true);
        for (AbstractStratification sample : stats.getElements()) {
            if (hasMissingStatuses(sample)) {
                int pos = 0;
                for (AbstractStratification locus : sample.getElements()) {
                    if (locus.callableStatuses().isEmpty()) {
                        missing[pos] = false;
                    }
                    pos++;
                }
            }
        }
        int start = -1;
        boolean insideMissing = false;
        for (int i = 0; i < missing.length; i++) {
            if (missing[i] && !insideMissing) {
                start = interval.getStart() + i;
                insideMissing = true;
            } else if (!missing[i] && insideMissing) {
                final int stop = interval.getStart() + i - 1;
                outputMissingInterval(interval.getContig(), start, stop);
                insideMissing = false;
            }
        }
        if (insideMissing) {
            outputMissingInterval(interval.getContig(), start, interval.getStop());
        }
    }
View Full Code Here

        else {
            alleles.add(Allele.create("A", true));
            alleles.add(Allele.create(Utils.dupString("A",Math.abs(indelSize)+1),false));

        }
        final GenomeLoc loc = genomeLocParser.createGenomeLoc(artificialContig,locStart+offset,locStart+offset);
        final ReferenceContext referenceContext = new ReferenceContext(genomeLocParser,loc,window,windowBases.getBytes());

        final VariantContext vc = new VariantContextBuilder("test", artificialContig, locStart+offset, locStart+offset+alleles.get(0).length()-1, alleles).make();
        final Pair<VariantContext,Integer> result = LeftAlignAndTrimVariants.alignAndWrite(vc,referenceContext);
        Assert.assertTrue(result.second == (offset>0?1:0));
View Full Code Here

                                         final List<Allele> allAllelesToUse,
                                         final boolean useBAQedPileup,
                                         final GenomeLocParser locParser,
                                         final Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap) {

        GenomeLoc loc = ref.getLocus();
//        if (!ref.getLocus().equals(lastSiteVisited)) {
        if (contextType == AlignmentContextUtils.ReadOrientation.COMPLETE) {
            // starting a new site: clear allele list
            haplotypeMap.clear();
            perReadAlleleLikelihoodMap.clear(); // clean mapping sample-> per read, per allele likelihoods
            alleleList = getInitialAlleleList(tracker, ref, contexts, contextType, UAC, ignoreSNPAllelesWhenGenotypingIndels);
            if (alleleList.isEmpty())
                return null;
        }

        getHaplotypeMapFromAlleles(alleleList, ref, loc, haplotypeMap); // will update haplotypeMap adding elements
        if (haplotypeMap == null || haplotypeMap.isEmpty())
            return null;

        // start making the VariantContext
        // For all non-snp VC types, VC end location is just startLocation + length of ref allele including padding base.
        final int endLoc = loc.getStart() + alleleList.get(0).length() - 1;
        final int eventLength = getEventLength(alleleList);

        final VariantContextBuilder builder = new VariantContextBuilder("UG_call", loc.getContig(), loc.getStart(), endLoc, alleleList);

        // create the genotypes; no-call everyone for now
        GenotypesContext genotypes = GenotypesContext.create();
        final int ploidy = UAC.genotypeArgs.samplePloidy;
        final List<Allele> noCall = GATKVariantContextUtils.noCallAlleles(ploidy);
View Full Code Here

TOP

Related Classes of org.broadinstitute.gatk.utils.GenomeLoc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.