Package blbutil

Class BGZipIt

java.lang.Object
blbutil.BGZipIt
All Implemented Interfaces:
FileIt<String>, Closeable, AutoCloseable, Iterator<String>

public final class BGZipIt extends Object implements FileIt<String>

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

    Constructors
    Constructor
    Description
    BGZipIt(InputStream is, int nBufferedBlocks)
    Constructs a new BGZipIt instance from the specified data
    BGZipIt(InputStream is, int nBufferedBlocks, File source)
    Constructs a new BGZipIt instance from the specified data
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    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, and returns false otherwise.
    void
    Closes the input stream and releases any system resources that are associated with it.
    Returns the file from which the data are read, or null if the data are read from standard input or if the data source is unknown.
    boolean
    Returns true if the iteration has more elements.
    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 blbutil.FileIt

    toString

    Methods inherited from interface java.util.Iterator

    forEachRemaining, remove
  • Constructor Details

    • BGZipIt

      public BGZipIt(InputStream is, int nBufferedBlocks)
      Constructs a new BGZipIt instance from the specified data
      Parameters:
      is - an input stream that reads from a gzip-compressed VCF file
      nBufferedBlocks - the number of buffered gzip blocks
      Throws:
      IllegalArgumentException - if nBufferedBlocks < 1
      NullPointerException - if is == null
    • BGZipIt

      public BGZipIt(InputStream is, int nBufferedBlocks, File source)
      Constructs a new BGZipIt instance from the specified data
      Parameters:
      is - an input stream that reads gzip-compressed VCF data
      nBufferedBlocks - the number of buffered gzip blocks
      source - the gzip-compressed VCF file that is read
      Throws:
      IllegalArgumentException - if nBufferedBlocks < 1
      NullPointerException - if is == 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.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface FileIt<String>
    • hasNext

      public boolean hasNext()
      Returns true if the iteration has more elements.
      Specified by:
      hasNext in interface Iterator<String>
      Returns:
      true if the iteration has more elements
    • next

      public String next()
      Returns the next line of the VCF file. End of line characters are not included in the returned line.
      Specified by:
      next in interface Iterator<String>
      Returns:
      the next line of the VCF file
      Throws:
      NoSuchElementException - if the VCF file has no more lines
    • file

      public File file()
      Description copied from interface: FileIt
      Returns the file from which the data are read, or null if the data are read from standard input or if the data source is unknown.
      Specified by:
      file in interface FileIt<String>
      Returns:
      the file from which the data are read, or null if the data are read from standard input or if the data source is unknown
    • beginsWithBgzipBlock

      public static boolean beginsWithBgzipBlock(BufferedInputStream bis)
      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, and returns false 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