vg
tools for working with variation graphs
Loading...
Searching...
No Matches
vg::MultipathAlignmentEmitter Class Reference

#include <multipath_alignment_emitter.hpp>

Inheritance diagram for vg::MultipathAlignmentEmitter:
vg::HTSWriter

Public Member Functions

 MultipathAlignmentEmitter (const string &filename, size_t num_threads, const string out_format="GAMP", const PathPositionHandleGraph *graph=nullptr, const SequenceDictionary *sequence_dictionary=nullptr)
 ~MultipathAlignmentEmitter ()
void set_read_group (const string &read_group)
 Choose a read group to apply to all emitted alignments.
void set_sample_name (const string &sample_name)
 Choose a sample name to apply to all emitted alignments.
void set_min_splice_length (int64_t min_splice_length)
void emit_pairs (const string &name_1, const string &name_2, vector< pair< multipath_alignment_t, multipath_alignment_t > > &&mp_aln_pairs, vector< pair< tuple< string, bool, int64_t >, tuple< string, bool, int64_t > > > *path_positions=nullptr, vector< int64_t > *tlen_limits=nullptr)
 Emit paired read mappings as interleaved protobuf messages or HTSLib output.
void emit_singles (const string &name, vector< multipath_alignment_t > &&mp_alns, vector< tuple< string, bool, int64_t > > *path_positions=nullptr)
 Emit read mappings as protobuf messages or HTSLib output.
void emit_paired_independent (const string &name_1, const string &name_2, vector< multipath_alignment_t > &&mp_alns_1, vector< multipath_alignment_t > &&mp_alns_2, vector< tuple< string, bool, int64_t > > *path_positions_1=nullptr, vector< tuple< string, bool, int64_t > > *path_positions_2=nullptr)
 Emit unpaired independent or supplementary alignments for paired reads.
Public Member Functions inherited from vg::HTSWriter
 HTSWriter (const string &filename, const string &format, const SequenceDictionary &sequence_dictionary, const unordered_map< string, size_t > &subpath_to_index, size_t max_threads)
 ~HTSWriter ()
 Tear down an HTSWriter and destroy HTSlib structures.
 HTSWriter (const HTSWriter &other)=delete
HTSWriter & operator= (const HTSWriter &other)=delete
 HTSWriter (HTSWriter &&other)=delete
HTSWriter & operator= (HTSWriter &&other)=delete

Private Types

enum  output_format_t {
  GAMP , GAM , GAF , BAM ,
  SAM , CRAM
}
 what format are we outputting in More...

Private Member Functions

void emit_singles_internal (const string &name, vector< multipath_alignment_t > &&mp_alns, vector< tuple< string, bool, int64_t > > *path_positions, const string *mate_name, bool is_read_1)
 Emit read mappings as protobuf messages or HTSLib output.
void convert_to_alignment (const multipath_alignment_t &mp_aln, Alignment &aln, const string *prev_name=nullptr, const string *next_name=nullptr) const
 make a GAM alignment from a multipath alignment
void create_alignment_shim (const string &name, const multipath_alignment_t &mp_aln, Alignment &shim, const string *prev_name=nullptr, const string *next_name=nullptr) const
 store the data in an Algnment that is used in the conversion to bam1_t
void convert_to_hts_unpaired (const string &name, const multipath_alignment_t &mp_aln, const string &ref_name, bool ref_rev, int64_t ref_pos, bam_hdr_t *header, vector< bam1_t * > &dest, const string *mate_name=nullptr) const
 store a bam1_t object with the indicated data in the dest vector
void convert_to_hts_paired (const string &name_1, const string &name_2, const multipath_alignment_t &mp_aln_1, const multipath_alignment_t &mp_aln_2, const string &ref_name_1, bool ref_rev_1, int64_t ref_pos_1, const string &ref_name_2, bool ref_rev_2, int64_t ref_pos_2, int64_t tlen_limit, bam_hdr_t *header, vector< bam1_t * > &dest) const
 store two paired bam1_t objects with the indicated data in the dest vector
void add_annotations (const multipath_alignment_t &mp_aln, bam1_t *bam) const
 transfer the allelic mapq, group mapq, and secondary annotations to a BAM record
void canonicalize_subrange (string &path_name, int32_t &pos) const
 take subrange info out of the path name and adjust the position for the subrange start

Private Attributes

output_format_t format
const PathPositionHandleGraph * graph
vector< unique_ptr< vg::io::ProtobufEmitter< Alignment > > > aln_emitters
 an Alignment emitter for each thread
vector< unique_ptr< vg::io::ProtobufEmitter< MultipathAlignment > > > mp_aln_emitters
 a MultipathAlignment emitter for each thread
string read_group
 read group applied to alignments
string sample_name
 sample name applied to alignments
int64_t min_splice_length = numeric_limits<int64_t>::max()
 the shortest deletion that we will interpret as a splice in the CIGAR string of HTS output

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.
vg::io::StreamMultiplexer multiplexer
string format
SequenceDictionary sequence_dictionary
unordered_map< string, size_t > subpath_to_index
 This maps from subpath to entry number in the sequence dictionary.
vector< hFILE * > backing_files
vector< samFile * > sam_files
atomic< bam_hdr_t * > atomic_header
 We need a header.
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.
bool output_is_bgzf
string hts_mode
 Remember the HTSlib mode string we need to open our files.
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.
static const size_t HTSLIB_CRAM_THREADS = 8
 For CRAM output, we use a separate pool of compressor threads inside htslib.

Member Enumeration Documentation

◆ output_format_t

what format are we outputting in

Enumerator
GAMP 
GAM 
GAF 
BAM 
SAM 
CRAM 

Constructor & Destructor Documentation

◆ MultipathAlignmentEmitter()

vg::MultipathAlignmentEmitter::MultipathAlignmentEmitter ( const string & filename,
size_t num_threads,
const string out_format = "GAMP",
const PathPositionHandleGraph * graph = nullptr,
const SequenceDictionary * sequence_dictionary = nullptr )

Initialize with the intended output stream and the maximum number of threads that will be outputting. Allowed formats:

  • "GAMP"
  • "GAM", involves conversion to single path
  • "GAF", involves conversion to single path, requires a graph
  • "SAM", "BAM", "CRAM:" requires path length map, and all input alignments must already be surjected. If alignments have connections, requires a graph

◆ ~MultipathAlignmentEmitter()

vg::MultipathAlignmentEmitter::~MultipathAlignmentEmitter ( )

Member Function Documentation

◆ add_annotations()

void vg::MultipathAlignmentEmitter::add_annotations ( const multipath_alignment_t & mp_aln,
bam1_t * bam ) const
private

transfer the allelic mapq, group mapq, and secondary annotations to a BAM record

◆ canonicalize_subrange()

void vg::MultipathAlignmentEmitter::canonicalize_subrange ( string & path_name,
int32_t & pos ) const
private

take subrange info out of the path name and adjust the position for the subrange start

◆ convert_to_alignment()

void vg::MultipathAlignmentEmitter::convert_to_alignment ( const multipath_alignment_t & mp_aln,
Alignment & aln,
const string * prev_name = nullptr,
const string * next_name = nullptr ) const
private

make a GAM alignment from a multipath alignment

◆ convert_to_hts_paired()

void vg::MultipathAlignmentEmitter::convert_to_hts_paired ( const string & name_1,
const string & name_2,
const multipath_alignment_t & mp_aln_1,
const multipath_alignment_t & mp_aln_2,
const string & ref_name_1,
bool ref_rev_1,
int64_t ref_pos_1,
const string & ref_name_2,
bool ref_rev_2,
int64_t ref_pos_2,
int64_t tlen_limit,
bam_hdr_t * header,
vector< bam1_t * > & dest ) const
private

store two paired bam1_t objects with the indicated data in the dest vector

◆ convert_to_hts_unpaired()

void vg::MultipathAlignmentEmitter::convert_to_hts_unpaired ( const string & name,
const multipath_alignment_t & mp_aln,
const string & ref_name,
bool ref_rev,
int64_t ref_pos,
bam_hdr_t * header,
vector< bam1_t * > & dest,
const string * mate_name = nullptr ) const
private

store a bam1_t object with the indicated data in the dest vector

◆ create_alignment_shim()

void vg::MultipathAlignmentEmitter::create_alignment_shim ( const string & name,
const multipath_alignment_t & mp_aln,
Alignment & shim,
const string * prev_name = nullptr,
const string * next_name = nullptr ) const
private

store the data in an Algnment that is used in the conversion to bam1_t

◆ emit_paired_independent()

void vg::MultipathAlignmentEmitter::emit_paired_independent ( const string & name_1,
const string & name_2,
vector< multipath_alignment_t > && mp_alns_1,
vector< multipath_alignment_t > && mp_alns_2,
vector< tuple< string, bool, int64_t > > * path_positions_1 = nullptr,
vector< tuple< string, bool, int64_t > > * path_positions_2 = nullptr )

Emit unpaired independent or supplementary alignments for paired reads.

◆ emit_pairs()

void vg::MultipathAlignmentEmitter::emit_pairs ( const string & name_1,
const string & name_2,
vector< pair< multipath_alignment_t, multipath_alignment_t > > && mp_aln_pairs,
vector< pair< tuple< string, bool, int64_t >, tuple< string, bool, int64_t > > > * path_positions = nullptr,
vector< int64_t > * tlen_limits = nullptr )

Emit paired read mappings as interleaved protobuf messages or HTSLib output.

◆ emit_singles()

void vg::MultipathAlignmentEmitter::emit_singles ( const string & name,
vector< multipath_alignment_t > && mp_alns,
vector< tuple< string, bool, int64_t > > * path_positions = nullptr )

Emit read mappings as protobuf messages or HTSLib output.

◆ emit_singles_internal()

void vg::MultipathAlignmentEmitter::emit_singles_internal ( const string & name,
vector< multipath_alignment_t > && mp_alns,
vector< tuple< string, bool, int64_t > > * path_positions,
const string * mate_name,
bool is_read_1 )
private

Emit read mappings as protobuf messages or HTSLib output.

◆ set_min_splice_length()

void vg::MultipathAlignmentEmitter::set_min_splice_length ( int64_t min_splice_length)

Set the length deletion (at a node boundary) that will be considered an unaligned splicing event in HTSLib output

◆ set_read_group()

void vg::MultipathAlignmentEmitter::set_read_group ( const string & read_group)

Choose a read group to apply to all emitted alignments.

◆ set_sample_name()

void vg::MultipathAlignmentEmitter::set_sample_name ( const string & sample_name)

Choose a sample name to apply to all emitted alignments.

Member Data Documentation

◆ aln_emitters

vector<unique_ptr<vg::io::ProtobufEmitter<Alignment> > > vg::MultipathAlignmentEmitter::aln_emitters
private

an Alignment emitter for each thread

◆ format

output_format_t vg::MultipathAlignmentEmitter::format
private

◆ graph

const PathPositionHandleGraph* vg::MultipathAlignmentEmitter::graph
private

◆ min_splice_length

int64_t vg::MultipathAlignmentEmitter::min_splice_length = numeric_limits<int64_t>::max()
private

the shortest deletion that we will interpret as a splice in the CIGAR string of HTS output

◆ mp_aln_emitters

vector<unique_ptr<vg::io::ProtobufEmitter<MultipathAlignment> > > vg::MultipathAlignmentEmitter::mp_aln_emitters
private

a MultipathAlignment emitter for each thread

◆ read_group

string vg::MultipathAlignmentEmitter::read_group
private

read group applied to alignments

◆ sample_name

string vg::MultipathAlignmentEmitter::sample_name
private

sample name applied to alignments


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