Skip to content

Instantly share code, notes, and snippets.

@mdshw5
Created July 3, 2014 13:53
Show Gist options
  • Save mdshw5/5edaf8b340d07f9575b9 to your computer and use it in GitHub Desktop.
Save mdshw5/5edaf8b340d07f9575b9 to your computer and use it in GitHub Desktop.
biostars 105338
from pyfaidx import Fasta, wrap_sequence
key_fn = lambda x: ' '.join(x.replace('len=', '').split()[:2])
fa = Fasta('multi.fasta', key_function = key_fn)
with open('out.fasta', 'w') as out:
for seq in Fasta:
out.write('>{name}\n'.format(seq.name))
for line in wrap_sequence(70, str(seq)):
out.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment