Examples of GATKFeature


Examples of org.broadinstitute.gatk.engine.refdata.utils.GATKFeature

     * curr_position <= max_position, as well as that we are still on the same contig.
     */
    private void purgeOutOfScopeRecords() {
        Iterator<GATKFeature> i = records.iterator();
        while ( i.hasNext() ) {
            GATKFeature r = i.next();
            if ( r.getLocation().getStop() < curr_position ) {
                i.remove(); // we moved past the end of interval the record r is associated with, purge the record forever
            }
        }

    }
View Full Code Here

Examples of org.broadinstitute.gatk.engine.refdata.utils.GATKFeature

        // the following is a trick: we would like the iterator to know the actual name assigned to
        // the ROD implementing object we are working with. But the only way to do that is to
        // get an instance of that ROD and query it for its name. Now, the only generic way we have at this point to instantiate
        // the ROD is to make the underlying stream iterator to do it for us. So we are reading (or rather peeking into)
        // the first line of the track data file just to get the ROD object created.
        GATKFeature r = null;
        if (this.it.hasNext()) r = this.it.element();
        name = (r==null?null:r.getName());

        curr_contig = referenceDictionary.getSequence(0).getSequenceName();
    }
View Full Code Here

Examples of org.broadinstitute.gatk.engine.refdata.utils.GATKFeature

        // sorry, next reference position is not covered by the RODs we are currently holding. In this case,
        // the location we will jump to upon next call to next() is the start of the next ROD record that we did
        // not read yet:
        if ( it.hasNext() ) {
            GATKFeature r = it.element(); // peek, do not load!
            return parser.createGenomeLoc(r.getLocation().getContig(),r.getLocation().getStart());
        }
        return null; // underlying iterator has no more records, there is no next location!
    }
View Full Code Here

Examples of org.broadinstitute.gatk.engine.refdata.utils.GATKFeature

             purgeOutOfScopeRecords();
         } else {
             // ooops, we are past the end of all loaded records - kill them all at once,
             // load next record and reinitialize by fastforwarding current position to the start of next record
             records.clear();
             GATKFeature r = it.next(); // if hasNext() previously returned true, we are guaranteed that this call to reader.next() is safe
             records.add( r );
             curr_contig = r.getLocation().getContig();
             curr_position = r.getLocation().getStart();
             max_position = r.getLocation().getStop();
         }

         // current position is ste and at this point 'records' only keeps those annotations, on which we did not reach the end yet
         // (we might have reloaded records completely if it was necessary); but we are not guaranteed yet that we
         // hold ALL the records overlapping with the current position. Time to check if we just walked into the interval(s)
         // covered by new records, so we need to load them too:

         while ( it.hasNext() ) {
             GATKFeature r = it.element();
             if ( r == null ) {
                 it.next();
                 continue;
             }

             GenomeLoc currentContig = parser.createOverEntireContig(curr_contig);
             GenomeLoc thatContig = r.getLocation();

             if ( currentContig.isPast(thatContig) )
                 throw new UserException("LocationAwareSeekableRODIterator: contig " +r.getLocation().getContig() +
                         " occurs out of order in track " + r.getName() );
             if ( currentContig.isBefore(thatContig) ) break; // next record is on a higher contig, we do not need it yet...

             if ( r.getLocation().getStart() < curr_position )
                 throw new UserException("LocationAwareSeekableRODIterator: track "+r.getName() +
                         " is out of coordinate order on contig "+r.getLocation() + " compared to " + curr_contig + ":" + curr_position);

             if ( r.getLocation().getStart() > curr_position ) break; // next record starts after the current position; we do not need it yet

             r = it.next(); // we got here only if we do need next record, time to load it for real

             int stop = r.getLocation().getStop();
             if ( stop < curr_position ) throw new ReviewedGATKException("DEBUG: encountered contig that should have been loaded earlier"); // this should never happen
             if ( stop > max_position ) max_position = stop; // max_position keeps the rightmost stop position across all loaded records
             records.add(r);
         }
View Full Code Here

Examples of org.broadinstitute.gatk.engine.refdata.utils.GATKFeature

        }

        // curr_contig and curr_position are set to where we asked to scroll to

        while ( it.hasNext() ) {
            GATKFeature r = it.next();
            if ( r == null ) continue;

            GenomeLoc currentContig = parser.createOverEntireContig(curr_contig);
            GenomeLoc thatContig = r.getLocation();

            if ( currentContig.isPast(thatContig) ) continue; // did not reach requested contig yet
            if ( currentContig.isBefore(thatContig) ) {
                it.pushback(r); // next record is on the higher contig, we do not need it yet...
                break;
            }

            // we get here if we are on the requested contig:

            if ( r.getLocation().getStop() < curr_position ) continue; // did not reach the requested interval yet

            if ( r.getLocation().getStart() > curr_query_end ) {
                // past the query interval
                it.pushback(r);
                break;
            }

            // we get here only if interval of the record r overlaps with query interval, so the record should be loaded
            if ( r.getLocation().getStop() > max_position ) max_position = r.getLocation().getStop();
            records.add(r);
        }

        if ( records.size() > 0 ) {
            return new RODRecordListImpl(name,records,interval);
View Full Code Here

Examples of org.broadinstitute.gatk.engine.refdata.utils.GATKFeature

    @Requires("loc != null")
    @Ensures("currentFeatures.size() <= old(currentFeatures.size())")
    public void trimCurrentFeaturesToLoc(final GenomeLoc loc) {
        final ListIterator<GATKFeature> it = currentFeatures.listIterator();
        while ( it.hasNext() ) {
            final GATKFeature feature = it.next();
            if ( feature.getLocation().isBefore(loc) )
                it.remove();
        }
    }
View Full Code Here

Examples of org.broadinstitute.gatk.engine.refdata.utils.GATKFeature

            // Note that we should really use some sort of seekable iterator here so that the search doesn't take forever
            // (but it's complicated because the hapmap location doesn't match the dbsnp location, so we don't know where to seek to)
        }

        while ( dbsnpIterator.hasNext() ) {
            GATKFeature feature = dbsnpIterator.next();
            VariantContext vc = (VariantContext)feature.getUnderlyingObject();
            if ( vc.getID().equals(rsID) )
                return vc;
        }

        return null;
View Full Code Here

Examples of org.broadinstitute.gatk.engine.refdata.utils.GATKFeature

            return ! gatkFeatures.isEmpty();
        }

        @Override
        public RODRecordList next() {
            final GATKFeature first = gatkFeatures.poll();
            final Collection<GATKFeature> myFeatures = new LinkedList<GATKFeature>();
            myFeatures.add(first);
            while ( gatkFeatures.peek() != null && gatkFeatures.peek().getLocation().getStart() == first.getStart() )
                myFeatures.add(gatkFeatures.poll());

            GenomeLoc loc = first.getLocation();
            for ( final GATKFeature feature : myFeatures )
                loc = loc.merge(feature.getLocation());

            return new RODRecordListImpl(name, myFeatures, loc); // is this safe?
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.