/** * Read CRAM header from the given {@link InputStream}. * * @param inputStream input stream to read from * @return complete {@link CramHeader} object * @throws IOException as per java IO contract */ public static CramHeader readCramHeader(final InputStream inputStream) throws IOException { final CramHeader header = readFormatDefinition(inputStream); final SAMFileHeader samFileHeader = readSAMFileHeader(header.getVersion(), inputStream, new String(header.getId())); return new CramHeader(header.getVersion(), new String(header.getId()), samFileHeader); }
/** * Read CRAM header from the given {@link InputStream}. * * @param inputStream input stream to read from * @return complete {@link CramHeader} object */ public static CramHeader readCramHeader(final InputStream inputStream) { try { final CramHeader header = readFormatDefinition(inputStream); final SAMFileHeader samFileHeader = readSAMFileHeader(header.getVersion(), inputStream, new String(header.getId())); return new CramHeader(header.getVersion(), new String(header.getId()), samFileHeader); } catch (final IOException e) { throw new RuntimeIOException(e); } }
try (final CountingInputStream countingInputStream = new CountingInputStream(new FileInputStream(file)); final RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) { final CramHeader header = readFormatDefinition(countingInputStream); final Container c = ContainerIO.readContainerHeader(header.getVersion().major, countingInputStream); final long pos = countingInputStream.getCount();
final CramHeader header = readFormatDefinition(countingInputStream); final Container c = ContainerIO.readContainerHeader(header.getVersion().major, countingInputStream); final long pos = countingInputStream.getCount();