Package htsjdk.tribble
Class AsciiFeatureCodec<T extends Feature>
- java.lang.Object
-
- htsjdk.tribble.AbstractFeatureCodec<T,LineIterator>
-
- htsjdk.tribble.AsciiFeatureCodec<T>
-
- Type Parameters:
T- The feature type this codec reads
- All Implemented Interfaces:
FeatureCodec<T,LineIterator>
- Direct Known Subclasses:
AbstractVCFCodec,BEDCodec
public abstract class AsciiFeatureCodec<T extends Feature> extends AbstractFeatureCodec<T,LineIterator>
A convenience base class for codecs that want to read in features from ASCII lines. This class overrides the general decode locs for streams and presents instead Strings to decode(String) and readHeader(LineReader) functions.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAsciiFeatureCodec(Class<T> myClass)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose(LineIterator lineIterator)Adapter method that closes the providedFeatureCodec.Tdecode(LineIterator lineIterator)Convenience method.abstract Tdecode(String s)booleanisDone(LineIterator lineIterator)Adapter method that assesses whether the providedFeatureCodechas more data.LocationAwaremakeIndexableSourceFromStream(InputStream inputStream)Return aFeatureCodecfor thisFeatureCodecthat implementsLocationAware, and is thus suitable for use during indexing.LineIteratormakeSourceFromStream(InputStream bufferedInputStream)Generates a reader of typeFeatureCodecappropriate for use by this codec from the generic input stream.abstract ObjectreadActualHeader(LineIterator reader)Read and return the header, or null if there is no header.FeatureCodecHeaderreadHeader(LineIterator lineIterator)Read and return the header, or null if there is no header.-
Methods inherited from class htsjdk.tribble.AbstractFeatureCodec
decodeLoc, getFeatureType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface htsjdk.tribble.FeatureCodec
canDecode, getPathToDataFile, getTabixFormat
-
-
-
-
Method Detail
-
close
public void close(LineIterator lineIterator)
Description copied from interface:FeatureCodecAdapter method that closes the providedFeatureCodec.
-
isDone
public boolean isDone(LineIterator lineIterator)
Description copied from interface:FeatureCodecAdapter method that assesses whether the providedFeatureCodechas more data. True if it does, false otherwise.
-
makeIndexableSourceFromStream
public LocationAware makeIndexableSourceFromStream(InputStream inputStream)
Description copied from interface:FeatureCodecReturn aFeatureCodecfor thisFeatureCodecthat implementsLocationAware, and is thus suitable for use during indexing. LikeFeatureCodec.makeSourceFromStream(java.io.InputStream), except theLocationAwarecompatibility is required for creating indexes. Implementers of this method must return a type that is bothLocationAwareas well asFeatureCodec. Note that this requirement cannot be enforced via the method signature due to limitations in Java's generic typing system. Instead, consumers should cast the call result into aFeatureCodecwhen applicable. NOTE: During the indexing process, the indexer passes theFeatureCodecto the codec to consume Features from the underlyingFeatureCodec, one at a time, recording the Feature location via theFeatureCodec'sLocationAwareinterface. Therefore, it is essential that theFeatureCodecimplementation, theFeatureCodec.readHeader(SOURCE)method, and theFeatureCodec.decodeLoc(SOURCE)method, which are used during indexing, not introduce any buffering that would that would advance theFeatureCodecmore than a single feature (or the more than the size of the header, in the case ofFeatureCodec.readHeader(SOURCE)).
-
makeSourceFromStream
public LineIterator makeSourceFromStream(InputStream bufferedInputStream)
Description copied from interface:FeatureCodecGenerates a reader of typeFeatureCodecappropriate for use by this codec from the generic input stream. Implementers should assume the stream is buffered.
-
decode
public T decode(LineIterator lineIterator)
Convenience method. Decoding in ASCII files operates line-by-line, so obviate the need to callIterator.next()in implementing classes and, instead, have them implementdecode(String).- Parameters:
lineIterator- the input stream from which to decode the next record- Returns:
- Return the Feature encoded by the line, or null if the line does not represent a feature (e.g. is a comment)
-
readHeader
public FeatureCodecHeader readHeader(LineIterator lineIterator) throws IOException
Description copied from interface:FeatureCodecRead and return the header, or null if there is no header. Note: Implementers of this method must be careful to read exactly as much fromFeatureCodecas needed to parse the header, and no more. Otherwise, data that might otherwise be fed into parsing aFeaturemay be lost.- Parameters:
lineIterator- the source from which to decode the header- Returns:
- header object
- Throws:
IOException
-
readActualHeader
public abstract Object readActualHeader(LineIterator reader)
Read and return the header, or null if there is no header.- Returns:
- the actual header data in the file, or null if none is available
-
-