@Override public Set<String> getReferenceNames() { Set<String> result = new HashSet<String>(); for (String chr: bbReader.getChromosomeNames()) { result.add(chr); } return result; }
private void init(Genome genome) { chrNameMap = new HashMap<String, String>(); if (genome != null) { Collection<String> seqNames = reader.getChromosomeNames(); if (seqNames != null) for (String seqName : seqNames) { String igvChr = genome.getCanonicalChrName(seqName); if (igvChr != null && !igvChr.equals(seqName)) { chrNameMap.put(igvChr, seqName); } } } }
public Set<String> getChromosomes() { if(this.tabixReader != null && this.bigBedReader == null){ return this.tabixReader.getChromosomes(); } else if(this.tabixReader == null && this.bigBedReader != null){ return new HashSet<String>(this.bigBedReader.getChromosomeNames()); } else{ System.err.println("Tabix and bigBed readers cannto be both set. One must be null."); throw new RuntimeException(); } }
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; }
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; }
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); }
int maxChromId = reader.getChromosomeNames().size() - 1; String firstChr = reader.getChromsomeFromId(0); String lastChr = reader.getChromsomeFromId(maxChromId);
@Override public List<String> getChromosomeNames(){ if(this.getTrackFormat().equals(TrackFormat.TDF)){ ResourceLocator resourceLocator= new ResourceLocator(this.getWorkFilename()); TDFReader reader= new TDFReader(resourceLocator); List<String> chroms= new ArrayList<String>(reader.getChromosomeNames()); if(chroms.get(0).equals("All")){ chroms.remove(0); } return chroms; // chroms.addAll(); } if(this.getTrackFormat().equals(TrackFormat.BEDGRAPH)){ TabixIndex tbi= (TabixIndex) IndexFactory.loadIndex(this.getWorkFilename() + TabixUtils.STANDARD_INDEX_EXTENSION); return tbi.getSequenceNames(); } if(this.getTrackFormat().equals(TrackFormat.BIGWIG)){ return this.bigWigReader.getChromosomeNames(); } return null; }
@Test public void canReadBigWigFromRemote() throws IOException{ // String urlStr= "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeHaibTfbs/wgEncodeHaibTfbsA549Atf3V0422111Etoh02RawRep1.bigWig"; String urlStr= "http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeHaibTfbs/wgEncodeHaibTfbsA549Cebpbsc150V0422111RawRep1.bigWig"; BBFileReader reader=new BBFileReader(urlStr); System.out.println(reader.getChromosomeNames()); BigWigIterator iter = reader.getBigWigIterator("chr1", 1000000, "chr1", 2000000, true); while(iter.hasNext()){ System.out.println(iter.next().getStartBase()); } System.out.println("NEW"); iter = reader.getBigWigIterator("chr10", 1000000, "chr10", 2000000, true); while(iter.hasNext()){ System.out.println(iter.next().getStartBase()); } reader.close(); }
List<String> chrNames = reader.getChromosomeNames(); for (String chr : chrNames) { BigWigIterator iter = reader.getBigWigIterator(chr, 0, chr, Integer.MAX_VALUE, false);