forked from jrjhealey/bioinfo-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
splitmultigenbank.py
executable file
·38 lines (28 loc) · 1.04 KB
/
splitmultigenbank.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
34
35
36
37
38
# Usage:
# python splitmultigenbank.py multigenbank.gbk
# Note, the script will just dump out all the GBKs in to the same
# folder, named according to their record IDs.
from Bio import SeqIO
import sys
import argparse
import traceback
import warnings
def main():
# Parse command line arguments
try:
parser = argparse.ArgumentParser(
description='This script separates out multi-genbank files into individual ones')
parser.add_argument(
'-g',
'--genbank',
action='store',
required=True,
help='The genbank file you wish to split.')
args = parser.parse_args()
except:
print "An exception occured with argument parsing. Check your provided options."
traceback.print_exc()
for rec in SeqIO.parse(genbank, "genbank"):
SeqIO.write([rec], open(rec.id + ".gbk", "w"), "genbank")
if __name__ == '__main__' :
main()