public static TDFReader getReader(ResourceLocator locator) { return new TDFReader(locator); }
public static TDFReader getReader(URI uri) throws IOException { return new TDFReader(uri); }
private String getAttributesFromTDF(String attr){ String path= this.getWorkFilename(); try{ ResourceLocator resourceLocator= new ResourceLocator(path); TDFReader reader= new TDFReader(resourceLocator); TDFGroup rootGroup= reader.getGroup("/"); return rootGroup.getAttribute(attr); } catch(Exception e){ return null; } }
@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; }
private void tstCountWindowFunctions(String inputFile, String chr, Iterable<WindowFunction> windowFunctions) throws Exception { String outputFile = TestUtils.TMP_OUTPUT_DIR + "testCountWindowFunctions.tdf"; String wfs = ""; for (WindowFunction wf : windowFunctions) { wfs += wf.name() + ","; } wfs = wfs.substring(0, wfs.lastIndexOf(",")); String[] cmd = {"count", "--windowFunctions", wfs, inputFile, outputFile, hg18id}; igvTools.run(cmd); TDFReader reader = new TDFReader(new ResourceLocator(outputFile)); for (WindowFunction wf : windowFunctions) { TDFDataset ds = reader.getDataset(chr, 0, wf); assertNotNull(ds); } }
@Test public void testReader() throws Exception { String url = "http://data.broadinstitute.org/igvdata/encode/hg18/broadHistone/SignalK562H3k4me3.tdf"; TDFReader reader = new TDFReader(new ResourceLocator(url)); int version = reader.getVersion(); assertEquals(3, version); assertTrue(reader.compressed); String [] trackNames = reader.getTrackNames(); int nTracks = trackNames.length; assertEquals(1, nTracks); String trackName = trackNames[0]; assertEquals(trackName, "SignalK562H3k4me3.wig.gz"); Set<String> chrNames = reader.getChromosomeNames(); int nChromosomes = chrNames.size(); assertEquals(24, nChromosomes); String datasetName = "/chr1/z0/mean"; TDFDataset dataset = reader.getDataset(datasetName); assertEquals(datasetName, dataset.getName()); TDFTile tile = reader.readTile(dataset, 0); assertNotNull(tile); } }
TDFReader reader = new TDFReader(new ResourceLocator(testFile)); TDFDataSource ds = new TDFDataSource(reader, 0, "", genome);