Last active
August 29, 2015 14:20
-
-
Save armanbilge/b48a62be1fae743844ae to your computer and use it in GitHub Desktop.
This file contains hidden or 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 python3 | |
import sys | |
from Bio import SeqIO | |
for fn in sys.argv[1:]: | |
with open(fn, 'r') as f: | |
print('\t<data id="{}" name="alignment">'.format(fn[:-len('_unphased.nex')])) | |
for record in SeqIO.parse(f, 'nexus'): | |
if record.id.endswith('_1'): | |
print('\t\t<sequence taxon="{}" totalcount="4" value="{}"/>'.format(record.id, record.seq)) | |
print('\t</data>') | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment