Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • student-t
    replied
    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);

    Leave a comment:


  • lindenb
    replied
    cross posted: http://stackoverflow.com/questions/2...lar-expression

    Leave a comment:


  • dpryan
    replied
    If you're using C/C++ already, then just use htslib. The functions for this have already been written (afterall, it's what samtools uses) and the API is generally convenient.

    Leave a comment:


  • Brian Bushnell
    replied
    Originally posted by tedwong View Post
    What'd be the best way to parse a CIGAR string fully according to the specification in C/C++? Would regular expression work?
    No. Unless you simply want to detect the presence of some operation, the best way is with a custom loop.

    Here's an example in Java that can easily be translated to C++:

    Discussion of next-gen sequencing related bioinformatics: resources, algorithms, open source efforts, etc

    Leave a comment:


  • tedwong
    started a topic Parse CIGAR string in C/C++

    Parse CIGAR string in C/C++

    What'd be the best way to parse a CIGAR string fully according to the specification in C/C++? Would regular expression work?

Latest Articles

Collapse

  • seqadmin
    Advanced Methods for the Detection of Infectious Disease
    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.
    ...
    11-27-2023, 01:15 PM
  • seqadmin
    Strategies for Investigating the Microbiome
    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...
    11-09-2023, 07:02 AM

ad_right_rmr

Collapse

News

Collapse

Topics Statistics Last Post
Started by seqadmin, 12-01-2023, 09:55 AM
0 responses
13 views
0 likes
Last Post seqadmin  
Started by seqadmin, 11-30-2023, 10:48 AM
0 responses
18 views
0 likes
Last Post seqadmin  
Started by seqadmin, 11-29-2023, 08:26 AM
0 responses
14 views
0 likes
Last Post seqadmin  
Started by seqadmin, 11-29-2023, 08:12 AM
0 responses
14 views
0 likes
Last Post seqadmin  
Working...
X