Package htsjdk.samtools
Class BAMFileWriter
java.lang.Object
htsjdk.samtools.SAMFileWriterImpl
htsjdk.samtools.BAMFileWriter
- All Implemented Interfaces:
SAMFileWriter
,Closeable
,AutoCloseable
Concrete implementation of SAMFileWriter for writing gzipped BAM files.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BAMFileWriter
(File path) protected
BAMFileWriter
(File path, int compressionLevel) protected
BAMFileWriter
(OutputStream os, File file) protected
BAMFileWriter
(OutputStream os, File file, int compressionLevel) protected
BAMFileWriter
(OutputStream os, File file, int compressionLevel, DeflaterFactory deflaterFactory) protected
BAMFileWriter
(OutputStream os, String absoluteFilename, int compressionLevel, DeflaterFactory deflaterFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
finish()
Do any required flushing here.protected String
For producing error messages.protected void
writeAlignment
(SAMRecord alignment) Writes the record to disk.protected static void
writeHeader
(BinaryCodec outputBinaryCodec, SAMFileHeader samFileHeader) Writes a header to a BAM file.protected static void
writeHeader
(BinaryCodec outputBinaryCodec, SAMFileHeader samFileHeader, String headerText) Writes a header to a BAM file.static void
writeHeader
(OutputStream outputStream, SAMFileHeader samFileHeader) Write a BAM file header to an output stream in block compressed BAM format.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, setSortOrderChecking, setTempDirectory, writeHeader
-
Constructor Details
-
BAMFileWriter
-
BAMFileWriter
-
BAMFileWriter
-
BAMFileWriter
-
BAMFileWriter
protected BAMFileWriter(OutputStream os, File file, int compressionLevel, DeflaterFactory deflaterFactory) -
BAMFileWriter
protected BAMFileWriter(OutputStream os, String absoluteFilename, int compressionLevel, DeflaterFactory deflaterFactory)
-
-
Method Details
-
writeAlignment
Description copied from class:SAMFileWriterImpl
Writes the record to disk. Sort order has been taken care of by the time this method is called. The record must hava a non-null SAMFileHeader.- Specified by:
writeAlignment
in classSAMFileWriterImpl
- Parameters:
alignment
-
-
writeHeader
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.
-
finish
protected void finish()Description copied from class:SAMFileWriterImpl
Do any required flushing here.- Specified by:
finish
in classSAMFileWriterImpl
-
getFilename
Description copied from class:SAMFileWriterImpl
For producing error messages.- Specified by:
getFilename
in classSAMFileWriterImpl
- Returns:
- absolute path in URI format, or null if this writer does not correspond to a file. To get a Path from this, use: IOUtil.getPath(getFilename())
-
writeHeader
protected static void writeHeader(BinaryCodec outputBinaryCodec, SAMFileHeader samFileHeader, String headerText) Writes a header to a BAM file. samFileHeader and headerText are redundant - one can be used to regenerate the other but in some instances we already have both so this allows us to save some cycles -
writeHeader
Writes a header to a BAM file. -
writeHeader
Write a BAM file header to an output stream in block compressed BAM format.- Parameters:
outputStream
- the stream to write the BAM header tosamFileHeader
- the header to write
-