Class SBIIndexWriter

java.lang.Object
htsjdk.samtools.SBIIndexWriter

public final class SBIIndexWriter extends Object
Writes SBI files as understood by SBIIndex.

To use this class, first construct an instance from an output stream, and a desired granularity. Then for each record in the file being indexed, pass the virtual file offset of the record to the processRecord(long) method. The indexer will keep a count of the records passed in an index every nth record. When there are no records left call finish(long, long) to complete writing the index.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Prepare to write an SBI index with the default granularity.
    SBIIndexWriter(OutputStream out, long granularity)
    Prepare to write an SBI index.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    finish(long finalVirtualOffset, long dataFileLength)
    Complete the index, and close the output stream.
    void
    finish(long finalVirtualOffset, long dataFileLength, byte[] md5, byte[] uuid)
    Complete the index, and close the output stream.
    void
    processRecord(long virtualOffset)
    Process a record for the index: the offset of every nth record will be written to the index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SBIIndexWriter

      public SBIIndexWriter(OutputStream out)
      Prepare to write an SBI index with the default granularity.
      Parameters:
      out - the stream to write the index to
    • SBIIndexWriter

      public SBIIndexWriter(OutputStream out, long granularity)
      Prepare to write an SBI index.
      Parameters:
      out - the stream to write the index to
      granularity - write the offset of every nth record to the index
  • Method Details

    • processRecord

      public void processRecord(long virtualOffset)
      Process a record for the index: the offset of every nth record will be written to the index.
      Parameters:
      virtualOffset - virtual file pointer of the record
    • finish

      public void finish(long finalVirtualOffset, long dataFileLength)
      Complete the index, and close the output stream.
      Parameters:
      finalVirtualOffset - the virtual offset at which the next record would start if it were added to the file
      dataFileLength - the length of the data file in bytes
    • finish

      public void finish(long finalVirtualOffset, long dataFileLength, byte[] md5, byte[] uuid)
      Complete the index, and close the output stream.
      Parameters:
      finalVirtualOffset - the virtual offset at which the next record would start if it were added to the file
      dataFileLength - the length of the data file in bytes
      md5 - the MD5 hash of the data file, or null if not specified
      uuid - the UUID for the data file, or null if not specified