Mercurial > repos > peterjc > get_orfs_or_cdss
comparison tools/get_orfs_or_cdss/get_orfs_or_cdss.py @ 11:d51db443aaa4 draft
v0.2.3 Python 3 compatible print function.
author | peterjc |
---|---|
date | Wed, 30 May 2018 08:33:20 -0400 |
parents | a06ad07431ba |
children | 71905a6d52a7 |
comparison
equal
deleted
inserted
replaced
10:01b0488d9cfb | 11:d51db443aaa4 |
---|---|
16 (formerly SCRI), Dundee, UK. All rights reserved. | 16 (formerly SCRI), Dundee, UK. All rights reserved. |
17 | 17 |
18 See accompanying text file for licence details (MIT licence). | 18 See accompanying text file for licence details (MIT licence). |
19 """ | 19 """ |
20 | 20 |
21 from __future__ import print_function | |
22 | |
21 import re | 23 import re |
22 import sys | 24 import sys |
23 | 25 |
24 from optparse import OptionParser | 26 from optparse import OptionParser |
25 | 27 |
26 usage = """Use as follows: | 28 usage = r"""Use as follows: |
27 | 29 |
28 $ python get_orfs_or_cdss.py -i genome.fa -f fasta --table 11 -t CDS -e open -m all -s both --on cds.nuc.fa --op cds.protein.fa --ob cds.bed --og cds.gff3 | 30 $ python get_orfs_or_cdss.py -i genome.fa -f fasta --table 11 \ |
31 -t CDS -e open -m all -s both --on cds.nuc.fa --op cds.protein.fa \ | |
32 --ob cds.bed --og cds.gff3 | |
29 """ | 33 """ |
30 | 34 |
31 try: | 35 try: |
32 from Bio.Seq import Seq, reverse_complement, translate | 36 from Bio.Seq import Seq, reverse_complement, translate |
33 from Bio.SeqRecord import SeqRecord | 37 from Bio.SeqRecord import SeqRecord |
77 help='Show version and quit') | 81 help='Show version and quit') |
78 | 82 |
79 options, args = parser.parse_args() | 83 options, args = parser.parse_args() |
80 | 84 |
81 if options.version: | 85 if options.version: |
82 print("v0.2.0") | 86 print("v0.2.3") |
83 sys.exit(0) | 87 sys.exit(0) |
84 | 88 |
85 if not options.input_file: | 89 if not options.input_file: |
86 sys.exit("Input file is required") | 90 sys.exit("Input file is required") |
87 | 91 |
100 elif options.seq_format.lower().startswith("fastq"): | 104 elif options.seq_format.lower().startswith("fastq"): |
101 seq_format = "fastq" | 105 seq_format = "fastq" |
102 else: | 106 else: |
103 sys.exit("Unsupported file type %r" % options.seq_format) | 107 sys.exit("Unsupported file type %r" % options.seq_format) |
104 | 108 |
105 print "Genetic code table %i" % options.table | 109 print("Genetic code table %i" % options.table) |
106 print "Minimum length %i aa" % options.min_len | 110 print("Minimum length %i aa" % options.min_len) |
107 # print "Taking %s ORF(s) from %s strand(s)" % (mode, strand) | 111 # print "Taking %s ORF(s) from %s strand(s)" % (mode, strand) |
108 | 112 |
109 starts = sorted(table_obj.start_codons) | 113 starts = sorted(table_obj.start_codons) |
110 assert "NNN" not in starts | 114 assert "NNN" not in starts |
111 re_starts = re.compile("|".join(starts)) | 115 re_starts = re.compile("|".join(starts)) |
281 if out_prot and out_prot is not sys.stdout: | 285 if out_prot and out_prot is not sys.stdout: |
282 out_prot.close() | 286 out_prot.close() |
283 if out_bed and out_bed is not sys.stdout: | 287 if out_bed and out_bed is not sys.stdout: |
284 out_bed.close() | 288 out_bed.close() |
285 | 289 |
286 print "Found %i %ss in %i sequences" % (out_count, options.ftype, in_count) | 290 print("Found %i %ss in %i sequences" % (out_count, options.ftype, in_count)) |