Package org.broadinstitute.gatk.utils

Examples of org.broadinstitute.gatk.utils.GenomeLoc


        if (indelSize == 0)
            return;

        final List<Allele> alleles = new ArrayList<Allele>();

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

        final int prefixLen = 10;
        final String prefix = refBases.substring(locStart+offset-prefixLen,locStart+offset);
        if (indelSize < 0) { // deletion
View Full Code Here


        VariantContext current1 = (currentIndex1 < size1 ? sourceVCs1.get(currentIndex1): null);
        VariantContext current2 = (currentIndex2 < size2 ? sourceVCs2.get(currentIndex2): null);

        while ( current1 != null && current2 != null ) {

            final GenomeLoc loc1 = getToolkit().getGenomeLocParser().createGenomeLoc(current1);
            final GenomeLoc loc2 = getToolkit().getGenomeLocParser().createGenomeLoc(current2);

            if ( loc1.equals(loc2) ||
                    (loc1.getStart() == loc2.getStart() && (current1.getAlternateAlleles().size() > 1 || current2.getAlternateAlleles().size() > 1)) ) {
                // test the alleles
                if ( determineAndWriteOverlap(current1, current2, status) ) {
                    sourceVCs1.remove(currentIndex1);
                    sourceVCs2.remove(currentIndex2);
                    size1--;
View Full Code Here

                writeOne(current1, source1, null);
                currentIndex1++;
                current1 = (currentIndex1 < size1 ? source1Alleles.get(currentIndex1): null);
            } else {

                final GenomeLoc loc1 = getToolkit().getGenomeLocParser().createGenomeLoc(current1);
                final GenomeLoc loc2 = getToolkit().getGenomeLocParser().createGenomeLoc(current2);

                if ( loc1.getStart() == loc2.getStart() || loc1.overlapsP(loc2) ) {
                    String status;
                    if ( loc1.getStart() == loc2.getStart() ) {
                        final String allele1 = current1.getAlternateAllele(0).getBaseString();
                        final String allele2 = current2.getAlternateAllele(0).getBaseString();
                        if ( allele1.indexOf(allele2) != -1 || allele2.indexOf(allele1) != -1 )
                            status = ONE_ALLELE_SUBSET_OF_OTHER_STATUS;
                        else
View Full Code Here

            if ( nGoodBases > 0 )
                GLs.add(new SampleGenotypeData(sample.getKey(), GL, getFilteredDepth(pileup)));
        }

        // start making the VariantContext
        final GenomeLoc loc = ref.getLocus();
        final List<Allele> alleles = new ArrayList<Allele>();
        alleles.add(refAllele);


        final VariantContextBuilder builder = new VariantContextBuilder("UG_call", loc.getContig(), loc.getStart(), loc.getStop(), alleles);
        // find the alternate allele(s) that we should be using
        if ( allAllelesToUse != null ) {
            alleles.addAll(allAllelesToUse.subList(1,allAllelesToUse.size()));   // this includes ref allele
        } else if ( useAlleleFromVCF ) {
            final VariantContext vc = GenotypingGivenAllelesUtils.composeGivenAllelesVariantContextFromRod(tracker, ref.getLocus(), true, logger, UAC.alleles);
View Full Code Here

        Allele ref1 = Allele.create(BaseUtils.Base.T.base,true);
        Allele alt1 = Allele.create(BaseUtils.Base.C.base);
        Allele alt2 = Allele.create(BaseUtils.Base.G.base);
        Allele alt3 = Allele.create(BaseUtils.Base.A.base);

        GenomeLoc loc1 = genomeLocParser.createGenomeLoc("chr1",1,1);
        VariantContextBuilder site1Eval = new VariantContextBuilder();
        VariantContextBuilder site1Comp = new VariantContextBuilder();


        // site 1: eval superset comp
        site1Eval.loc(loc1.getContig(),loc1.getStart(),loc1.getStop());
        site1Comp.loc(loc1.getContig(),loc1.getStart(),loc1.getStop());
        site1Eval.alleles(Arrays.asList(ref1,alt1,alt2));
        site1Comp.alleles(Arrays.asList(ref1,alt2));
        site1Eval.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt2)));
        site1Comp.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt2)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt2)));

        // site 2: eval subset comp
        GenomeLoc loc2 = genomeLocParser.createGenomeLoc("chr1",2,2);
        VariantContextBuilder site2Eval = new VariantContextBuilder();
        VariantContextBuilder site2Comp = new VariantContextBuilder();
        site2Eval.loc(loc2.getContig(),loc2.getStart(),loc2.getStop());
        site2Comp.loc(loc2.getContig(),loc2.getStart(),loc2.getStop());
        site2Eval.alleles(Arrays.asList(ref1,alt1));
        site2Comp.alleles(Arrays.asList(ref1,alt1,alt3));
        site2Eval.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt1)));
        site2Comp.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt3)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt1)));

        // site 3: eval only
        GenomeLoc loc3 = genomeLocParser.createGenomeLoc("chr1",3,3);
        VariantContextBuilder site3Eval = new VariantContextBuilder();
        VariantContextBuilder site3Comp = new VariantContextBuilder();
        site3Eval.loc(loc3.getContig(),loc3.getStart(),loc3.getStop());
        site3Comp.loc(loc3.getContig(),loc3.getStart(),loc3.getStop());
        site3Eval.alleles(Arrays.asList(ref1,alt1));
        site3Comp.alleles(Arrays.asList(ref1,alt1));
        site3Eval.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt1)));
        site3Comp.genotypes(GenotypeBuilder.create("test2_sample1",new ArrayList<Allele>(0)),GenotypeBuilder.create("test2_sample2",new ArrayList<Allele>(0)));

        // site 4: comp only - monomorphic
        GenomeLoc loc4 = genomeLocParser.createGenomeLoc("chr1",4,4);
        VariantContextBuilder site4Eval = new VariantContextBuilder();
        VariantContextBuilder site4Comp = new VariantContextBuilder();
        site4Eval.loc(loc4.getContig(),loc4.getStart(),loc4.getStop());
        site4Comp.loc(loc4.getContig(),loc4.getStart(),loc4.getStop());
        site4Eval.alleles(Arrays.asList(ref1,alt1));
        site4Comp.alleles(Arrays.asList(ref1,alt1));
        site4Eval.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,ref1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,ref1)));
        site4Comp.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt1)));

        // site 5: overlapping
        GenomeLoc loc5 = genomeLocParser.createGenomeLoc("chr1",5,5);
        VariantContextBuilder site5Eval = new VariantContextBuilder();
        VariantContextBuilder site5Comp = new VariantContextBuilder();
        site5Eval.loc(loc5.getContig(),loc5.getStart(),loc5.getStop());
        site5Comp.loc(loc5.getContig(),loc5.getStart(),loc5.getStop());
        site5Eval.alleles(Arrays.asList(ref1,alt1,alt3));
        site5Comp.alleles(Arrays.asList(ref1,alt1,alt3));
        site5Eval.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(alt1,alt3)));
        site5Comp.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(alt1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(alt3,alt3)));

        // site 6: some non-matching alts
        GenomeLoc loc6 = genomeLocParser.createGenomeLoc("chr1",6,6);
        VariantContextBuilder site6Eval = new VariantContextBuilder();
        VariantContextBuilder site6Comp = new VariantContextBuilder();
        site6Eval.loc(loc6.getContig(),loc6.getStart(),loc6.getStop());
        site6Comp.loc(loc6.getContig(),loc6.getStart(),loc6.getStop());
        site6Eval.alleles(Arrays.asList(ref1,alt1,alt2));
        site6Comp.alleles(Arrays.asList(ref1,alt1,alt3));
        site6Eval.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt2)));
        site6Comp.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt3)));

        // site 7: matching with no-calls
        GenomeLoc loc7 = genomeLocParser.createGenomeLoc("chr1",7,7);
        VariantContextBuilder site7Eval = new VariantContextBuilder();
        VariantContextBuilder site7Comp = new VariantContextBuilder();
        site7Eval.loc(loc7.getContig(),loc7.getStart(),loc7.getStop());
        site7Comp.loc(loc7.getContig(),loc7.getStart(),loc7.getStop());
        site7Eval.alleles(Arrays.asList(ref1,alt1));
        site7Comp.alleles(Arrays.asList(ref1,alt1));
        site7Eval.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(Allele.NO_CALL,Allele.NO_CALL)));
        site7Comp.genotypes(GenotypeBuilder.create("test2_sample1",Arrays.asList(ref1,alt1)),GenotypeBuilder.create("test2_sample2",Arrays.asList(ref1,alt1)));
View Full Code Here

        // start constructing the resulting VC
        final GenomeLocParser genomeLocParser = this.genomeLocParser != null || refContext == null ? this.genomeLocParser : refContext.getGenomeLocParser();
        if (genomeLocParser == null)
            throw new IllegalStateException("this UG engine was created without a valid genomeLocParser and no refContext was provided");
        final GenomeLoc loc = genomeLocParser.createGenomeLoc(vc);
        final List<Allele> outputAlleles = outputAlternativeAlleles.outputAlleles(vc.getReference());
        final VariantContextBuilder builder = new VariantContextBuilder(callSourceString(), loc.getContig(), loc.getStart(), loc.getStop(), outputAlleles);

        // Seems that when log10PError is 0.0, you must pass -0.0 to get a nice output at the other end otherwise is a "-0".
        // Truth is that this should be fixed in the "variant" dependency code but perhaps it can be amended also in the VariantContextWriter.
        //TODO Please remove this comment when this has been fixed (PT https://www.pivotaltracker.com/story/show/69492530)
        //TODO and change the code below accordingly.
View Full Code Here

            final Map<Allele, List<Haplotype>> alleleMapper,
            final ReadLikelihoods<Allele> readAlleleLikelihoodsForGenotyping,
            final VariantContext call) {

        final ReadLikelihoods<Allele> readAlleleLikelihoodsForAnnotations;
        final GenomeLoc loc = genomeLocParser.createGenomeLoc(call);

        // We can reuse for annotation the likelihood for genotyping as long as there is no contamination filtering
        // or the user want to use the contamination filtered set for annotations.
        // Otherwise (else part) we need to do it again.
        if (configuration.USE_FILTERED_READ_MAP_FOR_ANNOTATIONS || !configuration.isSampleContaminationPresent()) {
View Full Code Here

    }

    @Override
    public ArrayList<Integer> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
        ArrayList<Integer> result = new ArrayList<Integer>(2);
        GenomeLoc currentLocus = ref.getLocus();
        tallyUncoveredBases(currentLocus);
        previousLocus = currentLocus;
        result.add(context.getBasePileup().getReads().size()); // I want the reads instead of the base pileup because I want to count deletions.
        if (calculateFilteredDistribution)
            result.add(context.getBasePileup().getBaseAndMappingFilteredPileup(minBaseQuality, minMappingQuality).getReads().size()); // filtered pileup
View Full Code Here

     *
     * takes into account that the traversal may have been due over a set of intervals, or over the whole genome.
     */
    private void tallyUncoveredBasesTillEndOfTraversal() {
        GenomeLocParser parser = getToolkit().getGenomeLocParser();
        GenomeLoc lastLocus;
        if (intervalList.isEmpty()) { // whole genome, add up all contigs past previousLocus
            final int lastContigIndex = getToolkit().getSAMFileHeader().getSequenceDictionary().size() - 1;
            final int lastContigLength = getToolkit().getSAMFileHeader().getSequence(lastContigIndex).getSequenceLength();
            final String lastContigName = getToolkit().getSAMFileHeader().getSequence(lastContigIndex).getSequenceName();
            lastLocus = parser.createGenomeLoc(lastContigName, lastContigIndex, lastContigLength, lastContigLength);
        } else {
            GenomeLoc lastInterval = intervalList.getLast();
            lastLocus = parser.createGenomeLoc(lastInterval.getContig(), lastInterval.getContigIndex(), lastInterval.getStop(), lastInterval.getStop());
        }
        tallyUncoveredBases(lastLocus);
    }
View Full Code Here

    private void tallyUncoveredBases(GenomeLoc currentLocus) {
        long distance = 0;
        if (previousLocus == null) { // first base visited
            GenomeLocParser parser = getToolkit().getGenomeLocParser();
            if (intervalList.isEmpty()) { // if this is whole genome (no intervals requested), add what we missed.
                final GenomeLoc zeroLoc = parser.createGenomeLoc(getToolkit().getSAMFileHeader().getSequence(0).getSequenceName(), 0, 1, 1);
                distance += currentLocus.distanceAcrossContigs(zeroLoc, getToolkit().getSAMFileHeader());
            } else { // if we are running on an interval list, add all intervals before the current locus to the uncovered bases counter
                while (!intervalList.peek().containsP(currentLocus)) {
                    GenomeLoc interval = intervalList.removeFirst();
                    distance += interval.size();
                }
                distance += currentLocus.getStart() - intervalList.peek().getStart(); // now this is the interval that contains the current locus. Discount the bases from the beginning.
            }
        } else {
            final GenomeLoc previousInterval = intervalList.peekFirst()// peekFirst returns null if interval list is empty (WGS).
            distance = currentLocus.distanceAcrossContigs(previousLocus, getToolkit().getSAMFileHeader()) - 1;
            if (previousInterval != null && !previousInterval.containsP(currentLocus)) {
                intervalList.removeFirst(); // we're done with the previous interval
                final GenomeLoc currentInterval = intervalList.peekFirst();
                distance -= currentInterval.distanceAcrossContigs(previousInterval, getToolkit().getSAMFileHeader()) - 1;
            }
        }

        uncoveredBases += distance;
    }
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.