BamTools::BamWriter Class Reference

Provides write access for generating BAM files. More...

#include <BamWriter.h>

List of all members.

Public Types

enum  CompressionMode { Compressed = 0, Uncompressed }
 

This enum describes the compression behaviors for output BAM files.

More...

Public Member Functions

 BamWriter (void)
 constructor
 ~BamWriter (void)
 destructor
void Close (void)
 Closes the current BAM file.
std::string GetErrorString (void) const
 Returns a human-readable description of the last error that occurred.
bool IsOpen (void) const
 Returns true if BAM file is open for writing.
bool Open (const std::string &filename, const std::string &samHeaderText, const RefVector &referenceSequences)
 Opens a BAM file for writing.
bool Open (const std::string &filename, const SamHeader &samHeader, const RefVector &referenceSequences)
 Opens a BAM file for writing.
bool SaveAlignment (const BamAlignment &alignment)
 Saves an alignment to the BAM file.
void SetCompressionMode (const BamWriter::CompressionMode &compressionMode)
 Sets the output compression mode.

Detailed Description

Provides write access for generating BAM files.


Member Enumeration Documentation

This enum describes the compression behaviors for output BAM files.

Enumerator:
Compressed 

Use normal BAM compression.

Uncompressed 

Disable BAM compression.

Useful in situations where the BAM data is streamed (e.g. piping). It would be wasteful to compress, and then immediately decompress the data.


Constructor & Destructor Documentation

BamWriter::BamWriter ( void   ) 

constructor

BamWriter::~BamWriter ( void   ) 

destructor


Member Function Documentation

void BamWriter::Close ( void   ) 

Closes the current BAM file.

See also:
Open()
std::string BamWriter::GetErrorString ( void   )  const

Returns a human-readable description of the last error that occurred.

This method allows elimination of STDERR pollution. Developers of client code may choose how the messages are displayed to the user, if at all.

Returns:
error description
bool BamWriter::IsOpen ( void   )  const

Returns true if BAM file is open for writing.

See also:
Open()
bool BamWriter::Open ( const std::string &  filename,
const SamHeader samHeader,
const RefVector referenceSequences 
)

Opens a BAM file for writing.

This is an overloaded function.

Will overwrite the BAM file if it already exists.

Parameters:
[in] filename name of output BAM file
[in] samHeader header data, wrapped in SamHeader object
[in] referenceSequences list of reference entries
Returns:
true if opened successfully
See also:
Close(), IsOpen(), BamReader::GetHeader(), BamReader::GetReferenceData()
bool BamWriter::Open ( const std::string &  filename,
const std::string &  samHeaderText,
const RefVector referenceSequences 
)

Opens a BAM file for writing.

Will overwrite the BAM file if it already exists.

Parameters:
[in] filename name of output BAM file
[in] samHeaderText header data, as SAM-formatted string
[in] referenceSequences list of reference entries
Returns:
true if opened successfully
See also:
Close(), IsOpen(), BamReader::GetHeaderText(), BamReader::GetReferenceData()
bool BamWriter::SaveAlignment ( const BamAlignment alignment  ) 

Saves an alignment to the BAM file.

Parameters:
[in] alignment BamAlignment record to save
See also:
BamReader::GetNextAlignment(), BamReader::GetNextAlignmentCore()
void BamWriter::SetCompressionMode ( const BamWriter::CompressionMode compressionMode  ) 

Sets the output compression mode.

Default mode is BamWriter::Compressed.

Note:
Changing the compression mode is disabled on open files (i.e. the request will be ignored). Be sure to call this function before opening the BAM file.
        BamWriter writer;
        writer.SetCompressionMode(BamWriter::Uncompressed);
        writer.Open( ... );
        // ...
Parameters:
[in] compressionMode desired output compression behavior
See also:
IsOpen(), Open()

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Aug 29 17:43:46 2012 for BamTools by  doxygen 1.6.3