Skip to content

Instantly share code, notes, and snippets.

@ekg
Created February 4, 2019 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekg/18587dd22f77ac525c41c298d5e0bd89 to your computer and use it in GitHub Desktop.
Save ekg/18587dd22f77ac525c41c298d5e0bd89 to your computer and use it in GitHub Desktop.
summarize the softclips in a SAM/BAM file
#!/usr/bin/python
import sys;
import pysam
bamFile = sys.argv[1];
bamFP = pysam.Samfile(bamFile, "rb");
for read in bamFP:
if( not( read.is_unmapped ) ): #if it's mapped
cigarLine=read.cigar;
for (cigarType,cigarLength) in cigarLine:
try:
if cigarType == 4:
print cigarLength
except:
print "Problem";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment