Skip to main content
5 votes

Is there an efficient way to extract CIGAR strings for read pairs from bam files with python?

I think that the easiest way is to work with query-name sorted groups of reads. In that case, mates will be adjacent in the sort and you can use that to extract the paired CIGARs. If you are depending ...
Maximilian Press's user avatar
5 votes
Accepted

Is there a Python/R package with the ability to convert an alignment and reference into a CIGAR?

Your request is easy to implement. I wouldn't use any libraries in this case. As you haven't showed your implementation, I will provide one: ...
user172818's user avatar
  • 6,535
5 votes

How should the SAM MD tag match the CIGAR string?

The MD string doesn't apply to soft or hard clipped regions,. so your example read becomes 43G42. Since variant calling using something simplistic like this is only ...
Devon Ryan's user avatar
  • 19.6k
4 votes
Accepted

Generating CIGAR strings for MSA with reference

If you loop through the characters of two aligned sequences in parallel then you can easily determine the operations that compose the CIGAR. Then you just have to "collapse" the generated ...
Fravadona's user avatar
  • 181
4 votes
Accepted

Extracting the CIGAR string from a BAM via Python?

If you really do just want the cigar string then it's read.cigarstring. However, I'm not sure what you're trying to gain with the cigar package from Brent. Unless ...
Devon Ryan's user avatar
  • 19.6k
4 votes
Accepted

Is the optional SAM NM field strictly computable from the MD and CIGAR?

Assuming both the MD and CIGAR are present and correct, then yes, you can parse both to get the edit distance (NM auxiliary tag). One big caveat to this is that ...
Devon Ryan's user avatar
  • 19.6k
3 votes

How do I find split reads?

The answer to this question depends on the aligner used to generate SAM/BAM file. For BWA method that is part of the pipeline mentioned in comments, split reads will be flagged as supplementary ...
Mehrdad Bakhtiari's user avatar
3 votes

Is there a Python/R package with the ability to convert an alignment and reference into a CIGAR?

Here is what I would do in Python. There are a few extra checks I've included, and my definitions of a few cases are different than Heng Li's above, @user172818. The performance is fairly similar. <...
EB2127's user avatar
  • 1,423
3 votes

Extract end position from CIGAR

The start position is the first correctly mapped base. One way to do it, is to use GenomicAlignments in R to read in the alignments. For example the sam file looks like this: ...
StupidWolf's user avatar
  • 1,688
2 votes

Extract end position from CIGAR

The match is starting with the first mapped base ignoring any softclipped parts of the read. As an example this are two reads from a bam file of mine: ...
PPK's user avatar
  • 886
1 vote

What does presence/absence of black lines mean in IGV?

Black line represents an indel. Read was lengthened to fit consensus. No black line (blank), no read/sequence. Read likely ended or was truncated.
Stuber's user avatar
  • 221

Only top scored, non community-wiki answers of a minimum length are eligible