@InternalAPI public abstract class VCFCodec extends java.lang.Object implements VariantsCodec
HtsContentType.VARIANT_CONTEXTS codecs.| Constructor and Description |
|---|
VCFCodec() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canDecodeSignature(SignatureStream probingInputStream,
java.lang.String sourceName)
Determine if the codec can decode an input stream by inspecting a signature embedded
within the stream.
|
boolean |
canDecodeURI(IOPath ioPath)
Determine if the URI for
ioPath (obtained via IOPath.getURI())
conforms to the expected URI format this codec's file format. |
java.lang.String |
getFileFormat()
Get the name of the file format supported by this codec.
|
int |
getSignatureLength()
Get the number of bytes in the format and version signature used by the file format supported
by this codec.
|
int |
getSignatureProbeLength()
Get the number of bytes of needed by this codec to probe an input stream for a format/version
signature, and determine if it can supply a decoder for the stream.
|
protected abstract java.lang.String |
getSignatureString()
Get the signature string for this codec.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetContentTypegetDecoder, getDisplayName, getEncoder, getVersion, ownsURIrunVersionUpgradepublic java.lang.String getFileFormat()
HtsCodecBundleResourceType and BundleResource.getFileFormat()).getFileFormat in interface HtsCodec<VariantsDecoderOptions,VariantsEncoderOptions>public boolean canDecodeURI(IOPath ioPath)
HtsCodecioPath (obtained via IOPath.getURI())
conforms to the expected URI format this codec's file format.
Most implementations only look at the file extension (see IOPath.hasExtension(java.lang.String)).
For codecs that implement formats that use specific, well known file extensions, the codec should
reject inputs that do not conform to any of the accepted extensions. If the format does not use a
specific extension, or if the codec cannot determine if it can decode the underlying resource
without inspecting the underlying stream, it is safe to return true, after which the framework will
subsequently call this codec's HtsCodec.canDecodeSignature(SignatureStream, String) method, at
which time the codec can inspect the actual underlying stream via the SignatureStream.
Implementations should generally not inspect the URI's protocol scheme unless the file format
supported by the codec requires the use a specific protocol scheme. For codecs that do own
a specific scheme or URI format, the return values for HtsCodec.ownsURI(IOPath) and
HtsCodec.canDecodeURI(IOPath) must always be the same (both true or both false) for a given IOPath.
For codecs that do not use a custom URI (and rely on NIO access), @link #ownsURI(IOPath)} should
always return false, with only the value returned from HtsCodec.canDecodeURI(IOPath) varying based
on features such as file extension probes.
It is never safe to attempt to directly inspect the underlying stream for ioPath
in this method. If the stream needs to be inspected, it should be done using the signature stream
when the HtsCodec.canDecodeSignature(SignatureStream, String) method is called.
HtsCodec.ownsURI(IOPath), codecs should avoid making remote calls
to determine the suitability of the input resource; the return value for this method should be based
only on the format of the URI that is presented.
Since this method is used during codec resolution, implementations should avoid calling methods that
may throw exceptions.canDecodeURI in interface HtsCodec<VariantsDecoderOptions,VariantsEncoderOptions>ioPath - to be decodedpublic int getSignatureLength()
HtsCodecgetSignatureLength in interface HtsCodec<VariantsDecoderOptions,VariantsEncoderOptions>HtsCodec.ownsURI(htsjdk.io.IOPath)), should
always return 0 from this method.
Since this method is used during codec resolution, implementations should avoid calling methods that
may throw exceptions.public int getSignatureProbeLength()
HtsCodecgetSignatureProbeLength in interface HtsCodec<VariantsDecoderOptions,VariantsEncoderOptions>HtsCodec.getSignatureLength() for codecs that support compressed or encrypted
streams, since they may require a larger and more semantically meaningful input fragment
(such as an entire encrypted or compressed block) in order to inspect the plaintext signature.
Therefore signatureProbeLength should be expressed in "compressed/encrypted" space rather
than "plaintext" space. The length returned from this method is used to determine the size of the
SignatureStream that is subsequently passed to
HtsCodec.canDecodeSignature(SignatureStream, String).
Note: Codecs that are custom URI handlers (those that return true for HtsCodec.ownsURI(IOPath)),
should always return 0 from this method when it is called.
Since this method is used during codec resolution, implementations should avoid calling methods that
may throw exceptions.
public boolean canDecodeSignature(SignatureStream probingInputStream, java.lang.String sourceName)
HtsCodec
HtsCodec.getSignatureProbeLength() HtsCodec.getSignatureProbeLength()
Codecs that handle custom URIs that reference remote resources (those that return true for HtsCodec.ownsURI(htsjdk.io.IOPath))
should generally not inspect the stream, and should return false from this method, since the method
will never be called with any resource for which HtsCodec.ownsURI(htsjdk.io.IOPath) returned true.
Since this method is used during codec resolution, implementations should avoid calling methods that
may throw exceptions.
canDecodeSignature in interface HtsCodec<VariantsDecoderOptions,VariantsEncoderOptions>probingInputStream - the stream to be inspect for the resource's embedded
signature and versionsourceName - a display name describing the source of the input stream, for use in error messagesprotected abstract java.lang.String getSignatureString()