Skip to content

Instantly share code, notes, and snippets.

@epaule
Last active November 14, 2024 11:32
Show Gist options
  • Save epaule/c012ed4a64d2fc284830d14423fd3da6 to your computer and use it in GitHub Desktop.
Save epaule/c012ed4a64d2fc284830d14423fd3da6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# usage: python3 hap_bedgraph.py FASTA > BEDGRAPH
import sys
import re
from Bio import SeqIO
ns=re.compile("[Nn]+")
for seq_record in SeqIO.parse(sys.argv[1], "fasta"):
for m in ns.finditer(str(seq_record.seq)):
print(f'{seq_record.id}\t{m.start()}\t{m.end()+1}\t200')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment