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 voidfinish()Do any required flushing here.Set<String>getCaptureTags()protected StringgetFilename()For producing error messages.Set<String>getIgnoreTags()List<PreservationPolicy>getPreservationPolicies()booleanisCaptureAllTags()booleanisPreserveReadNames()voidsetCaptureAllTags(boolean captureAllTags)voidsetCaptureTags(Set<String> captureTags)voidsetIgnoreTags(Set<String> ignoreTags)voidsetPreserveReadNames(boolean preserveReadNames)protected voidwriteAlignment(SAMRecord alignment)Write an alignment record.protected voidwriteHeader(SAMFileHeader header)Write the header to disk.protected voidwriteHeader(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-SAMFileHeaderto 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,referenceSourceorsamFileHeaderare 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-SAMFileHeaderto 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,referenceSourceorsamFileHeaderare 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-SAMFileHeaderto 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,referenceSourceorsamFileHeaderare null
-
-
Method Detail
-
writeAlignment
protected void writeAlignment(SAMRecord alignment)
Write an alignment record.- Specified by:
writeAlignmentin classSAMFileWriterImpl- Parameters:
alignment- must not be null and must have a valid SAMFileHeader.
-
writeHeader
protected void writeHeader(String textHeader)
Description copied from class:SAMFileWriterImplWrite the header to disk. Header object is available via getHeader().- Specified by:
writeHeaderin classSAMFileWriterImpl- Parameters:
textHeader- for convenience if the implementation needs it.
-
writeHeader
protected void writeHeader(SAMFileHeader header)
Description copied from class:SAMFileWriterImplWrite 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:
writeHeaderin classSAMFileWriterImpl- Parameters:
header- object to write.
-
finish
protected void finish()
Description copied from class:SAMFileWriterImplDo any required flushing here.- Specified by:
finishin classSAMFileWriterImpl
-
getFilename
protected String getFilename()
Description copied from class:SAMFileWriterImplFor producing error messages.- Specified by:
getFilenamein 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)
-
-