File: python3

package info (click to toggle)
vg 1.59.0%2Bds-0.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 361,528 kB
  • sloc: cpp: 479,590; ansic: 191,648; python: 23,671; javascript: 13,961; sh: 7,025; makefile: 5,577; perl: 3,636; lisp: 293; java: 136
file content (1137 lines) | stat: -rw-r--r-- 45,675 bytes parent folder | 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
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
From: "Michael R. Crusoe" <crusoe@debian.org>
Date: Sun, 9 Feb 2020 12:45:16 +0100
Subject: convert all Python scripts to Python v3

Forwarded: https://github.com/vgteam/gfakluge/pull/7
Forwarded: https://github.com/benedictpaten/sonLib/pull/43
---
 deps/libbdsg/make_and_run_binder.py                |  2 +-
 deps/pinchesAndCacti/__init__.py                   |  2 +-
 .../externalTools/threeEdgeConnected/__init__.py   |  2 +-
 .../threeEdgeConnected/threeEdgeTests.py           |  2 +-
 .../document_listing/generate_collection.py        |  6 +-
 deps/sonLib/C/Makefile                             |  2 +-
 deps/sonLib/Makefile                               |  2 +-
 deps/sonLib/__init__.py                            |  2 +-
 deps/sonLib/allTests.py                            | 14 ++--
 deps/sonLib/bioio.py                               | 52 ++++++-------
 deps/sonLib/bioioTest.py                           | 88 +++++++++++-----------
 deps/sonLib/cigarsTest.py                          | 18 ++---
 deps/sonLib/kvdbTest.py                            |  2 +-
 deps/sonLib/misc.py                                |  2 +-
 deps/sonLib/nxnewick.py                            | 17 ++---
 deps/sonLib/nxnewickTest.py                        |  2 +-
 deps/sonLib/nxtree.py                              |  3 +-
 deps/sonLib/nxtreeTest.py                          |  2 +-
 deps/sonLib/setup.py                               |  2 +-
 deps/sonLib/sonLib_daemonize.py                    |  4 +-
 deps/sonLib/tree.py                                | 88 +++++++++++-----------
 deps/sonLib/treeTest.py                            | 48 ++++++------
 deps/sonLib/unitTest.py                            |  2 +-
 deps/xg/deps/gfakluge/scripts/fa_to_gfa.py         |  4 +-
 deps/xg/deps/gfakluge/scripts/gfa_to_cytoscape.py  |  2 +-
 25 files changed, 184 insertions(+), 186 deletions(-)

diff --git a/deps/libbdsg/make_and_run_binder.py b/deps/libbdsg/make_and_run_binder.py
index 15496fc..d779f04 100755
--- a/deps/libbdsg/make_and_run_binder.py
+++ b/deps/libbdsg/make_and_run_binder.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/python3
 
 import glob
 import os
diff --git a/deps/pinchesAndCacti/__init__.py b/deps/pinchesAndCacti/__init__.py
index 3483949..313c6b5 100644
--- a/deps/pinchesAndCacti/__init__.py
+++ b/deps/pinchesAndCacti/__init__.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2009-2011 by Benedict Paten (benedictpaten@gmail.com)
 #
diff --git a/deps/pinchesAndCacti/externalTools/threeEdgeConnected/__init__.py b/deps/pinchesAndCacti/externalTools/threeEdgeConnected/__init__.py
index 3483949..313c6b5 100644
--- a/deps/pinchesAndCacti/externalTools/threeEdgeConnected/__init__.py
+++ b/deps/pinchesAndCacti/externalTools/threeEdgeConnected/__init__.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2009-2011 by Benedict Paten (benedictpaten@gmail.com)
 #
diff --git a/deps/pinchesAndCacti/externalTools/threeEdgeConnected/threeEdgeTests.py b/deps/pinchesAndCacti/externalTools/threeEdgeConnected/threeEdgeTests.py
index ebbcbff..5db5c3f 100644
--- a/deps/pinchesAndCacti/externalTools/threeEdgeConnected/threeEdgeTests.py
+++ b/deps/pinchesAndCacti/externalTools/threeEdgeConnected/threeEdgeTests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2009-2011 by Benedict Paten (benedictpaten@gmail.com)
 #
diff --git a/deps/sdsl-lite/tutorial/document_listing/generate_collection.py b/deps/sdsl-lite/tutorial/document_listing/generate_collection.py
index 27b0325..e141946 100644
--- a/deps/sdsl-lite/tutorial/document_listing/generate_collection.py
+++ b/deps/sdsl-lite/tutorial/document_listing/generate_collection.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import fnmatch
 import sys
@@ -13,7 +13,7 @@ collection_path = "collection.txt"
 def main():
 
     if len(sys.argv) == 1:
-        print "Usage ./", sys.argv[0], "directory"
+        print("Usage ./", sys.argv[0], "directory")
         sys.exit(0)
     cur_dir = sys.argv[1]
     doc_paths = []
@@ -23,7 +23,7 @@ def main():
             doc_path = root+"/"+f
             doc_paths.append(doc_path)
 
-    print "Found ", len(doc_paths), "source files in", cur_dir
+    print("Found ", len(doc_paths), "source files in", cur_dir)
     collection_f = open(collection_path,'w')
     for doc_path in doc_paths:
         f = open(doc_path, 'r')
diff --git a/deps/sonLib/C/Makefile b/deps/sonLib/C/Makefile
index bbb2781..371b965 100644
--- a/deps/sonLib/C/Makefile
+++ b/deps/sonLib/C/Makefile
@@ -60,4 +60,4 @@ ${libPath}/sonLib.a : ${libSources} ${cppSources} $(foreach l, ${libHeaders}, ${
 	mv sonLib.a ${libPath}/
 
 test:
-	python allTests.py --testLength=SHORT --logLevel CRITICAL
+	python3 allTests.py --testLength=SHORT --logLevel CRITICAL
diff --git a/deps/sonLib/Makefile b/deps/sonLib/Makefile
index 35eb8b5..d60dd41 100644
--- a/deps/sonLib/Makefile
+++ b/deps/sonLib/Makefile
@@ -21,7 +21,7 @@ externalToolsP.clean :
 	cd externalTools && $(MAKE) clean
 
 test : all
-	PYTHONPATH=.. PATH=../../bin:$$PATH python allTests.py --testLength=SHORT --logLevel=CRITICAL
+	PYTHONPATH=.. PATH=../../bin:$$PATH python3 allTests.py --testLength=SHORT --logLevel=CRITICAL
 
 ${binPath}/sonLib_daemonize.py : sonLib_daemonize.py cP
 	cp sonLib_daemonize.py ${binPath}/sonLib_daemonize.py
diff --git a/deps/sonLib/__init__.py b/deps/sonLib/__init__.py
index 9d39579..ca1459a 100644
--- a/deps/sonLib/__init__.py
+++ b/deps/sonLib/__init__.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
diff --git a/deps/sonLib/allTests.py b/deps/sonLib/allTests.py
index 04272fb..e398c02 100644
--- a/deps/sonLib/allTests.py
+++ b/deps/sonLib/allTests.py
@@ -1,20 +1,20 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
 #Released under the MIT license, see LICENSE.txt
 import unittest
 
-import bioioTest
-import cigarsTest
-import treeTest
-import kvdbTest
+from . import bioioTest
+from . import cigarsTest
+from . import treeTest
+from . import kvdbTest
 import socket
 try:
     import networkx as NX
     networkx_installed = True
-    import nxtreeTest
-    import nxnewickTest
+    from . import nxtreeTest
+    from . import nxnewickTest
 except ImportError:
     networkx_installed = False
 
diff --git a/deps/sonLib/bioio.py b/deps/sonLib/bioio.py
index 3b1070a..ae17ce5 100644
--- a/deps/sonLib/bioio.py
+++ b/deps/sonLib/bioio.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
@@ -16,8 +16,8 @@ import math
 import shutil
 from argparse import ArgumentParser
 from optparse import OptionParser, OptionContainer, OptionGroup
-from tree import BinaryTree
-from misc import close
+from .tree import BinaryTree
+from .misc import close
 import subprocess
 import array
 import string
@@ -421,14 +421,14 @@ def nameValue(name, value, valueType=str, quotes=False):
 def getRandomAlphaNumericString(length=10):
     """Returns a random alpha numeric string of the given length.
     """
-    return "".join([ random.choice('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') for i in xrange(0, length) ])
+    return "".join([ random.choice('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') for i in range(0, length) ])
 
 def makeSubDir(dirName):
     """Makes a given subdirectory if it doesn't already exist, making sure it us public.
     """
     if not os.path.exists(dirName):
         os.mkdir(dirName)
-        os.chmod(dirName, 0777)
+        os.chmod(dirName, 0o777)
     return dirName
 
 def getTempFile(suffix="", rootDir=None):
@@ -441,7 +441,7 @@ def getTempFile(suffix="", rootDir=None):
     else:
         tmpFile = os.path.join(rootDir, "tmp_" + getRandomAlphaNumericString() + suffix)
         open(tmpFile, 'w').close()
-        os.chmod(tmpFile, 0777) #Ensure everyone has access to the file.
+        os.chmod(tmpFile, 0o777) #Ensure everyone has access to the file.
         return tmpFile
 
 def getTempDirectory(rootDir=None):
@@ -468,7 +468,7 @@ def getTempDirectory(rootDir=None):
                 break
                 
         os.mkdir(tmpDir)
-        os.chmod(tmpDir, 0777) #Ensure everyone has access to the file.
+        os.chmod(tmpDir, 0o777) #Ensure everyone has access to the file.
         return tmpDir
 
 class TempFileTree:
@@ -744,7 +744,7 @@ def fastaWrite(fileHandleOrFile, name, seq, mode="w"):
     fileHandle = _getFileHandle(fileHandleOrFile, mode)
     valid_chars = {x for x in string.ascii_letters + "-"}
     try:
-        assert any([isinstance(seq, unicode), isinstance(seq, str)])
+        assert any([isinstance(seq, str), isinstance(seq, str)])
     except AssertionError:
         raise RuntimeError("Sequence is not unicode or string")
     try:
@@ -754,7 +754,7 @@ def fastaWrite(fileHandleOrFile, name, seq, mode="w"):
         raise RuntimeError("Invalid FASTA character(s) see in fasta sequence: {}".format(bad_chars))
     fileHandle.write(">%s\n" % name)
     chunkSize = 100
-    for i in xrange(0, len(seq), chunkSize):
+    for i in range(0, len(seq), chunkSize):
         fileHandle.write("%s\n" % seq[i:i+chunkSize])
     if isinstance(fileHandleOrFile, "".__class__):
         fileHandle.close()
@@ -849,23 +849,23 @@ def fastaAlignmentRead(fasta, mapFn=(lambda x : x), l=None):
     else:
         l = l[:]
     seqNo = len(l)
-    for i in xrange(0, seqNo):
+    for i in range(0, seqNo):
         j = open(fasta, 'r')
         j.seek(l[i])
         l[i] = j
-    column = [sys.maxint]*seqNo
+    column = [sys.maxsize]*seqNo
     if seqNo != 0:
         while True:
-            for j in xrange(0, seqNo):
+            for j in range(0, seqNo):
                 i = l[j].read(1)
                 while i == '\n':
                     i = l[j].read(1)
                 column[j] = i
             if column[0] == '>' or column[0] == '':
-                for j in xrange(1, seqNo):
+                for j in range(1, seqNo):
                     assert column[j] == '>' or column[j] == ''
                 break
-            for j in xrange(1, seqNo):
+            for j in range(1, seqNo):
                  assert column[j] != '>' and column[j] != ''
                  column[j] = mapFn(column[j])
             yield column[:]
@@ -878,8 +878,8 @@ def fastaAlignmentWrite(columnAlignment, names, seqNo, fastaFile,
     Writes out column alignment to given file multi-fasta format
     """
     fastaFile = open(fastaFile, 'w')
-    columnAlignment = [ i for i in columnAlignment if filter(i) ]
-    for seq in xrange(0, seqNo):
+    columnAlignment = [ i for i in columnAlignment if list(filter(i)) ]
+    for seq in range(0, seqNo):
         fastaFile.write(">%s\n" % names[seq])
         for column in columnAlignment:
             fastaFile.write(column[seq])
@@ -890,10 +890,10 @@ def getRandomSequence(length=500):
     """Generates a random name and sequence.
     """
     fastaHeader = ""
-    for i in xrange(int(random.random()*100)):
+    for i in range(int(random.random()*100)):
         fastaHeader = fastaHeader + random.choice([ 'A', 'C', '0', '9', ' ', '\t' ])
     return (fastaHeader, \
-            "".join([ random.choice([ 'A', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'N' ]) for i in xrange((int)(random.random() * length))]))
+            "".join([ random.choice([ 'A', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'A', 'C', 'T', 'G', 'N' ]) for i in range((int)(random.random() * length))]))
 
 def _expLength(i=0, prob=0.95):
     if random.random() >= prob:
@@ -1043,9 +1043,9 @@ def pWMRead(fileHandle, alphabetSize=4):
     for line in lines[1:]:
         l2 = [ float(i) for i in line.split() ]
         assert len(l) == len(l2)
-        for i in xrange(0, len(l)):
+        for i in range(0, len(l)):
             l[i].append(l2[i])
-    for i in xrange(0, len(l)):
+    for i in range(0, len(l)):
         j = sum(l[i]) + 0.0
         l[i] = [ k/j for k in l[i] ]
     return l
@@ -1053,8 +1053,8 @@ def pWMRead(fileHandle, alphabetSize=4):
 def pWMWrite(fileHandle, pWM, alphabetSize=4):
     """Writes file in standard PWM format, is reverse of pWMParser
     """
-    for i in xrange(0, alphabetSize):
-        fileHandle.write("%s\n" % ' '.join([ str(pWM[j][i]) for j in xrange(0, len(pWM)) ]))
+    for i in range(0, alphabetSize):
+        fileHandle.write("%s\n" % ' '.join([ str(pWM[j][i]) for j in range(0, len(pWM)) ]))
 
 #########################################################
 #########################################################
@@ -1229,8 +1229,8 @@ def cigarWrite(fileHandle, pairwiseAlignment, withProbs=True):
 
 def _getRandomSegment():
     contig = random.choice([ "one", "two", "three", "four" ])
-    start = random.choice(xrange(0, 10000))
-    end = start + random.choice(xrange(0, 1000))
+    start = random.choice(range(0, 10000))
+    end = start + random.choice(range(0, 1000))
     strand = random.choice([ True, False ])
     if not strand:
         start, end = end, start
@@ -1244,7 +1244,7 @@ def getRandomOperationList(xLength, yLength, operationMaxLength=100):
         if operationMaxLength == 1:
             length = 1
         else:
-            length = random.choice(xrange(1, operationMaxLength))
+            length = random.choice(range(1, operationMaxLength))
         if opType != PairwiseAlignment.PAIRWISE_INDEL_Y and xLength - length < 0:
             continue
         if opType != PairwiseAlignment.PAIRWISE_INDEL_X and yLength - length < 0:
@@ -1262,7 +1262,7 @@ def getRandomPairwiseAlignment():
     """
     i, j, k, l = _getRandomSegment()
     m, n, o, p = _getRandomSegment()
-    score = random.choice(xrange(-1000, 1000))
+    score = random.choice(range(-1000, 1000))
     return PairwiseAlignment(i, j, k, l, m, n, o, p, score, getRandomOperationList(abs(k - j), abs(o - n)))
 
 #########################################################
diff --git a/deps/sonLib/bioioTest.py b/deps/sonLib/bioioTest.py
index c7404d1..4b74176 100644
--- a/deps/sonLib/bioioTest.py
+++ b/deps/sonLib/bioioTest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
@@ -11,32 +11,32 @@ import sys
 import random
 import math
 
-from bioio import getTempFile
-from bioio import getTempDirectory
-from bioio import TempFileTree
-from bioio import getRandomAlphaNumericString
+from .bioio import getTempFile
+from .bioio import getTempDirectory
+from .bioio import TempFileTree
+from .bioio import getRandomAlphaNumericString
 
-from bioio import fastaRead
-from bioio import fastaWrite 
-from bioio import fastqRead
-from bioio import fastqWrite 
-from bioio import getRandomSequence
+from .bioio import fastaRead
+from .bioio import fastaWrite 
+from .bioio import fastqRead
+from .bioio import fastqWrite 
+from .bioio import getRandomSequence
 
-from bioio import pWMRead
-from bioio import pWMWrite
+from .bioio import pWMRead
+from .bioio import pWMWrite
 
-from bioio import newickTreeParser
-from bioio import printBinaryTree
+from .bioio import newickTreeParser
+from .bioio import printBinaryTree
 
-from bioio import cigarRead
-from bioio import cigarWrite
-from bioio import PairwiseAlignment
-from bioio import getRandomPairwiseAlignment
+from .bioio import cigarRead
+from .bioio import cigarWrite
+from .bioio import PairwiseAlignment
+from .bioio import getRandomPairwiseAlignment
 
 from sonLib.bioio import TestStatus
 
-from bioio import system
-from bioio import logger
+from .bioio import system
+from .bioio import logger
 
 class TestCase(unittest.TestCase):
     
@@ -61,12 +61,12 @@ class TestCase(unittest.TestCase):
     #########################################################
     
     def testTempFileTree(self):
-        for test in xrange(100): #self.testNo):
-            levels = random.choice(xrange(1, 4))
-            fileNo = random.choice(xrange(1, 6))
+        for test in range(100): #self.testNo):
+            levels = random.choice(range(1, 4))
+            fileNo = random.choice(range(1, 6))
             maxTempFiles = int(math.pow(fileNo, levels))
             
-            print "Got %s levels, %s fileNo and %s maxTempFiles" % (levels, fileNo, maxTempFiles)
+            print("Got %s levels, %s fileNo and %s maxTempFiles" % (levels, fileNo, maxTempFiles))
             
             tempFileTreeRootDir = os.path.join(self.tempDir, getRandomAlphaNumericString())
             tempFileTree = TempFileTree(tempFileTreeRootDir, fileNo, levels)
@@ -74,7 +74,7 @@ class TestCase(unittest.TestCase):
             tempFiles = []
             tempDirs = []
             #Check we can mac number of temp files.
-            for i in xrange(maxTempFiles):
+            for i in range(maxTempFiles):
                 if random.random() > 0.5:
                     tempFile = tempFileTree.getTempFile()
                     assert os.path.isfile(tempFile)
@@ -132,9 +132,9 @@ class TestCase(unittest.TestCase):
     def testFastaReadWrite(self):
         tempFile = getTempFile()
         self.tempFiles.append(tempFile)
-        for test in xrange(0, self.testNo):
-            fastaNumber = random.choice(xrange(10))
-            l = [ getRandomSequence() for i in xrange(fastaNumber) ]
+        for test in range(0, self.testNo):
+            fastaNumber = random.choice(range(10))
+            l = [ getRandomSequence() for i in range(fastaNumber) ]
             fileHandle = open(tempFile, 'w')
             for name, seq in l:
                 fastaWrite(fileHandle, name, seq)
@@ -150,9 +150,9 @@ class TestCase(unittest.TestCase):
     def testFastqReadWrite(self):
         tempFile = getTempFile()
         self.tempFiles.append(tempFile)
-        for test in xrange(0, self.testNo):
-            fastaNumber = random.choice(xrange(10))
-            fastqs = [ (name, seq, [ random.randint(33, 126) for i in range(len(seq)) ]) for name, seq in [ getRandomSequence() for i in xrange(fastaNumber) ]]
+        for test in range(0, self.testNo):
+            fastaNumber = random.choice(range(10))
+            fastqs = [ (name, seq, [ random.randint(33, 126) for i in range(len(seq)) ]) for name, seq in [ getRandomSequence() for i in range(fastaNumber) ]]
             fH = open(tempFile, 'w')
             for name, seq, quals in fastqs:
                 fastqWrite(fH, name, seq, quals)
@@ -170,9 +170,9 @@ class TestCase(unittest.TestCase):
         self.tempFiles.append(tempFile)
         tempFile2 = getTempFile()
         self.tempFiles.append(tempFile2)
-        for test in xrange(0, self.testNo):
-            fastaNumber = random.choice(xrange(10))
-            l = [ getRandomSequence() for i in xrange(fastaNumber) ]
+        for test in range(0, self.testNo):
+            fastaNumber = random.choice(range(10))
+            l = [ getRandomSequence() for i in range(fastaNumber) ]
             fileHandle = open(tempFile, 'w')
             for name, seq in l:
                 fastaWrite(fileHandle, name, seq)
@@ -180,7 +180,7 @@ class TestCase(unittest.TestCase):
             
             command = "sonLib_fastaCTest %s %s" % (tempFile, tempFile2)
             
-            print command
+            print(command)
             
             system(command)
             
@@ -205,12 +205,12 @@ class TestCase(unittest.TestCase):
             d = '((human,baboon),chimp);'
             e = newickTreeParser(d)
             f = printBinaryTree(e, False)
-            print d, f
+            print(d, f)
             assert d == f
     
     def testNewickTreeParser_UnaryNodes(self):
         #tests with unary nodes 
-        for test in xrange(0, self.testNo):
+        for test in range(0, self.testNo):
             tree = getRandomTreeString()
             logger.debug("tree to try\t", tree)
             tree2 = newickTreeParser(tree, reportUnaryNodes=True)
@@ -229,7 +229,7 @@ class TestCase(unittest.TestCase):
     def testPWMParser(self):
         tempFile = getTempFile()
         self.tempFiles.append(tempFile)
-        for test in xrange(0, self.testNo):
+        for test in range(0, self.testNo):
             pWM = getRandomPWM()
             
             fileHandle = open(tempFile, 'w')
@@ -240,7 +240,7 @@ class TestCase(unittest.TestCase):
             pWM2 = pWMRead(fileHandle)
             fileHandle.close()
             
-            for i in xrange(0, len(pWM)):  
+            for i in range(0, len(pWM)):  
                 pWM[i] == pWM2[i]
     
     #########################################################
@@ -254,9 +254,9 @@ class TestCase(unittest.TestCase):
     def testCigarReadWrite(self):
         tempFile = getTempFile()
         self.tempFiles.append(tempFile)
-        for test in xrange(0, self.testNo):
-            cigarNumber = random.choice(xrange(10))
-            l = [ getRandomPairwiseAlignment() for i in xrange(cigarNumber) ]
+        for test in range(0, self.testNo):
+            cigarNumber = random.choice(range(10))
+            l = [ getRandomPairwiseAlignment() for i in range(cigarNumber) ]
             fileHandle = open(tempFile, 'w')
             for cigar in l:
                 cigarWrite(fileHandle, cigar)
@@ -292,10 +292,10 @@ def getRandomPWM(length=-1):
     if length == -1:
         length = 1 + int(random.random()*10)
     def fn():
-        l = [ random.random()*100 for i in xrange(0, 4) ]
+        l = [ random.random()*100 for i in range(0, 4) ]
         i = sum(l)
         return [ j/i for j in l ]
-    return [ fn() for i in xrange(0, length) ]
+    return [ fn() for i in range(0, length) ]
         
 if __name__ == '__main__':
     unittest.main()
diff --git a/deps/sonLib/cigarsTest.py b/deps/sonLib/cigarsTest.py
index 5339fb4..ad7b5b2 100644
--- a/deps/sonLib/cigarsTest.py
+++ b/deps/sonLib/cigarsTest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
@@ -10,12 +10,12 @@ import os
 import sys
 import random
 
-from bioio import getTempFile
+from .bioio import getTempFile
 
-from bioio import cigarRead
-from bioio import cigarWrite
-from bioio import getRandomPairwiseAlignment
-from bioio import system
+from .bioio import cigarRead
+from .bioio import cigarWrite
+from .bioio import getRandomPairwiseAlignment
+from .bioio import system
 from sonLib.bioio import TestStatus
 from sonLib.bioio import logger
 
@@ -36,9 +36,9 @@ class TestCase(unittest.TestCase):
         """
         tempFile = getTempFile()
         self.tempFiles.append(tempFile)
-        for test in xrange(0, self.testNo):
-            pairwiseAlignmentNumber = random.choice(xrange(10))
-            l = [ getRandomPairwiseAlignment() for i in xrange(pairwiseAlignmentNumber) ]
+        for test in range(0, self.testNo):
+            pairwiseAlignmentNumber = random.choice(range(10))
+            l = [ getRandomPairwiseAlignment() for i in range(pairwiseAlignmentNumber) ]
             fileHandle = open(tempFile, 'w')
             
             keepProbs = random.random() > 0.5
diff --git a/deps/sonLib/kvdbTest.py b/deps/sonLib/kvdbTest.py
index ae0de1d..cc5b8a6 100644
--- a/deps/sonLib/kvdbTest.py
+++ b/deps/sonLib/kvdbTest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
diff --git a/deps/sonLib/misc.py b/deps/sonLib/misc.py
index 4c3af55..a8bcd41 100644
--- a/deps/sonLib/misc.py
+++ b/deps/sonLib/misc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
diff --git a/deps/sonLib/nxnewick.py b/deps/sonLib/nxnewick.py
index 65223dc..9005a92 100644
--- a/deps/sonLib/nxnewick.py
+++ b/deps/sonLib/nxnewick.py
@@ -1,9 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Glenn Hickey
 #
 #Released under the MIT license, see LICENSE.txt
-#!/usr/bin/env python
 
 """read and write newick trees to and from networkx graphs (as wrapped by nxtree). 
 """
@@ -14,7 +13,7 @@ import math
 import random
 from string import whitespace as ws
 from sonLib.misc import close
-import bioio
+from . import bioio
 import networkx as NX
 from optparse import OptionParser
 from sonLib.nxtree import NXTree
@@ -187,15 +186,15 @@ def main():
     parser.parseFile(args[0])
     NX.drawing.nx_agraph.write_dot(parser.nxTree.nxDg, args[1])
     parser.writeFile(args[2])
-    print "PRE"
+    print("PRE")
     for i in parser.nxTree.preOrderTraversal():
-        print ("%d %s" % (i, parser.nxTree.getName(i)))
-    print "POST"
+        print(("%d %s" % (i, parser.nxTree.getName(i))))
+    print("POST")
     for i in parser.nxTree.postOrderTraversal():
-        print ("%d %s" % (i, parser.nxTree.getName(i)))
-    print "BFS"
+        print(("%d %s" % (i, parser.nxTree.getName(i))))
+    print("BFS")
     for i in parser.nxTree.breadthFirstTraversal():
-        print ("%d %s" % (i, parser.nxTree.getName(i)))
+        print(("%d %s" % (i, parser.nxTree.getName(i))))
     return 0
 
 if __name__ == '__main__':    
diff --git a/deps/sonLib/nxnewickTest.py b/deps/sonLib/nxnewickTest.py
index b38bd25..63953bc 100644
--- a/deps/sonLib/nxnewickTest.py
+++ b/deps/sonLib/nxnewickTest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 011 by Glenn Hickey
 #
diff --git a/deps/sonLib/nxtree.py b/deps/sonLib/nxtree.py
index 3fe82b8..02392a9 100644
--- a/deps/sonLib/nxtree.py
+++ b/deps/sonLib/nxtree.py
@@ -1,9 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Glenn Hickey
 #
 #Released under the MIT license, see LICENSE.txt
-#!/usr/bin/env python
 
 """A more general (ie arbitrary degree) tree to replace the BinaryTree
 in sonLib.tree.py.  Implemented as a lightweight wrapper over a 
diff --git a/deps/sonLib/nxtreeTest.py b/deps/sonLib/nxtreeTest.py
index d7600c1..1cd0c67 100644
--- a/deps/sonLib/nxtreeTest.py
+++ b/deps/sonLib/nxtreeTest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 011 by Glenn Hickey
 #
diff --git a/deps/sonLib/setup.py b/deps/sonLib/setup.py
index 17503b2..a749737 100755
--- a/deps/sonLib/setup.py
+++ b/deps/sonLib/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 from setuptools import setup
 import subprocess
diff --git a/deps/sonLib/sonLib_daemonize.py b/deps/sonLib/sonLib_daemonize.py
index 9e146e0..080d166 100644
--- a/deps/sonLib/sonLib_daemonize.py
+++ b/deps/sonLib/sonLib_daemonize.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 # Glenn Hickey 2011
 #
@@ -66,7 +66,7 @@ else:
    
 if __name__ == '__main__':
     if len(sys.argv) != 2:
-        raise Exception, "%s: Wrong number of arguments" % sys.argv[0]
+        raise Exception("%s: Wrong number of arguments" % sys.argv[0])
     
     pid = os.fork()
     if pid > 0:
diff --git a/deps/sonLib/tree.py b/deps/sonLib/tree.py
index 0818c8c..d37c670 100644
--- a/deps/sonLib/tree.py
+++ b/deps/sonLib/tree.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
@@ -69,7 +69,7 @@ def binaryTree_depthFirstNumbers(binaryTree, labelTree=True, dontStopAtID=True):
         return mid+1, leafNo+1
     traverse(binaryTree)
     if labelTree:
-        for binaryTree in traversalIDs.keys():
+        for binaryTree in list(traversalIDs.keys()):
             binaryTree.traversalID = traversalIDs[binaryTree]
     return traversalIDs
 
@@ -164,18 +164,18 @@ def transformByDistance(wV, subModel, alphabetSize=4):
     transform wV by given substitution matrix
     """
     nc = [0.0]*alphabetSize
-    for i in xrange(0, alphabetSize):
+    for i in range(0, alphabetSize):
         j = wV[i]
         k = subModel[i]
-        for l in xrange(0, alphabetSize):
+        for l in range(0, alphabetSize):
             nc[l] += j * k[l]
     return nc
 
 def multiplyWV(wVX, wVY, alphabetSize=4):
-    return [ wVX[i] * wVY[i] for i in xrange(0, alphabetSize) ]
+    return [ wVX[i] * wVY[i] for i in range(0, alphabetSize) ]
 
 def sumWV(wVX, wVY, alphabetSize=4):
-    return [ wVX[i] + wVY[i] for i in xrange(0, alphabetSize) ]
+    return [ wVX[i] + wVY[i] for i in range(0, alphabetSize) ]
     
 def normaliseWV(wV, normFac=1.0):
     """
@@ -187,7 +187,7 @@ def normaliseWV(wV, normFac=1.0):
 def sumWVA(wVA, alphabetSize=4):
     totals = [0.0]*alphabetSize
     for wV in wVA:
-        for i in xrange(0, alphabetSize):
+        for i in range(0, alphabetSize):
             totals[i] += wV[i]
     return totals
 
@@ -222,7 +222,7 @@ def felsensteins(binaryTree, subMatrices, ancestorProbs, leaves, alphabetSize):
 def calculateCharacterFrequencies(seq, map, alphabetSize):
     counts = [0.0]*alphabetSize
     for i in seq:
-        counts[map(i)] += 1
+        counts[list(map(i))] += 1
     return counts
     
 #########################################################
@@ -261,9 +261,9 @@ def calculateDNADistanceMatrix(seqNo, fastaIter, transitionTransversionRatio=2.0
     transversions = [0.1]*seqNo*seqNo
     counts = [1.0]*seqNo*seqNo
     for column in fastaIter:
-        for i in xrange(0, seqNo):
+        for i in range(0, seqNo):
             if column[i] in [ 'A', 'C', 'T', 'G' ]:
-                for j in xrange(i+1, seqNo):
+                for j in range(i+1, seqNo):
                     if column[j] in [ 'A', 'C', 'T', 'G' ]:
                         counts[i*seqNo + j] += 1
                         if column[i] != column[j]:
@@ -277,9 +277,9 @@ def calculateDNADistanceMatrix(seqNo, fastaIter, transitionTransversionRatio=2.0
                                     transversions[i*seqNo + j] += 1
                                 else:
                                     transitions[i*seqNo + j] += 1
-    distanceMatrix = [ [None]*seqNo for i in xrange(0, seqNo) ]
-    for i in xrange(0, seqNo*seqNo):
-        for j in xrange(i+1, seqNo):
+    distanceMatrix = [ [None]*seqNo for i in range(0, seqNo) ]
+    for i in range(0, seqNo*seqNo):
+        for j in range(i+1, seqNo):
             k = i * seqNo + j
             distanceMatrix[i][j] = -0.75*math.log(1 - (4/3)*((transitions[k]+transversions[k])/counts[k])) #jukes cantor correction
             distanceMatrix[j][i] = distanceMatrix[i][j]
@@ -288,10 +288,10 @@ def calculateDNADistanceMatrix(seqNo, fastaIter, transitionTransversionRatio=2.0
     return distanceMatrix
 
 def makeDistancePairs(distanceMatrix, iDs, seqNo):
-    binaryTrees = [ BinaryTree(0.0, False, None, None, iDs[i]) for i in xrange(0, seqNo) ]
+    binaryTrees = [ BinaryTree(0.0, False, None, None, iDs[i]) for i in range(0, seqNo) ]
     distancePairs = []
-    for i in xrange(0, seqNo):
-        for j in xrange(i+1, seqNo): 
+    for i in range(0, seqNo):
+        for j in range(i+1, seqNo): 
             distancePairs.append(DistancePair(distanceMatrix[i][j], binaryTrees[i], 1, binaryTrees[j], 1))
             distancePairs.append(DistancePair(distanceMatrix[i][j], binaryTrees[j], 1, binaryTrees[i], 1))
     return distancePairs
@@ -327,10 +327,10 @@ def upgmaI(distancePairs, leafNo):
             holder1[i.leaf2] = i
         if i.leaf1 == distancePair.leaf2 and i.leaf2 != distancePair.leaf1:
             holder2[i.leaf2] = i
-    assert len(holder1.keys()) == leafNo-2
-    assert len(holder2.keys()) == leafNo-2
+    assert len(list(holder1.keys())) == leafNo-2
+    assert len(list(holder2.keys())) == leafNo-2
     assert set(holder1.keys()) == set(holder2.keys())
-    for i in holder1.keys():
+    for i in list(holder1.keys()):
         j = holder1[i]
         k = holder2[i]
         newDistance = (j.distance*j.leafNo1 + k.distance*k.leafNo1)/(j.leafNo1 + k.leafNo1)
@@ -346,7 +346,7 @@ def nj(distanceMatrix, iDs, leafNo):
 
 def getMinPair(distancePairs, rValues, leafNo):
     j = None
-    k = sys.maxint
+    k = sys.maxsize
     for i in distancePairs:
         adjustD = i.distance - (rValues[i.leaf1] + rValues[i.leaf2])/(leafNo-2)
         #print "the adjusted value ", adjustD, i.distance, rValues[i.leaf1]/(leafNo-2), rValues[i.leaf2]/(leafNo-2)
@@ -359,11 +359,11 @@ def getMinPair(distancePairs, rValues, leafNo):
 def calculateRValues(distancePairs, leafNo):
     j = {}
     for i in distancePairs:
-        if j.has_key(i.leaf1):
+        if i.leaf1 in j:
             j[i.leaf1] += i.distance
         else:
             j[i.leaf1] = i.distance
-    assert len(j.keys()) == leafNo
+    assert len(list(j.keys())) == leafNo
     return j
 
 def njI(distancePairs, leafNo):
@@ -391,10 +391,10 @@ def njI(distancePairs, leafNo):
             holder1[i.leaf2] = i
         if i.leaf1 == distancePair.leaf2 and i.leaf2 != distancePair.leaf1:
             holder2[i.leaf2] = i
-    assert len(holder1.keys()) == leafNo-2
-    assert len(holder2.keys()) == leafNo-2
+    assert len(list(holder1.keys())) == leafNo-2
+    assert len(list(holder2.keys())) == leafNo-2
     assert set(holder1.keys()) == set(holder2.keys())
-    for i in holder1.keys():
+    for i in list(holder1.keys()):
         j = holder1[i]
         k = holder2[i]
         assert j.leaf2 == k.leaf2
@@ -416,13 +416,13 @@ def njI(distancePairs, leafNo):
 
 def checkMatrix(m, fV, AS=4, reversible=True):
     #print m
-    for i in xrange(0, AS):
+    for i in range(0, AS):
         j = sum(m[i])
         #print "AAAAA", j
         assert j <= 1.0001
         assert j >= 0.9999
         if reversible:
-            for k in xrange(0, AS):
+            for k in range(0, AS):
                 #print "comp2", (fV[i] * m[i][k]), (fV[k] * m[k][i] )
                 assert close(fV[i] * m[i][k], fV[k] * m[k][i], 0.00001)
     
@@ -436,9 +436,9 @@ def checkMatrix(m, fV, AS=4, reversible=True):
     assert close(i, j, 0.00001)
     
 def reverseSubMatrix(m, AS=4):
-    k = [ [None]*AS for i in xrange(0, AS) ]
-    for i in xrange(0, AS):
-        for j in xrange(0, AS):
+    k = [ [None]*AS for i in range(0, AS) ]
+    for i in range(0, AS):
+        for j in range(0, AS):
             k[j][i] = m[i][j]
     return k
     
@@ -476,7 +476,7 @@ def subMatrix_TamuraNei(d, fA, fC, fG, fT, alphaPur, alphaPyr, beta):
     AS = 4
     freq = ( fA, fC, fG, fT )
     alpha = ( alphaPur, alphaPyr, alphaPur, alphaPyr )
-    matrix = [ [ 0.0 ]*AS for i in xrange(0, AS) ]
+    matrix = [ [ 0.0 ]*AS for i in range(0, AS) ]
     #see page 203 of Felsenstein's Inferring Phylogenies for explanation of calculations
     def watKro(j, k):
         if (j % 2) == (k % 2):
@@ -486,10 +486,10 @@ def subMatrix_TamuraNei(d, fA, fC, fG, fT, alphaPur, alphaPyr, beta):
         if i == j:
             return 1.0
         return 0.0
-    for i in xrange(0, AS): #long winded, totally unoptimised method for calculating matrix
-        for j in xrange(0, AS):
+    for i in range(0, AS): #long winded, totally unoptimised method for calculating matrix
+        for j in range(0, AS):
             l = 0.0
-            for k in xrange(0, AS):
+            for k in range(0, AS):
                 l += watKro(j, k) * freq[k]
             matrix[i][j] =\
             math.exp(-(alpha[i] + beta) * d) * kroenickerDelta(i, j) + \
@@ -516,9 +516,9 @@ def subMatrix_HKY(d, fA, fC, fG, fT, transitionTransversionR):
 def subMatrix_HalpernBruno(d, freqColumn, subMatrix, AS=4):
     #return subMatrix_HKY(d, freqColumn[0], freqColumn[1], freqColumn[2], freqColumn[3], 2.0)
     #return subMatrix
-    matrix = [ [ 0.0 ]*AS for i in xrange(0, AS) ]
-    for i in xrange(0, AS):
-        for j in xrange(0, AS):
+    matrix = [ [ 0.0 ]*AS for i in range(0, AS) ]
+    for i in range(0, AS):
+        for j in range(0, AS):
             a = freqColumn[i] * subMatrix[i][j]
             b = freqColumn[j] * subMatrix[j][i]
             if not close(a, b, 0.0001):
@@ -580,8 +580,8 @@ def mapTraversalIDsBetweenTrees(oldTree, newTree):
             internalMap[(fn(oldTree), fn(oldTree.left))] = fn(oldTree.right)
             internalMap[(fn(oldTree.left), fn(oldTree))] = fn(oldTree.right)
     fn3(oldTree)
-    print leafMap
-    print internalMap
+    print(leafMap)
+    print(internalMap)
     def fn4(newTree):
         if newTree.internal:
             fn4(newTree.left)
@@ -596,7 +596,7 @@ def remodelTreeRemovingRoot(root, node):
     """
     Node is mid order number
     """
-    import bioio
+    from . import bioio
     assert root.traversalID.mid != node
     hash = {}
     def fn(bT):
@@ -632,7 +632,7 @@ def moveRoot(root, branch):
     """
     Removes the old root and places the new root at the mid point along the given branch
     """
-    import bioio
+    from . import bioio
     if root.traversalID.mid == branch:
         return bioio.newickTreeParser(bioio.printBinaryTree(root, True))
     def fn2(tree, seq):
@@ -703,7 +703,7 @@ def calculateDupsAndLossesByReconcilingTrees(speciesTree, geneTree, processID):
             if nodes.issubset(a[speciesTree.right.traversalID.mid]):
                 return fn2(nodes, speciesTree.right)
         return speciesTree.traversalID.mid
-    for iD in b.keys():
+    for iD in list(b.keys()):
         nodes = b[iD]
         b[iD] = fn2(nodes, speciesTree)
     dups = []
@@ -725,7 +725,7 @@ def calculateDupsAndLossesByReconcilingTrees(speciesTree, geneTree, processID):
                 nodes.append((node, losses+1))
         return nodes
     for node, losses in fn4(speciesTree):
-        lossMap[(sys.maxint, node)] = losses+1
+        lossMap[(sys.maxsize, node)] = losses+1
     losses = [0]
     def fn5(geneTree, ancestor):
         if geneTree.internal:
@@ -745,7 +745,7 @@ def calculateDupsAndLossesByReconcilingTrees(speciesTree, geneTree, processID):
         if speciesTree.internal:
             fn6(speciesTree.left, speciesTree.traversalID.mid, node)
             fn6(speciesTree.right, speciesTree.traversalID.mid, node)
-    ancestor = fn6(speciesTree, sys.maxint, b[geneTree.traversalID.mid])
+    ancestor = fn6(speciesTree, sys.maxsize, b[geneTree.traversalID.mid])
     assert ancestorHolder[0] is not None
     fn5(geneTree, ancestorHolder[0])
     return len(dups), losses[0]
diff --git a/deps/sonLib/treeTest.py b/deps/sonLib/treeTest.py
index e7c6c9a..7301b25 100644
--- a/deps/sonLib/treeTest.py
+++ b/deps/sonLib/treeTest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
@@ -7,16 +7,16 @@
 import unittest
 import random
 
-from tree import remodelTreeRemovingRoot
-from tree import binaryTree_depthFirstNumbers
-from tree import mapTraversalIDsBetweenTrees
-from tree import BinaryTree
-from bioio import printBinaryTree
-from bioio import newickTreeParser
-from misc import close
-from tree import moveRoot
-from tree import calculateDupsAndLossesByReconcilingTrees
-from tree import calculateProbableRootOfGeneTree
+from .tree import remodelTreeRemovingRoot
+from .tree import binaryTree_depthFirstNumbers
+from .tree import mapTraversalIDsBetweenTrees
+from .tree import BinaryTree
+from .bioio import printBinaryTree
+from .bioio import newickTreeParser
+from .misc import close
+from .tree import moveRoot
+from .tree import calculateDupsAndLossesByReconcilingTrees
+from .tree import calculateProbableRootOfGeneTree
 from sonLib.bioio import TestStatus
 
 class TestCase(unittest.TestCase):
@@ -29,29 +29,29 @@ class TestCase(unittest.TestCase):
         unittest.TestCase.tearDown(self)
         
     def testRemodelTreeRemovingRoot(self):
-        for test in xrange(0, self.testNo):
+        for test in range(0, self.testNo):
             binaryTree = getRandomTree()
             binaryTree_depthFirstNumbers(binaryTree) 
             node = getRandomLeafNode(binaryTree)
             remodTree = remodelTreeRemovingRoot(binaryTree, node.traversalID.mid)
-            print "test", test, printBinaryTree(binaryTree, True), printBinaryTree(node, True), printBinaryTree(remodTree, True)
+            print("test", test, printBinaryTree(binaryTree, True), printBinaryTree(node, True), printBinaryTree(remodTree, True))
             binaryTree_depthFirstNumbers(remodTree)
             distances = mapTraversalIDsBetweenTrees(binaryTree, remodTree)
             d = getDistancesBetweenLeaves(binaryTree)
             d2 = getDistancesBetweenLeaves(remodTree)
-            print d
-            print d2
+            print(d)
+            print(d2)
             for key in d2:
                 assert close(d2[key], d[key], 0.0001)
                 
     def testMoveRoot(self):
-        for test in xrange(0, self.testNo):
+        for test in range(0, self.testNo):
             binaryTree = getRandomTree()
             binaryTree_depthFirstNumbers(binaryTree)
             node = getRandomNode(binaryTree)
-            print "before", printBinaryTree(binaryTree, True), printBinaryTree(node, True)
+            print("before", printBinaryTree(binaryTree, True), printBinaryTree(node, True))
             remodTree = moveRoot(binaryTree, node.traversalID.mid)
-            print "test", test, printBinaryTree(binaryTree, True), printBinaryTree(node, True), printBinaryTree(remodTree, True)
+            print("test", test, printBinaryTree(binaryTree, True), printBinaryTree(node, True), printBinaryTree(remodTree, True))
             binaryTree_depthFirstNumbers(remodTree)
             #distances = mapTraversalIDsBetweenTrees(binaryTree, remodTree)
             #d = getDistancesBetweenLeaves(binaryTree)
@@ -62,7 +62,7 @@ class TestCase(unittest.TestCase):
             #    assert close(d2[key], d[key], 0.0001)
     
     def testCalculateDupsAndLossesByReconcilingTrees(self):
-        for test in xrange(0, self.testNo):
+        for test in range(0, self.testNo):
             speciesTree = getRandomTree()
             binaryTree_depthFirstNumbers(speciesTree)
             geneTree = getRandomTree()
@@ -102,13 +102,13 @@ class TestCase(unittest.TestCase):
         geneStrings = [ geneString1, geneString2, geneString3, geneString4, \
                         geneString5, geneString6, geneString7, geneString8,
                         geneString9, geneString10, geneString11 ]
-        print ""
+        print("")
         for geneString, dupCount, lossCount in geneStrings:
             geneTree = newickTreeParser(geneString)
             binaryTree_depthFirstNumbers(geneTree)
-            print printBinaryTree(geneTree, True), printBinaryTree(speciesTree, True)
+            print(printBinaryTree(geneTree, True), printBinaryTree(speciesTree, True))
             dupCount2, lossCount2 = calculateDupsAndLossesByReconcilingTrees(speciesTree, geneTree, processID=lambda x : x)
-            print geneString, "dups", dupCount, dupCount2, "losses", lossCount, lossCount2
+            print(geneString, "dups", dupCount, dupCount2, "losses", lossCount, lossCount2)
             assert dupCount == dupCount2
             assert lossCount == lossCount2
             
@@ -144,11 +144,11 @@ class TestCase(unittest.TestCase):
             rootedGeneTree = newickTreeParser(geneString)
             binaryTree_depthFirstNumbers(geneTree)
             rootedGeneTree2, dupCount, lossCount = calculateProbableRootOfGeneTree(speciesTree, geneTree)
-            print "rootedGeneTree", rootedGeneString, dupCount, lossCount, printBinaryTree(rootedGeneTree2, False)
+            print("rootedGeneTree", rootedGeneString, dupCount, lossCount, printBinaryTree(rootedGeneTree2, False))
             #assert printBinaryTree(rootedGeneTree, False) == printBinaryTree(rootedGeneTree2, False)
     
     def testCalculateProbableRootOfGeneTree(self):
-        for test in xrange(0, self.testNo):
+        for test in range(0, self.testNo):
             speciesTree = getRandomTree()
             binaryTree_depthFirstNumbers(speciesTree)
             geneTree = getRandomTree()
diff --git a/deps/sonLib/unitTest.py b/deps/sonLib/unitTest.py
index b561105..11c99ee 100644
--- a/deps/sonLib/unitTest.py
+++ b/deps/sonLib/unitTest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
 
 #Copyright (C) 2006-2012 by Benedict Paten (benedictpaten@gmail.com)
 #
diff --git a/deps/xg/deps/gfakluge/scripts/fa_to_gfa.py b/deps/xg/deps/gfakluge/scripts/fa_to_gfa.py
index e94c672..6f0e521 100644
--- a/deps/xg/deps/gfakluge/scripts/fa_to_gfa.py
+++ b/deps/xg/deps/gfakluge/scripts/fa_to_gfa.py
@@ -3,10 +3,10 @@ import sys
 if __name__ == "__main__":
 
     id_ctr = 0
-    print "\t".join(["H", "VZ:i:2.0"])
+    print("\t".join(["H", "VZ:i:2.0"]))
     with open(sys.argv[1],"r") as ifi:
         for line in ifi:
             if not line.startswith(">"):
                 id_ctr += 1
-                print "\t".join(["S", str(id_ctr), str(len(line.strip())), line.strip(), ""])
+                print("\t".join(["S", str(id_ctr), str(len(line.strip())), line.strip(), ""]))
 
diff --git a/deps/xg/deps/gfakluge/scripts/gfa_to_cytoscape.py b/deps/xg/deps/gfakluge/scripts/gfa_to_cytoscape.py
index 9d5d2eb..858f41c 100644
--- a/deps/xg/deps/gfakluge/scripts/gfa_to_cytoscape.py
+++ b/deps/xg/deps/gfakluge/scripts/gfa_to_cytoscape.py
@@ -15,7 +15,7 @@ if __name__ == "__main__":
                 name_to_seq[tokens[1]] = tokens[3]
             elif line.startswith("E"):
                 tokens = line.split("\t")
-                print tokens[2][0:-1], tokens[3][0:-1]
+                print(tokens[2][0:-1], tokens[3][0:-1])
 
     with open(node_file_name, "w") as ofi:
         for i in name_to_seq: