vg
tools for working with variation graphs
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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 vector< pair< string, int64_t >> *path_order_and_length=nullptr)
 
 ~MultipathAlignmentEmitter ()
 
void set_read_group (const string &read_group)
 Choose a read group to apply to all emitted alignments. More...
 
void set_sample_name (const string &sample_name)
 Choose a sample name to apply to all emitted alignments. More...
 
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. More...
 
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. 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 Types

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

Private Member Functions

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 More...
 
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 More...
 
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
 store a bam1_t object with the indicated data in the dest vector More...
 
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 More...
 
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 More...
 

Private Attributes

output_format_t format
 
const PathPositionHandleGraphgraph
 
vector< unique_ptr< vg::io::ProtobufEmitter< Alignment > > > aln_emitters
 an Alignment emitter for each thread More...
 
vector< unique_ptr< vg::io::ProtobufEmitter< MultipathAlignment > > > mp_aln_emitters
 a MultipathAlignment emitter for each thread More...
 
string read_group
 read group applied to alignments More...
 
string sample_name
 sample name applied to alignments More...
 
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 More...
 

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...
 

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 vector< pair< string, int64_t >> *  path_order_and_length = 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

◆ 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
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_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.

◆ 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.

◆ 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: