vg
tools for working with variation graphs
Public Member Functions | Private Member Functions | List of all members
vg::HTSAlignmentEmitter Class Reference

#include <hts_alignment_emitter.hpp>

Inheritance diagram for vg::HTSAlignmentEmitter:
vg::io::AlignmentEmitter vg::HTSWriter vg::SplicedHTSAlignmentEmitter

Public Member Functions

 HTSAlignmentEmitter (const string &filename, const string &format, const vector< pair< string, int64_t >> &path_order_and_length, const unordered_map< string, int64_t > &subpath_to_length, size_t max_threads)
 
 ~HTSAlignmentEmitter ()=default
 Tear down an HTSAlignmentEmitter and destroy HTSlib structures. More...
 
 HTSAlignmentEmitter (const HTSAlignmentEmitter &other)=delete
 
HTSAlignmentEmitteroperator= (const HTSAlignmentEmitter &other)=delete
 
 HTSAlignmentEmitter (HTSAlignmentEmitter &&other)=delete
 
HTSAlignmentEmitteroperator= (HTSAlignmentEmitter &&other)=delete
 
void emit_singles (vector< Alignment > &&aln_batch)
 Emit a batch of Alignments. More...
 
void emit_mapped_singles (vector< vector< Alignment >> &&alns_batch)
 
void emit_pairs (vector< Alignment > &&aln1_batch, vector< Alignment > &&aln2_batch, vector< int64_t > &&tlen_limit_batch)
 Emit a batch of pairs of Alignments. More...
 
void emit_mapped_pairs (vector< vector< Alignment >> &&alns1_batch, vector< vector< Alignment >> &&alns2_batch, vector< int64_t > &&tlen_limit_batch)
 
- Public Member Functions inherited from vg::io::AlignmentEmitter
virtual void emit_extra_message (const std::string &tag, std::string &&data)
 Emit some extra type-tagged data, if the backing format supports it. More...
 
virtual void emit_single (Alignment &&aln)
 Emit a single Alignment. More...
 
virtual void emit_mapped_single (vector< Alignment > &&alns)
 Emit a single Alignment with secondaries. All secondaries must have is_secondary set already. More...
 
virtual void emit_pair (Alignment &&aln1, Alignment &&aln2, int64_t tlen_limit=0)
 
virtual void emit_mapped_pair (vector< Alignment > &&alns1, vector< Alignment > &&alns2, int64_t tlen_limit=0)
 
virtual ~AlignmentEmitter ()=default
 Allow destruction through base class pointer. More...
 
- Public Member Functions inherited from vg::HTSWriter
 HTSWriter (const string &filename, const string &format, const vector< pair< string, int64_t >> &path_order_and_length, const unordered_map< string, int64_t > &subpath_to_length, size_t max_threads)
 
 ~HTSWriter ()
 Tear down an HTSWriter and destroy HTSlib structures. More...
 
 HTSWriter (const HTSWriter &other)=delete
 
HTSWriteroperator= (const HTSWriter &other)=delete
 
 HTSWriter (HTSWriter &&other)=delete
 
HTSWriteroperator= (HTSWriter &&other)=delete
 

Private Member Functions

virtual void convert_alignment (const Alignment &aln, vector< pair< int, char >> &cigar, bool &pos_rev, int64_t &pos, string &path_name) const
 
void convert_unpaired (Alignment &aln, bam_hdr_t *header, vector< bam1_t * > &dest)
 
void convert_paired (Alignment &aln1, Alignment &aln2, bam_hdr_t *header, int64_t tlen_limit, vector< bam1_t * > &dest)
 

Additional Inherited Members

- Protected Member Functions inherited from vg::HTSWriter
void save_records (bam_hdr_t *header, vector< bam1_t * > &records, size_t thread_number)
 
bam_hdr_t * ensure_header (const string &read_group, const string &sample_name, size_t thread_number)
 
void initialize_sam_file (bam_hdr_t *header, size_t thread_number, bool keep_header=false)
 
- Protected Attributes inherited from vg::HTSWriter
unique_ptr< ofstream > out_file
 If we are doing output to a file, this will hold the open file. Otherwise (for stdout) it will be empty. More...
 
vg::io::StreamMultiplexer multiplexer
 
string format
 This holds our format name, for later error messages. More...
 
vector< pair< string, int64_t > > path_order_and_length
 Store the path names and lengths in the order to put them in the header. More...
 
unordered_map< string, int64_t > subpath_to_length
 
vector< hFILE * > backing_files
 
vector< samFile * > sam_files
 
atomic< bam_hdr_t * > atomic_header
 We need a header. More...
 
string sam_header
 
mutex header_mutex
 If the header isn't present when we want to write, we need a mutex to control creating it. More...
 
bool output_is_bgzf
 
string hts_mode
 Remember the HTSlib mode string we need to open our files. More...
 
- Static Protected Attributes inherited from vg::HTSWriter
static const size_t BGZF_FOOTER_LENGTH = 28
 We hack about with htslib's BGZF EOF footers, so we need to know how long they are. More...
 

Detailed Description

Emit Alignments to a stream in SAM/BAM/CRAM format. Thread safe.

Constructor & Destructor Documentation

◆ HTSAlignmentEmitter() [1/3]

vg::HTSAlignmentEmitter::HTSAlignmentEmitter ( const string &  filename,
const string &  format,
const vector< pair< string, int64_t >> &  path_order_and_length,
const unordered_map< string, int64_t > &  subpath_to_length,
size_t  max_threads 
)

Create an HTSAlignmentEmitter writing to the given file (or "-") in the given HTS format ("SAM", "BAM", "CRAM"). path_order_and_length must give contig names and lengths to include in the header, in order. Sample names and read groups for the header will be guessed from the first reads. HTSlib positions will be read from the alignments' refpos, and the alignments must be surjected.

◆ ~HTSAlignmentEmitter()

vg::HTSAlignmentEmitter::~HTSAlignmentEmitter ( )
default

Tear down an HTSAlignmentEmitter and destroy HTSlib structures.

◆ HTSAlignmentEmitter() [2/3]

vg::HTSAlignmentEmitter::HTSAlignmentEmitter ( const HTSAlignmentEmitter other)
delete

◆ HTSAlignmentEmitter() [3/3]

vg::HTSAlignmentEmitter::HTSAlignmentEmitter ( HTSAlignmentEmitter &&  other)
delete

Member Function Documentation

◆ convert_alignment()

void vg::HTSAlignmentEmitter::convert_alignment ( const Alignment aln,
vector< pair< int, char >> &  cigar,
bool &  pos_rev,
int64_t &  pos,
string &  path_name 
) const
privatevirtual

Reimplemented in vg::SplicedHTSAlignmentEmitter.

◆ convert_paired()

void vg::HTSAlignmentEmitter::convert_paired ( Alignment aln1,
Alignment aln2,
bam_hdr_t *  header,
int64_t  tlen_limit,
vector< bam1_t * > &  dest 
)
private

Convert a paired alignment to HTS format. Header must have been created already.

◆ convert_unpaired()

void vg::HTSAlignmentEmitter::convert_unpaired ( Alignment aln,
bam_hdr_t *  header,
vector< bam1_t * > &  dest 
)
private

Convert an unpaired alignment to HTS format. Header must have been created already.

◆ emit_mapped_pairs()

void vg::HTSAlignmentEmitter::emit_mapped_pairs ( vector< vector< Alignment >> &&  alns1_batch,
vector< vector< Alignment >> &&  alns2_batch,
vector< int64_t > &&  tlen_limit_batch 
)
virtual

Emit the mappings of a batch of pairs of Alignments. All secondaries must have is_secondary set already.

Implements vg::io::AlignmentEmitter.

◆ emit_mapped_singles()

void vg::HTSAlignmentEmitter::emit_mapped_singles ( vector< vector< Alignment >> &&  alns_batch)
virtual

Emit a batch of Alignments with secondaries. All secondaries must have is_secondary set already.

Implements vg::io::AlignmentEmitter.

◆ emit_pairs()

void vg::HTSAlignmentEmitter::emit_pairs ( vector< Alignment > &&  aln1_batch,
vector< Alignment > &&  aln2_batch,
vector< int64_t > &&  tlen_limit_batch 
)
virtual

Emit a batch of pairs of Alignments.

Implements vg::io::AlignmentEmitter.

◆ emit_singles()

void vg::HTSAlignmentEmitter::emit_singles ( vector< Alignment > &&  aln_batch)
virtual

Emit a batch of Alignments.

Implements vg::io::AlignmentEmitter.

◆ operator=() [1/2]

HTSAlignmentEmitter& vg::HTSAlignmentEmitter::operator= ( const HTSAlignmentEmitter other)
delete

◆ operator=() [2/2]

HTSAlignmentEmitter& vg::HTSAlignmentEmitter::operator= ( HTSAlignmentEmitter &&  other)
delete

The documentation for this class was generated from the following files: