/** * Returns an iterator for BigWig values for all chromosome regions. * <p/> * Note: the BBFile type should be BigWig; 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 BigWig.(see isBigWigFile method) */ public BigWigIterator getBigWigIterator() { if (!isBigWigFile()) return null; // get all regions bounds RPChromosomeRegion selectionRegion = chromosomeDataTree.getChromosomeBounds(); // compose an iterator boolean contained = true; // all regions are contained BigWigIterator wigIterator = new BigWigIterator(fis, chromosomeIDTree, chromosomeDataTree, selectionRegion, contained); return wigIterator; }
/** * Returns an iterator for BigWig values for all chromosome regions. * <p/> * Note: the BBFile type should be BigWig; 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 BigWig.(see isBigWigFile method) */ public BigWigIterator getBigWigIterator() { if (!isBigWigFile()) return null; // get all regions bounds RPChromosomeRegion selectionRegion = chromosomeDataTree.getChromosomeBounds(); // compose an iterator boolean contained = true; // all regions are contained BigWigIterator wigIterator = new BigWigIterator(fis, chromosomeIDTree, chromosomeDataTree, selectionRegion, contained); return wigIterator; }
public BigWigDataSource(URI uri) throws IOException { bbReader = new BBFileReader(NetworkUtils.getNeatPathFromURI(uri), new TribbleStream(uri)); if (!bbReader.isBigWigFile()) { throw new IOException("Input is not a BigWig file."); } }
public BigWigDataSource(BBFileReader reader, Genome genome) throws IOException { super(genome); this.reader = reader; this.levels = reader.getZoomLevels(); this.wholeGenomeScores = new HashMap<>(); if (reader.isBigWigFile()) initMinMax(); // Assume 1000 pixel screen, pick visibility level to be @ highest resolution zoom. // TODO -- something smarter, like scaling by actual density if (levels != null && levels.getZoomHeaderCount() > 0) { BBZoomLevelHeader firstLevel = levels.getZoomLevelHeaders().get(0); // Highest res featureVisiblityWindow = firstLevel.getReductionLevel() * 2000; } if (genome != null) { Collection<String> chrNames = reader.getChromosomeNames(); for (String chr : chrNames) { String igvChr = genome.getCanonicalChrName(chr); if (igvChr != null && !igvChr.equals(chr)) { chrNameMap.put(igvChr, chr); } } } bedCodec = new IGVBEDCodec(genome); }
if (!isBigWigFile()) return null;
if (!isBigWigFile()) return null;
if (!isBigWigFile()) 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 initRegionFromBigWig(String bigWigFile) throws IOException{ BBFileReader reader= new BBFileReader(bigWigFile); if(! reader.isBigWigFile()){ System.err.println("File " + bigWigFile + " is not bigWig."); throw new RuntimeException(); } String region= reader.getChromosomeNames().get(0); // Just get chrom to start with for(String chrom : reader.getChromosomeNames()){ BigWigIterator iter = reader.getBigWigIterator(chrom, 0, chrom, Integer.MAX_VALUE, false); if(iter.hasNext()){ WigItem x = iter.next(); region= x.getChromosome() + ":" + (x.getStartBase() + 1); reader.close(); return region; } } reader.close(); return region; }