Package htsjdk.samtools
Class CRAMFileWriter
- java.lang.Object
-
- htsjdk.samtools.SAMFileWriterImpl
-
- htsjdk.samtools.CRAMFileWriter
-
- All Implemented Interfaces:
SAMFileWriter
,Closeable
,AutoCloseable
public class CRAMFileWriter extends SAMFileWriterImpl
-
-
Constructor Summary
Constructors Constructor Description CRAMFileWriter(OutputStream outputStream, CRAMReferenceSource referenceSource, SAMFileHeader samFileHeader, String fileName)
Create a CRAMFileWriter on an output stream.CRAMFileWriter(OutputStream outputStream, OutputStream indexOS, boolean presorted, CRAMReferenceSource referenceSource, SAMFileHeader samFileHeader, String fileName)
Create a CRAMFileWriter and optional index on output streams.CRAMFileWriter(OutputStream outputStream, OutputStream indexOS, CRAMReferenceSource referenceSource, SAMFileHeader samFileHeader, String fileName)
Create a CRAMFileWriter and optional index on output streams.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
finish()
Do any required flushing here.Set<String>
getCaptureTags()
protected String
getFilename()
For producing error messages.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 void
writeAlignment(SAMRecord alignment)
Write an alignment record.protected void
writeHeader(SAMFileHeader header)
Write the header to disk.protected void
writeHeader(String textHeader)
Write the header to disk.-
Methods inherited from class htsjdk.samtools.SAMFileWriterImpl
addAlignment, close, getDefaultMaxRecordsInRam, getFileHeader, getMaxRecordsInRam, getSortOrder, getTempDirectory, setDefaultMaxRecordsInRam, setHeader, setMaxRecordsInRam, setProgressLogger, setSortOrder, setTempDirectory
-
-
-
-
Constructor Detail
-
CRAMFileWriter
public CRAMFileWriter(OutputStream outputStream, CRAMReferenceSource referenceSource, SAMFileHeader samFileHeader, String fileName)
Create a CRAMFileWriter on an output stream. Requires input records to be presorted to match the sort order defined by the inputsamFileHeader
.- Parameters:
outputStream
- where to write the output. Can not be null.referenceSource
- reference source. Can not be null.samFileHeader
-SAMFileHeader
to be used. Can not be null. Sort order is determined by the sortOrder property of this arg.fileName
- used for display in error messages- Throws:
IllegalArgumentException
- if theoutputStream
,referenceSource
orsamFileHeader
are null
-
CRAMFileWriter
public CRAMFileWriter(OutputStream outputStream, OutputStream indexOS, CRAMReferenceSource referenceSource, SAMFileHeader samFileHeader, String fileName)
Create a CRAMFileWriter and optional index on output streams. Requires input records to be presorted to match the sort order defined by the inputsamFileHeader
.- Parameters:
outputStream
- where to write the output. Can not be null.indexOS
- where to write the output index. Can be null if no index is required.referenceSource
- reference sourcesamFileHeader
-SAMFileHeader
to be used. Can not be null. Sort order is determined by the sortOrder property of this arg.fileName
- used for display in error messages- Throws:
IllegalArgumentException
- if theoutputStream
,referenceSource
orsamFileHeader
are null
-
CRAMFileWriter
public CRAMFileWriter(OutputStream outputStream, OutputStream indexOS, boolean presorted, CRAMReferenceSource referenceSource, SAMFileHeader samFileHeader, String fileName)
Create a CRAMFileWriter and optional index on output streams.- Parameters:
outputStream
- where to write the output. Can not be null.indexOS
- where to write the output index. Can be null if no index is required.presorted
- if true records written to this writer must already be sorted in the order specified by the headerreferenceSource
- reference sourcesamFileHeader
-SAMFileHeader
to be used. Can not be null. Sort order is determined by the sortOrder property of this arg.fileName
- used for display in error message display- Throws:
IllegalArgumentException
- if theoutputStream
,referenceSource
orsamFileHeader
are null
-
-
Method Detail
-
writeAlignment
protected void writeAlignment(SAMRecord alignment)
Write an alignment record.- Specified by:
writeAlignment
in classSAMFileWriterImpl
- Parameters:
alignment
- must not be null and must have a valid SAMFileHeader.
-
writeHeader
protected void writeHeader(String textHeader)
Description copied from class:SAMFileWriterImpl
Write the header to disk. Header object is available via getHeader().- Specified by:
writeHeader
in classSAMFileWriterImpl
- Parameters:
textHeader
- for convenience if the implementation needs it.
-
writeHeader
protected void writeHeader(SAMFileHeader header)
Description copied from class:SAMFileWriterImpl
Write the header to disk. Header object is available via getHeader().IMPORTANT: this method will be abstract once
SAMFileWriterImpl.writeHeader(String)
is removed.Note: default implementation uses
SAMTextHeaderCodec.encode(java.io.Writer, htsjdk.samtools.SAMFileHeader)
and callsSAMFileWriterImpl.writeHeader(String)
.- Overrides:
writeHeader
in classSAMFileWriterImpl
- Parameters:
header
- object to write.
-
finish
protected void finish()
Description copied from class:SAMFileWriterImpl
Do any required flushing here.- Specified by:
finish
in classSAMFileWriterImpl
-
getFilename
protected String getFilename()
Description copied from class:SAMFileWriterImpl
For producing error messages.- Specified by:
getFilename
in classSAMFileWriterImpl
- Returns:
- Output filename, or null if there isn't one.
-
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)
-
-