comparison prokka.py @ 1:4b6f16a79fe4 draft

Add txt output file. Use a definition list instead of a block quote in <help>. Correct 2 dependency minimum versions.
author crs4
date Thu, 26 Sep 2013 12:39:52 -0400
parents 95505a9fa26f
children
comparison
equal deleted inserted replaced
0:95505a9fa26f 1:4b6f16a79fe4
19 parser.add_option('--fasta', dest='fasta', help='FASTA file with contigs') 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') 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') 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") 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") 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") 24 parser.add_option('--gff', dest="gff", help="This is the master annotation in GFF3 format, containing both sequences and annotations")
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") 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") 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") 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") 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") 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") 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") 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") 32 parser.add_option('--err', dest="err", help="Unacceptable annotations - the NCBI discrepancy report")
33 parser.add_option('--txt', dest='txt', help='Statistics relating to the annotated features found')
33 parser.add_option('--log', dest="log", help="Contains all the output that Prokka produced during its run") 34 parser.add_option('--log', dest="log", help="Contains all the output that Prokka produced during its run")
34 (options, args) = parser.parse_args() 35 (options, args) = parser.parse_args()
35 if len(args) > 0: 36 if len(args) > 0:
36 parser.error('Wrong number of arguments') 37 parser.error('Wrong number of arguments')
37 38
38 # Build command 39 # Build command
39 cpus = "--cpus %d" % (options.cpus) if options.cpus is not None else '' 40 cpus = "--cpus %d" % (options.cpus) if options.cpus is not None else ''
40 rfam = '--rfam' if options.rfam else '' 41 rfam = '--rfam' if options.rfam else ''
41 mincontig = "--mincontig %d" % options.mincontig if options.mincontig is not None else '' 42 mincontig = "--mincontig %d" % options.mincontig if options.mincontig is not None else ''
42 43
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 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 print '\nProkka command to be executed:\n %s' % cl
45 46
46 # Run command 47 # Run command
47 log = open(options.log, 'w') if options.log else sys.stdout 48 log = open(options.log, 'w') if options.log else sys.stdout
48 try: 49 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 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 finally:
51 if log != sys.stdout: 52 if log != sys.stdout:
52 log.close() 53 log.close()
53 54
54 # Rename output files 55 # Rename output files
55 suffix = ['gbk', 'fna', 'faa', 'ffn', 'sqn', 'fsa', 'tbl', 'err', 'gff'] 56 suffix = ['gff', 'gbk', 'fna', 'faa', 'ffn', 'sqn', 'fsa', 'tbl', 'err', 'txt']
56 for s in suffix: 57 for s in suffix:
57 shutil.move( 'prokka.' + s, getattr(options, s)) 58 shutil.move('prokka.' + s, getattr(options, s))
58 59
59 if __name__ == "__main__": 60 if __name__ == "__main__":
60 __main__() 61 __main__()