Skip to content

Instantly share code, notes, and snippets.

@mdshw5
Created March 10, 2016 17:22
Show Gist options
  • Save mdshw5/5f4ca2ae627c8aea1786 to your computer and use it in GitHub Desktop.
Save mdshw5/5f4ca2ae627c8aea1786 to your computer and use it in GitHub Desktop.
biostars 75693
import simplesam
with simplesam.Reader(open('input.sam')) as sam:
with simplesam.Writer(open('output.sam', 'w'), sam.header) as fixed:
for read in sam:
if bool(read.flag & 0x800):
read.flag -= 0x800
if not read.secondary:
read.flag += 0x100
fixed.write(read)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment