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(); } }
/** * * @param featureFile - path to a feature file. Can be a local file, http url, or ftp url * @param codec * @throws IOException */ public TabixFeatureReader(final String featureFile, final AsciiFeatureCodec codec) throws IOException { super(featureFile, codec); tabixReader = new TabixReader(featureFile); sequenceNames = new ArrayList<String>(tabixReader.getChromosomes()); readHeader(); }
/** * * @param featureFile - path to a feature file. Can be a local file, http url, or ftp url * @param indexFile - path to the index file. * @param codec * @throws IOException */ public TabixFeatureReader(final String featureFile, final String indexFile, final AsciiFeatureCodec codec) throws IOException { super(featureFile, codec); tabixReader = new TabixReader(featureFile, indexFile); sequenceNames = new ArrayList<String>(tabixReader.getChromosomes()); readHeader(); }
/** * @param featureFile path to a feature file. Can be a local file, http url, or ftp url * @param indexFile path to the index file. * @param wrapper a wrapper to apply to the byte stream from the featureResource allowing injecting features * like caching and prefetching of the stream, may be null, will only be applied if featureFile * is a uri representing a {@link java.nio.file.Path} * @param indexWrapper a wrapper to apply to the byte stream from the indexResource, may be null, will only be * applied if indexFile is a uri representing a {@link java.nio.file.Path} */ public TabixFeatureReader(final String featureFile, final String indexFile, final AsciiFeatureCodec codec, final Function<SeekableByteChannel, SeekableByteChannel> wrapper, final Function<SeekableByteChannel, SeekableByteChannel> indexWrapper) throws IOException { super(featureFile, codec, wrapper, indexWrapper); tabixReader = new TabixReader(this.path, indexFile, wrapper, indexWrapper); sequenceNames = new ArrayList<>(tabixReader.getChromosomes()); readHeader(); }
/** * @param featureFile path to a feature file. Can be a local file, http url, or ftp url * @param indexFile path to the index file. * @param wrapper a wrapper to apply to the byte stream from the featureResource allowing injecting features * like caching and prefetching of the stream, may be null, will only be applied if featureFile * is a uri representing a {@link java.nio.file.Path} * @param indexWrapper a wrapper to apply to the byte stream from the indexResource, may be null, will only be * applied if indexFile is a uri representing a {@link java.nio.file.Path} */ public TabixFeatureReader(final String featureFile, final String indexFile, final AsciiFeatureCodec codec, final Function<SeekableByteChannel, SeekableByteChannel> wrapper, final Function<SeekableByteChannel, SeekableByteChannel> indexWrapper) throws IOException { super(featureFile, codec, wrapper, indexWrapper); tabixReader = new TabixReader(this.path, indexFile, wrapper, indexWrapper); sequenceNames = new ArrayList<>(tabixReader.getChromosomes()); readHeader(); }
@Test public void testSequenceSet() { Set<String> chroms= tabixReader.getChromosomes(); Assert.assertFalse(chroms.isEmpty()); Assert.assertTrue(chroms.contains("1")); Assert.assertFalse(chroms.contains("MT")); }
@BeforeClass public void setup() throws IOException { tabixReader = new TabixReader(tabixFile); sequenceNames = new ArrayList<String>(tabixReader.getChromosomes()); }