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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
|
Description: Use 2to3 to port to Python3
Bug-Debian: https://bugs.debian.org/938565
Author: Andreas Tille <tille@debian.org>
Last-Update: Wed, 04 Sep 2019 16:44:45 +0200
--- a/tools/TQS.py
+++ b/tools/TQS.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
__doc__ = """
TQS
@@ -53,18 +53,18 @@ def main():
f = open(opts.seqfile)
seq = f.readlines()
f.close()
- except Exception, e:
- print "ERROR: Could not read from %s: %s" % (opts.seqfile, e)
- print usage % (sys.argv[0:])
+ except Exception as e:
+ print("ERROR: Could not read from %s: %s" % (opts.seqfile, e))
+ print(usage % (sys.argv[0:]))
sys.exit()
try:
f = open(opts.qualfile)
qual = f.readlines()
f.close()
- except Exception, e:
- print "ERROR: Could not read from %s: %s" % (opts.qualfile, e)
- print usage % (sys.argv[0:])
+ except Exception as e:
+ print("ERROR: Could not read from %s: %s" % (opts.qualfile, e))
+ print(usage % (sys.argv[0:]))
sys.exit()
@@ -75,22 +75,22 @@ def main():
try:
FASTA = open(fasta, 'w')
except:
- print "ERROR: Can not write to %s" % fasta
+ print("ERROR: Can not write to %s" % fasta)
sys.exit()
try:
LOG = open(log, 'w')
except:
- print "ERROR: Can not write to %s" % log
+ print("ERROR: Can not write to %s" % log)
sys.exit()
if opts.mer < 15 or opts.mer > 200:
- print "ERROR: -l must be a number between 15 and 200."
+ print("ERROR: -l must be a number between 15 and 200.")
sys.exit()
if opts.consec < 16 or opts.consec > opts.mer:
- print "ERROR: -c must be a number between 16 and -l."
+ print("ERROR: -c must be a number between 16 and -l.")
sys.exit()
LOG.write("""
@@ -130,7 +130,7 @@ def parseQualFile(threshold, difference,
read_number = 0
if verbose:
- print "Printing trimming pattern for all reads passing the set threshold values...\n"
+ print("Printing trimming pattern for all reads passing the set threshold values...\n")
for line in qual:
read_number += 1 ### this keeps track of the read order, respected between the prb and seq files
@@ -156,7 +156,7 @@ def parseQualFile(threshold, difference,
if head_match != None:
ok_read += 1
col = head_match.span()
- if not trim_info.has_key(read_number):
+ if read_number not in trim_info:
trim_info[read_number] = {}
start = int(col[0])
@@ -167,7 +167,7 @@ def parseQualFile(threshold, difference,
if verbose:
sub = concat[trim_info[read_number]['start']:trim_info[read_number]['end']]
- print "passed seqs:%i line#%i %s (start trim:%i,length:%i) %s\n" % (ok_read, read_number, concat, start, end, sub)
+ print("passed seqs:%i line#%i %s (start trim:%i,length:%i) %s\n" % (ok_read, read_number, concat, start, end, sub))
LOG.write("%i out of %i sequences passed your filter (I >= %i and D >= %i and L >= %i)\n" % (ok_read, read_number, threshold, difference, consecutive))
@@ -191,7 +191,7 @@ def readNTrim(trim_info, seq, verbose, F
gDNAlinker2_field = re.compile('^ATCTAACAG')
if verbose:
- print "Printing trimmed sequences for all reads passing the set threshold values minus, excluding sequence containing linkers...\n"
+ print("Printing trimmed sequences for all reads passing the set threshold values minus, excluding sequence containing linkers...\n")
for line in seq:
read_number += 1 ### tracks read number / will match order in prb file
@@ -199,7 +199,7 @@ def readNTrim(trim_info, seq, verbose, F
info = line.split("\t") ### split line, the seq file lists: lane tile xcoord y coord DNAseq
dna_string = info[4]
- if trim_info.has_key(read_number):
+ if read_number in trim_info:
trim_seq = dna_string[trim_info[read_number]['start']:trim_info[read_number]['end']]
if re.match(dna_sequence_field, trim_seq): ### no ambiguous bases?
if re.match(gDNAlinker1_field, trim_seq) or re.match(gDNAlinker2_field,trim_seq): ### matches gDNA linker?
@@ -208,7 +208,7 @@ def readNTrim(trim_info, seq, verbose, F
usable_reads += 1
FASTA.write(">%s-%s-%s-%s\n%s\n" % (info[0],info[1],info[2],info[3],trim_seq))
if verbose:
- print "line#%i %s (start trim:%i,length:%i) %s" % (read_number,info[4],trim_info[read_number]['start'],trim_info[read_number]['end'],trim_seq)
+ print("line#%i %s (start trim:%i,length:%i) %s" % (read_number,info[4],trim_info[read_number]['start'],trim_info[read_number]['end'],trim_seq))
LOG.write("%i out of %i sequences appear to be usable, after filtering out sequences hard-coded in this program * %i gDNA linker sequences*\n" % (usable_reads, read_number,gDNAlinker_count))
return
--- a/tools/TQS.readme
+++ b/tools/TQS.readme
@@ -24,12 +24,12 @@ __version__ = '1.0'
Execution example
==================
-python TQS.py -f test_seq.txt -q test_prb.txt -l 36 -t 5 -d 5 -c 20
+python3 TQS.py -f test_seq.txt -q test_prb.txt -l 36 -t 5 -d 5 -c 20
Options
=======
-python TQS.py --help
+python3 TQS.py --help
Usage: TQS.py [options]
--- a/tools/TQSexport.py
+++ b/tools/TQSexport.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
__doc__ = """
TQS
@@ -47,9 +47,9 @@ def main():
f = open(opts.exportfile)
seq = f.readlines()
f.close()
- except Exception, e:
- print "ERROR: Could not read from %s: %s" % (opts.exportfile, e)
- print usage % (sys.argv[0:])
+ except Exception as e:
+ print("ERROR: Could not read from %s: %s" % (opts.exportfile, e))
+ print(usage % (sys.argv[0:]))
sys.exit()
@@ -61,17 +61,17 @@ def main():
try:
FASTA = open(fasta, 'w')
except:
- print "ERROR: Can not write to %s" % fasta
+ print("ERROR: Can not write to %s" % fasta)
sys.exit()
try:
LOG = open(log, 'w')
except:
- print "ERROR: Can not write to %s" % log
+ print("ERROR: Can not write to %s" % log)
sys.exit()
if opts.consec < minimum_length:
- print "ERROR: -c must be a number larger than %i." % (minimum_length)
+ print("ERROR: -c must be a number larger than %i." % (minimum_length))
sys.exit()
LOG.write("""
@@ -106,7 +106,7 @@ YYYYRYYYYYYYYYYYTTTTTOOOMOOOMMOOOOOG chr
read_number = 0
if verbose:
- print "Printing trimming pattern for all reads passing the set threshold values...\n"
+ print("Printing trimming pattern for all reads passing the set threshold values...\n")
for line in export:
read_number += 1
@@ -134,7 +134,7 @@ YYYYRYYYYYYYYYYYTTTTTOOOMOOOMMOOOOOG chr
if head_match != None:
ok_read += 1
col = head_match.span()
- if not trim_info.has_key(read_number):
+ if read_number not in trim_info:
trim_info[read_number] = {}
start = int(col[0])
@@ -150,7 +150,7 @@ YYYYRYYYYYYYYYYYTTTTTOOOMOOOMMOOOOOG chr
FASTA.write(">%s-%s-%s-%s%s\n%s\n" % (info[1],info[2],info[3],info[4],pair,trim_seq))
if verbose:
- print "passed seqs:%i line#%i %s (start trim:%i,end trim:%i) %s\n" % (ok_read, read_number, concat, start, end, trim_seq)
+ print("passed seqs:%i line#%i %s (start trim:%i,end trim:%i) %s\n" % (ok_read, read_number, concat, start, end, trim_seq))
LOG.write("%i out of %i sequences passed your filter (-t >= %i and -c >= %i)\n" % (ok_read, read_number, threshold, consecutive))
--- a/tools/TQSfastq.py
+++ b/tools/TQSfastq.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
__doc__ = """
TQS
@@ -52,9 +52,9 @@ def main():
f = open(opts.fastqfile)
seq = f.readlines()
f.close()
- except Exception, e:
- print "ERROR: Could not read from %s: %s" % (opts.fastqfile, e)
- print usage % (sys.argv[0:])
+ except Exception as e:
+ print("ERROR: Could not read from %s: %s" % (opts.fastqfile, e))
+ print(usage % (sys.argv[0:]))
sys.exit()
@@ -66,21 +66,21 @@ def main():
try:
FASTA = open(fasta, 'w')
except:
- print "ERROR: Can not write to %s" % fasta
+ print("ERROR: Can not write to %s" % fasta)
sys.exit()
try:
LOG = open(log, 'w')
except:
- print "ERROR: Can not write to %s" % log
+ print("ERROR: Can not write to %s" % log)
sys.exit()
if opts.consec < minimum_length:
- print "ERROR: -c must be a number larger than %i." % (minimum_length)
+ print("ERROR: -c must be a number larger than %i." % (minimum_length))
sys.exit()
if opts.encoding != 33 and opts.encoding != 64:
- print "ERROR: -e must be either 33 or 64."
+ print("ERROR: -e must be either 33 or 64.")
sys.exit()
LOG.write("""
@@ -114,7 +114,7 @@ def readNtrim(fastq, threshold, consecut
record_line = 0
if verbose:
- print "Printing trimming pattern for all reads passing the set threshold values...\n"
+ print("Printing trimming pattern for all reads passing the set threshold values...\n")
for line in fastq:
record_line += 1
@@ -150,7 +150,7 @@ def readNtrim(fastq, threshold, consecut
if head_match != None:
ok_read += 1
col = head_match.span()
- if not trim_info.has_key(read_number):
+ if read_number not in trim_info:
trim_info[read_number] = {}
start = int(col[0])
@@ -160,7 +160,7 @@ def readNtrim(fastq, threshold, consecut
FASTA.write(">%s\n%s\n" % (read_id, trim_seq))
if verbose:
- print "%s\n%s\n%s\n passed seqs:%i line#%i %s (start trim:%i,end trim:%i) %s\n" % (read_id,seq,qual,ok_read, read_number, concat, start, end, trim_seq)
+ print("%s\n%s\n%s\n passed seqs:%i line#%i %s (start trim:%i,end trim:%i) %s\n" % (read_id,seq,qual,ok_read, read_number, concat, start, end, trim_seq))
LOG.write("%i out of %i sequences passed your filter (-t >= %i and -c >= %i)\n" % (ok_read, read_number, threshold, consecutive))
|