Package blbutil
Class BGZipIt
java.lang.Object
blbutil.BGZipIt
Class BGZipIt
is a blbutil.FileIt<String>
whose
next()
method returns lines of a bgzip-compressed file.
The GZIP file format specification is described RFC 1952 and the BGZIP file format specification is described in the Sequence Alignment/Map Format Specification
Instances of class BGZipIt
are not thread safe.
-
Constructor Summary
ConstructorsConstructorDescriptionBGZipIt
(InputStream is, int nBufferedBlocks) Constructs a newBGZipIt
instance from the specified dataBGZipIt
(InputStream is, int nBufferedBlocks, File source) Constructs a newBGZipIt
instance from the specified data -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returnstrue
if the first 16 bytes of the specified input stream are a gzip header that includes a 6 byte extra field containing the block size as described in the bgzip specification, and returnsfalse
otherwise.void
close()
Closes the input stream and releases any system resources that are associated with it.file()
Returns the file from which the data are read, ornull
if the data are read from standard input or if the data source is unknown.boolean
hasNext()
Returnstrue
if the iteration has more elements.next()
Returns the next line of the VCF file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
BGZipIt
Constructs a newBGZipIt
instance from the specified data- Parameters:
is
- an input stream that reads from a gzip-compressed VCF filenBufferedBlocks
- the number of buffered gzip blocks- Throws:
IllegalArgumentException
- ifnBufferedBlocks < 1
NullPointerException
- ifis == null
-
BGZipIt
Constructs a newBGZipIt
instance from the specified data- Parameters:
is
- an input stream that reads gzip-compressed VCF datanBufferedBlocks
- the number of buffered gzip blockssource
- the gzip-compressed VCF file that is read- Throws:
IllegalArgumentException
- ifnBufferedBlocks < 1
NullPointerException
- ifis == null
-
-
Method Details
-
close
public void close()Description copied from interface:FileIt
Closes the input stream and releases any system resources that are associated with it. If the input stream is already closed then invoking this method has no effect. -
hasNext
public boolean hasNext()Returnstrue
if the iteration has more elements. -
next
Returns the next line of the VCF file. End of line characters are not included in the returned line.- Specified by:
next
in interfaceIterator<String>
- Returns:
- the next line of the VCF file
- Throws:
NoSuchElementException
- if the VCF file has no more lines
-
file
Description copied from interface:FileIt
Returns the file from which the data are read, ornull
if the data are read from standard input or if the data source is unknown. -
beginsWithBgzipBlock
Returnstrue
if the first 16 bytes of the specified input stream are a gzip header that includes a 6 byte extra field containing the block size as described in the bgzip specification, and returnsfalse
otherwise. The method sets a mark before reading the initial bytes from the stream, and resets the stream to the mark position before returning.- Parameters:
bis
- a buffered input stream- Returns:
true
if the first 16 bytes of the specified input stream are a gzip header that includes a 6 byte extra field containing the block size as described in the bgzip specification
-