comparison gff_to_gbk.py @ 5:6e589f267c14

Uploaded
author devteam
date Tue, 04 Nov 2014 12:15:19 -0500
parents
children
comparison
equal deleted inserted replaced
4:619e0fcd9126 5:6e589f267c14
1 #!/usr/bin/env python
2 """
3 Convert data from GFF and associated genome sequence in fasta file into GenBank.
4
5 Usage:
6 python gff_to_gbk.py in.gff in.fasta out.gbk
7
8 Requirements:
9 BioPython:- http://biopython.org/
10 helper.py : https://github.com/vipints/GFFtools-GX/blob/master/helper.py
11
12 Copyright (C)
13 2010-2012 Friedrich Miescher Laboratory of the Max Planck Society, Tubingen, Germany.
14 2012-2014 Memorial Sloan Kettering Cancer Center New York City, USA.
15 """
16
17 import sys
18 import helper
19 import gffparser_bcbio
20
21 from Bio import SeqIO
22 from Bio.Alphabet import generic_dna
23
24 def __main__():
25 """
26 main wrapper
27 """
28
29 try:
30 gff_fname = sys.argv[1]
31 fasta_fname = sys.argv[2]
32 gb_fname = sys.argv[3]
33 except:
34 print __doc__
35 sys.exit(-1)
36
37 fasta_fh = helper.open_file(fasta_fname)
38
39 fasta_rec = SeqIO.to_dict(SeqIO.parse(fasta_fh, "fasta", generic_dna))
40 fasta_fh.close()
41
42 gff_rec = gffparser_bcbio.parse(gff_fname, fasta_rec)
43
44 try:
45 gb_fh = open(gb_fname, "w")
46 except:
47 print 'file not ready for writing %s' % gb_fname
48 sys.exit(-1)
49
50 SeqIO.write(gff_rec, gb_fh, "genbank")
51 gb_fh.close()
52
53 if __name__=="__main__":
54 __main__()