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
|
Author: Andreas Tille
Description: Use 2to3 to port from Python2 to Python3
Bug-Debian: https://bugs.debian.org/942909
Last-Update: Fri, 10 Jan 2020 15:23:50 +0100
--- a/README
+++ b/README
@@ -100,7 +100,7 @@ The general process is:
On Microsoft Windows when building for MINGW within Cygwin,
you need to type here: rm .deps/*; ../configure
to run "configure" a second time for reasons we do not understand.
- make check (optional but recommended, requires "python")
+ make check (optional but recommended, requires "python3")
make install (optional, this will install autodock4 executable)
Second, in the src/autogrid directory, do the same steps
--- a/autodock/Makefile.am
+++ b/autodock/Makefile.am
@@ -608,7 +608,7 @@ test : autodock4 $(srcdir)/Tests/test_au
endif
#if HAVE_PYTHON
@echo " "
- @echo "Running the Python test_autodock4.py unit-tests on autodock4"
+ @echo "Running the Python3 test_autodock4.py unit-tests on autodock4"
@echo " "
# for technical reasons, autodock must be run in the directory where the
# test files reside because it writes its logs into its current directory
@@ -627,13 +627,13 @@ endif
cp $(srcdir)/Tests/*.map* $$outputdir/Testruns;\
chmod -fR a+w $$outputdir/Testruns;
-cd Testruns; rm -f test_*.dlg ; \
- python ./test_autodock4.py -d . -e ../autodock4$(EXEEXT) -o . ;
+ python3 ./test_autodock4.py -d . -e ../autodock4$(EXEEXT) -o . ;
if WANT_OMP
@echo " "
- @echo "Running the Python test_autodock4.py unit-tests on autodock4.omp"
+ @echo "Running the Python3 test_autodock4.py unit-tests on autodock4.omp"
@echo " "
-cd Testruns; rm -f test_*.dlg ; \
- python ./test_autodock4.py -d . -e ../autodock4.omp$(EXEEXT) -o . ;
+ python3 ./test_autodock4.py -d . -e ../autodock4.omp$(EXEEXT) -o . ;
endif
#else
--- a/autodock/Makefile.in
+++ b/autodock/Makefile.in
@@ -3982,7 +3982,7 @@ check : test
@WANT_OMP_FALSE@test : autodock4 $(srcdir)/Tests/test_autodock4.py
#if HAVE_PYTHON
@echo " "
- @echo "Running the Python test_autodock4.py unit-tests on autodock4"
+ @echo "Running the Python3 test_autodock4.py unit-tests on autodock4"
@echo " "
# for technical reasons, autodock must be run in the directory where the
# test files reside because it writes its logs into its current directory
@@ -4001,12 +4001,12 @@ check : test
cp $(srcdir)/Tests/*.map* $$outputdir/Testruns;\
chmod -fR a+w $$outputdir/Testruns;
-cd Testruns; rm -f test_*.dlg ; \
- python ./test_autodock4.py -d . -e ../autodock4$(EXEEXT) -o . ;
+ python3 ./test_autodock4.py -d . -e ../autodock4$(EXEEXT) -o . ;
@WANT_OMP_TRUE@ @echo " "
-@WANT_OMP_TRUE@ @echo "Running the Python test_autodock4.py unit-tests on autodock4.omp"
+@WANT_OMP_TRUE@ @echo "Running the Python3 test_autodock4.py unit-tests on autodock4.omp"
@WANT_OMP_TRUE@ @echo " "
@WANT_OMP_TRUE@ -cd Testruns; rm -f test_*.dlg ; \
-@WANT_OMP_TRUE@ python ./test_autodock4.py -d . -e ../autodock4.omp$(EXEEXT) -o . ;
+@WANT_OMP_TRUE@ python3 ./test_autodock4.py -d . -e ../autodock4.omp$(EXEEXT) -o . ;
#else
# @echo " "
--- a/autodock/README
+++ b/autodock/README
@@ -100,7 +100,7 @@ The general process is:
On Microsoft Windows when building for MINGW within Cygwin,
you need to type here: rm .deps/*; ../configure
to run "configure" a second time for reasons we do not understand.
- make check (optional but recommended, requires "python")
+ make check (optional but recommended, requires "python3")
make install (optional, this will install autodock4 executable)
Second, in the src/autogrid directory, do the same steps
--- a/autodock/Tests/DlgParser.py
+++ b/autodock/Tests/DlgParser.py
@@ -23,7 +23,6 @@ This Object parses the result of an Auto
"""
import os
-from string import find, join, replace, split, rfind, strip
import re
#import Numeric
@@ -125,7 +124,7 @@ class DlgParser:
def getReDict(self):
if hasattr(self, 'reDict'):
- for k, d in self.reDict.items():
+ for k, d in list(self.reDict.items()):
d['lines'] = []
return
self.reDict = {}
@@ -195,19 +194,19 @@ class DlgParser:
input_key = 'INPUT-LIGAND-PDBQT: '
if k==input_key:
if verbose and self.version[:3]!="4.0":
- print "!!no lines found for key=", k, "!!"
+ print("!!no lines found for key=", k, "!!")
else:
if verbose:
- print "!!no lines found for key=", k, "!!"
+ print("!!no lines found for key=", k, "!!")
else:
- apply(d['func'], (lines,), {})
+ d['func'](*(lines,), **{})
def setADVersion(self,lines):
if len(lines):
for l in lines:
- if find(l, 'AutoDock')>-1:
- ll = split(l)
+ if l.find('AutoDock')>-1:
+ ll = l.split()
self.version = ll[2]
break
else:
@@ -216,7 +215,7 @@ class DlgParser:
def setOutlev(self,lines):
if len(lines):
- ll = split(lines[0])
+ ll = lines[0].split()
self.outlev = int(ll[2])
else:
self.outlev = None
@@ -228,7 +227,7 @@ class DlgParser:
def getLigandAtomCount(self, lines):
- self.ligand_atom_count = int(split(lines[0])[-2])
+ self.ligand_atom_count = int(lines[0].split()[-2])
#print "parsed ligand_atom_count =", self.ligand_atom_count
def getNonBondTable(self, lines, echo=False):
@@ -244,7 +243,7 @@ class DlgParser:
if echo:
for l in nb_lines:
- print l,
+ print(l, end=' ')
for i in range(ct):
l = nb_lines[i][10:-1]
for j in range(ct):
@@ -252,15 +251,15 @@ class DlgParser:
if l[jind]=='X':
self.nb_array[i][j]=1
if echo:
- print
- print l
- print self.nb_array[i]
+ print()
+ print(l)
+ print(self.nb_array[i])
def getSeedInfo(self, lines):
seeds = []
for l in lines:
- ilist = split(l)
+ ilist = l.split()
slist = []
for item in ilist[1:]:
slist.append(int(item))
@@ -269,7 +268,7 @@ class DlgParser:
if len(seeds)==len(self.clist):
for i in range(len(seeds)):
conf = self.clist[i]
- if not conf.has_key('run'):
+ if 'run' not in conf:
continue
#outlev -1 prints States in order
#s = seeds[i]
@@ -295,9 +294,9 @@ class DlgParser:
cl = self.clusterlines
hl = self.histogramlines
for l in lines:
- if find(l, 'RANKING')>-1:
+ if l.find('RANKING')>-1:
cl.append(l[:-1])
- elif find(l, '#')>-1:
+ elif l.find('#')>-1:
hl.append(l[:-1])
if len(cl):
self.getClusterRecord(cl)
@@ -310,19 +309,19 @@ class DlgParser:
clRecList = []
curList = []
#curList gets list of conf info
- curInd = int(split(cl[0])[0])
+ curInd = int(cl[0].split()[0])
ctr = 1
for l in cl:
- ll = split(l)
+ ll = l.split()
#when built, newList is
#[Rank,SubRank,Run,DockedEnergy,ClusterRMSD,RefREMSD]
- newList = map(lambda x:int(x),ll[:3])
+ newList = [int(x) for x in ll[:3]]
#3/29/05
if self.wroteAll and self.version[:3]!="4.0":
#print "setting run number to ", ctr
newList[2] = ctr
ctr = ctr + 1
- newList2 = map(lambda x:float(x),ll[3:-1])
+ newList2 = [float(x) for x in ll[3:-1]]
newList.extend(newList2)
if newList[0]==curInd:
curList.append(newList)
@@ -340,7 +339,7 @@ class DlgParser:
if len(l[:-1])>5:
self.dpfLines.append(l[5:-1])
if l.find('ga_run')>-1:
- ll = split(l)
+ ll = l.split()
self.runs = int(ll[2])
#print "self.runs=", self.runs
@@ -351,7 +350,7 @@ class DlgParser:
dpfLines = []
keys = []
for l in lines:
- ll = split(l)
+ ll = l.split()
ind = ll.index('NEWDPF')
k = ll[ind+1]
#only add each key once
@@ -371,9 +370,9 @@ class DlgParser:
foundRun = 0
for l in lines:
#in clustering dlg, multiple copies of input-pdbq are present
- if find(l, 'Run')>-1 and foundRun:
+ if l.find('Run')>-1 and foundRun:
break
- elif find(l, 'Run')>-1:
+ elif l.find('Run')>-1:
foundRun = 1
else:
ligLINES.append(l[12:-1])
@@ -389,18 +388,18 @@ class DlgParser:
def processFlexResLinesV4(self, lines):
#print "in processFlexResLinesV4: len(self.ligLines=)", len(self.ligLines)
if self.version[:3]!="4.0":
- print "not version 4.0! RETURNING!!"
+ print("not version 4.0! RETURNING!!")
return
ligLINES = []
foundRun = 0
ind = 21
for l in lines:
#in clustering dlg, multiple copies of input-pdbq are present
- if find(l, 'Run')>-1 and foundRun:
+ if l.find('Run')>-1 and foundRun:
break
- elif find(l, 'Run')>-1:
+ elif l.find('Run')>-1:
foundRun = 1
- elif find(l, '^_____________________')>-1:
+ elif l.find('^_____________________')>-1:
#last line is ________________-
break
else:
@@ -431,18 +430,18 @@ class DlgParser:
return
ligLINES = []
foundRun = 0
- if find(lines[0], 'INPUT-LIGAND-PDBQT')==0:
+ if lines[0].find('INPUT-LIGAND-PDBQT')==0:
ind = 20
- elif find(lines[0], 'INPUT-PDBQ')==0:
+ elif lines[0].find('INPUT-PDBQ')==0:
ind = 13
for l in lines:
#in clustering dlg, multiple copies of input-pdbq are present
- if find(l, 'Run')>-1 and foundRun:
+ if l.find('Run')>-1 and foundRun:
break
- elif find(l, 'Run')>-1:
+ elif l.find('Run')>-1:
foundRun = 1
- elif find(l, 'TORSDOF')>-1:
+ elif l.find('TORSDOF')>-1:
#eg run-on TORSDOF line:
#TORSDOF 3___
lastChar = l.find('_')
@@ -454,8 +453,8 @@ class DlgParser:
#print "found TORSDOF on last line!"
break
next_line = lines[l_index+1]
- if find(next_line, 'BEGIN_RES')<0:
- print len(lines[l_index:]), ' lines left unparsed!!!'
+ if next_line.find('BEGIN_RES')<0:
+ print(len(lines[l_index:]), ' lines left unparsed!!!')
break
else:
#ligLINES.append(l[13:-1])
@@ -474,11 +473,11 @@ class DlgParser:
if not len(lines):
return
modelList = []
- if find(lines[0], 'DOCKED')==0:
+ if lines[0].find('DOCKED')==0:
ind = 8
- elif find(lines[0], 'INPUT-LIGAND-PDBQT')==0:
+ elif lines[0].find('INPUT-LIGAND-PDBQT')==0:
ind = 20
- elif find(lines[0], 'INPUT-PDBQ')==0:
+ elif lines[0].find('INPUT-PDBQ')==0:
ind = 12
#preprocess lines to remove DOCKED or INPUT-PDBQ
nlines = []
@@ -489,7 +488,7 @@ class DlgParser:
#if self.version[:3]!=4.0:
# nlines.append(l[ind:-1])
#else:
- # if find(l, 'ATOM')>-1:
+ # if l.find('ATOM')>-1:
# newLine = l[ind:64] + l[66:-1]
# nlines.append(newLine)
# else:
@@ -512,7 +511,7 @@ class DlgParser:
try:
nlines.append(l[ind:-1])
except:
- print 'cutting out 64+65 of ', l
+ print('cutting out 64+65 of ', l)
nlines.append(l[ind:64]+ l[66:-1])
else:
nlines.append(l[ind:-1])
@@ -522,7 +521,7 @@ class DlgParser:
if self.version[:3]!=4.0:
curMod = [nlines[0]]
for l in nlines[1:]:
- if find(l, 'MODEL')>-1:
+ if l.find('MODEL')>-1:
modelList.append(curMod)
curMod = [l]
else:
@@ -548,7 +547,7 @@ class DlgParser:
#use endmdl because cluster dlg format
# has MODEL then lines w/o MODEL then MODEL
#again in desc of 1 model...
- if find(l, 'ENDMDL')>-1:
+ if l.find('ENDMDL')>-1:
curMod.append(l)
modelList.append(curMod)
endmdl = 1
@@ -576,7 +575,7 @@ class DlgParser:
self.clist = []
for l in lines:
# in test-1 State= + 17 items: 3 trans, 4quat + ndihe(10) torsions
- xx = split(l)
+ xx = l.split()
# remove possible punctuation
for ind in range(len(xx)):
if xx[ind][-1]==',':
@@ -643,74 +642,74 @@ class DlgParser:
binding_energy2 = None
version = self.version[:3]
for l in lines:
- ll = split(l)
- #if find(l, 'MODEL')>-1:
+ ll = l.split()
+ #if l.find('MODEL')>-1:
# d['num'] = int((ll)[1])
- if find(l, 'Run')>-1 and find(l, 'Rank')==-1:
+ if l.find('Run')>-1 and l.find('Rank')==-1:
d['run'] = int((ll)[3])
- elif find(l, 'Estimated Free Energy of Binding')>-1:
+ elif l.find('Estimated Free Energy of Binding')>-1:
d['binding_energy'] = float((ll)[7])
if version==4.0: d['energy'] = float((ll)[7])
- elif find(l, 'vdW + Hbond + desolv Energy')>-1:
+ elif l.find('vdW + Hbond + desolv Energy')>-1:
d['vdw_hb_desolv_energy'] = float((ll)[8])
- elif find(l, 'Electrostatic Energy')>-1:
+ elif l.find('Electrostatic Energy')>-1:
d['electrostatic_energy'] = float((ll)[4])
- elif find(l, 'Moving Ligand-Fixed Receptor')>-1:
+ elif l.find('Moving Ligand-Fixed Receptor')>-1:
d['moving_ligand_fixed_receptor'] = float((ll)[5])
- elif find(l, 'Moving Ligand-Moving Receptor')>-1:
+ elif l.find('Moving Ligand-Moving Receptor')>-1:
d['moving_ligand_moving_receptor'] = float((ll)[5])
- elif find(l, 'Total Internal Energy')>-1:
+ elif l.find('Total Internal Energy')>-1:
d['total_internal'] = float((ll)[7])
- elif find(l, 'Internal Energy Ligand')>-1:
+ elif l.find('Internal Energy Ligand')>-1:
d['ligand_internal'] = float((ll)[5])
- elif find(l, 'Internal Energy Receptor')>-1:
+ elif l.find('Internal Energy Receptor')>-1:
d['receptor_internal'] = float((ll)[5])
- elif find(l, 'Torsional Free Energy')>-1:
+ elif l.find('Torsional Free Energy')>-1:
d['torsional_energy'] = float((ll)[6])
- elif find(l, 'Estimated Inhibition Constant')>-1:
- if find(l, 'N/A') < 0:
+ elif l.find('Estimated Inhibition Constant')>-1:
+ if l.find('N/A') < 0:
d['inhib_constant'] = float((ll)[6])
if version==4.0:
d['inhib_constant_units'] = ll[7]
- elif find(l, 'Final Docked Energy')>-1:
+ elif l.find('Final Docked Energy')>-1:
d['docking_energy'] = float((ll)[5])
- elif find(l, 'Final Intermolecular Energy')>-1:
+ elif l.find('Final Intermolecular Energy')>-1:
d['intermol_energy'] = float((ll)[6])
- elif find(l, 'Final Internal Energy of Ligand')>-1:
+ elif l.find('Final Internal Energy of Ligand')>-1:
d['internal_energy'] = float((ll)[8])
- elif find(l, 'Final Internal Energy')>-1:
+ elif l.find('Final Internal Energy')>-1:
d['internal_energy'] = float((ll)[6])
- elif find(l, 'Torsional Free Energy')>-1:
+ elif l.find('Torsional Free Energy')>-1:
d['torsional_energy'] = float((ll)[6])
- elif find(l, 'NEWDPF tran0')>-1:
+ elif l.find('NEWDPF tran0')>-1:
d['trn_x'] = float(ll[3])
d['trn_y'] = float(ll[4])
d['trn_z'] = float(ll[5])
- elif find(l, 'NEWDPF quat0')>-1:
+ elif l.find('NEWDPF quat0')>-1:
d['qtn_nx'] = float(ll[3])
d['qtn_ny'] = float(ll[4])
d['qtn_nz'] = float(ll[5])
d['qtn_ang_deg'] = float(ll[6])
- elif find(l, 'NEWDPF dihe0')>-1:
+ elif l.find('NEWDPF dihe0')>-1:
angList = []
for n in ll[3:]:
angList.append(float(n))
d['torsion_values'] = angList
d['num_torsions'] = len(angList)
- elif find(l, 'Intermol. vdW + Hbond Energy ')>-1:
+ elif l.find('Intermol. vdW + Hbond Energy ')>-1:
#AD4 specific model information:
# USER Intermol. vdW + Hbond Energy = -14.63 kcal/mol
d['vdw_energy'] = float((ll)[7])
- elif find(l, 'Intermol. Electrostatic Energy')>-1:
+ elif l.find('Intermol. Electrostatic Energy')>-1:
#USER Intermol. Electrostatic Energy = -0.62 kcal/mol
d['estat_energy'] = float((ll)[5])
- elif find(l, '(3) Torsional Free Energy')>-1:
+ elif l.find('(3) Torsional Free Energy')>-1:
#USER (3) Torsional Free Energy = +3.84 kcal/mol
d['torsional_energy'] = float((ll)[6])
- elif find(l, "(4) Unbound System's Energy")>-1:
+ elif l.find("(4) Unbound System's Energy")>-1:
#USER (4) Unbound System's Energy = -0.85 kcal/mol
d['unbound_energy'] = float((ll)[-2])
- elif find(l, 'ATOM')>-1:
+ elif l.find('ATOM')>-1:
coords.append([float(l[30:38]),float(l[38:46]),float(l[46:54])])
try:
vdW.append(float(l[54:60]))
@@ -727,7 +726,7 @@ class DlgParser:
binding_energy2 = float(l[70:76])
except:
pass
- elif find(l, 'HETA')>-1:
+ elif l.find('HETA')>-1:
coords.append([float(l[30:38]),float(l[38:46]),float(l[46:54])])
try:
vdW.append(float(l[54:60]))
@@ -744,7 +743,7 @@ class DlgParser:
for i in range(len(vdW)):
d['total_energies'].append(vdW[i]+Elec[i])
#d['total_energies'] = Numeric.array(Numeric.array(vdW)+Numeric.array(Elec)).tolist()
- if binding_energy2 and not d.has_key('binding_energy'):
+ if binding_energy2 and 'binding_energy' not in d:
d['binding_energy'] = binding_energy2
d['docking_energy'] = binding_energy2
return d
--- a/autodock/Tests/test_autodock4.py
+++ b/autodock/Tests/test_autodock4.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#!/usr/bin/python3
#
# $Id: test_autodock4.py,v 1.74 2014/07/16 23:27:27 mp Exp $
#
@@ -28,7 +28,7 @@ fnull = open(os.devnull, "w")
try:
opts, argv = getopt.getopt(sys.argv[1:], "d:e:o:",
["dpf-directory=","executable=","test-output-directory="])
-except getopt.GetoptError, v:
+except getopt.GetoptError as v:
usage()
sys.exit(2)
@@ -45,7 +45,7 @@ for o,a in opts:
def usage():
"""Print out the usage of this command."""
- print """Usage: python test_autodock4.py [-d <string>] [-e <string>] [-o <string>]
+ print("""Usage: python3 test_autodock4.py [-d <string>] [-e <string>] [-o <string>]
where:
-d, --dpf-directory
@@ -59,7 +59,7 @@ where:
this flag is optional; default is '.'
NOTE: these may be relative to the directory where this script was invoked.
-"""
+""")
#______________________________________________________________________________
@@ -72,13 +72,13 @@ def run_AutoDock( dpf_filename, dlg_file
dlg = test_output_directory + os.sep + dlg_filename
rm( dlg )
command = [autodock_executable, '-p', dpf, '-l', dlg ]
- print '\nRunning ' + autodock_executable + ' using DPF "'+dpf+'", saving results in "'+dlg+'":'
+ print('\nRunning ' + autodock_executable + ' using DPF "'+dpf+'", saving results in "'+dlg+'":')
try:
rc = subprocess.call( command, stdout = fnull, stderr = fnull )
#print 'autodock returned ', rc # DEBUG
return find_success_in_DLG( dlg_filename )
- except OSError,e:
- print "\nUnable to run " + autodock_executable + " :", e
+ except OSError as e:
+ print("\nUnable to run " + autodock_executable + " :", e)
return False
#______________________________________________________________________________
@@ -93,7 +93,7 @@ def parse_energy_from_DLG( dlg_filename,
result = []
for energy_type in energy_list:
newVal = docked.get(energy_type, 'ERROR')
- print energy_type, ' is now ', newVal
+ print(energy_type, ' is now ', newVal)
result.append(docked.get(energy_type, 'ERROR'))
#intermol_energy = docked['intermol_energy'] #-6.17
#internal_energy = docked['total_internal'] # -1.58
@@ -132,8 +132,8 @@ def rm( filename ):
if os.access(filename, os.F_OK) :
try:
os.remove( filename )
- except OSError,e:
- print 'unable to remove '+filename
+ except OSError as e:
+ print('unable to remove '+filename)
#______________________________________________________________________________
@@ -173,9 +173,9 @@ class AutoDock_simple_test( unittest.Tes
"""Check that run finished and a new DLG has been computed."""
# Check that run finished and a new DLG has been computed.
if (self.expected_outcome == True ):
- print "Testing that DLG exists and AutoDock successfully completed."
+ print("Testing that DLG exists and AutoDock successfully completed.")
else:
- print "Testing that DLG exists and AutoDock did not complete."
+ print("Testing that DLG exists and AutoDock did not complete.")
self.assertEqual( self.computed, self.expected_outcome )
#______________________________________________________________________________
@@ -183,7 +183,7 @@ class AutoDock4_1pgp_no_extension( AutoD
"""Test that autodock4 stops early if .dpf extension is missing
keywords are specified."""
dpf_stem = "1pgp_no_extension"
- print "in 1pgp_no_extension"
+ print("in 1pgp_no_extension")
expected_outcome = False # True means Successful Completion!
def setUp( self ):
"""Set up for autodock4 tests. Locate the autodock binary now during setUp."""
@@ -196,7 +196,7 @@ class AutoDock4_1pgp_wrong_extension( Au
"""Test that autodock4 stops early if extension is not '.dpf'
keywords are specified."""
dpf_stem = "1pgp.fpd"
- print "in 1pgp_wrong_extension"
+ print("in 1pgp_wrong_extension")
expected_outcome = False # True means Successful Completion!
def setUp( self ):
"""Set up for autodock4 tests. Locate the autodock binary now during setUp."""
@@ -210,7 +210,7 @@ class AutoDock4_1pgp_two_extensions( Aut
"""Test that autodock4 stops early if dpf name includes two .dpf
keywords are specified."""
dpf_stem = "1pgp.dpf"
- print "in 1pgp_two_extensions"
+ print("in 1pgp_two_extensions")
expected_outcome = False # True means Successful Completion!
def setUp( self ):
"""Set up for autodock4 tests. Locate the autodock binary now during setUp."""
@@ -557,18 +557,18 @@ class AutoDock_test( AutoDock_base_test
Also check the final energy is the expected value."""
# Check that run finished and a new DLG has been computed.
if (self.expected_outcome == True ):
- print "Testing that DLG exists and AutoDock successfully completed."
+ print("Testing that DLG exists and AutoDock successfully completed.")
else:
- print "Testing that DLG exists and AutoDock did not complete."
+ print("Testing that DLG exists and AutoDock did not complete.")
self.assertEqual( self.computed, self.expected_outcome )
# Check the final energy is expected value.
# These values are for the quick GALS search in 1pgp.dpf and relatives
expected_intermol_energy = -6.17 # -6.44 for Real==float, -6.17 for Real==double
expected_internal_energy = -3.23 # -3.28 for Real==float, -3.23 for Real==double
(intermol_energy, internal_energy) = parse_energy_from_DLG( self.dlg_filename, ['intermol_energy','total_internal'] )
- print "Testing that intermolecular energy = %.2f kcal/mol." % (expected_intermol_energy,)
+ print("Testing that intermolecular energy = %.2f kcal/mol." % (expected_intermol_energy,))
self.assertEqual( round(intermol_energy,6), round(expected_intermol_energy,6))
- print "Testing that internal energy = %.2f kcal/mol." % (expected_internal_energy,)
+ print("Testing that internal energy = %.2f kcal/mol." % (expected_internal_energy,))
self.assertEqual( round(internal_energy,6), round(expected_internal_energy,6))
#______________________________________________________________________________
@@ -741,16 +741,16 @@ class AutoDock4_energy_test( AutoDock_ba
Also check the final energy is the expected value."""
# Check that run finished and a new DLG has been computed.
if (self.expected_outcome == True ):
- print "Testing that DLG exists and AutoDock successfully completed."
+ print("Testing that DLG exists and AutoDock successfully completed.")
else:
- print "Testing that DLG exists and AutoDock did not complete."
+ print("Testing that DLG exists and AutoDock did not complete.")
self.assertEqual( self.computed, self.expected_outcome )
# Check the final energy is expected value.
#expected_unbound_energy = -3.23
#expected_binding_energy = +843.59 -5.87
(binding_energy) = parse_energy_from_DLG( self.dlg_filename, ['binding_energy'])[0]
- print "Testing that binding energy = %.2f kcal/mol." % (self.expected_binding_energy,)
- print "binding_energy=", binding_energy
+ print("Testing that binding energy = %.2f kcal/mol." % (self.expected_binding_energy,))
+ print("binding_energy=", binding_energy)
self.assertEqual( round(binding_energy,6), round(self.expected_binding_energy,6))
#______________________________________________________________________________
@@ -764,15 +764,15 @@ class AutoDock4_unbound_test( AutoDock_b
Also check the final energy is the expected value."""
# Check that run finished and a new DLG has been computed.
if (self.expected_outcome == True ):
- print "Testing that DLG exists and AutoDock successfully completed."
+ print("Testing that DLG exists and AutoDock successfully completed.")
else:
- print "Testing that DLG exists and AutoDock did not complete."
+ print("Testing that DLG exists and AutoDock did not complete.")
self.assertEqual( self.computed, self.expected_outcome )
# Check the final energy is expected value.
#expected_unbound_energy = -3.23
(unbound_energy) = parse_energy_from_DLG( self.dlg_filename, ['unbound_energy'])[0]
- print "Testing that unbound energy = %.2f kcal/mol." % (self.expected_unbound_energy,)
- print "unbound_energy=", unbound_energy
+ print("Testing that unbound energy = %.2f kcal/mol." % (self.expected_unbound_energy,))
+ print("unbound_energy=", unbound_energy)
self.assertEqual( round(unbound_energy,6), round(self.expected_unbound_energy,6))
#______________________________________________________________________________
--- a/autodock/makecheck
+++ b/autodock/makecheck
@@ -4,7 +4,7 @@
#
# $Id: makecheck,v 1.2 2012/10/25 16:55:21 mp Exp $
#
-echo "Running the Python test_autodock4.py unit-tests on ../autodock4"
+echo "Running the Python3 test_autodock4.py unit-tests on ../autodock4"
outputdir=`pwd` ;\
umask 0 ;\
test -d $outputdir/Tests || mkdir $outputdir/Tests ;\
@@ -15,4 +15,4 @@ outputdir=`pwd` ;\
cp ../Tests/*.dpf $outputdir/Tests;\
cp ../Tests/*.pdbqt $outputdir/Tests;\
cp ../Tests/*.map* $outputdir/Tests;\
- cd Tests ; python ./test_autodock4.py -d . -e ../autodock4 -o .
+ cd Tests ; python3 ./test_autodock4.py -d . -e ../autodock4 -o .
--- a/autogrid/Makefile.am
+++ b/autogrid/Makefile.am
@@ -129,7 +129,7 @@ check : test
test : autogrid4 $(srcdir)/Tests/test_autogrid4.py
#if HAVE_PYTHON
@echo " "
- @echo "Running the Python test_autogrid4.py unit-tests on autogrid4"
+ @echo "Running the Python3 test_autogrid4.py unit-tests on autogrid4"
@echo " "
# for technical reasons, autogrid must be run in the directory where the
# test files reside because it writes its maps into its current directory
@@ -147,7 +147,7 @@ test : autogrid4 $(srcdir)/Tests/test_au
cp $(srcdir)/Tests/*.map* $$outputdir/Testruns;\
chmod -fR a+w $$outputdir/Testruns;\
cd $$outputdir/Testruns;\
- python ./test_autogrid4.py -d . -e ../autogrid4$(EXEEXT) -o .
+ python3 ./test_autogrid4.py -d . -e ../autogrid4$(EXEEXT) -o .
#else
# @echo " "
# @echo "Python version 2.1 or higher needed for 'make test', but not found."
--- a/autogrid/Makefile.in
+++ b/autogrid/Makefile.in
@@ -1097,7 +1097,7 @@ check : test
test : autogrid4 $(srcdir)/Tests/test_autogrid4.py
#if HAVE_PYTHON
@echo " "
- @echo "Running the Python test_autogrid4.py unit-tests on autogrid4"
+ @echo "Running the Python3 test_autogrid4.py unit-tests on autogrid4"
@echo " "
# for technical reasons, autogrid must be run in the directory where the
# test files reside because it writes its maps into its current directory
@@ -1115,7 +1115,7 @@ test : autogrid4 $(srcdir)/Tests/test_au
cp $(srcdir)/Tests/*.map* $$outputdir/Testruns;\
chmod -fR a+w $$outputdir/Testruns;\
cd $$outputdir/Testruns;\
- python ./test_autogrid4.py -d . -e ../autogrid4$(EXEEXT) -o .
+ python3 ./test_autogrid4.py -d . -e ../autogrid4$(EXEEXT) -o .
#else
# @echo " "
# @echo "Python version 2.1 or higher needed for 'make test', but not found."
--- a/autogrid/Tests/test_autogrid4.py
+++ b/autogrid/Tests/test_autogrid4.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#!/usr/bin/python3
#
#
# $Id: test_autogrid4.py,v 1.18 2013/11/14 22:16:02 mp Exp $
@@ -15,7 +15,6 @@ import types
import unittest
import getopt
import subprocess
-from string import split, strip
#______________________________________________________________________________
#
@@ -28,7 +27,7 @@ test_output_directory = '.' # where the
try:
opts, argv = getopt.getopt(sys.argv[1:], "d:g:e:o:",
["gpf-directory=","gpf-directory=","executable=","test-output-directory="])
-except getopt.GetoptError, v:
+except getopt.GetoptError as v:
usage()
sys.exit(2)
@@ -59,7 +58,7 @@ built_missing_map = False
def usage():
"""Print out the usage of this command."""
- print """Usage: python test_autogrid4.py [-d <string>] [-e <string>] [-o <string>]
+ print("""Usage: python3 test_autogrid4.py [-d <string>] [-e <string>] [-o <string>]
where:
-d, --gpf-directory
@@ -73,7 +72,7 @@ where:
this flag is optional; default is '.'
NOTE: these may be relative to the directory where this script was invoked.
-"""
+""")
#______________________________________________________________________________
@@ -85,13 +84,13 @@ def run_AutoGrid( gpf_filename, glg_file
glg = test_output_directory + os.sep + glg_filename
rm(glg)
command = [ autogrid_executable, '-p', gpf, '-l', glg ]
- print '\nRunning ' + autogrid_executable + ' using GPF "'+gpf+'", saving results in "'+glg+'":'
+ print('\nRunning ' + autogrid_executable + ' using GPF "'+gpf+'", saving results in "'+glg+'":')
try:
- rc = subprocess.call( command )
- #print 'autogrid returned ', rc # DEBUG
+ rc = subprocess.call( command )
+ #print 'autogrid returned ', rc # DEBUG
return find_success_in_GLG(glg_filename)
- except OSError, e:
- print "\nUnable to run " + autogrid_executable + " :", e
+ except OSError as e:
+ print("\nUnable to run " + autogrid_executable + " :", e)
return False
#______________________________________________________________________________
@@ -121,8 +120,8 @@ def rm( filename ):
if os.access(filename, os.F_OK) :
try:
os.remove( filename )
- except OSError,e:
- print 'unable to remove '+filename
+ except OSError as e:
+ print('unable to remove '+filename)
#______________________________________________________________________________
@@ -169,14 +168,14 @@ class AutoGrid_hsg1_sm_test(unittest.Tes
# skip starting lines
self.assertEqual(len(c_autogrid4_lines), len(py_autogrid4_lines))
for atomL, py_atomL in zip(c_autogrid4_lines[6:], py_autogrid4_lines[6:]):
- c_num = float(strip(atomL))
- py_num = float(strip(py_atomL))
+ c_num = float(atomL.strip())
+ py_num = float(py_atomL.strip())
if abs(c_num)>.30:
# use percentage difference for large(r) values:
# allowing up to 0.5% error
#if ((abs(c_num-py_num)/(c_num))*100.<.5)==False:
# print "c_num=", c_num," py_num=", py_num, "test=", (abs(c_num-py_num)/(c_num))*100.
- self.assertEquals(((abs(c_num-py_num)/(c_num))*100.)<.5, True)
+ self.assertEqual(((abs(c_num-py_num)/(c_num))*100.)<.5, True)
else:
#but use precision only for smaller values
cutoff = 10**(-precision)
@@ -285,14 +284,14 @@ class AutoGrid_simple_test(unittest.Test
""" Set up for autogrid4 tests. Locate the autogrid binary now during setUp."""
self.glg_filename = "test_" + self.gpf_stem + ".glg"
self.computed = run_AutoGrid(self.gpf_stem + ".gpf", self.glg_filename)
- print "after call to run_AutoGrid"
+ print("after call to run_AutoGrid")
def test_glg_exists(self):
#Check that autogrid calculation finished and a new GLG has been computed
if (self.expected_outcome == True):
- print "Testing that GLG exists and AutoGrid successfully completed."
+ print("Testing that GLG exists and AutoGrid successfully completed.")
else:
- print "Testing that GLG exists and AutoGrid did not complete."
+ print("Testing that GLG exists and AutoGrid did not complete.")
self.assertEqual(self.computed, self.expected_outcome)
#------------------------------------------------------------------
@@ -350,10 +349,10 @@ if __name__ == '__main__':
'AutoGrid_control_test',
#'AutoGrid_ligand_types_before_receptor_test',
#3/18/09 not sure of status of ligand_types_before_receptor test, rh
- 'AutoGrid_nbpreps_test',
- 'AutoGrid_nbpreps_illegal_atom_test',
- 'AutoGrid_nbpreps_toofew_test',
- 'AutoGrid_nbpcoeffs_test',
+ 'AutoGrid_nbpreps_test',
+ 'AutoGrid_nbpreps_illegal_atom_test',
+ 'AutoGrid_nbpreps_toofew_test',
+ 'AutoGrid_nbpcoeffs_test',
]
unittest.main( argv=([__name__,] + test_cases)) # non-verbose output
# optional: for verbose output, use this:
--- a/autogrid/makecheck
+++ b/autogrid/makecheck
@@ -4,7 +4,7 @@
#
# $Id: makecheck,v 1.2 2012/10/24 23:40:27 mp Exp $
#
-echo "Running the Python test_autogrid4.py unit-tests on ../autogrid4"
+echo "Running the Python3 test_autogrid4.py unit-tests on ../autogrid4"
outputdir=`pwd` ;\
umask 0 ;\
test -d $outputdir/Tests || mkdir $outputdir/Tests ;\
@@ -16,4 +16,4 @@ outputdir=`pwd` ;\
cp ../Tests/*.map* $outputdir/Tests;\
chmod a+w $outputdir/Tests/*;\
cd $outputdir/Tests;\
- python ./test_autogrid4.py -d . -e ../autogrid4 -o .
+ python3 ./test_autogrid4.py -d . -e ../autogrid4 -o .
|