public Collection<RODRecordList> allElementsLTE(RODRecordList elt) { return allElementsLTE(elt, true); }
public boolean hasNext() { if ( ! rodQueue.hasNext() ) return false; else { return ! rodQueue.peekLocation().isPast(locus); } }
public RODMergingIterator(Collection<Iterator<RODRecordList>> its) { for ( Iterator<RODRecordList> it : its ) { add(it); } }
public Collection<RODRecordList> allElementsLTE(RODRecordList elt, boolean includeElt) { LinkedList<RODRecordList> all = new LinkedList<RODRecordList>(); if ( includeElt ) all.add(elt); while ( hasNext() ) { Element x = queue.peek(); //System.out.printf("elt.compareTo(x) == %d%n", elt.compareTo(x)); //System.out.printf("In allElementLTE%n"); int cmp = elt.getLocation().compareTo(x.nextLoc); //System.out.printf("x=%s%n elt=%s%n => elt.compareTo(x) == %d%n", x, elt, cmp); if ( cmp >= 0 ) { //System.out.printf(" Adding element x=%s, size = %d%n", x, all.size()); all.add(next()); //System.out.printf(" Added size = %d%n", all.size()); } else { //System.out.printf("breaking...%n"); break; } } return all; }
/** * Returns the next covered locus context in the shard. * @return Next covered locus context in the shard. * @throw NoSuchElementException if no such element exists. */ public AlignmentContext next() { if ( DEBUG ) System.out.printf("In RodLocusView.next()...%n"); RODRecordList datum = rodQueue.next(); if ( DEBUG ) System.out.printf("In RodLocusView.next(); datum = %s...%n", datum.getLocation()); if ( DEBUG ) System.out.printf("In RodLocusView.next(): creating tracker...%n"); allTracksHere = getSpanningTracks(datum); GenomeLoc rodSite = datum.getLocation(); GenomeLoc site = genomeLocParser.createGenomeLoc( rodSite.getContig(), rodSite.getStart(), rodSite.getStart()); if ( DEBUG ) System.out.printf("rodLocusView.next() is at %s%n", site); // calculate the number of skipped bases, and update lastLoc so we can do that again in the next() long skippedBases = getSkippedBases( rodSite ); lastLoc = site; return new AlignmentContext(site, new ReadBackedPileupImpl(site), skippedBases); }
/** * Create a new view of reference-ordered data. * * @param provider */ public RodLocusView( LocusShardDataProvider provider ) { super(provider); GenomeLoc loc = provider.getLocus(); List< Iterator<RODRecordList> > iterators = new LinkedList< Iterator<RODRecordList> >(); for( ReferenceOrderedDataSource dataSource: provider.getReferenceOrderedData() ) { if ( DEBUG ) System.out.printf("Shard is %s%n", provider.getLocus()); // grab the ROD iterator from the data source, and compute the first location in this shard, forwarding // the iterator to immediately before it, so that it can be added to the merging iterator primed for // next() to return the first real ROD in this shard LocationAwareSeekableRODIterator it = dataSource.seek(provider.getLocus()); it.seekForward(genomeLocParser.createGenomeLoc(loc.getContig(), loc.getStart()-1)); states.add(new ReferenceOrderedDataState(dataSource,it)); // we need to special case the interval so we don't always think there's a rod at the first location if ( dataSource.getName().equals(INTERVAL_ROD_NAME) ) { if ( interval != null ) throw new RuntimeException("BUG: interval local variable already assigned " + interval); interval = it.next(); } else { iterators.add( it ); } } rodQueue = new RODMergingIterator(iterators); }
private Collection<RODRecordList> getSpanningTracks(RODRecordList marker) { return rodQueue.allElementsLTE(marker); }
public RODMergingIterator(Iterator<RODRecordList> it) { add(it); }