Created
January 17, 2016 17:57
-
-
Save flashton2003/eb1951aab22b005d565e to your computer and use it in GitHub Desktop.
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
import os | |
from Bio import SeqIO | |
from BCBio import GFF | |
root_dir = '/Users/flashton/projects/nctc3000/2016.01.17' | |
def main(root_dir): | |
for each in os.listdir(root_dir): | |
with open('%s/%s' % (root_dir, each)) as fi: | |
basename = each.split('.')[0] | |
if each.endswith('embl'): | |
with open('%s/%s.fa' % (root_dir, basename), 'w') as fo: | |
for rec in SeqIO.parse(fi, 'embl'): | |
fo.write('>%s\n' % rec.id) | |
fo.write('%s\n' % rec.seq) | |
elif each.endswith('gff'): | |
with open('%s/%s.fa' % (root_dir, basename), 'w') as fo: | |
try: | |
for rec in GFF.parse(fi): | |
fo.write('>%s\n' % rec.id) | |
fo.write('%s\n' % rec.seq) | |
except: | |
print each, 'no dice' | |
# os.system('rm -rf %s/%s' % (root_dir, each)) | |
main(root_dir) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment