-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathembl_export.py
33 lines (26 loc) · 990 Bytes
/
embl_export.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Convert embl format to a couple of other formats
"""
import os
import sys
import argparse
from Bio import SeqIO
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Convert EMBL format sequence files")
parser.add_argument('-e', help='EMBL input file', required=True)
parser.add_argument('-f', help='Store fasta file', action="store_true")
parser.add_argument('-g', help='Store genbank file', action="store_true")
parser.add_argument('-o', help='output file base name')
args = parser.parse_args()
outfile = args.e
if args.o:
outfile = args.o
sin = SeqIO.read(args.e, 'embl')
if args.f:
outfafile = outfile + ".fasta"
sout = SeqIO.write(sin, outfafile, 'fasta')
print("Wrote {} records to a fasta file".format(sout))
if args.g:
outgbfile = outfile + ".gbk"
sout = SeqIO.write(sin, outgbfile, 'genbank')
print("Wrote {} records to a genbank file".format(sout))