0
|
1 # -*- coding: utf-8 -*-
|
|
2 """
|
|
3 Wrapper for Prokka - Prokaryotic annotation tool
|
|
4 Author: Paolo Uva paolo dot uva at crs4 dot it
|
|
5 Date: February 14, 2013
|
|
6 Update: March 14, 2013 - Added more options
|
|
7 """
|
|
8
|
|
9 import optparse
|
|
10 import shutil
|
|
11 import subprocess
|
|
12 import sys
|
|
13
|
|
14
|
|
15 def __main__():
|
|
16 #Parse Command Line
|
|
17 parser = optparse.OptionParser()
|
|
18 parser.add_option('--cpus', dest='cpus', type='int', help='Number of CPUs to use [0=all]')
|
|
19 parser.add_option('--fasta', dest='fasta', help='FASTA file with contigs')
|
|
20 parser.add_option('--kingdom', dest='kingdom', choices=['Archaea', 'Bacteria', 'Viruses'], default='Bacteria', help='Kingdom')
|
|
21 parser.add_option('--mincontig', dest='mincontig', type='int', help='Minimun contig size')
|
|
22 parser.add_option('--rfam', action="store_true", dest="rfam", help="Enable searching for ncRNAs")
|
|
23 parser.add_option('--centre', dest="centre", default="CRS4", help="Sequencing centre")
|
|
24 parser.add_option('--gff', dest="gff", help="This is the master annotation in GFF3 format, containing both sequences and annotations. It can be viewed directly in Artemis or IGV")
|
|
25 parser.add_option('--gbk', dest="gbk", help="This is a standard Genbank file derived from the master .gff. If the input to prokka was a multi-FASTA, then this will be a multi-Genbank, with one record for each sequence")
|
|
26 parser.add_option('--fna', dest="fna", help="Nucleotide FASTA file of the input contig sequences")
|
|
27 parser.add_option('--faa', dest="faa", help="Protein FASTA file of the translated CDS sequences")
|
|
28 parser.add_option('--ffn', dest="ffn", help="Nucleotide FASTA file of all the annotated sequences, not just CDS")
|
|
29 parser.add_option('--sqn', dest="sqn", help="An ASN1 format Sequin file for submission to Genbank. It needs to be edited to set the correct taxonomy, authors, related publication etc")
|
|
30 parser.add_option('--fsa', dest="fsa", help="Nucleotide FASTA file of the input contig sequences, used by tbl2asn to create the .sqn file. It is mostly the same as the .fna file, but with extra Sequin tags in the sequence description lines")
|
|
31 parser.add_option('--tbl', dest="tbl", help="Feature Table file, used by tbl2asn to create the .sqn file")
|
|
32 parser.add_option('--err', dest="err", help="Unacceptable annotations - the NCBI discrepancy report")
|
|
33 parser.add_option('--log', dest="log", help="Contains all the output that Prokka produced during its run")
|
|
34 (options, args) = parser.parse_args()
|
|
35 if len(args) > 0:
|
|
36 parser.error('Wrong number of arguments')
|
|
37
|
|
38 # Build command
|
|
39 cpus = "--cpus %d" % (options.cpus) if options.cpus is not None else ''
|
|
40 rfam = '--rfam' if options.rfam else ''
|
|
41 mincontig = "--mincontig %d" % options.mincontig if options.mincontig is not None else ''
|
|
42
|
|
43 cl = "prokka --force --outdir . --prefix prokka --kingdom %s %s --centre %s %s %s %s" % (options.kingdom, mincontig, options.centre, rfam, cpus, options.fasta)
|
|
44 print '\nProkka command to be executed: \n %s' % cl
|
|
45
|
|
46 # Run command
|
|
47 log = open(options.log, 'w') if options.log else sys.stdout
|
|
48 try:
|
|
49 subprocess.check_call(cl, stdout=log, stderr=subprocess.STDOUT, shell=True) # need to redirect stderr because prokka writes many logging info there
|
|
50 finally:
|
|
51 if log != sys.stdout:
|
|
52 log.close()
|
|
53
|
|
54 # Rename output files
|
|
55 suffix = ['gbk', 'fna', 'faa', 'ffn', 'sqn', 'fsa', 'tbl', 'err', 'gff']
|
|
56 for s in suffix:
|
|
57 shutil.move( 'prokka.' + s, getattr(options, s))
|
|
58
|
|
59 if __name__ == "__main__":
|
|
60 __main__()
|