Debian Codegraph @

debian/patches/python3.patch

raw symbols SCIP
1 Descriptionscip-debian debian poretools 0.6.0+dfsg-7 poretools/patches/`python3.patch`#Description.: port to python3
2 Python2 is obsolete. Port this code to python3.
3 Changes consist of 2to3 output, plus fixes for tab vs. space issues, and
4 a fix to argparse handling when we're called with no arguments.
5 Authorscip-debian debian poretools 0.6.0+dfsg-7 poretools/patches/`python3.patch`#Author.: Steve Langasek <[email protected]scip-debian . . . identity/`[email protected]`.>
6 Last-Modifiedscip-debian debian poretools 0.6.0+dfsg-7 poretools/patches/`python3.patch`#Last-Modified.: 2019-08-15
7 Bug-Debianscip-debian debian poretools 0.6.0+dfsg-7 poretools/patches/`python3.patch`#Bug-Debian.: https://bugs.debian.org/934845scip-debian-bts debian-bts . . 934845:
8
9 --- a/setup.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`setup.py`:
10 +++ b/setup.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`setup.py`:
11 @@ -3,7 +3,7 @@
12
13 version_py = os.path.join(os.path.dirname(__file__), 'poretools', 'version.py')
14 version = open(version_py).read().strip().split('=')[-1].replace('"','').strip()
15 -print version
16 +print(version)
17 long_description = """
18 ``poretools`` is a toolset for working with nanopore sequencing data'
19 """
20 --- a/poretools/__init__.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/__init__.py`:
21 +++ b/poretools/__init__.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/__init__.py`:
22 @@ -1,5 +1,4 @@
23 import os
24 import sys
25 -import scripts
26 -from Fast5File import *
27 -from version import __version__
28 +from . import scripts
29 +from .version import __version__
30 --- a/poretools/Fast5File.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/Fast5File.py`:
31 +++ b/poretools/Fast5File.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/Fast5File.py`:
32 @@ -11,8 +11,8 @@
33
34
35 # poretools imports
36 -import formats
37 -from Event import Event
38 +from . import formats
39 +from .Event import Event
40
41 fastq_paths = {
42 'closed' : {},
43 @@ -63,7 +63,7 @@
44 def __iter__(self):
45 return self
46
47 - def next(self):
48 + def __next__(self):
49 if len(self.files) > 0:
50 return self.files.pop(0)
51 else:
52 @@ -93,9 +93,9 @@
53 def __iter__(self):
54 return self
55
56 - def next(self):
57 + def __next__(self):
58 try:
59 - return Fast5File(self.files.next(), self.group)
60 + return Fast5File(next(self.files), self.group)
61 except Exception as e:
62 # cleanup our mess
63 if self.set_type == FAST5SET_TARBALL:
64 @@ -156,9 +156,9 @@
65 def __iter__(self):
66 return self
67
68 - def next(self):
69 + def __next__(self):
70 while True:
71 - tarinfo = self._tarfile.next()
72 + tarinfo = next(self._tarfile)
73 if tarinfo is None:
74 raise StopIteration
75 elif self._fast5_filename_filter(tarinfo.name):
76 @@ -211,7 +211,7 @@
77 try:
78 self.hdf5file = h5py.File(self.filename, 'r')
79 return True
80 - except Exception, e:
81 + except Exception as e:
82 logger.warning("Cannot open file: %s. Perhaps it is corrupt? Moving on.\n" % self.filename)
83 return False
84
85 @@ -327,7 +327,7 @@
86 self._extract_fastas_from_fast5()
87 self.have_fastas = True
88
89 - return self.fastas
90 + return self.fastas
91
92 def get_fastq(self):
93 """
94 @@ -465,7 +465,7 @@
95 https://github.com/arq5x/poretools/issues""" % (self.filename, reason)
96 sys.exit(msg)
97
98 - def find_read_number_block_fixed_raw(self):
99 + def find_read_number_block_fixed_raw(self):
100 """
101 New-style FAST5/HDF5 structure:
102 There is a fixed 'Raw/Reads' node with only one 'read_NNN' item
103 @@ -477,7 +477,7 @@
104 if raw_reads is None:
105 return None
106
107 - reads = raw_reads.keys()
108 + reads = list(raw_reads.keys())
109 if len(reads)==0:
110 self.hdf_internal_error("Raw/Reads group does not contain any items")
111 if len(reads)>1:
112 @@ -489,7 +489,7 @@
113 self.hdf_internal_error("Failed to get HDF5 item '%s'"% (path))
114 return node
115
116 - def find_read_number_block(self):
117 + def find_read_number_block(self):
118 """Returns the node of the 'Read_NNN' information, or None if not
119 found"""
120 node = self.find_read_number_block_link()
121 @@ -652,31 +652,31 @@
122 self._get_metadata()
123 self.have_metadata = True
124
125 - def get_host_name(self):
126 - """
127 - Return the MinKNOW host computer name.
128 - """
129 - if self.have_metadata is False:
130 - self._get_metadata()
131 - self.have_metadata = True
132 -
133 - try:
134 - return self.keyinfo['tracking_id'].attrs['hostname']
135 - except:
136 - return None
137 -
138 - if self.have_metadata is False:
139 - self._get_metadata()
140 - self.have_metadata = True
141 + def get_host_name(self):
142 + """
143 + Return the MinKNOW host computer name.
144 + """
145 + if self.have_metadata is False:
146 + self._get_metadata()
147 + self.have_metadata = True
148 +
149 + try:
150 + return self.keyinfo['tracking_id'].attrs['hostname']
151 + except:
152 + return None
153 +
154 + if self.have_metadata is False:
155 + self._get_metadata()
156 + self.have_metadata = True
157
158 def get_device_id(self):
159 """
160 Return the flowcell's device id.
161 """
162
163 - if self.have_metadata is False:
164 - self._get_metadata()
165 - self.have_metadata = True
166 + if self.have_metadata is False:
167 + self._get_metadata()
168 + self.have_metadata = True
169
170 try:
171 return self.keyinfo['tracking_id'].attrs['device_id']
172 @@ -688,13 +688,13 @@
173 Return the user supplied sample name
174 """
175
176 - if self.have_metadata is False:
177 - self._get_metadata()
178 - self.have_metadata = True
179 + if self.have_metadata is False:
180 + self._get_metadata()
181 + self.have_metadata = True
182
183 try:
184 return self.keyinfo['context_tags'].attrs['user_filename_input']
185 - except Exception, e:
186 + except Exception as e:
187 return None
188
189
190 @@ -705,7 +705,7 @@
191 try:
192 table = self.hdf5file[fastq_paths[self.version]['template'] % self.group]
193 return len(table['Events'][()])
194 - except Exception, e:
195 + except Exception as e:
196 return 0
197
198 def get_complement_events_count(self):
199 @@ -715,7 +715,7 @@
200 try:
201 table = self.hdf5file[fastq_paths[self.version]['complement'] % self.group]
202 return len(table['Events'][()])
203 - except Exception, e:
204 + except Exception as e:
205 return 0
206
207 def is_high_quality(self):
208 @@ -746,7 +746,7 @@
209 return 'template'
210 else:
211 return 'complement'
212 - except Exception, e:
213 + except Exception as e:
214 return None
215
216 ####################################################################
217 @@ -757,26 +757,26 @@
218 """
219 Return the sequence in the FAST5 file in FASTQ format
220 """
221 - for id, h5path in fastq_paths[self.version].iteritems():
222 + for id, h5path in fastq_paths[self.version].items():
223 try:
224 table = self.hdf5file[h5path % self.group]
225 fq = formats.Fastq(table['Fastq'][()])
226 fq.name += " " + self.filename
227 self.fastqs[id] = fq
228 - except Exception, e:
229 + except Exception as e:
230 pass
231
232 def _extract_fastas_from_fast5(self):
233 """
234 Return the sequence in the FAST5 file in FASTA format
235 """
236 - for id, h5path in fastq_paths[self.version].iteritems():
237 + for id, h5path in fastq_paths[self.version].items():
238 try:
239 table = self.hdf5file[h5path % self.group]
240 fa = formats.Fasta(table['Fastq'][()])
241 fa.name += " " + self.filename
242 self.fastas[id] = fa
243 - except Exception, e:
244 + except Exception as e:
245 pass
246
247 def _extract_template_events(self):
248 @@ -786,7 +786,7 @@
249 try:
250 table = self.hdf5file[fastq_paths[self.version]['template'] % self.group]
251 self.template_events = [Event(x) for x in table['Events'][()]]
252 - except Exception, e:
253 + except Exception as e:
254 self.template_events = []
255
256 def _extract_complement_events(self):
257 @@ -796,7 +796,7 @@
258 try:
259 table = self.hdf5file[fastq_paths[self.version]['complement'] % self.group]
260 self.complement_events = [Event(x) for x in table['Events'][()]]
261 - except Exception, e:
262 + except Exception as e:
263 self.complement_events = []
264
265 def _extract_pre_basecalled_events(self):
266 @@ -815,9 +815,9 @@
267 def _get_metadata(self):
268 try:
269 self.keyinfo = self.hdf5file['/UniqueGlobalKey']
270 - except Exception, e:
271 + except Exception as e:
272 try:
273 self.keyinfo = self.hdf5file['/Key']
274 - except Exception, e:
275 + except Exception as e:
276 self.keyinfo = None
277 logger.warning("Cannot find keyinfo. Exiting.\n")
278 --- a/poretools/formats.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/formats.py`:
279 +++ b/poretools/formats.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/formats.py`:
280 @@ -19,7 +19,7 @@
281 phred = ord(score) - 33
282 error_count += 10.0 ** (-phred / 10.0)
283 return error_count / len(self.qual)
284 - except Exception, e:
285 + except Exception as e:
286 return 0.0
287
288
289 --- a/poretools/times.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/times.py`:
290 +++ b/poretools/times.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/times.py`:
291 @@ -1,4 +1,4 @@
292 -import Fast5File
293 +from . import Fast5File
294 from time import strftime, localtime
295 import sys
296
297 @@ -7,10 +7,10 @@
298 logger = logging.getLogger('poretools')
299
300 def run(parser, args):
301 - print '\t'.join(['channel', 'filename', 'read_length',
302 + print('\t'.join(['channel', 'filename', 'read_length',
303 'exp_starttime', 'unix_timestamp', 'duration',
304 'unix_timestamp_end', 'iso_timestamp', 'day',
305 - 'hour', 'minute'])
306 + 'hour', 'minute']))
307
308 for fast5 in Fast5File.Fast5FileSet(args.files):
309 if fast5.is_open:
310 @@ -29,8 +29,8 @@
311 read_length = 0
312
313 lt = localtime(start_time)
314 - print "\t".join([fast5.get_channel_number(),
315 - fast5.filename,
316 + print("\t".join([str(fast5.get_channel_number()),
317 + str(fast5.filename),
318 str(read_length),
319 str(fast5.get_exp_start_time()),
320 str(start_time), \
321 @@ -39,5 +39,5 @@
322 strftime('%Y-%m-%dT%H:%M:%S%z', lt),
323 strftime('%d', lt),
324 strftime('%H', lt),
325 - strftime('%M', lt)])
326 + strftime('%M', lt)]))
327 fast5.close()
328 --- a/poretools/events.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/events.py`:
329 +++ b/poretools/events.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/events.py`:
330 @@ -1,4 +1,4 @@
331 -import Fast5File
332 +from . import Fast5File
333
334 def run(parser, args):
335
336 @@ -7,18 +7,18 @@
337 'length', 'model_state', 'model_level', 'move', \
338 'p_model_state', 'mp_model_state', 'p_mp_model_state', \
339 'p_A', 'p_C', 'p_G', 'p_T', 'raw_index']
340 - print "\t".join(keys)
341 + print("\t".join(keys))
342
343 if args.pre_basecalled:
344 for fast5 in Fast5File.Fast5FileSet(args.files):
345 for event in fast5.get_pre_basecalled_events():
346 - print '\t'.join([fast5.filename, 'pre_basecalled', str(event)])
347 + print('\t'.join([fast5.filename, 'pre_basecalled', str(event)]))
348 else:
349 for fast5 in Fast5File.Fast5FileSet(args.files):
350 for event in fast5.get_template_events():
351 - print '\t'.join([fast5.filename, 'template', str(event)])
352 + print('\t'.join([fast5.filename, 'template', str(event)]))
353 for event in fast5.get_complement_events():
354 - print '\t'.join([fast5.filename, 'complement', str(event)])
355 + print('\t'.join([fast5.filename, 'complement', str(event)]))
356
357 fast5.close()
358
359 --- a/poretools/qualdist.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/qualdist.py`:
360 +++ b/poretools/qualdist.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/qualdist.py`:
361 @@ -1,4 +1,4 @@
362 -import Fast5File
363 +from . import Fast5File
364 from collections import Counter
365
366 def run(parser, args):
367 @@ -15,5 +15,5 @@
368 fast5.close()
369
370 for q in qual_count:
371 - print '\t'.join(str(s) for s in [chr(q+33), q, qual_count[q],
372 - total_nucs, float(qual_count[q]) / float(total_nucs)])
373 \ No newline at end of file
374 + print ('\t'.join(str(s) for s in [chr(q+33), q, qual_count[q],
375 + total_nucs, float(qual_count[q]) / float(total_nucs)]))
376 --- a/poretools/metadata.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/metadata.py`:
377 +++ b/poretools/metadata.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/metadata.py`:
378 @@ -1,4 +1,4 @@
379 -import Fast5File
380 +from . import Fast5File
381
382 def run(parser, args):
383
384 @@ -6,17 +6,17 @@
385 for i, fast5 in enumerate(Fast5File.Fast5FileSet(args.files)):
386 for metadata_dict in fast5.read_metadata:
387 if i == 0:
388 - header = metadata_dict.keys()
389 - print "\t".join(["filename"] + header)
390 - print "\t".join([fast5.filename] + [str( metadata_dict[k] ) for k in header])
391 + header = list(metadata_dict.keys())
392 + print("\t".join(["filename"] + header))
393 + print("\t".join([fast5.filename] + [str( metadata_dict[k] ) for k in header]))
394 else:
395 - print "asic_id\tasic_temp\theatsink_temp"
396 + print("asic_id\tasic_temp\theatsink_temp")
397 for fast5 in Fast5File.Fast5FileSet(args.files):
398
399 asic_temp = fast5.get_asic_temp()
400 asic_id = fast5.get_asic_id()
401 heatsink_temp = fast5.get_heatsink_temp()
402
403 - print "%s\t%s\t%s" % (asic_id, asic_temp, heatsink_temp)
404 + print("%s\t%s\t%s" % (asic_id, asic_temp, heatsink_temp))
405
406 fast5.close()
407 --- a/poretools/fastq.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/fastq.py`:
408 +++ b/poretools/fastq.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/fastq.py`:
409 @@ -1,4 +1,4 @@
410 -import Fast5File
411 +from . import Fast5File
412 import sys
413
414 def run(parser, args):
415 @@ -42,7 +42,7 @@
416 args.max_length > 0):
417 continue
418
419 - print fa
420 + print(fa)
421
422 fast5.close()
423
424 --- a/poretools/occupancy.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/occupancy.py`:
425 +++ b/poretools/occupancy.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/occupancy.py`:
426 @@ -1,4 +1,4 @@
427 -import Fast5File
428 +from . import Fast5File
429 from collections import Counter
430 import sys
431 import pandas as pd
432 @@ -35,8 +35,8 @@
433 pore_values.append(0)
434
435 # make a data frame of the lists
436 - d = {'rownum': range(1,17)*32,
437 - 'colnum': sorted(range(1,33)*16),
438 + d = {'rownum': list(range(1,17))*32,
439 + 'colnum': sorted(list(range(1,33))*16),
440 'tot_reads': pore_values,
441 'labels': flowcell_layout}
442 df = pd.DataFrame(d)
443 @@ -55,7 +55,7 @@
444 tot_reads_per_pore = Counter()
445 tot_bp_per_pore = Counter()
446
447 - print "\t".join(['channel_number', 'start_time', 'duration'])
448 + print("\t".join(['channel_number', 'start_time', 'duration']))
449 for fast5 in Fast5File.Fast5FileSet(args.files):
450 if fast5.is_open:
451 fq = fast5.get_fastq()
452 @@ -70,10 +70,10 @@
453 tot_reads_per_pore[int(pore_id)] += 1
454 tot_bp_per_pore[int(pore_id)] += len(fq.seq)
455
456 - print "\t".join([
457 + print("\t".join([
458 str(pore_id),
459 str(start_time),
460 - str(fast5.get_duration())])
461 + str(fast5.get_duration())]))
462 fast5.close()
463
464 if args.plot_type == 'read_count':
465 --- a/poretools/index.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/index.py`:
466 +++ b/poretools/index.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/index.py`:
467 @@ -1,4 +1,4 @@
468 -import Fast5File
469 +from . import Fast5File
470 import datetime
471
472 ############
473 @@ -17,7 +17,7 @@
474
475 def run(parser, args):
476
477 - print "source_filename\ttemplate_fwd_length\tcomplement_rev_length\t2d_length\tasic_id\tasic_temp\theatsink_temp\tchannel\texp_start_time\texp_start_time_string_date\texp_start_time_string_time\tstart_time\tstart_time_string_date\tstart_time_string_time\tduration\tfast5_version"
478 + print("source_filename\ttemplate_fwd_length\tcomplement_rev_length\t2d_length\tasic_id\tasic_temp\theatsink_temp\tchannel\texp_start_time\texp_start_time_string_date\texp_start_time_string_time\tstart_time\tstart_time_string_date\tstart_time_string_time\tduration\tfast5_version")
479
480 for fast5 in Fast5File.Fast5FileSet(args.files):
481
482 @@ -56,11 +56,11 @@
483 length_complement = len(fastq_reads[1].seq)
484 length_2d = len(fastq_reads[2].seq)
485
486 - print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (
487 + print("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (
488 fast5.filename,
489 length_template,
490 length_complement,
491 length_2d,
492 - asic_id, asic_temp, heatsink_temp,channel_number,exp_start_time,exp_start_time_string,start_time,start_time_string,duration,fast5_version)
493 + asic_id, asic_temp, heatsink_temp,channel_number,exp_start_time,exp_start_time_string,start_time,start_time_string,duration,fast5_version))
494
495 fast5.close()
496 --- a/poretools/readstats.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/readstats.py`:
497 +++ b/poretools/readstats.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/readstats.py`:
498 @@ -1,8 +1,8 @@
499 -import Fast5File
500 +from . import Fast5File
501
502 def run(parser, args):
503
504 - print "start_time\tchannel_number\tread_number\ttemplate_events\tcomplement_events"
505 + print("start_time\tchannel_number\tread_number\ttemplate_events\tcomplement_events")
506
507 for fast5 in Fast5File.Fast5FileSet(args.files):
508
509 @@ -22,6 +22,6 @@
510 else:
511 complement_len = 0
512
513 - print "%s\t%s\t%s\t%s\t%s" % (start_time, channel_number, read_number, template_len, complement_len)
514 + print("%s\t%s\t%s\t%s\t%s" % (start_time, channel_number, read_number, template_len, complement_len))
515
516 fast5.close()
517 --- a/poretools/winner.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/winner.py`:
518 +++ b/poretools/winner.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/winner.py`:
519 @@ -1,4 +1,4 @@
520 -import Fast5File
521 +from . import Fast5File
522 import sys
523
524 #logging
525 @@ -21,5 +21,5 @@
526 fast5.close()
527
528 logger.info("Wow, it's a whopper: your longest read is %d bases." % (longest_size,))
529 - print longest_read
530 + print(longest_read)
531
532 --- a/poretools/stats.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/stats.py`:
533 +++ b/poretools/stats.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/stats.py`:
534 @@ -1,5 +1,5 @@
535 -import statistics as stat
536 -import Fast5File
537 +from . import statistics as stat
538 +from . import Fast5File
539 import logging
540 from collections import defaultdict
541 logger = logging.getLogger('poretools')
542 @@ -14,7 +14,7 @@
543 fas = fast5.get_fastas_dict()
544 if len(fas) > 0:
545 basecalled_files += 1
546 - for category, fa in fas.iteritems():
547 + for category, fa in fas.items():
548 if fa is not None:
549 stats[category].append(len(fa.seq))
550 if category == 'twodirections':
551 @@ -23,22 +23,22 @@
552
553 fast5.close()
554
555 - print "files\ttotal reads\t%d" % (files)
556 - print "files\ttotal base-called reads\t%d" % (basecalled_files)
557 + print("files\ttotal reads\t%d" % (files))
558 + print("files\ttotal base-called reads\t%d" % (basecalled_files))
559 for category in sorted(stats.keys()):
560 sizes = stats[category]
561
562 if len(sizes) > 0:
563 - print "%s\ttotal reads\t%d" % (category, len(sizes))
564 - print "%s\ttotal base pairs\t%d" % (category, sum(sizes))
565 - print "%s\tmean\t%.2f" % (category, stat.mean(sizes))
566 - print "%s\tmedian\t%d" % (category, stat.median(sizes))
567 - print "%s\tmin\t%d" % (category, min(sizes))
568 - print "%s\tmax\t%d" % (category, max(sizes))
569 + print("%s\ttotal reads\t%d" % (category, len(sizes)))
570 + print("%s\ttotal base pairs\t%d" % (category, sum(sizes)))
571 + print("%s\tmean\t%.2f" % (category, stat.mean(sizes)))
572 + print("%s\tmedian\t%d" % (category, stat.median(sizes)))
573 + print("%s\tmin\t%d" % (category, min(sizes)))
574 + print("%s\tmax\t%d" % (category, max(sizes)))
575 nxvalues = stat.NX(sizes, [25,50,75])
576 - print "%s\tN25\t%d" % (category, nxvalues[25])
577 - print "%s\tN50\t%d" % (category, nxvalues[50])
578 - print "%s\tN75\t%d" % (category, nxvalues[75])
579 + print("%s\tN25\t%d" % (category, nxvalues[25]))
580 + print("%s\tN50\t%d" % (category, nxvalues[50]))
581 + print("%s\tN75\t%d" % (category, nxvalues[75]))
582 else:
583 logger.warning("No valid sequences observed.\n")
584 else:
585 @@ -49,15 +49,15 @@
586 fast5.close()
587
588 if len(sizes) > 0:
589 - print "total reads\t%d" % (len(sizes))
590 - print "total base pairs\t%d" % (sum(sizes))
591 - print "mean\t%.2f" % (stat.mean(sizes))
592 - print "median\t%d" % (stat.median(sizes))
593 - print "min\t%d" % (min(sizes))
594 - print "max\t%d" % (max(sizes))
595 - nxvalues = stat.NX(sizes, [25,50,75])
596 - print "N25\t%d" % (nxvalues[25])
597 - print "N50\t%d" % (nxvalues[50])
598 - print "N75\t%d" % (nxvalues[75])
599 + print("total reads\t%d" % (len(sizes)))
600 + print("total base pairs\t%d" % (sum(sizes)))
601 + print("mean\t%.2f" % (stat.mean(sizes)))
602 + print("median\t%d" % (stat.median(sizes)))
603 + print("min\t%d" % (min(sizes)))
604 + print("max\t%d" % (max(sizes)))
605 + nxvalues = stat.NX(sizes, [25,50,75])
606 + print("N25\t%d" % (nxvalues[25]))
607 + print("N50\t%d" % (nxvalues[50]))
608 + print("N75\t%d" % (nxvalues[75]))
609 else:
610 logger.warning("No valid sequences observed.\n")
611 --- a/poretools/nucdist.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/nucdist.py`:
612 +++ b/poretools/nucdist.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/nucdist.py`:
613 @@ -1,4 +1,4 @@
614 -import Fast5File
615 +from . import Fast5File
616 from collections import Counter
617
618 def run(parser, args):
619 @@ -15,5 +15,5 @@
620 fast5.close()
621
622 for n in nuc_count:
623 - print '\t'.join(str(s) for s in [n, nuc_count[n],
624 - total_nucs, float(nuc_count[n]) / float(total_nucs)])
625 \ No newline at end of file
626 + print ('\t'.join(str(s) for s in [n, nuc_count[n],
627 + total_nucs, float(nuc_count[n]) / float(total_nucs)]))
628 --- a/poretools/tabular.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/tabular.py`:
629 +++ b/poretools/tabular.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/tabular.py`:
630 @@ -1,8 +1,8 @@
631 -import Fast5File
632 +from . import Fast5File
633
634 def run(parser, args):
635
636 - print '\t'.join(['length', 'name', 'sequence', 'quals'])
637 + print('\t'.join(['length', 'name', 'sequence', 'quals']))
638
639 for fast5 in Fast5File.Fast5FileSet(args.files):
640 fqs = fast5.get_fastqs(args.type)
641 @@ -10,5 +10,5 @@
642 if fq is None:
643 fast5.close()
644 continue
645 - print '\t'.join([str(len(fq.seq)), fq.name, fq.seq, fq.qual])
646 - fast5.close()
647 \ No newline at end of file
648 + print ('\t'.join([str(len(fq.seq)), fq.name, fq.seq, fq.qual]))
649 + fast5.close()
650 --- a/poretools/fasta.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/fasta.py`:
651 +++ b/poretools/fasta.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/fasta.py`:
652 @@ -1,4 +1,4 @@
653 -import Fast5File
654 +from . import Fast5File
655 import sys
656
657 def run(parser, args):
658 @@ -42,7 +42,7 @@
659 args.max_length > 0):
660 continue
661
662 - print fa
663 + print(fa)
664
665 fast5.close()
666
667 --- a/poretools/statistics.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/statistics.py`:
668 +++ b/poretools/statistics.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/statistics.py`:
669 @@ -27,25 +27,25 @@
670 return None
671
672 def NX(l, x=[25,50,75]):
673 - """
674 - Returns NX for all x for a list of numbers l.
675 - Default: N25, N50, N75
676 - Assumes all values in list x are between 0 and 100.
677 - Interpretation: When NX = NX_value, X% of data (in bp) is contained in reads at least NX_value bp long.
678 - """
679 + """
680 + Returns NX for all x for a list of numbers l.
681 + Default: N25, N50, N75
682 + Assumes all values in list x are between 0 and 100.
683 + Interpretation: When NX = NX_value, X% of data (in bp) is contained in reads at least NX_value bp long.
684 + """
685 if isinstance(l, list) and isinstance(x, list):
686 l = sorted(l)
687 x = sorted(x)
688 total = sum(l)
689 - nxsum = 0
690 - nxvalues = {e:0 for e in x}
691 + nxsum = 0
692 + nxvalues = {e:0 for e in x}
693 for e in x:
694 - xpct = total*e/100.0
695 - while nxsum < xpct and l:
696 - nxsum += l[-1]
697 - lastsize = l.pop()
698 - nxvalues[e] = lastsize
699 - return nxvalues
700 + xpct = total*e/100.0
701 + while nxsum < xpct and l:
702 + nxsum += l[-1]
703 + lastsize = l.pop()
704 + nxvalues[e] = lastsize
705 + return nxvalues
706
707 else:
708 return None
709 --- a/poretools/poretools_main.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/poretools_main.py`:
710 +++ b/poretools/poretools_main.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/poretools_main.py`:
711 @@ -13,43 +13,43 @@
712
713 def run_subtool(parser, args):
714 if args.command == 'combine':
715 - import combine as submodule
716 + from . import combine as submodule
717 elif args.command == 'events':
718 - import events as submodule
719 + from . import events as submodule
720 elif args.command == 'fasta':
721 - import fasta as submodule
722 + from . import fasta as submodule
723 elif args.command == 'fastq':
724 - import fastq as submodule
725 + from . import fastq as submodule
726 elif args.command == 'hist':
727 - import hist as submodule
728 + from . import hist as submodule
729 elif args.command == 'metadata':
730 - import metadata as submodule
731 + from . import metadata as submodule
732 elif args.command == 'nucdist':
733 - import nucdist as submodule
734 + from . import nucdist as submodule
735 elif args.command == 'occupancy':
736 - import occupancy as submodule
737 + from . import occupancy as submodule
738 elif args.command == 'qualdist':
739 - import qualdist as submodule
740 + from . import qualdist as submodule
741 elif args.command == 'qualpos':
742 - import qual_v_pos as submodule
743 + from . import qual_v_pos as submodule
744 elif args.command == 'readstats':
745 - import readstats as submodule
746 + from . import readstats as submodule
747 elif args.command == 'stats':
748 - import stats as submodule
749 + from . import stats as submodule
750 elif args.command == 'tabular':
751 - import tabular as submodule
752 + from . import tabular as submodule
753 elif args.command == 'times':
754 - import times as submodule
755 + from . import times as submodule
756 elif args.command == 'squiggle':
757 - import squiggle as submodule
758 + from . import squiggle as submodule
759 elif args.command == 'winner':
760 - import winner as submodule
761 + from . import winner as submodule
762 elif args.command == 'yield_plot':
763 - import yield_plot as submodule
764 + from . import yield_plot as submodule
765 elif args.command == 'index':
766 - import index as submodule
767 + from . import index as submodule
768 elif args.command == 'organise':
769 - import organise as submodule
770 + from . import organise as submodule
771
772 # run the chosen submodule.
773 submodule.run(parser, args)
774 @@ -57,7 +57,7 @@
775 class ArgumentParserWithDefaults(argparse.ArgumentParser):
776 def __init__(self, *args, **kwargs):
777 super(ArgumentParserWithDefaults, self).__init__(*args, **kwargs)
778 - self.add_argument("-q", "--quiet", help="Do not output warnings to stderr",
779 + self.add_argument("-q", "--quiet", help="Do not output warnings to stderr",
780 action="store_true",
781 dest="quiet")
782
783 @@ -526,12 +526,16 @@
784 #######################################################
785 args = parser.parse_args()
786
787 + if not args.command:
788 + parser.print_help()
789 + sys.exit(0)
790 +
791 if args.quiet:
792 logger.setLevel(logging.ERROR)
793
794 try:
795 args.func(parser, args)
796 - except IOError, e:
797 + except IOError as e:
798 if e.errno != 32: # ignore SIGPIPE
799 raise
800
801 --- a/poretools/combine.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/combine.py`:
802 +++ b/poretools/combine.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/combine.py`:
803 @@ -1,6 +1,6 @@
804 import tarfile
805 import sys
806 -import Fast5File
807 +from . import Fast5File
808
809 #logging
810 import logging
811 --- a/poretools/hist.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/hist.py`:
812 +++ b/poretools/hist.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/hist.py`:
813 @@ -6,7 +6,7 @@
814 from matplotlib import pyplot as plt
815
816 import seaborn as sns
817 -import Fast5File
818 +from . import Fast5File
819
820 import logging
821 logger = logging.getLogger('poretools')
822 --- a/poretools/organise.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/organise.py`:
823 +++ b/poretools/organise.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/organise.py`:
824 @@ -1,4 +1,4 @@
825 -import Fast5File
826 +from . import Fast5File
827 import sys
828 import os
829 from os import makedirs
830 --- a/poretools/qual_v_pos.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/qual_v_pos.py`:
831 +++ b/poretools/qual_v_pos.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/qual_v_pos.py`:
832 @@ -1,4 +1,4 @@
833 -import Fast5File
834 +from . import Fast5File
835 from collections import defaultdict
836 import pandas
837 import matplotlib.pyplot as plt
838 --- a/poretools/squiggle.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/squiggle.py`:
839 +++ b/poretools/squiggle.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/squiggle.py`:
840 @@ -10,7 +10,7 @@
841 import logging
842 logger = logging.getLogger('poretools')
843
844 -import Fast5File
845 +from . import Fast5File
846
847 def plot_squiggle(args, filename, start_times, mean_signals):
848 """
849 @@ -70,7 +70,7 @@
850
851 fast5_set = Fast5File.Fast5FileSet(args.files)
852
853 - first_fast5 = fast5_set.next()
854 + first_fast5 = next(fast5_set)
855 for fast5 in fast5_set:
856 # only create a squiggle plot for multiple reads if saving to file.
857 if args.saveas is None:
858 --- a/poretools/yield_plot.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/yield_plot.py`:
859 +++ b/poretools/yield_plot.pyscip-debian debian poretools 0.6.0+dfsg-7 poretools/upstream/`poretools/yield_plot.py`:
860 @@ -1,4 +1,4 @@
861 -import Fast5File
862 +from . import Fast5File
863 import matplotlib
864 #matplotlib.use('Agg') # Must be called before any other matplotlib calls
865 from matplotlib import pyplot as plt
866 @@ -25,16 +25,16 @@
867 # compute the cumulative based on reads or total base pairs
868 if args.plot_type == 'reads':
869 y_label = "Total reads"
870 - cumulative = np.cumsum(range(len(start_times)))
871 + cumulative = np.cumsum(list(range(len(start_times))))
872 elif args.plot_type == 'basepairs':
873 y_label = "Total base pairs"
874 cumulative = np.cumsum(read_lengths)
875
876 step = args.skip
877 # make a data frame of the lists
878 - d = {'start': [start_times[n] for n in xrange(0, len(start_times), step)],
879 - 'lengths': [read_lengths[n] for n in xrange(0, len(read_lengths), step)],
880 - 'cumul': [cumulative[n] for n in xrange(0, len(cumulative), step)]}
881 + d = {'start': [start_times[n] for n in range(0, len(start_times), step)],
882 + 'lengths': [read_lengths[n] for n in range(0, len(read_lengths), step)],
883 + 'cumul': [cumulative[n] for n in range(0, len(cumulative), step)]}
884 df = pd.DataFrame(d)
885
886 if args.savedf: