![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to parse the bases string in pileup file | lethalfang | Bioinformatics | 0 | 06-08-2014 09:12 PM |
[Bowtie2] CIGAR string calculation. | Coryza | Bioinformatics | 6 | 03-14-2014 03:12 AM |
CIGAR string from BWA-SW output incorrect ? | robs | Bioinformatics | 13 | 01-13-2012 05:07 AM |
BWA generating incorrect CIGAR string? | foxyg | Bioinformatics | 6 | 09-16-2011 12:22 PM |
generate CIGAR string from 2 sequences? | bbimber | Bioinformatics | 0 | 03-20-2010 10:44 AM |
![]() |
|
Thread Tools |
![]() |
#1 |
Member
Location: Sydney Join Date: Mar 2015
Posts: 13
|
![]()
What'd be the best way to parse a CIGAR string fully according to the specification in C/C++? Would regular expression work?
|
![]() |
![]() |
![]() |
#2 | |
Super Moderator
Location: Walnut Creek, CA Join Date: Jan 2014
Posts: 2,707
|
![]() Quote:
Here's an example in Java that can easily be translated to C++: http://seqanswers.com/forums/showthread.php?t=51162 |
|
![]() |
![]() |
![]() |
#4 |
Senior Member
Location: France Join Date: Apr 2010
Posts: 143
|
![]()
cross posted: http://stackoverflow.com/questions/2...lar-expression
|
![]() |
![]() |
![]() |
#5 |
Member
Location: Garvan Institute Join Date: Mar 2015
Posts: 16
|
![]()
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); |
![]() |
![]() |
![]() |
Thread Tools | |
|
|