Created
August 27, 2015 04:25
-
-
Save Tabea-K/d61d5495f6efd8f4c11c to your computer and use it in GitHub Desktop.
Converts a maf alignment file into fasta file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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