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
ConstructorsModifierConstructorDescriptionprotectedBAMFileWriter(File path) protectedBAMFileWriter(File path, int compressionLevel) protectedBAMFileWriter(OutputStream os, File file) protectedBAMFileWriter(OutputStream os, File file, int compressionLevel) protectedBAMFileWriter(OutputStream os, File file, int compressionLevel, DeflaterFactory deflaterFactory) protectedBAMFileWriter(OutputStream os, String absoluteFilename, int compressionLevel, DeflaterFactory deflaterFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfinish()Do any required flushing here.protected StringFor producing error messages.protected voidwriteAlignment(SAMRecord alignment) Writes the record to disk.protected static voidwriteHeader(BinaryCodec outputBinaryCodec, SAMFileHeader samFileHeader) Writes a header to a BAM file.protected static voidwriteHeader(BinaryCodec outputBinaryCodec, SAMFileHeader samFileHeader, String headerText) Writes a header to a BAM file.static voidwriteHeader(OutputStream outputStream, SAMFileHeader samFileHeader) Write a BAM file header to an output stream in block compressed BAM format.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, 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:SAMFileWriterImplWrites 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:
writeAlignmentin classSAMFileWriterImpl- Parameters:
alignment-
-
writeHeader
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.
-
finish
protected void finish()Description copied from class:SAMFileWriterImplDo any required flushing here.- Specified by:
finishin classSAMFileWriterImpl
-
getFilename
Description copied from class:SAMFileWriterImplFor producing error messages.- Specified by:
getFilenamein 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
-