Package org.broadinstitute.gatk.utils

Examples of org.broadinstitute.gatk.utils.GenomeLoc


     * @param alignmentStart the read's alignment start
     */
    @Test(enabled = true, dataProvider = "reads")
    public void testAddingReads(String cigarString, int alignmentStart) {
        final GATKSAMRecord read = createReadAndAddToBin(cigarString, alignmentStart);
        final GenomeLoc readLoc = parser.createGenomeLoc(read.getReferenceName(), read.getReferenceIndex(), read.getSoftStart(), Math.max(read.getSoftStart(), read.getSoftEnd()));
        Assert.assertEquals(readBin.getLocation(), readLoc);
        readBin.clear();
    }
View Full Code Here


        }
        System.out.printf("%n");
    }

    private static Pair<Byte, Byte> combineBaseProbs(GenomeLocParser genomeLocParser,List<GATKSAMRecord> duplicates, int readOffset, int maxQScore) {
        GenomeLoc loc = genomeLocParser.createGenomeLoc(duplicates.get(0));
        ReadBackedPileup pileup = new ReadBackedPileupImpl(loc, duplicates, readOffset);

        final boolean debug = false;

        // calculate base probs
View Full Code Here

         */
        public static boolean isCodingExon(RODRecordList l) {

            if ( l == null ) return false;

            GenomeLoc loc = l.getLocation();

            for ( GATKFeature t : l ) {
                if ( ((RefSeqFeature)t.getUnderlyingObject()).overlapsCodingP(loc) && ((RefSeqFeature)t.getUnderlyingObject()).overlapsExonP(loc) ) return true;
            }
            return false;
View Full Code Here

        final int nPileupsToGenerate = 100;
        pileups = new ArrayList<ReadBackedPileup>(nPileupsToGenerate);
        SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000);
        GenomeLocParser genomeLocParser;
        genomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
        GenomeLoc loc = genomeLocParser.createGenomeLoc("chr1", 50);
        final int readLen = 100;

        for ( int pileupN = 0; pileupN < nPileupsToGenerate; pileupN++ ) {
            ReadBackedPileup rbp = ArtificialSAMUtils.createReadBackedPileup(header, loc, readLen, insertSize, pileupSize);
            pileups.add(rbp);
View Full Code Here

        // Create location for all haplotypes
        final int startLoc = ref.getWindow().getStart() + startIdxInReference;
        final int stopLoc = startLoc + haplotypeSize-1;

        final GenomeLoc locus = ref.getGenomeLocParser().createGenomeLoc(ref.getLocus().getContig(),startLoc,stopLoc);

        for (final Allele a : alleleList) {

            final byte[] alleleBases = a.getBases();
            // use string concatenation
View Full Code Here

            nextFilePointer = new FilePointer(intervalMergingRule);

            int coveredRegionStart = 1;
            int coveredRegionStop = Integer.MAX_VALUE;
            GenomeLoc coveredRegion = null;

            BAMScheduleEntry scheduleEntry = getNextOverlappingBAMScheduleEntry(currentLocus);

            // No overlapping data at all.
            if(scheduleEntry != null) {
                coveredRegionStart = Math.max(coveredRegionStart,scheduleEntry.start);
                coveredRegionStop = Math.min(coveredRegionStop,scheduleEntry.stop);
                coveredRegion = loci.getGenomeLocParser().createGenomeLoc(currentLocus.getContig(),coveredRegionStart,coveredRegionStop);

                nextFilePointer.addFileSpans(scheduleEntry.fileSpans);
            }
            else {
                // Always create a file span, whether there was covered data or not.  If there was no covered data, then the binTree is empty.
                for(SAMReaderID reader: indexFiles.keySet())
                    nextFilePointer.addFileSpans(reader,new GATKBAMFileSpan());
            }

            // Early exit if no bins were found.
            if(coveredRegion == null) {
                // for debugging only: maximum split is 16384.               
                nextFilePointer.addLocation(currentLocus);
                currentLocus = locusIterator.hasNext() ? locusIterator.next() : null;
                continue;
            }

            // Early exit if only part of the first interval was found.
            if(currentLocus.startsBefore(coveredRegion)) {
                int splitPoint = Math.min(coveredRegion.getStart()-currentLocus.getStart(),16384)+currentLocus.getStart();
                GenomeLoc[] splitContigs = currentLocus.split(splitPoint);
                nextFilePointer.addLocation(splitContigs[0]);
                currentLocus = splitContigs[1];
                continue;
            }

            // Define the initial range of the file pointer, aka the region where the locus currently being processed intersects the BAM list.
            GenomeLoc initialLocation = currentLocus.intersect(coveredRegion);
            nextFilePointer.addLocation(initialLocation);

            // See whether the BAM regions discovered overlap the next set of intervals in the interval list.  If so, include every overlapping interval.
            if(!nextFilePointer.locations.isEmpty()) {
                while(locusIterator.hasNext() && locusIterator.peek().overlapsP(coveredRegion)) {
View Full Code Here

     * @param location the location to try and flash back to
     *
     * @return true if we can, false otherwise
     */
    public boolean canFlashBackTo(GenomeLoc location) {
        GenomeLoc farthestBack = (pastQueue.size() > 0) ? pastQueue.getFirst().getLocation() : iterator.peekNextLocation();
        return (!farthestBack.isPast(location));
    }
View Full Code Here

    public String getTraversalUnits() {
        return "dups";
    }

    private List<GATKSAMRecord> readsAtLoc(final GATKSAMRecord read, PushbackIterator<SAMRecord> iter) {
        GenomeLoc site = engine.getGenomeLocParser().createGenomeLoc(read);
        ArrayList<GATKSAMRecord> l = new ArrayList<GATKSAMRecord>();

        l.add(read);
        for (SAMRecord read2 : iter) {
            GenomeLoc site2 = engine.getGenomeLocParser().createGenomeLoc(read2);

            // the next read starts too late
            if (site2.getStart() != site.getStart()) {
                iter.pushback(read2);
                break;
            } else {
                l.add((GATKSAMRecord) read2);
            }
View Full Code Here

     * @return The list of duplicate reads that read is a member of, or null if it's the only one of its kind
     */
    protected List<GATKSAMRecord> findDuplicateReads(GATKSAMRecord read, Set<List<GATKSAMRecord>> readSets ) {
        if ( read.getReadPairedFlag() ) {
            // paired
            final GenomeLoc readMateLoc = engine.getGenomeLocParser().createGenomeLoc(read.getMateReferenceName(), read.getMateAlignmentStart(), read.getMateAlignmentStart());

            for (List<GATKSAMRecord> reads : readSets) {
                GATKSAMRecord key = reads.get(0);

                // read and key start at the same place, and either the this read and the key
                // share a mate location or the read is flagged as a duplicate
                if ( read.getAlignmentStart() == key.getAlignmentStart() && key.getReadPairedFlag() && ( key.getDuplicateReadFlag() || read.getDuplicateReadFlag() ) ) {
                    // at least one has to be marked as a duplicate
                    final GenomeLoc keyMateLoc = engine.getGenomeLocParser().createGenomeLoc(key.getMateReferenceName(), key.getMateAlignmentStart(), key.getMateAlignmentStart());
                    if ( readMateLoc.compareTo(keyMateLoc) == 0 ) {
                        // we are at the same position as the dup and have the same mat pos, it's a dup
                        if (DEBUG) logger.debug(String.format("  => Adding read to dups list: %s %d %s vs. %s", read, reads.size(), readMateLoc, keyMateLoc));
                        return reads;
                    }
View Full Code Here

         */
        boolean done = walker.isDone();
        for (SAMRecord read : iter) {
            if ( done ) break;
            // get the genome loc from the read
            GenomeLoc site = engine.getGenomeLocParser().createGenomeLoc(read);

            Set<List<GATKSAMRecord>> readSets = uniqueReadSets(readsAtLoc((GATKSAMRecord) read, iter));
            if ( DEBUG ) logger.debug(String.format("*** TraverseDuplicates.traverse at %s with %d read sets", site, readSets.size()));

            // Jump forward in the reference to this locus location
            AlignmentContext locus = new AlignmentContext(site, new ReadBackedPileupImpl(site));

            // update the number of duplicate sets we've seen
            dataProvider.getShard().getReadMetrics().incrementNumIterations();

            // actually call filter and map, accumulating sum
            final boolean keepMeP = walker.filter(site, locus, readSets);
            if (keepMeP) {
                M x = walker.map(site, locus, readSets);
                sum = walker.reduce(x, sum);
            }

            printProgress(site.getStopLocation());
            done = walker.isDone();
        }

        return sum;
    }
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.