/** * 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); }