vg
tools for working with variation graphs
Classes | Namespaces | Functions | Variables
alignment.hpp File Reference
#include <iostream>
#include <functional>
#include <zlib.h>
#include "utility.hpp"
#include "path.hpp"
#include "position.hpp"
#include <vg/vg.pb.h>
#include "vg/io/edit.hpp"
#include <htslib/hfile.h>
#include <htslib/hts.h>
#include <htslib/sam.h>
#include <htslib/vcf.h>
#include "handle.hpp"
#include "vg/io/alignment_io.hpp"
#include <vg/io/alignment_emitter.hpp>

Classes

struct  vg::AlignmentValidity
 

Namespaces

 vg
 

Functions

int vg::hts_for_each (string &filename, function< void(Alignment &)> lambda)
 
int vg::hts_for_each_parallel (string &filename, function< void(Alignment &)> lambda)
 
int vg::hts_for_each (string &filename, function< void(Alignment &)> lambda, const PathPositionHandleGraph *graph)
 
int vg::hts_for_each_parallel (string &filename, function< void(Alignment &)> lambda, const PathPositionHandleGraph *graph)
 
int vg::fastq_for_each (string &filename, function< void(Alignment &)> lambda)
 
bool vg::get_next_alignment_from_fastq (gzFile fp, char *buffer, size_t len, Alignment &alignment)
 
bool vg::get_next_interleaved_alignment_pair_from_fastq (gzFile fp, char *buffer, size_t len, Alignment &mate1, Alignment &mate2)
 
bool vg::get_next_alignment_pair_from_fastqs (gzFile fp1, gzFile fp2, char *buffer, size_t len, Alignment &mate1, Alignment &mate2)
 
size_t vg::fastq_unpaired_for_each (const string &filename, function< void(Alignment &)> lambda)
 
size_t vg::fastq_paired_interleaved_for_each (const string &filename, function< void(Alignment &, Alignment &)> lambda)
 
size_t vg::fastq_paired_two_files_for_each (const string &file1, const string &file2, function< void(Alignment &, Alignment &)> lambda)
 
size_t vg::fastq_unpaired_for_each_parallel (const string &filename, function< void(Alignment &)> lambda, uint64_t batch_size)
 
size_t vg::fastq_paired_interleaved_for_each_parallel (const string &filename, function< void(Alignment &, Alignment &)> lambda, uint64_t batch_size)
 
size_t vg::fastq_paired_interleaved_for_each_parallel_after_wait (const string &filename, function< void(Alignment &, Alignment &)> lambda, function< bool(void)> single_threaded_until_true, uint64_t batch_size)
 
size_t vg::fastq_paired_two_files_for_each_parallel (const string &file1, const string &file2, function< void(Alignment &, Alignment &)> lambda, uint64_t batch_size)
 
size_t vg::fastq_paired_two_files_for_each_parallel_after_wait (const string &file1, const string &file2, function< void(Alignment &, Alignment &)> lambda, function< bool(void)> single_threaded_until_true, uint64_t batch_size)
 
bam_hdr_t * vg::hts_file_header (string &filename, string &header)
 
bam_hdr_t * vg::hts_string_header (string &header, const map< string, int64_t > &path_length, const map< string, string > &rg_sample)
 
bam_hdr_t * vg::hts_string_header (string &header, const vector< pair< string, int64_t >> &path_order_and_length, const map< string, string > &rg_sample)
 
void vg::write_alignment_to_file (const Alignment &aln, const string &filename)
 
void vg::mapping_cigar (const Mapping &mapping, vector< pair< int, char > > &cigar)
 
string vg::cigar_string (const vector< pair< int, char > > &cigar)
 
string vg::mapping_string (const string &source, const Mapping &mapping)
 
void vg::cigar_mapping (const bam1_t *b, Mapping &mapping)
 
Alignment vg::bam_to_alignment (const bam1_t *b, const map< string, string > &rg_sample, const map< int, path_handle_t > &tid_path_handle, const bam_hdr_t *bh, const PathPositionHandleGraph *graph)
 
Alignment vg::bam_to_alignment (const bam1_t *b, const map< string, string > &rg_sample, const map< int, path_handle_t > &tid_path_handle)
 
void vg::append_cigar_operation (const int length, const char operation, vector< pair< int, char >> &cigar)
 
bam1_t * vg::alignment_to_bam (bam_hdr_t *bam_header, const Alignment &alignment, const string &refseq, const int32_t refpos, const bool refrev, const vector< pair< int, char >> &cigar, const string &mateseq, const int32_t matepos, bool materev, const int32_t tlen, const int32_t tlen_max)
 
bam1_t * vg::alignment_to_bam (bam_hdr_t *bam_header, const Alignment &alignment, const string &refseq, const int32_t refpos, const bool refrev, const vector< pair< int, char >> &cigar)
 
string vg::alignment_to_sam (const Alignment &alignment, const string &refseq, const int32_t refpos, const bool refrev, const vector< pair< int, char >> &cigar, const string &mateseq, const int32_t matepos, bool materev, const int32_t tlen, const int32_t tlen_max)
 
string vg::alignment_to_sam (const Alignment &alignment, const string &refseq, const int32_t refpos, const bool refrev, const vector< pair< int, char >> &cigar)
 
int32_t vg::determine_flag (const Alignment &alignment, const string &refseq, const int32_t refpos, const bool refrev, const string &mateseq, const int32_t matepos, bool materev, const int32_t tlen, bool paired, const int32_t tlen_max)
 Returns the SAM bit-coded flag for alignment with. More...
 
vector< pair< int, char > > vg::cigar_against_path (const Alignment &alignment, bool on_reverse_strand, int64_t &pos, size_t path_len, size_t softclip_suppress)
 
void vg::simplify_cigar (vector< pair< int, char >> &cigar)
 
void vg::mapping_against_path (Alignment &alignment, const bam1_t *b, const path_handle_t &path, const PathPositionHandleGraph *graph, bool on_reverse_strand)
 
pair< int32_t, int32_t > vg::compute_template_lengths (const int64_t &pos1, const vector< pair< int, char >> &cigar1, const int64_t &pos2, const vector< pair< int, char >> &cigar2)
 
int32_t vg::sam_flag (const Alignment &alignment, bool on_reverse_strand, bool paired)
 
void vg::parse_rg_sample_map (char *hts_header, map< string, string > &rg_sample)
 Populate a mapping from read group to sample name, given the text BAM header. More...
 
void vg::parse_tid_path_handle_map (const bam_hdr_t *hts_header, const PathHandleGraph *graph, map< int, path_handle_t > &tid_path_handle)
 
int vg::alignment_to_length (const Alignment &a)
 
int vg::alignment_from_length (const Alignment &a)
 
Alignmentvg::extend_alignment (Alignment &a1, const Alignment &a2, bool debug)
 
Alignment vg::merge_alignments (const vector< Alignment > &alns)
 
Alignment vg::merge_alignments (const Alignment &a1, const Alignment &a2, bool debug)
 
Alignment vg::strip_from_start (const Alignment &aln, size_t drop)
 
Alignment vg::strip_from_end (const Alignment &aln, size_t drop)
 
Alignment vg::trim_alignment (const Alignment &aln, const Position &pos1, const Position &pos2)
 
vector< Alignmentvg::alignment_ends (const Alignment &aln, size_t len1, size_t len2)
 
Alignment vg::alignment_middle (const Alignment &aln, int len)
 
const string vg::hash_alignment (const Alignment &aln)
 
Alignment vg::reverse_complement_alignment (const Alignment &aln, const function< int64_t(id_t)> &node_length)
 
void vg::reverse_complement_alignment_in_place (Alignment *aln, const function< int64_t(id_t)> &node_length)
 
vector< Alignmentvg::reverse_complement_alignments (const vector< Alignment > &alns, const function< int64_t(int64_t)> &node_length)
 
int vg::non_match_start (const Alignment &alignment)
 
int vg::non_match_end (const Alignment &alignment)
 
int vg::softclip_start (const Alignment &alignment)
 
int vg::softclip_end (const Alignment &alignment)
 
int vg::softclip_trim (Alignment &alignment)
 
int vg::query_overlap (const Alignment &aln1, const Alignment &aln2)
 
int vg::edit_count (const Alignment &alignment)
 
size_t vg::to_length_after_pos (const Alignment &aln, const Position &pos)
 
size_t vg::from_length_after_pos (const Alignment &aln, const Position &pos)
 
size_t vg::to_length_before_pos (const Alignment &aln, const Position &pos)
 
size_t vg::from_length_before_pos (const Alignment &aln, const Position &pos)
 
string vg::signature (const Alignment &aln)
 
pair< string, string > vg::signature (const Alignment &aln1, const Alignment &aln2)
 
string vg::middle_signature (const Alignment &aln, int len)
 
pair< string, string > vg::middle_signature (const Alignment &aln1, const Alignment &aln2, int len)
 
void vg::translate_nodes (Alignment &a, const unordered_map< id_t, pair< id_t, bool > > &ids, const std::function< size_t(int64_t)> &node_length)
 
void vg::flip_nodes (Alignment &a, const set< int64_t > &ids, const std::function< size_t(int64_t)> &node_length)
 
bool vg::uses_Us (const Alignment &alignment)
 
void vg::convert_Us_to_Ts (Alignment &alignment)
 Replaces any U's in the sequence or the Path with T's. More...
 
void vg::convert_Ts_to_Us (Alignment &alignment)
 Replaces any T's in the sequence or the Path with U's. More...
 
Alignment vg::simplify (const Alignment &a, bool trim_internal_deletions)
 
void vg::normalize_alignment (Alignment &alignment)
 Merge adjacent edits of the same type and convert all N matches to mismatches. More...
 
map< id_t, int > vg::alignment_quality_per_node (const Alignment &aln)
 
void vg::parse_bed_regions (istream &bedstream, const PathPositionHandleGraph *graph, const std::function< void(Alignment &)> &callback)
 
void vg::parse_gff_regions (istream &gffstream, const PathPositionHandleGraph *graph, const std::function< void(Alignment &)> &callback)
 
void vg::parse_bed_regions (istream &bedstream, const PathPositionHandleGraph *graph, vector< Alignment > *out_alignments)
 
void vg::parse_gff_regions (istream &gffstream, const PathPositionHandleGraph *graph, vector< Alignment > *out_alignments)
 
Position vg::alignment_start (const Alignment &aln)
 
Position vg::alignment_end (const Alignment &aln)
 
map< string,vector< pair< size_t, bool > > > vg::alignment_refpos_to_path_offsets (const Alignment &aln)
 return the path offsets as cached in the alignment More...
 
void vg::alignment_set_distance_to_correct (Alignment &aln, const Alignment &base, const unordered_map< string, string > *translation)
 
void vg::alignment_set_distance_to_correct (Alignment &aln, const map< string, vector< pair< size_t, bool >>> &base_offsets, const unordered_map< string, string > *translation=nullptr)
 
AlignmentValidity vg::alignment_is_valid (const Alignment &aln, const HandleGraph *hgraph, bool check_sequence)
 
Alignment vg::target_alignment (const PathPositionHandleGraph *graph, const path_handle_t &path, size_t pos1, size_t pos2, const string &feature, bool is_reverse)
 
Alignment vg::target_alignment (const PathPositionHandleGraph *graph, const path_handle_t &path, size_t pos1, size_t pos2, const string &feature, bool is_reverse, Mapping &cigar_mapping)
 

Variables

const char *const vg::BAM_DNA_LOOKUP = "=ACMGRSVTWYHKDBN"