public int setSelectionRegion(RPChromosomeRegion selectionRegion, boolean contained) { this.selectionRegion = selectionRegion; this.contained = contained; // set up hit list and first data block read leafHitList = null; // Must nullify existing hit list first! int hitCount = getHitRegion(selectionRegion, contained); if(hitCount == 0) // no hits - no point in fetching data throw new RuntimeException("No wig data found in the selection region"); // Ready for next() data extraction return hitCount; }
public int setSelectionRegion(RPChromosomeRegion selectionRegion, boolean contained) { this.selectionRegion = selectionRegion; this.contained = contained; // set up hit list and first data block read leafHitList = null; // Must nullify existing hit list first! int hitCount = getHitRegion(selectionRegion, contained); if(hitCount == 0) // no hits - no point in fetching data throw new RuntimeException("No wig data found in the selection region"); // Ready for next() data extraction return hitCount; }
int hitCount = getHitRegion(selectionRegion, contained); if(hitCount == 0) // no hits - no point in fetching data empty = true;
int hitCount = getHitRegion(selectionRegion, contained); if(hitCount == 0) // no hits - no point in fetching data empty = true;
private int getHitRegion(RPChromosomeRegion hitRegion, boolean contained) { int hitCount = 0; // check if new hit list is needed if(leafHitList == null){ hitCount = getHitList(hitRegion, contained); if(hitCount == 0) return 0; // no hit data found } else { hitCount = leafHitList.size() - leafItemIndex; if(hitCount == 0) return 0; // hit list exhausted } // Perform a block read for starting base of selection region - use first leaf hit dataBlockRead = getDataBlock(leafItemIndex++); // try next item - probably intersection issue // Note: recursive call until a block is valid or hit list exhuasted if(!dataBlockRead) hitCount = getHitRegion(hitRegion, contained); return hitCount; }
private int getHitRegion(RPChromosomeRegion hitRegion, boolean contained) { int hitCount = 0; // check if new hit list is needed if(leafHitList == null){ hitCount = getHitList(hitRegion, contained); if(hitCount == 0) return 0; // no hit data found } else { hitCount = leafHitList.size() - leafItemIndex; if(hitCount == 0) return 0; // hit list exhausted } // Perform a block read for starting base of selection region - use first leaf hit dataBlockRead = getDataBlock(leafItemIndex++); // try next item - probably intersection issue // Note: recursive call until a block is valid or hit list exhuasted if(!dataBlockRead) hitCount = getHitRegion(hitRegion, contained); return hitCount; }
/** * Method returns the current bed feature and advances to the next bed record. * * Returns: * Bed feature for current BigBed data record. * * Note: If "next" method is called when a "next item" does not exist, * an UnsupportedOperationException will be thrown. */ public BedFeature next() { // Is there a need to fetch next data block? if(bedFeatureIndex < bedFeatureList.size()) return(bedFeatureList.get(bedFeatureIndex++)); // attempt to get next leaf item data block else { int nHits = getHitRegion(selectionRegion, contained); if(nHits > 0){ // Note: getDataBlock initializes bed feature index to 0 return(bedFeatureList.get(bedFeatureIndex++)); // return 1st Data Block item } else{ String result = String.format("Failed to find data for bed region (%d,%d,%d,%d)\n", hitRegion.getStartChromID(), hitRegion.getStartBase(), hitRegion.getEndChromID(), hitRegion.getEndBase()); log.error(result); return null; //throw new NoSuchElementException(result); } } }
/** * Method returns the current bed feature and advances to the next bed record. * * Returns: * Bed feature for current BigBed data record. * * Note: If "next" method is called when a "next item" does not exist, * an UnsupportedOperationException will be thrown. */ public BedFeature next() { // Is there a need to fetch next data block? if(bedFeatureIndex < bedFeatureList.size()) return(bedFeatureList.get(bedFeatureIndex++)); // attempt to get next leaf item data block else { int nHits = getHitRegion(selectionRegion, contained); if(nHits > 0){ // Note: getDataBlock initializes bed feature index to 0 return(bedFeatureList.get(bedFeatureIndex++)); // return 1st Data Block item } else{ String result = String.format("Failed to find data for bed region (%d,%d,%d,%d)\n", hitRegion.getStartChromID(), hitRegion.getStartBase(), hitRegion.getEndChromID(), hitRegion.getEndBase()); log.error(result); return null; //throw new NoSuchElementException(result); } } }