htsjdk.samtools
Class SAMTextWriter

java.lang.Object
  extended by htsjdk.samtools.SAMFileWriterImpl
      extended by htsjdk.samtools.SAMTextWriter
All Implemented Interfaces:
SAMFileWriter, java.io.Closeable

public class SAMTextWriter
extends SAMFileWriterImpl

Writer for text-format SAM files.


Constructor Summary
SAMTextWriter(java.io.File file)
          Constructs a SAMTextWriter that writes to a File.
SAMTextWriter(java.io.OutputStream stream)
          Constructs a SAMTextWriter that writes to an OutputStream.
SAMTextWriter(java.io.Writer out)
          Constructs a SAMTextWriter that outputs to a Writer.
 
Method Summary
 void finish()
          Do any required flushing here.
 java.lang.String getFilename()
          For producing error messages.
 java.io.Writer getWriter()
          Returns the Writer used by this instance.
 void writeAlignment(SAMRecord alignment)
          Write the record.
 void writeHeader(java.lang.String textHeader)
          Write the header text.
 
Methods inherited from class htsjdk.samtools.SAMFileWriterImpl
addAlignment, close, getDefaultMaxRecordsInRam, getFileHeader, getSortOrder, setDefaultMaxRecordsInRam, setHeader, setProgressLogger, setSortOrder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAMTextWriter

public SAMTextWriter(java.io.Writer out)
Constructs a SAMTextWriter that outputs to a Writer.

Parameters:
out - Writer.

SAMTextWriter

public SAMTextWriter(java.io.File file)
Constructs a SAMTextWriter that writes to a File.

Parameters:
file - Where to write the output.

SAMTextWriter

public SAMTextWriter(java.io.OutputStream stream)
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 Detail

getWriter

public java.io.Writer getWriter()
Returns the Writer used by this instance. Useful for flushing the output.


writeAlignment

public void writeAlignment(SAMRecord alignment)
Write the record.

Specified by:
writeAlignment in class SAMFileWriterImpl
Parameters:
alignment - SAMRecord.

writeHeader

public void writeHeader(java.lang.String textHeader)
Write the header text. This method can also be used to write an arbitrary String, not necessarily the header.

Specified by:
writeHeader in class SAMFileWriterImpl
Parameters:
textHeader - String containing the text to write.

finish

public void finish()
Do any required flushing here.

Specified by:
finish in class SAMFileWriterImpl

getFilename

public java.lang.String getFilename()
For producing error messages.

Specified by:
getFilename in class SAMFileWriterImpl
Returns:
Output filename, or null if there isn't one.