Class CRAMCRAIIndexer

  • All Implemented Interfaces:
    CRAMIndexer

    public class CRAMCRAIIndexer
    extends Object
    implements CRAMIndexer
    Indexer for creating/reading/writing a CRAIIndex for a CRAM file/stream. There are three ways to obtain an index:

    • create an index for an entire CRAM stream and write it to an output stream
    • create an index on-the-fly by processing one container at a time
    • read an existing index from an input stream

    • Constructor Detail

      • CRAMCRAIIndexer

        public CRAMCRAIIndexer​(OutputStream os,
                               SAMFileHeader samHeader)
        Create a CRAMCRAIIndexer that writes to the given output stream.
        Parameters:
        os - output stream to which the index will be written
        samHeader - SAMFileHeader - user to verify sort order
      • CRAMCRAIIndexer

        public CRAMCRAIIndexer​(OutputStream os,
                               SAMFileHeader samHeader,
                               Collection<CRAIEntry> entries)
        Create a CRAMCRAIIndexer that writes to the given output stream, initialized with a Collection of CRAIEntry objects.
        Parameters:
        os - output stream to which the index will be written
        samHeader - SAMFileHeader - user to verify sort order
        entries - the CRAI entries to index
    • Method Detail

      • processContainer

        public void processContainer​(Container container)
        Create index entries for a single container.
        Parameters:
        container - the container to index
      • processContainer

        public void processContainer​(Container container,
                                     ValidationStringency validationStringency)
        Description copied from interface: CRAMIndexer
        Create index entries for a single container.
        Specified by:
        processContainer in interface CRAMIndexer
        Parameters:
        container - the container to index
        validationStringency - stringency for validating records (used when processing multi-reference slices, since creating an index on a multi-ref slices requires actually decoding the records in order to resove the constituent reference spans}
      • finish

        public void finish()
        Finish creating the index by writing the accumulated entries out to the stream.
        Specified by:
        finish in interface CRAMIndexer
      • writeIndex

        public static void writeIndex​(SeekableStream cramStream,
                                      OutputStream craiStream)
        Generate and write a CRAI index to an output stream from a CRAM input stream
        Parameters:
        cramStream - CRAM stream to index; must be coordinate sorted
        craiStream - stream for output index
      • readIndex

        public static CRAIIndex readIndex​(InputStream is)
        Read an input stream containing a .crai index and return a CRAIIndex object.
        Parameters:
        is - Input stream to read
        Returns:
        A CRAIIndex object representing the index.