Skip to content

Instantly share code, notes, and snippets.

@Tabea-K
Created August 27, 2015 04:25
Show Gist options
  • Save Tabea-K/d61d5495f6efd8f4c11c to your computer and use it in GitHub Desktop.
Save Tabea-K/d61d5495f6efd8f4c11c to your computer and use it in GitHub Desktop.
Converts a maf alignment file into fasta file.
#!/usr/bin/env python
"""
Created by Tabea Kischka at 2015-01-27 10:34:05
converts a last maf alignment into a fasta alignment
"""
import sys
path_to_alignio = '/home/tabeah/Scripts/alignio-maf'
try:
sys.path.insert(1, path_to_alignio)
from Bio.AlignIO import MafIO
except ImportError:
print("ERROR: Couldn't import module MafIO from path '%s'" % \
(path_to_alignio))
sys.exit(1)
filnam = sys.argv[1]
fh = open(filnam, 'r')
alignments=[]
for seqobj in MafIO.MafIterator(fh):
alignments.append(seqobj)
for aln in alignments:
for record in aln._records:
sys.stdout.write('>%s\n%s\n'%(record.id, record.seq))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment