Package: sra-sdk / 2.10.9+dfsg-2

python3 Patch series | download
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
From: Michael R. Crusoe <michael.crusoe@gmail.com>
Subject: Upgrade from Python2 to Python 3
--- a/build/gprof2dot.py
+++ b/build/gprof2dot.py
@@ -1,4 +1,4 @@
-#!/opt/python-2.5/bin/python
+#!/usr/bin/python3
 #
 # Copyright 2008-2009 Jose Fonseca
 #
@@ -40,7 +40,7 @@ except ImportError:
 
 
 def times(x):
-    return u"%u\xd7" % (x,)
+    return "%u\xd7" % (x,)
 
 def percentage(p):
     return "%.02f%%" % (p*100.0,)
@@ -245,8 +245,8 @@ class Profile(Object):
     def validate(self):
         """Validate the edges."""
 
-        for function in self.functions.itervalues():
-            for callee_id in function.calls.keys():
+        for function in self.functions.values():
+            for callee_id in list(function.calls.keys()):
                 assert function.calls[callee_id].callee_id == callee_id
                 if callee_id not in self.functions:
                     sys.stderr.write('warning: call to undefined function %s from function %s\n' % (str(callee_id), function.name))
@@ -257,11 +257,11 @@ class Profile(Object):
 
         # Apply the Tarjan's algorithm successively until all functions are visited
         visited = set()
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             if function not in visited:
                 self._tarjan(function, 0, [], {}, {}, visited)
         cycles = []
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             if function.cycle is not None and function.cycle not in cycles:
                 cycles.append(function.cycle)
         self.cycles = cycles
@@ -284,7 +284,7 @@ class Profile(Object):
         order += 1
         pos = len(stack)
         stack.append(function)
-        for call in function.calls.itervalues():
+        for call in function.calls.values():
             callee = self.functions[call.callee_id]
             # TODO: use a set to optimize lookup
             if callee not in orders:
@@ -308,10 +308,10 @@ class Profile(Object):
         for cycle in self.cycles:
             cycle_totals[cycle] = 0.0
         function_totals = {}
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             function_totals[function] = 0.0
-        for function in self.functions.itervalues():
-            for call in function.calls.itervalues():
+        for function in self.functions.values():
+            for call in function.calls.values():
                 if call.callee_id != function.id:
                     callee = self.functions[call.callee_id]
                     function_totals[callee] += call[event]
@@ -319,8 +319,8 @@ class Profile(Object):
                         cycle_totals[callee.cycle] += call[event]
 
         # Compute the ratios
-        for function in self.functions.itervalues():
-            for call in function.calls.itervalues():
+        for function in self.functions.values():
+            for call in function.calls.values():
                 assert call.ratio is None
                 if call.callee_id != function.id:
                     callee = self.functions[call.callee_id]
@@ -341,10 +341,10 @@ class Profile(Object):
 
         # Sanity checking
         assert outevent not in self
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             assert outevent not in function
             assert inevent in function
-            for call in function.calls.itervalues():
+            for call in function.calls.values():
                 assert outevent not in call
                 if call.callee_id != function.id:
                     assert call.ratio is not None
@@ -352,13 +352,13 @@ class Profile(Object):
         # Aggregate the input for each cycle 
         for cycle in self.cycles:
             total = inevent.null()
-            for function in self.functions.itervalues():
+            for function in self.functions.values():
                 total = inevent.aggregate(total, function[inevent])
             self[inevent] = total
 
         # Integrate along the edges
         total = inevent.null()
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             total = inevent.aggregate(total, function[inevent])
             self._integrate_function(function, outevent, inevent)
         self[outevent] = total
@@ -369,7 +369,7 @@ class Profile(Object):
         else:
             if outevent not in function:
                 total = function[inevent]
-                for call in function.calls.itervalues():
+                for call in function.calls.values():
                     if call.callee_id != function.id:
                         total += self._integrate_call(call, outevent, inevent)
                 function[outevent] = total
@@ -390,7 +390,7 @@ class Profile(Object):
             total = inevent.null()
             for member in cycle.functions:
                 subtotal = member[inevent]
-                for call in member.calls.itervalues():
+                for call in member.calls.values():
                     callee = self.functions[call.callee_id]
                     if callee.cycle is not cycle:
                         subtotal += self._integrate_call(call, outevent, inevent)
@@ -399,9 +399,9 @@ class Profile(Object):
             
             # Compute the time propagated to callers of this cycle
             callees = {}
-            for function in self.functions.itervalues():
+            for function in self.functions.values():
                 if function.cycle is not cycle:
-                    for call in function.calls.itervalues():
+                    for call in function.calls.values():
                         callee = self.functions[call.callee_id]
                         if callee.cycle is cycle:
                             try:
@@ -412,7 +412,7 @@ class Profile(Object):
             for member in cycle.functions:
                 member[outevent] = outevent.null()
 
-            for callee, call_ratio in callees.iteritems():
+            for callee, call_ratio in callees.items():
                 ranks = {}
                 call_ratios = {}
                 partials = {}
@@ -427,7 +427,7 @@ class Profile(Object):
     def _rank_cycle_function(self, cycle, function, rank, ranks):
         if function not in ranks or ranks[function] > rank:
             ranks[function] = rank
-            for call in function.calls.itervalues():
+            for call in function.calls.values():
                 if call.callee_id != function.id:
                     callee = self.functions[call.callee_id]
                     if callee.cycle is cycle:
@@ -436,7 +436,7 @@ class Profile(Object):
     def _call_ratios_cycle(self, cycle, function, ranks, call_ratios, visited):
         if function not in visited:
             visited.add(function)
-            for call in function.calls.itervalues():
+            for call in function.calls.values():
                 if call.callee_id != function.id:
                     callee = self.functions[call.callee_id]
                     if callee.cycle is cycle:
@@ -447,7 +447,7 @@ class Profile(Object):
     def _integrate_cycle_function(self, cycle, function, partial_ratio, partials, ranks, call_ratios, outevent, inevent):
         if function not in partials:
             partial = partial_ratio*function[inevent]
-            for call in function.calls.itervalues():
+            for call in function.calls.values():
                 if call.callee_id != function.id:
                     callee = self.functions[call.callee_id]
                     if callee.cycle is not cycle:
@@ -474,7 +474,7 @@ class Profile(Object):
         """Aggregate an event for the whole profile."""
 
         total = event.null()
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             try:
                 total = event.aggregate(total, function[event])
             except UndefinedEvent:
@@ -484,11 +484,11 @@ class Profile(Object):
     def ratio(self, outevent, inevent):
         assert outevent not in self
         assert inevent in self
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             assert outevent not in function
             assert inevent in function
             function[outevent] = ratio(function[inevent], self[inevent])
-            for call in function.calls.itervalues():
+            for call in function.calls.values():
                 assert outevent not in call
                 if inevent in call:
                     call[outevent] = ratio(call[inevent], self[inevent])
@@ -498,13 +498,13 @@ class Profile(Object):
         """Prune the profile"""
 
         # compute the prune ratios
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             try:
                 function.weight = function[TOTAL_TIME_RATIO]
             except UndefinedEvent:
                 pass
 
-            for call in function.calls.itervalues():
+            for call in function.calls.values():
                 callee = self.functions[call.callee_id]
 
                 if TOTAL_TIME_RATIO in call:
@@ -518,24 +518,24 @@ class Profile(Object):
                         pass
 
         # prune the nodes
-        for function_id in self.functions.keys():
+        for function_id in list(self.functions.keys()):
             function = self.functions[function_id]
             if function.weight is not None:
                 if function.weight < node_thres:
                     del self.functions[function_id]
 
         # prune the egdes
-        for function in self.functions.itervalues():
-            for callee_id in function.calls.keys():
+        for function in self.functions.values():
+            for callee_id in list(function.calls.keys()):
                 call = function.calls[callee_id]
                 if callee_id not in self.functions or call.weight is not None and call.weight < edge_thres:
                     del function.calls[callee_id]
     
     def dump(self):
-        for function in self.functions.itervalues():
+        for function in self.functions.values():
             sys.stderr.write('Function %s:\n' % (function.name,))
             self._dump_events(function.events)
-            for call in function.calls.itervalues():
+            for call in function.calls.values():
                 callee = self.functions[call.callee_id]
                 sys.stderr.write('  Call %s:\n' % (callee.name,))
                 self._dump_events(call.events)
@@ -546,7 +546,7 @@ class Profile(Object):
                 sys.stderr.write('  Function %s\n' % (function.name,))
 
     def _dump_events(self, events):
-        for event, value in events.iteritems():
+        for event, value in events.items():
             sys.stderr.write('    %s: %s\n' % (event.name, event.format(value)))
 
 
@@ -630,7 +630,7 @@ class LineParser(Parser):
         return self.__eof
 
 
-XML_ELEMENT_START, XML_ELEMENT_END, XML_CHARACTER_DATA, XML_EOF = range(4)
+XML_ELEMENT_START, XML_ELEMENT_END, XML_CHARACTER_DATA, XML_EOF = list(range(4))
 
 
 class XmlToken:
@@ -698,7 +698,7 @@ class XmlTokenizer:
                 self.tokens.append(token)
             self.character_data = ''
     
-    def next(self):
+    def __next__(self):
         size = 16*1024
         while self.index >= len(self.tokens) and not self.final:
             self.tokens = []
@@ -707,7 +707,7 @@ class XmlTokenizer:
             self.final = len(data) < size
             try:
                 self.parser.Parse(data, self.final)
-            except xml.parsers.expat.ExpatError, e:
+            except xml.parsers.expat.ExpatError as e:
                 #if e.code == xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS:
                 if e.code == 3:
                     pass
@@ -744,7 +744,7 @@ class XmlParser(Parser):
         self.consume()
     
     def consume(self):
-        self.token = self.tokenizer.next()
+        self.token = next(self.tokenizer)
 
     def match_element_start(self, name):
         return self.token.type == XML_ELEMENT_START and self.token.name_or_data == name
@@ -813,7 +813,7 @@ class GprofParser(Parser):
         """Extract a structure from a match object, while translating the types in the process."""
         attrs = {}
         groupdict = mo.groupdict()
-        for name, value in groupdict.iteritems():
+        for name, value in groupdict.items():
             if value is None:
                 value = None
             elif self._int_re.match(value):
@@ -986,10 +986,10 @@ class GprofParser(Parser):
         profile[TIME] = 0.0
         
         cycles = {}
-        for index in self.cycles.iterkeys():
+        for index in self.cycles.keys():
             cycles[index] = Cycle()
 
-        for entry in self.functions.itervalues():
+        for entry in self.functions.values():
             # populate the function
             function = Function(entry.index, entry.name)
             function[TIME] = entry.self
@@ -1031,7 +1031,7 @@ class GprofParser(Parser):
 
             profile[TIME] = profile[TIME] + function[TIME]
 
-        for cycle in cycles.itervalues():
+        for cycle in cycles.values():
             profile.add_cycle(cycle)
 
         # Compute derived events
@@ -1185,7 +1185,7 @@ class CallgrindParser(LineParser):
                 position = int(position)
             self.last_positions[i] = position
 
-        events = map(float, events)
+        events = list(map(float, events))
 
         if calls is None:
             function[SAMPLES] += events[0] 
@@ -1382,7 +1382,7 @@ class OprofileParser(LineParser):
             self.update_subentries_dict(callees_total, callees)
     
     def update_subentries_dict(self, totals, partials):
-        for partial in partials.itervalues():
+        for partial in partials.values():
             try:
                 total = totals[partial.id]
             except KeyError:
@@ -1404,7 +1404,7 @@ class OprofileParser(LineParser):
         
         # populate the profile
         profile[SAMPLES] = 0
-        for _callers, _function, _callees in self.entries.itervalues():
+        for _callers, _function, _callees in self.entries.values():
             function = Function(_function.id, _function.name)
             function[SAMPLES] = _function.samples
             profile.add_function(function)
@@ -1416,10 +1416,10 @@ class OprofileParser(LineParser):
                 function.module = os.path.basename(_function.image)
 
             total_callee_samples = 0
-            for _callee in _callees.itervalues():
+            for _callee in _callees.values():
                 total_callee_samples += _callee.samples
 
-            for _callee in _callees.itervalues():
+            for _callee in _callees.values():
                 if not _callee.self:
                     call = Call(_callee.id)
                     call[SAMPLES2] = _callee.samples
@@ -1552,7 +1552,7 @@ class HProfParser(LineParser):
         functions = {}
 
         # build up callgraph
-        for id, trace in self.traces.iteritems():
+        for id, trace in self.traces.items():
             if not id in self.samples: continue
             mtime = self.samples[id][0]
             last = None
@@ -1681,7 +1681,7 @@ class SysprofParser(XmlParser):
         profile = Profile()
         
         profile[SAMPLES] = 0
-        for id, object in objects.iteritems():
+        for id, object in objects.items():
             # Ignore fake objects (process names, modules, "Everything", "kernel", etc.)
             if object['self'] == 0:
                 continue
@@ -1691,7 +1691,7 @@ class SysprofParser(XmlParser):
             profile.add_function(function)
             profile[SAMPLES] += function[SAMPLES]
 
-        for id, node in nodes.iteritems():
+        for id, node in nodes.items():
             # Ignore fake calls
             if node['self'] == 0:
                 continue
@@ -1805,7 +1805,7 @@ class SharkParser(LineParser):
                 
         profile = Profile()
         profile[SAMPLES] = 0
-        for _function, _callees in self.entries.itervalues():
+        for _function, _callees in self.entries.values():
             function = Function(_function.id, _function.name)
             function[SAMPLES] = _function.samples
             profile.add_function(function)
@@ -1814,7 +1814,7 @@ class SharkParser(LineParser):
             if _function.image:
                 function.module = os.path.basename(_function.image)
 
-            for _callee in _callees.itervalues():
+            for _callee in _callees.values():
                 call = Call(_callee.id)
                 call[SAMPLES] = _callee.samples
                 function.add_call(call)
@@ -1852,7 +1852,7 @@ class XPerfParser(Parser):
             lineterminator = '\r\n',
             quoting = csv.QUOTE_NONE)
         it = iter(reader)
-        row = reader.next()
+        row = next(reader)
         self.parse_header(row)
         for row in it:
             self.parse_row(row)
@@ -1874,7 +1874,7 @@ class XPerfParser(Parser):
 
     def parse_row(self, row):
         fields = {}
-        for name, column in self.column.iteritems():
+        for name, column in self.column.items():
             value = row[column]
             for factory in int, float:
                 try:
@@ -2201,7 +2201,8 @@ class PstatsParser:
         self.profile = Profile()
         self.function_ids = {}
 
-    def get_function_name(self, (filename, line, name)):
+    def get_function_name(self, xxx_todo_changeme):
+        (filename, line, name) = xxx_todo_changeme
         module = os.path.splitext(filename)[0]
         module = os.path.basename(module)
         return "%s:%d:%s" % (module, line, name)
@@ -2222,18 +2223,18 @@ class PstatsParser:
     def parse(self):
         self.profile[TIME] = 0.0
         self.profile[TOTAL_TIME] = self.stats.total_tt
-        for fn, (cc, nc, tt, ct, callers) in self.stats.stats.iteritems():
+        for fn, (cc, nc, tt, ct, callers) in self.stats.stats.items():
             callee = self.get_function(fn)
             callee.called = nc
             callee[TOTAL_TIME] = ct
             callee[TIME] = tt
             self.profile[TIME] += tt
             self.profile[TOTAL_TIME] = max(self.profile[TOTAL_TIME], ct)
-            for fn, value in callers.iteritems():
+            for fn, value in callers.items():
                 caller = self.get_function(fn)
                 call = Call(callee.id)
                 if isinstance(value, tuple):
-                    for i in xrange(0, len(value), 4):
+                    for i in range(0, len(value), 4):
                         nc, cc, tt, ct = value[i:i+4]
                         if CALLS in call:
                             call[CALLS] += cc
@@ -2426,7 +2427,7 @@ class DotWriter:
         self.attr('node', fontname=fontname, shape="box", style="filled", fontcolor="white", width=0, height=0)
         self.attr('edge', fontname=fontname)
 
-        for function in profile.functions.itervalues():
+        for function in profile.functions.values():
             labels = []
             if function.process is not None:
                 labels.append(function.process)
@@ -2438,7 +2439,7 @@ class DotWriter:
                     label = event.format(function[event])
                     labels.append(label)
             if function.called is not None:
-                labels.append(u"%u\xd7" % (function.called,))
+                labels.append("%u\xd7" % (function.called,))
 
             if function.weight is not None:
                 weight = function.weight
@@ -2453,7 +2454,7 @@ class DotWriter:
                 fontsize = "%.2f" % theme.node_fontsize(weight),
             )
 
-            for call in function.calls.itervalues():
+            for call in function.calls.values():
                 callee = profile.functions[call.callee_id]
 
                 labels = []
@@ -2514,7 +2515,7 @@ class DotWriter:
             return
         self.write(' [')
         first = True
-        for name, value in attrs.iteritems():
+        for name, value in attrs.items():
             if first:
                 first = False
             else:
@@ -2527,7 +2528,7 @@ class DotWriter:
     def id(self, id):
         if isinstance(id, (int, float)):
             s = str(id)
-        elif isinstance(id, basestring):
+        elif isinstance(id, str):
             if id.isalnum() and not id.startswith('0x'):
                 s = id
             else:
@@ -2536,8 +2537,9 @@ class DotWriter:
             raise TypeError
         self.write(s)
 
-    def color(self, (r, g, b)):
+    def color(self, xxx_todo_changeme1):
 
+        (r, g, b) = xxx_todo_changeme1
         def float2int(f):
             if f <= 0.0:
                 return 0
@@ -2753,7 +2755,7 @@ class Main:
         profile = self.profile
         profile.prune(self.options.node_thres/100.0, self.options.edge_thres/100.0)
 
-        for function in profile.functions.itervalues():
+        for function in profile.functions.values():
             function.name = self.compress_function_name(function.name)
 
         dot.graph(profile, self.theme)
--- a/setup/install.perl
+++ b/setup/install.perl
@@ -880,7 +880,7 @@ sub finishinstall {
 
     if ($HAVE{PYTHON}) {
         chdir "$Bin/.." or die "cannot cd '$Bin/..'";
-        my $cmd = "python setup.py install";
+        my $cmd = "python3 setup.py install";
         $cmd .= ' --user' unless (linux_root());
         print `$cmd`;
         if ($?) {
--- a/test/dbgap-mount/py/test/__init__.py
+++ b/test/dbgap-mount/py/test/__init__.py
@@ -2,6 +2,6 @@
 #
 
 
-from base import *
-from test import *
-from utils import *
+from .base import *
+from .test import *
+from .utils import *
--- a/test/dbgap-mount/py/test/test.py
+++ b/test/dbgap-mount/py/test/test.py
@@ -5,8 +5,8 @@ import subprocess
 import gc
 
 import platform
-import base
-import utils
+from . import base
+from . import utils
 
 class Test ( base.Base ):
 
--- a/test/samline/bx_tag_test.py
+++ b/test/samline/bx_tag_test.py
@@ -1,4 +1,4 @@
-#!/opt/python-all/bin/python
+#!/usr/bin/python3
 from sam import *
 
 REF   = "NC_011752.1"
@@ -7,7 +7,7 @@ CSRA1 = "X.CSRA"
 
 def load( L ) :
     R1 = bam_load( L, CSRA1, "--make-spots-with-secondary -E0 -Q0" )
-    print "bam-load = %d"%( R1 )
+    print("bam-load = %d"%( R1 ))
 
 def load_and_print( L ) :
     load( L )
--- a/test/samline/ca_test.py
+++ b/test/samline/ca_test.py
@@ -1,12 +1,12 @@
-#!/opt/python-all/bin/python
+#!/usr/bin/python3
 from sam import *
 
 def dump( acc ) :
-    print "%s.SEQ"%(acc)
+    print("%s.SEQ"%(acc))
     vdb_dump( acc, "-C SPOT_ID,READ -l0 -f tab" )
-    print "%s.PRIM"%( acc )
+    print("%s.PRIM"%( acc ))
     vdb_dump( acc, "-T PRIMARY_ALIGNMENT -C ALIGN_ID,READ -l0, -f tab" )
-    print "%s.SEC"%( acc )
+    print("%s.SEC"%( acc ))
     vdb_dump( acc, "-T SECONDARY_ALIGNMENT -C ALIGN_ID,READ -l0 -f tab" )
 
 REF   = "NC_011752.1"
@@ -17,14 +17,14 @@ CSRA2 = "AFTER_SRA_SORT.CSRA"
 def load_sort( L ) :
     R1 = bam_load( L, CSRA1, "--make-spots-with-secondary -L 3 -E0 -Q0" )
     if R1 == 1 :
-        print "bam-load = OK"
+        print("bam-load = OK")
         R2 = sra_sort( CSRA1, CSRA2 )
         if R2 == 1 :
-            print "sra-sort = OK"
+            print("sra-sort = OK")
         else :
-            print "sra-sort = FAILED"
+            print("sra-sort = FAILED")
     else :
-        print "bam-load = FAILED"
+        print("bam-load = FAILED")
         
 def load_sort_print( L ) :
     load_sort( L )
@@ -33,8 +33,8 @@ def load_sort_print( L ) :
 
 
 def test1() :
-    print "test #1 --------------------------------------------------"
-    print "...having a single recondary alignmnet without a primary it belongs to"
+    print("test #1 --------------------------------------------------")
+    print("...having a single recondary alignmnet without a primary it belongs to")
     A1 = make_prim( "A1", 0, REF, ALIAS, 17000, 20, "60M" )
     A2 = make_prim( "A2", 0, REF, ALIAS, 12500, 20, "50M" )
     A1.pair_with( A2 )
@@ -51,9 +51,9 @@ def test1() :
 
 # the resulting X.CSRA and S.CSRA produce errors in seq_restore_read_impl2
 def test2() :
-    print "test #2 --------------------------------------------------"
-    print "...having a pair of a prim. and a sec. alignment"
-    print "= SEQUENCE-table cannot reconstruct READ"
+    print("test #2 --------------------------------------------------")
+    print("...having a pair of a prim. and a sec. alignment")
+    print("= SEQUENCE-table cannot reconstruct READ")
     A1 = make_prim( "A1", 0, REF, ALIAS, 17000, 20, "60M" )
     A2 = make_sec( "A2", 0, REF, ALIAS, 12500, 20, "50M" )
     A1.pair_with( A2 )
@@ -63,7 +63,7 @@ def test2() :
 # the resulting X.CSRA produces errors in seq_restore_read_impl2
 # but S.CSRA sefaults in vdb-dump!
 def test3() :
-    print "test #3 --------------------------------------------------"
+    print("test #3 --------------------------------------------------")
     A1 = make_prim( "A1", 0, REF, ALIAS, 1000, 20, "53M" )
     A2 = make_sec( "A2", 0, REF, ALIAS, 3500, 20, "50M" )
     A1.pair_with( A2 )
--- a/test/samline/sam.py
+++ b/test/samline/sam.py
@@ -58,11 +58,11 @@ def load_file( filename ) :
 def print_file( filename ) :
     s = load_file( filename )
     if len( s ) > 0 :
-        print s
+        print(s)
 
 def print_txt( txt ) :
     if len( txt ) > 0 :
-        print txt
+        print(txt)
 
 def print_txt_list( list ) :
     for a in list :
@@ -144,7 +144,7 @@ def vdb_dump( accession, params = "" ) :
     try :
         cmd = "vdb-dump %s %s"%( accession, params )
         txt = subprocess.check_output( cmd, stderr=subprocess.STDOUT, shell=True )
-        print txt
+        print(txt)
         return 1
     except :
         pass
@@ -154,7 +154,7 @@ def sam_dump( accession, params = "" ) :
     try :
         cmd = "sam-dump %s %s"%( accession, params )
         txt = subprocess.check_output( cmd, stderr=subprocess.STDOUT, shell=True )
-        print txt
+        print(txt)
         return 1
     except :
         pass
@@ -218,7 +218,7 @@ helper function: create SAM-headers from
 def extract_headers( list ) :
     reflist = make_refdict( list )
     res = [ "@HD\tVN:1.3" ]
-    for k, v in reflist.items():
+    for k, v in list(reflist.items()):
         l = ref_len( v )
         res.append( "@SQ\tSN:%s\tAS:%s\tLN:%d"%( k, k, l ) )
     return res
@@ -231,7 +231,7 @@ helper function: create a config-file fo
 def produce_config( list ) :
     reflist = make_refdict( list )
     res = []
-    for k, v in reflist.items():
+    for k, v in list(reflist.items()):
         if k != "*" and k != "-" :
             res.append( "%s\t%s"%( k, v ) )
     return res
@@ -250,9 +250,9 @@ helper function: prints a list of SAM-ob
 ---------------------------------------------------------------'''
 def print_sam( list ):
     for s in extract_headers( list ) :
-        print s
+        print(s)
     for s in list :
-        print s
+        print(s)
 
 '''---------------------------------------------------------------
 helper function: save a list of SAM-objects as file
--- a/test/sra-pileup/check_skiplist.py
+++ b/test/sra-pileup/check_skiplist.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import subprocess
 import sys
--- a/test/sra-pileup/test_all_sam_dump_has_spotgroup.py
+++ b/test/sra-pileup/test_all_sam_dump_has_spotgroup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import sys, getopt, subprocess, multiprocessing
 
--- a/test/sra-pileup/test_diff_fastq_dump_vs_sam_dump.py
+++ b/test/sra-pileup/test_diff_fastq_dump_vs_sam_dump.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 import sys, getopt, subprocess, multiprocessing
 
--- a/test/tarballs/test-tarballs.sh
+++ b/test/tarballs/test-tarballs.sh
@@ -58,7 +58,7 @@ echo "Testing sra-tools tarballs, workin
 
 case $(uname) in
 Linux)
-    python -mplatform | grep -q Ubuntu && OS=ubuntu64 || OS=centos_linux64
+    python3 -mplatform | grep -q Ubuntu && OS=ubuntu64 || OS=centos_linux64
     TOOLS="${TOOLS} pacbio-load remote-fuser"
     realpath() {
         readlink -f $1
--- a/tools/fasterq-dump/fastq-diff.py
+++ b/tools/fasterq-dump/fastq-diff.py
@@ -1,10 +1,10 @@
-#! /usr/bin/env python
+#!/usr/bin/python3
 
 import sys
 import os
 import stat
 import datetime
-from itertools import izip
+
 
 def perform( fn1, fn2 ) :
     print( "comparing: " )
@@ -14,7 +14,7 @@ def perform( fn1, fn2 ) :
     A = [ "", "", "", "" ]
     B = [ "", "", "", "" ]
     with open( fn1 ) as f1, open( fn2 ) as f2 :
-        for L1, L2 in izip( f1, f2 ) :
+        for L1, L2 in zip( f1, f2 ) :
             A[ ln ] = L1.strip()
             B[ ln ] = L2.strip()
             ln += 1