What'd be the best way to parse a CIGAR string fully according to the specification in C/C++? Would regular expression work?
Announcement
Collapse
No announcement yet.
X
-
Originally posted by tedwong View PostWhat'd be the best way to parse a CIGAR string fully according to the specification in C/C++? Would regular expression work?
Here's an example in Java that can easily be translated to C++:
-
-
For reference (using the htslib library)
#include <htslib/sam.h>
auto f = sam_open(file.c_str(), "r");
auto h = sam_hdr_read(f);
auto t = bam_init1();
while (sam_read1(f, h, t) >= 0)
{
auto id = std::string(h->target_name[0]);
auto mapped = !(t->core.flag & BAM_FUNMAP);
const auto cigar = bam_get_cigar(t);
for (int k = 0; k < t->core.n_cigar; k++)
{
const int op = bam_cigar_op(cigar[k]);
const int ol = bam_cigar_oplen(cigar[k]);
if (op == BAM_CMATCH || op == BAM_CINS || op == BAM_CDEL)
{
// your code, you have the length in ol (eg: 101M -> ol == 101)
}
}
}
sam_close(f);
Comment
Latest Articles
Collapse
-
by seqadmin
The recent pandemic caused worldwide health, economic, and social disruptions with its reverberations still felt today. A key takeaway from this event is the need for accurate and accessible tools for detecting and tracking infectious diseases. Timely identification is essential for early intervention, managing outbreaks, and preventing their spread. This article reviews several valuable tools employed in the detection and surveillance of infectious diseases.
...-
Channel: Articles
11-27-2023, 01:15 PM -
-
by seqadmin
Microbiome research has led to the discovery of important connections to human and environmental health. Sequencing has become a core investigational tool in microbiome research, a subject that we covered during a recent webinar. Our expert speakers shared a number of advancements including improved experimental workflows, research involving transmission dynamics, and invaluable analysis resources. This article recaps their informative presentations, offering insights...-
Channel: Articles
11-09-2023, 07:02 AM -
ad_right_rmr
Collapse
News
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by seqadmin, Yesterday, 09:55 AM
|
0 responses
13 views
0 likes
|
Last Post
by seqadmin
Yesterday, 09:55 AM
|
||
Started by seqadmin, 11-30-2023, 10:48 AM
|
0 responses
18 views
0 likes
|
Last Post
by seqadmin
11-30-2023, 10:48 AM
|
||
Started by seqadmin, 11-29-2023, 08:26 AM
|
0 responses
14 views
0 likes
|
Last Post
by seqadmin
11-29-2023, 08:26 AM
|
||
Started by seqadmin, 11-29-2023, 08:12 AM
|
0 responses
14 views
0 likes
|
Last Post
by seqadmin
11-29-2023, 08:12 AM
|
Comment