Package htsjdk.samtools
Class CRAMContainerStreamWriter
- java.lang.Object
-
- htsjdk.samtools.CRAMContainerStreamWriter
-
public class CRAMContainerStreamWriter extends Object
Class for writing SAMRecords into a series of CRAM containers on an output stream.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
containerSize
protected int
recordsPerSlice
-
Constructor Summary
Constructors Constructor Description CRAMContainerStreamWriter(OutputStream outputStream, OutputStream indexStream, CRAMReferenceSource source, SAMFileHeader samFileHeader, String cramId)
Create a CRAMContainerStreamWriter for writing SAM records into a series of CRAM containers on output stream, with an optional index.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
finish(boolean writeEOFContainer)
Finish writing to the stream.protected void
flushContainer()
Complete the current container and flush it to the output stream.Set<String>
getCaptureTags()
Set<String>
getIgnoreTags()
List<PreservationPolicy>
getPreservationPolicies()
boolean
isCaptureAllTags()
boolean
isPreserveReadNames()
void
setCaptureAllTags(boolean captureAllTags)
void
setCaptureTags(Set<String> captureTags)
void
setIgnoreTags(Set<String> ignoreTags)
void
setPreserveReadNames(boolean preserveReadNames)
protected boolean
shouldFlushContainer(SAMRecord nextRecord)
Decide if the current container should be completed and flushed.void
writeAlignment(SAMRecord alignment)
Write an alignment record.void
writeHeader(SAMFileHeader header)
Write a CRAM file header and SAM header to the stream.
-
-
-
Constructor Detail
-
CRAMContainerStreamWriter
public CRAMContainerStreamWriter(OutputStream outputStream, OutputStream indexStream, CRAMReferenceSource source, SAMFileHeader samFileHeader, String cramId)
Create a CRAMContainerStreamWriter for writing SAM records into a series of CRAM containers on output stream, with an optional index.- Parameters:
outputStream
- where to write the CRAM stream.indexStream
- where to write the output index. Can be null if no index is required.source
- reference sourcesamFileHeader
-SAMFileHeader
to be used. Sort order is determined by the sortOrder property of this arg.cramId
- used for display in error message display
-
-
Method Detail
-
writeAlignment
public void writeAlignment(SAMRecord alignment)
Write an alignment record.- Parameters:
alignment
- must not be null
-
writeHeader
public void writeHeader(SAMFileHeader header)
Write a CRAM file header and SAM header to the stream.- Parameters:
header
- SAMFileHeader to write
-
finish
public void finish(boolean writeEOFContainer)
Finish writing to the stream. Flushes the record cache and optionally emits an EOF container.- Parameters:
writeEOFContainer
- true if an EOF container should be written. Only use false if writing a CRAM file fragment which will later be aggregated into a complete CRAM file.
-
isPreserveReadNames
public boolean isPreserveReadNames()
-
setPreserveReadNames
public void setPreserveReadNames(boolean preserveReadNames)
-
getPreservationPolicies
public List<PreservationPolicy> getPreservationPolicies()
-
isCaptureAllTags
public boolean isCaptureAllTags()
-
setCaptureAllTags
public void setCaptureAllTags(boolean captureAllTags)
-
shouldFlushContainer
protected boolean shouldFlushContainer(SAMRecord nextRecord)
Decide if the current container should be completed and flushed. The decision is based on a) number of records and b) if the reference sequence id has changed.- Parameters:
nextRecord
- the record to be added into the current or next container- Returns:
- true if the current container should be flushed and the following records should go into a new container; false otherwise.
-
flushContainer
protected void flushContainer() throws IllegalArgumentException, IllegalAccessException, IOException
Complete the current container and flush it to the output stream.
-
-