src/c++/lib/common/BamReader.cpp
/**
 * Decode BAM alignment from HTSLib struct.
 *
 * @param hts_align_ptr a bam1_t * to initialize from.
 * Passed as void* to avoid dependency on htslib headers
 *
 * TODO we could make this a constructor
 */
Decode BAM alignment from HTSLib struct.
@param hts_align_ptr a bam1_t * to initialize from.
Passed as void* to avoid dependency on htslib headers


Decode BAM alignment from HTSLib struct . @param hts_align_ptr a bam1_t * to initialize from . Passed as void * to avoid dependency on htslib headers
static inline void decodeHtsAlign(void* _hts_align_ptr, Read& read)
{
    auto* hts_align_ptr = (bam1_t*)_hts_align_ptr;
    const string fragment_id = bam_get_qname(hts_align_ptr);
    string bases, quals;
    decodeHtsBases(hts_align_ptr, bases);
    decodeHtsQuals(hts_align_ptr, quals);
    read.set_fragment_id(fragment_id);
    read.set_bases(bases);
    read.set_quals(quals);
    const auto& flag = hts_align_ptr->core.flag;
    read.set_is_mapped((flag & BamReader::kIsMapped) == 0);
    read.set_is_first_mate((flag & BamReader::kIsFirstMate) != 0);
    read.set_is_mate_mapped((flag & BamReader::kIsMateMapped) == 0);
    read.set_is_reverse_strand(bam_is_rev(hts_align_ptr));
    read.set_is_mate_reverse_strand(bam_is_mrev(hts_align_ptr));
    read.set_chrom_id(hts_align_ptr->core.tid);
    read.set_pos(hts_align_ptr->core.pos);
    read.set_mapq(hts_align_ptr->core.qual);
    read.set_mate_chrom_id(hts_align_ptr->core.mtid);
    read.set_mate_pos(hts_align_ptr->core.mpos);
}
static inline void decodeHtsAlign ( void * _hts_align_ptr , Read & read ) { auto * hts_align_ptr = ( bam1_t * ) _hts_align_ptr ; const string fragment_id = bam_get_qname ( hts_align_ptr ) ; string bases , quals ; decodeHtsBases ( hts_align_ptr , bases ) ; decodeHtsQuals ( hts_align_ptr , quals ) ; read . set_fragment_id ( fragment_id ) ; read . set_bases ( bases ) ; read . set_quals ( quals ) ; const auto & flag = hts_align_ptr -> core . flag ; read . set_is_mapped ( ( flag & BamReader :: kIsMapped ) == 0 ) ; read . set_is_first_mate ( ( flag & BamReader :: kIsFirstMate ) != 0 ) ; read . set_is_mate_mapped ( ( flag & BamReader :: kIsMateMapped ) == 0 ) ; read . set_is_reverse_strand ( bam_is_rev ( hts_align_ptr ) ) ; read . set_is_mate_reverse_strand ( bam_is_mrev ( hts_align_ptr ) ) ; read . set_chrom_id ( hts_align_ptr -> core . tid ) ; read . set_pos ( hts_align_ptr -> core . pos ) ; read . set_mapq ( hts_align_ptr -> core . qual ) ; read . set_mate_chrom_id ( hts_align_ptr -> core . mtid ) ; read . set_mate_pos ( hts_align_ptr -> core . mpos ) ; }
Decode BAM alignment from HTSLib struct.
Decode BAM alignment from HTSLib struct .