/** * Returns an iterator for BigBed features for all chromosome regions. * <p/> * Note: the BBFile type should be BigBed; else a null iterator is returned. * <p/> * Returns: * Iterator to provide BedFeature(s) for all chromosome regions. * Error conditions: * 1) An empty iterator is returned if region has no data available * 2) A null object is returned if the file is not BigBed.(see isBigBedFile method) */ public BigBedIterator getBigBedIterator() { if (!isBigBedFile()) return null; // get all region bounds RPChromosomeRegion selectionRegion = chromosomeDataTree.getChromosomeBounds(); // compose an iterator boolean contained = true; /// all regions are contained BigBedIterator bedIterator = new BigBedIterator(fis, chromosomeIDTree, chromosomeDataTree, selectionRegion, contained); return bedIterator; }
/** * Returns an iterator for BigBed features for all chromosome regions. * <p/> * Note: the BBFile type should be BigBed; else a null iterator is returned. * <p/> * Returns: * Iterator to provide BedFeature(s) for all chromosome regions. * Error conditions: * 1) An empty iterator is returned if region has no data available * 2) A null object is returned if the file is not BigBed.(see isBigBedFile method) */ public BigBedIterator getBigBedIterator() { if (!isBigBedFile()) return null; // get all region bounds RPChromosomeRegion selectionRegion = chromosomeDataTree.getChromosomeBounds(); // compose an iterator boolean contained = true; /// all regions are contained BigBedIterator bedIterator = new BigBedIterator(fis, chromosomeIDTree, chromosomeDataTree, selectionRegion, contained); return bedIterator; }
String endChromosome, int endBase, boolean contained) { if (!isBigBedFile()) return null;
String endChromosome, int endBase, boolean contained) { if (!isBigBedFile()) return null;
String endChromosome, int endBase, boolean contained) { if (!isBigBedFile()) return null;
public void loadBWFile(ResourceLocator locator, List<Track> newTracks, Genome genome) throws IOException { String trackName = locator.getTrackName(); String trackId = locator.getPath(); String path = locator.getPath(); BBFileReader reader = new BBFileReader(path); BigWigDataSource bigwigSource = new BigWigDataSource(reader, genome); if (reader.isBigWigFile()) { DataSourceTrack track = new DataSourceTrack(locator, trackId, trackName, bigwigSource); newTracks.add(track); } else if (reader.isBigBedFile()) { if (locator.getPath().contains("RRBS_cpgMethylation") || locator.getPath().contains("BiSeq_cpgMethylation") || (reader.getAutoSql() != null && reader.getAutoSql().startsWith("table BisulfiteSeq"))) { loadMethylTrack(locator, reader, newTracks, genome); } else { FeatureTrack track = new FeatureTrack(locator, trackId, trackName, bigwigSource); newTracks.add(track); } } else { throw new RuntimeException("Unknown BIGWIG type: " + locator.getPath()); } }
private static String initRegionFromBigBed(String bigBedFile) throws IOException{ BBFileReader reader= new BBFileReader(bigBedFile); if(! reader.isBigBedFile()){ System.err.println("File " + bigBedFile + " is not bigBed."); throw new RuntimeException(); } String region= reader.getChromosomeNames().get(0); // Just get chrom to start with for(String chrom : reader.getChromosomeNames()){ BigBedIterator iter = reader.getBigBedIterator(chrom, 0, chrom, Integer.MAX_VALUE, false); if(iter.hasNext()){ BedFeature x= (BedFeature) iter.next(); region= x.getChromosome() + ":" + (x.getStartBase() + 1); reader.close(); return region; } } reader.close(); return region; }
protected List<LocusScore> getZoomSummaryScores(String chr, int start, int end, int zoom) { Chromosome c = genome.getChromosome(chr); if (c == null) return null; double nBins = Math.pow(2, zoom); double scale = c.getLength() / (nBins * 700); BBZoomLevelHeader zlHeader = getZoomLevelForScale(scale); if (zlHeader == null) return null; int bbLevel = zlHeader.getZoomLevel(); int reductionLevel = zlHeader.getReductionLevel(); // If we are at the highest precomputed resolution compare to the requested resolution. If they differ // by more than a factor of 2 compute "on the fly" String tmp = chrNameMap.get(chr); String querySeq = tmp == null ? chr : tmp; if (reader.isBigBedFile() || bbLevel > 1 || (bbLevel == 1 && (reductionLevel / scale) < 2)) { ArrayList<LocusScore> scores = new ArrayList(1000); ZoomLevelIterator zlIter = reader.getZoomLevelIterator(bbLevel, querySeq, start, querySeq, end, false); while (zlIter.hasNext()) { ZoomDataRecord rec = zlIter.next(); float v = getValue(rec); BasicScore bs = new BasicScore(rec.getChromStart(), rec.getChromEnd(), v); scores.add(bs); } return scores; } else { // No precomputed scores for this resolution level return null; } }