Package htsjdk.samtools
Class SAMTextWriter
java.lang.Object
htsjdk.samtools.SAMFileWriterImpl
htsjdk.samtools.SAMTextWriter
- All Implemented Interfaces:
SAMFileWriter,Closeable,AutoCloseable
Writer for text-format SAM files.
-
Constructor Summary
ConstructorsConstructorDescriptionSAMTextWriter(File file) Constructs a SAMTextWriter that writes to a File.SAMTextWriter(File file, SamFlagField samFlagFieldOutput) Constructs a SAMTextWriter that writes to a File.SAMTextWriter(OutputStream stream) Constructs a SAMTextWriter that writes to an OutputStream.SAMTextWriter(OutputStream stream, SamFlagField samFlagFieldOutput) Constructs a SAMTextWriter that writes to an OutputStream.SAMTextWriter(Writer out) Constructs a SAMTextWriter that outputs to a Writer.SAMTextWriter(Writer out, SamFlagField samFlagFieldOutput) Constructs a SAMTextWriter that outputs to a Writer. -
Method Summary
Modifier and TypeMethodDescriptionvoidfinish()Do any required flushing here.For producing error messages.Returns the Writer used by this instance.voidwriteAlignment(SAMRecord alignment) Write the record.protected voidwriteHeader(SAMFileHeader header) Write the header to disk.voidwriteHeader(String textHeader) Write the header text.Methods inherited from class htsjdk.samtools.SAMFileWriterImpl
addAlignment, close, getDefaultMaxRecordsInRam, getFileHeader, getMaxRecordsInRam, getSortOrder, getTempDirectory, setDefaultMaxRecordsInRam, setHeader, setMaxRecordsInRam, setProgressLogger, setSortOrder, setSortOrderChecking, setTempDirectory
-
Constructor Details
-
SAMTextWriter
Constructs a SAMTextWriter that outputs to a Writer.- Parameters:
out- Writer.
-
SAMTextWriter
Constructs a SAMTextWriter that writes to a File.- Parameters:
file- Where to write the output.
-
SAMTextWriter
Constructs a SAMTextWriter that writes to an OutputStream. The OutputStream is wrapped in an AsciiWriter, which can be retrieved with getWriter().- Parameters:
stream- Need not be buffered because this class provides buffering.
-
SAMTextWriter
Constructs a SAMTextWriter that outputs to a Writer.- Parameters:
out- Writer.
-
SAMTextWriter
Constructs a SAMTextWriter that writes to a File.- Parameters:
file- Where to write the output.
-
SAMTextWriter
Constructs a SAMTextWriter that writes to an OutputStream. The OutputStream is wrapped in an AsciiWriter, which can be retrieved with getWriter().- Parameters:
stream- Need not be buffered because this class provides buffering.
-
-
Method Details
-
getWriter
Returns the Writer used by this instance. Useful for flushing the output. -
writeAlignment
Write the record.- Specified by:
writeAlignmentin classSAMFileWriterImpl- Parameters:
alignment- SAMRecord.
-
writeHeader
Write the header text. This method can also be used to write an arbitrary String, not necessarily the header.- Specified by:
writeHeaderin classSAMFileWriterImpl- Parameters:
textHeader- String containing the text to write.
-
writeHeader
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
public void finish()Do any required flushing here.- Specified by:
finishin classSAMFileWriterImpl
-
getFilename
For producing error messages.- Specified by:
getFilenamein classSAMFileWriterImpl- Returns:
- Output filename, or null if there isn't one.
-