1 #ifndef __gamgee__sam__
2 #define __gamgee__sam__
9 #include "htslib/sam.h"
22 explicit Sam(
const std::shared_ptr<bam_hdr_t>&
header,
const std::shared_ptr<bam1_t>& body) noexcept;
31 uint32_t
chromosome()
const {
return uint32_t(m_body->core.tid); }
33 uint32_t
alignment_stop()
const {
return uint32_t(bam_endpos(m_body.get())+1); }
49 std::string
name()
const {
return std::string{bam_get_qname(m_body.get())}; }
55 bool paired()
const {
return m_body->core.flag & BAM_FPAIRED; }
57 bool unmapped()
const {
return m_body->core.flag & BAM_FUNMAP; }
59 bool reverse()
const {
return m_body->core.flag & BAM_FREVERSE; }
60 bool next_reverse()
const {
return m_body->core.flag & BAM_FMREVERSE; }
61 bool first()
const {
return m_body->core.flag & BAM_FREAD1; }
62 bool last()
const {
return m_body->core.flag & BAM_FREAD2; }
63 bool secondary()
const {
return m_body->core.flag & BAM_FSECONDARY; }
64 bool fail()
const {
return m_body->core.flag & BAM_FQCFAIL; }
65 bool duplicate()
const {
return m_body->core.flag & BAM_FDUP; }
66 bool supplementary()
const {
return m_body->core.flag & BAM_FSUPPLEMENTARY; }
79 void set_first() { m_body->core.flag |= BAM_FREAD1; }
81 void set_last() { m_body->core.flag |= BAM_FREAD2; }
85 void set_fail() { m_body->core.flag |= BAM_FQCFAIL; }
92 bool empty()
const {
return m_body ==
nullptr; }
95 std::shared_ptr<bam_hdr_t> m_header;
96 std::shared_ptr<bam1_t> m_body;
uint32_t alignment_stop() const
returns a (1-based and inclusive) alignment stop position (as you would see in a Sam file)...
Definition: sam.h:33
void set_first()
Definition: sam.h:79
uint32_t mate_unclipped_stop() const
void set_not_paired()
Definition: sam.h:70
void set_not_first()
Definition: sam.h:80
void set_duplicate()
Definition: sam.h:87
bool next_reverse() const
whether or not the next read is from the reverse strand
Definition: sam.h:60
uint32_t mate_unclipped_start() const
Definition: sam.h:39
uint32_t alignment_start() const
returns a (1-based and inclusive) alignment start position (as you would see in a Sam file)...
Definition: sam.h:32
void set_reverse()
Definition: sam.h:75
BaseQuals base_quals() const
returns the base qualities
Definition: sam.h:51
bool empty() const
whether or not this Sam object is empty, meaning that the internal memory has not been initialized (i...
Definition: sam.h:92
uint32_t mate_chromosome() const
returns the integer representation of the mate's chromosome. Notice that chromosomes are listed in in...
Definition: sam.h:36
uint32_t chromosome() const
returns the integer representation of the chromosome. Notice that chromosomes are listed in index ord...
Definition: sam.h:31
void set_not_last()
Definition: sam.h:82
bool paired() const
whether or not this read is paired
Definition: sam.h:55
SamHeader header()
Definition: sam.h:28
void set_not_duplicate()
Definition: sam.h:88
bool last() const
whether or not this read is the last read in a pair (or multiple pairs)
Definition: sam.h:62
bool secondary() const
whether or not this read is a secondary alignment (see definition in BAM spec)
Definition: sam.h:63
void set_fail()
Definition: sam.h:85
bool fail() const
whether or not this read is marked as failing vendor (sequencer) quality control
Definition: sam.h:64
utility class to write out a SAM/BAM/CRAM file to any stream
Definition: sam_writer.h:16
uint32_t unclipped_stop() const
calculates the theoretical alignment stop of a read that has soft/hard-clips preceding the alignment ...
Definition: sam.cpp:101
Sam & operator=(const Sam &other)
deep copy assignment of a Sam and it's header. Shared pointers maintain state to all other associated...
Definition: sam.cpp:49
bool next_unmapped() const
whether or not the next read is unmapped
Definition: sam.h:58
Utility class to handle the memory management of the sam record object for a read base qualities...
Definition: base_quals.h:13
bool first() const
whether or not this read is the first read in a pair (or multiple pairs)
Definition: sam.h:61
void set_mate_alignment_start(const uint32_t mstart)
simple setter for the mate's alignment start.
Definition: sam.h:46
uint32_t unclipped_start() const
calculates the theoretical alignment start of a read that has soft/hard-clips preceding the alignment...
Definition: sam.cpp:78
bool duplicate() const
whether or not this read is a duplicate
Definition: sam.h:65
bool unmapped() const
whether or not this read is unmapped
Definition: sam.h:57
uint32_t mate_alignment_stop() const
returns a (1-based and inclusive) mate'salignment stop position (as you would see in a Sam file)...
bool properly_paired() const
whether or not this read is properly paired (see definition in BAM spec)
Definition: sam.h:56
void set_next_unmapped()
Definition: sam.h:73
uint32_t mate_alignment_start() const
returns a (1-based and inclusive) mate's alignment start position (as you would see in a Sam file)...
Definition: sam.h:37
void set_not_secondary()
Definition: sam.h:84
std::string name() const
returns the read name
Definition: sam.h:49
Sam()=default
initializes a null Sam
void set_mate_chromosome(const uint32_t mchr)
simple setter for the mate's chromosome index. Index is 0-based.
Definition: sam.h:45
void set_not_next_reverse()
Definition: sam.h:78
void set_not_unmapped()
Definition: sam.h:72
bool reverse() const
whether or not this read is from the reverse strand
Definition: sam.h:59
void set_alignment_start(const uint32_t start)
simple setter for the alignment start.
Definition: sam.h:44
void set_last()
Definition: sam.h:81
void set_supplementary()
Definition: sam.h:89
void set_next_reverse()
Definition: sam.h:77
void set_not_reverse()
Definition: sam.h:76
void set_not_next_unmapped()
Definition: sam.h:74
Utility class to manipulate a Sam record.
Definition: sam.h:19
void set_not_supplementary()
Definition: sam.h:90
Utility class to handle the memory management of the sam record object for read bases.
Definition: read_bases.h:26
void set_paired()
Definition: sam.h:69
void set_chromosome(const uint32_t chr)
simple setter for the chromosome index. Index is 0-based.
Definition: sam.h:43
Utility class to manage the memory of the cigar structure.
Definition: cigar.h:20
void set_not_fail()
Definition: sam.h:86
ReadBases bases() const
returns the read bases
Definition: sam.h:50
bool supplementary() const
whether or not this read is a supplementary alignment (see definition in the BAM spec) ...
Definition: sam.h:66
Cigar cigar() const
returns the cigar
Definition: sam.h:52
void set_secondary()
Definition: sam.h:83
void set_unmapped()
Definition: sam.h:71