Class ContainerIO


  • public class ContainerIO
    extends Object
    Methods to read and write CRAM containers.
    • Constructor Detail

      • ContainerIO

        public ContainerIO()
    • Method Detail

      • readContainer

        public static Container readContainer​(Version version,
                                              InputStream inputStream)
                                       throws IOException
        Reads a CRAM container from the input stream. Returns an EOF container when there is no more data or the EOF marker found.
        Parameters:
        version - CRAM version to expect
        inputStream - the stream to read from
        Returns:
        a new container object read from the stream
        Throws:
        IOException - as per java IO contract
      • readContainerHeader

        public static Container readContainerHeader​(int major,
                                                    InputStream inputStream)
                                             throws IOException
        Reads container header only from a InputStream.
        Parameters:
        major - the CRAM version to assume
        inputStream - the input stream to read from
        Returns:
        a new Container object with container header values filled out but empty body (no slices and blocks).
        Throws:
        IOException - as per java IO contract
      • writeContainerHeader

        public static int writeContainerHeader​(int major,
                                               Container container,
                                               OutputStream outputStream)
                                        throws IOException
        Writes a Container header information to a OutputStream.
        Parameters:
        major - the CRAM version to assume
        container - the container holding the header to write
        outputStream - the stream to write to
        Returns:
        the number of bytes written
        Throws:
        IOException - as per java IO contract
      • writeContainer

        public static int writeContainer​(Version version,
                                         Container container,
                                         OutputStream outputStream)
                                  throws IOException
        Writes a complete Container with it's header to a OutputStream. The method is aware of file header containers and is suitable for general purpose use: basically any container is allowed.
        Parameters:
        version - the CRAM version to assume
        container - the container to write
        outputStream - the stream to write to
        Returns:
        the number of bytes written out
        Throws:
        IOException - as per java IO contract
      • getByteSize

        public static long getByteSize​(Version version,
                                       Container container)
        Calculates the byte size of a container based on the CRAM version.
        Parameters:
        version - the CRAM version to assume
        container - the container to be weighted
        Returns:
        the total number of bytes the container would occupy if written out