Class CramIO


  • public final class CramIO
    extends Object
    A collection of methods to read and write special values to/from CRAM files.
    • Field Detail

      • ZERO_B_EOF_MARKER

        public static final byte[] ZERO_B_EOF_MARKER
        The 'zero-B' EOF marker as per CRAM specs v2.1. This is basically a serialized empty CRAM container with sequence id set to some number to spell out 'EOF' in hex.
      • ZERO_F_EOF_MARKER

        public static final byte[] ZERO_F_EOF_MARKER
        The zero-F EOF marker as per CRAM specs v3.0. This is basically a serialized empty CRAM container with sequence id set to some number to spell out 'EOF' in hex.
    • Constructor Detail

      • CramIO

        public CramIO()
    • Method Detail

      • writeCramEOF

        public static long writeCramEOF​(CRAMVersion cramVersion,
                                        OutputStream outputStream)
        Write an end-of-file marker to the OutputStream. The specific EOF marker is chosen based on the CRAM version. On read, this is interpreted as a special container sentinel indicating no more containers. The treatment of these EOF markers is asymmetric in that on read, the EOF marker is read in as a special container with sentinel values indicating it is an EOF container (as defined by the spec).
        Parameters:
        cramVersion - the CRAM version to assume
        outputStream - the stream to write to
        Returns:
        the number of bytes written out
      • writeCramHeader

        public static long writeCramHeader​(CramHeader cramHeader,
                                           OutputStream outputStream)
        Writes CRAM header into the specified OutputStream.
        Parameters:
        cramHeader - the CramHeader object to write
        outputStream - the output stream to write to
        Returns:
        the number of bytes written out
      • readCramHeader

        public static CramHeader readCramHeader​(InputStream inputStream)
        Read CRAM header from the given InputStream.
        Parameters:
        inputStream - input stream to read from
        Returns:
        complete CramHeader object
      • samHeaderToByteArray

        public static byte[] samHeaderToByteArray​(SAMFileHeader samFileHeader)