Package htsjdk.tribble
Class AbstractFeatureReader<T extends Feature,SOURCE>
- java.lang.Object
-
- htsjdk.tribble.AbstractFeatureReader<T,SOURCE>
-
- All Implemented Interfaces:
FeatureReader<T>
,Closeable
,AutoCloseable
- Direct Known Subclasses:
TabixFeatureReader
,TribbleIndexedFeatureReader
public abstract class AbstractFeatureReader<T extends Feature,SOURCE> extends Object implements FeatureReader<T>
jrobinso the feature reader class, which uses indices and codecs to read in Tribble file formats.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractFeatureReader.ComponentMethods
-
Field Summary
Fields Modifier and Type Field Description static Set<String>
BLOCK_COMPRESSED_EXTENSIONS
Deprecated.since June 2019 useFileExtensions.BLOCK_COMPRESSED
instead.protected FeatureCodec<T,SOURCE>
codec
protected FeatureCodecHeader
header
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFeatureReader(String path, FeatureCodec<T,SOURCE> codec)
protected
AbstractFeatureReader(String path, FeatureCodec<T,SOURCE> codec, Function<SeekableByteChannel,SeekableByteChannel> wrapper, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <FEATURE extends Feature,SOURCE>
AbstractFeatureReader<FEATURE,SOURCE>getFeatureReader(String featureFile, FeatureCodec<FEATURE,SOURCE> codec)
CallsgetFeatureReader(String, FeatureCodec, boolean)
withrequireIndex
= truestatic <FEATURE extends Feature,SOURCE>
AbstractFeatureReader<FEATURE,SOURCE>getFeatureReader(String featureResource, FeatureCodec<FEATURE,SOURCE> codec, boolean requireIndex)
getFeatureReader(String, String, FeatureCodec, boolean, Function, Function)
withnull
for indexResource, wrapper, and indexWrapperstatic <FEATURE extends Feature,SOURCE>
AbstractFeatureReader<FEATURE,SOURCE>getFeatureReader(String featureResource, FeatureCodec<FEATURE,SOURCE> codec, Index index)
Return a reader with a supplied index.static <FEATURE extends Feature,SOURCE>
AbstractFeatureReader<FEATURE,SOURCE>getFeatureReader(String featureResource, String indexResource, FeatureCodec<FEATURE,SOURCE> codec, boolean requireIndex)
getFeatureReader(String, String, FeatureCodec, boolean, Function, Function)
withnull
for wrapper, and indexWrapperstatic <FEATURE extends Feature,SOURCE>
AbstractFeatureReader<FEATURE,SOURCE>getFeatureReader(String featureResource, String indexResource, FeatureCodec<FEATURE,SOURCE> codec, boolean requireIndex, Function<SeekableByteChannel,SeekableByteChannel> wrapper, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper)
Object
getHeader()
get the headerstatic boolean
hasBlockCompressedExtension(File file)
Deprecated.static boolean
hasBlockCompressedExtension(String fileName)
Deprecated.static boolean
hasBlockCompressedExtension(URI uri)
Deprecated.boolean
hasIndex()
Whether the reader has an index or not Default implementation returns falseboolean
isQueryable()
static boolean
isTabix(String resourcePath, String indexPath)
static void
setComponentMethods(AbstractFeatureReader.ComponentMethods methods)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface htsjdk.tribble.FeatureReader
close, getSequenceNames, iterator, query, query
-
-
-
-
Field Detail
-
codec
protected final FeatureCodec<T extends Feature,SOURCE> codec
-
header
protected FeatureCodecHeader header
-
BLOCK_COMPRESSED_EXTENSIONS
@Deprecated public static final Set<String> BLOCK_COMPRESSED_EXTENSIONS
Deprecated.since June 2019 useFileExtensions.BLOCK_COMPRESSED
instead.
-
-
Constructor Detail
-
AbstractFeatureReader
protected AbstractFeatureReader(String path, FeatureCodec<T,SOURCE> codec)
-
AbstractFeatureReader
protected AbstractFeatureReader(String path, FeatureCodec<T,SOURCE> codec, Function<SeekableByteChannel,SeekableByteChannel> wrapper, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper)
-
-
Method Detail
-
getFeatureReader
public static <FEATURE extends Feature,SOURCE> AbstractFeatureReader<FEATURE,SOURCE> getFeatureReader(String featureFile, FeatureCodec<FEATURE,SOURCE> codec) throws TribbleException
CallsgetFeatureReader(String, FeatureCodec, boolean)
withrequireIndex
= true- Throws:
TribbleException
-
getFeatureReader
public static <FEATURE extends Feature,SOURCE> AbstractFeatureReader<FEATURE,SOURCE> getFeatureReader(String featureResource, FeatureCodec<FEATURE,SOURCE> codec, boolean requireIndex) throws TribbleException
getFeatureReader(String, String, FeatureCodec, boolean, Function, Function)
withnull
for indexResource, wrapper, and indexWrapper- Throws:
TribbleException
-
getFeatureReader
public static <FEATURE extends Feature,SOURCE> AbstractFeatureReader<FEATURE,SOURCE> getFeatureReader(String featureResource, String indexResource, FeatureCodec<FEATURE,SOURCE> codec, boolean requireIndex) throws TribbleException
getFeatureReader(String, String, FeatureCodec, boolean, Function, Function)
withnull
for wrapper, and indexWrapper- Throws:
TribbleException
-
getFeatureReader
public static <FEATURE extends Feature,SOURCE> AbstractFeatureReader<FEATURE,SOURCE> getFeatureReader(String featureResource, String indexResource, FeatureCodec<FEATURE,SOURCE> codec, boolean requireIndex, Function<SeekableByteChannel,SeekableByteChannel> wrapper, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper) throws TribbleException
- Parameters:
featureResource
- the feature file to create fromindexResource
- the index for the feature file. If null, will auto-generate (if necessary)codec
- the codec to use to decode the individual featuresrequireIndex
- whether an index is required for this filewrapper
- 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 featureResource is a uri representing aPath
indexWrapper
- a wrapper to apply to the byte stream from the indexResource, may be null, will only be applied if indexResource is a uri representing aPath
- Throws:
TribbleException
-
getFeatureReader
public static <FEATURE extends Feature,SOURCE> AbstractFeatureReader<FEATURE,SOURCE> getFeatureReader(String featureResource, FeatureCodec<FEATURE,SOURCE> codec, Index index) throws TribbleException
Return a reader with a supplied index.- Parameters:
featureResource
- the path to the source file containing the featurescodec
- used to decode the featuresindex
- index of featureResource- Returns:
- a reader for this data
- Throws:
TribbleException
-
hasIndex
public boolean hasIndex()
Whether the reader has an index or not Default implementation returns false- Returns:
- false
-
isQueryable
public boolean isQueryable()
- Specified by:
isQueryable
in interfaceFeatureReader<T extends Feature>
- Returns:
- true if the reader has an index, which means that it can be queried.
-
setComponentMethods
public static void setComponentMethods(AbstractFeatureReader.ComponentMethods methods)
-
hasBlockCompressedExtension
@Deprecated public static boolean hasBlockCompressedExtension(String fileName)
Deprecated.
-
hasBlockCompressedExtension
@Deprecated public static boolean hasBlockCompressedExtension(File file)
Deprecated.
-
hasBlockCompressedExtension
@Deprecated public static boolean hasBlockCompressedExtension(URI uri)
Deprecated.
-
getHeader
public Object getHeader()
get the header- Specified by:
getHeader
in interfaceFeatureReader<T extends Feature>
- Returns:
- the header object we've read-in
-
isTabix
public static boolean isTabix(String resourcePath, String indexPath) throws IOException
- Throws:
IOException
-
-