Skip to content

Commit ed2d73a

Browse files
committed
Python 3 fixes
async, universal_newlines, string
1 parent fbe205d commit ed2d73a

File tree

8 files changed

+44
-47
lines changed

8 files changed

+44
-47
lines changed

nmr_cnstr.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def upl(fname):
2828
while upl != '':
2929

3030
print(upl, i)
31-
cns = string.split(upl)
31+
cns = upl.split()
3232
cmd.dist('upl' + str(i), 'i. ' + cns[0] + ' & n. ' + cns[2], 'i. ' + cns[3] + ' & n. ' + cns[5])
3333
upl = f.readline()
3434
i += 1
@@ -50,7 +50,7 @@ def cns(fname):
5050
if upl == '\n':
5151
upl = f.readline()
5252
continue
53-
cns = string.split(upl)
53+
cns = upl.split()
5454
print(cns, i)
5555
if cns[0] == 'assign':
5656
print('CNS')

plugins/Caver2_1_2.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def execute(self, result):
509509
return
510510
elif not os.path.exists(outdir):
511511
self.CreateDirectory(outdir)
512-
self.stdamString = string.join(self.stdam_list, "+")
512+
self.stdamString = "+".join(self.stdam_list)
513513
# jen to zaskrtnute
514514
generatedString = ""
515515
for key in self.s:
@@ -696,7 +696,7 @@ def containsValue(self, array, value):
696696
return 0
697697

698698
def stdamMessage(self):
699-
Pmw.MessageDialog(self.parent, title='Information', message_text='AA: Standard amino acids: \n ' + string.join(self.stdam_list, ", "))
699+
Pmw.MessageDialog(self.parent, title='Information', message_text='AA: Standard amino acids: \n ' + ", ".join(self.stdam_list))
700700

701701
def inputAnalyseWrap(self, args):
702702
# print self.listbox1.curselection()[0] # aby to fungovalo, musi byt bindnute na <<ListboxSelect>>

plugins/annocryst.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import Pmw
2020
import sys
21-
import string
2221
import webbrowser
2322
from pymol import cmd
2423
from xml.dom.minidom import parseString
@@ -334,7 +333,7 @@ def openRemote(self, pdbURL=''):
334333
httpRequest = urllib2.Request(url=pdbURL)
335334
pdbHttpHandle = urllib2.urlopen(httpRequest)
336335
pdbStr = pdbHttpHandle.read()
337-
modelName = string.split(string.split(str(pdbURL), "/")[-1], ".")[0]
336+
modelName = str(pdbURL).split("/")[-1].split(".")[0]
338337
cmd.read_pdbstr(pdbStr, modelName)
339338
self.status.setvalue(modelName + " loaded")
340339
self.loadedModels[modelName] = pdbURL
@@ -916,18 +915,18 @@ def select(self, event=None):
916915
self.annotationservice.selectedText = text
917916
# notify annotationservice to highlight context in graphical view
918917
if self.item.label == "context":
919-
contextsplit = string.split(text, ";")
918+
contextsplit = text.split(";")
920919
if len(contextsplit) > 0:
921920
view = contextsplit[0]
922-
view = string.replace(view, "view:", "")
923-
view = string.split(view, ",")
921+
view = view.replace("view:", "")
922+
view = view.split(",")
924923
viewfloats = []
925924
for v in view:
926925
viewfloats.append(float(v))
927926
if len(contextsplit) > 1:
928927
context = contextsplit[1]
929928
context = context.replace("ids:", "")
930-
contextids = string.split(context, ",")
929+
contextids = context.split(",")
931930
# print "context: " + repr(contextids)
932931
# print "view: " + repr(view)
933932
self.annotationservice.selectAnnotation(contextids, view)

plugins/apbsplugin.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
import os
144144
import math
145145
import re
146-
import string
147146
import sys
148147

149148
if sys.version_info[0] < 3:
@@ -279,7 +278,7 @@ def verify(name, f):
279278
searchDirs.append(os.path.join("/sw", "share", "apbs-mpi-lammpi", "tools", "manip"))
280279
searchDirs.append(os.path.join("/usr", "local", "share", "tools", "manip"))
281280

282-
searchDirs.extend(string.split(os.environ["PATH"], ":"))
281+
searchDirs.extend(os.environ["PATH"].split(":"))
283282
searchDirs.append(os.path.join("/usr", "local", "bin"))
284283
searchDirs.append(os.path.join("/opt", "local", "bin"))
285284
searchDirs.append(os.path.join("/sw", "bin"))

plugins/bnitools.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ def bni_fetch(parent, typ="pdb"):
11411141
typ = ["2fofc", "fofc"]
11421142
for source in typ:
11431143
print("# Fetch %s of %s" % (source, code))
1144-
cmd.fetch(code, async=0, type=source)
1144+
cmd.fetch(code, type=source)
11451145
if __pymol_version__ < 1.4:
11461146
print("# Pymol < 1.4 detected.(v. %s)" % __pymol_version__)
11471147
print("# Maps are mixed up. FoFc is 2FoFc and FoFc is 2FoFc.")
@@ -1199,7 +1199,7 @@ def bni_fetch(parent, typ="pdb"):
11991199
for code in PDBcode:
12001200
for source in typ:
12011201
print("# Fetch %s of %s" % (source, code))
1202-
cmd.fetch(code, async=0, type=source)
1202+
cmd.fetch(code, type=source)
12031203
if source == "pdb1":
12041204
cmd.split_states(code)
12051205
cmd.delete(code)
@@ -1290,10 +1290,9 @@ def combine_sele(selections=None, check="enabled", name="sele"):
12901290
print("# BNI - Tools v. %s" % __version__)
12911291
print("# Combined selections: %s" % sele_names)
12921292
print("# to (%s)" % name)
1293-
def _set_bni_ray(setting="set", app=None, async=1):
1293+
def _set_bni_ray(setting="set", app=None, async_=1):
12941294
'''Run sidebar input
12951295
'''
1296-
async = int(_remove_brakets(async))
12971296
width = 100
12981297
dpi = 200
12991298
width_unit = "mm"
@@ -1367,9 +1366,9 @@ def _set_bni_ray(setting="set", app=None, async=1):
13671366
dpi = 1200
13681367
print("# width: %s %s" % (width, width_unit))
13691368
print("# resolution: %s dpi" % dpi)
1370-
if async == 1:
1369+
if async_ == 1:
13711370
print("# Ray is working in the background")
1372-
bni_ray(width, width_unit=width_unit, dpi=dpi, async=async)
1371+
bni_ray(width, width_unit=width_unit, dpi=dpi, {'async': async_})
13731372
def bni_ray(width, name_png=None, dpi="300", width_unit="cm", **arg):
13741373
'''Ray specified with dpi and width.
13751374
USAGE: bni_ray(width,dpi="300",width_unit="cm",name_png=None,**arg)

plugins/emovie.py

+27-28
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from tkinter import messagebox as tkMessageBox
3434
from tkinter import filedialog as tkFileDialog
3535

36-
import string
3736
import os
3837
import pickle
3938
import time
@@ -1473,7 +1472,7 @@ def __init__(self, root, title="Save"):
14731472
# split the string using "." as the delimiter string and check if last entry is "pse" or "emov" if so, remove them
14741473
# if not, add emov to string
14751474

1476-
splitFileName = string.split(fileName, ".")
1475+
splitFileName = fileName.split(".")
14771476
if splitFileName[len(splitFileName) - 1] == "pse":
14781477
fileName = fileName[:-4]
14791478
elif splitFileName[len(splitFileName) - 1] == "emov":
@@ -1555,7 +1554,7 @@ def apply(self):
15551554
# split the string using "." as the delimiter string and check if last entry is "pse" or "emov" if so, remove them
15561555
# if not, add emov to string
15571556

1558-
splitFileName = string.split(fileName, ".")
1557+
splitFileName = fileName.split(".")
15591558
if splitFileName[len(splitFileName) - 1] == "pse":
15601559
fileName = fileName[:-4]
15611560
elif splitFileName[len(splitFileName) - 1] == "emov":
@@ -1649,7 +1648,7 @@ def __init__(self, root, title="Load"):
16491648
# if it does not have an extension of either .pse or .emov, we will use it as is
16501649
# if it has an extenstion of either .pse or .emov, we will strip away that extension
16511650

1652-
splitFileName = string.split(fileName, ".")
1651+
splitFileName = fileName.split(".")
16531652

16541653
if splitFileName[len(splitFileName) - 1] == "emov":
16551654
fileName = fileName[:-5]
@@ -1745,7 +1744,7 @@ def apply(self):
17451744
# if it does not have an extension of either .pse or .emov, we will use it as is
17461745
# if it has an extenstion of either .pse or .emov, we will strip away that extension
17471746

1748-
splitFileName = string.split(fileName, ".")
1747+
splitFileName = fileName.split(".")
17491748

17501749
if splitFileName[len(splitFileName) - 1] == "emov":
17511750
fileName = fileName[:-5]
@@ -2447,8 +2446,8 @@ def cmpStoryBoard(a, b):
24472446
elif b[0] == "-":
24482447
return 1
24492448

2450-
x = string.split(a[0], "-")
2451-
y = string.split(b[0], "-")
2449+
x = a[0].split("-")
2450+
y = b[0].split("-")
24522451

24532452
xStartFrame = int(x[0])
24542453
yStartFrame = int(y[0])
@@ -2520,7 +2519,7 @@ def getActionValues(action):
25202519

25212520
# first we get the startFrame and the endFrame
25222521
frames = action[0]
2523-
t = string.split(frames, "-")
2522+
t = frames.split("-")
25242523
startFrame = t[0] # the first token is the start frame
25252524
if len(t) == 2:
25262525
endFrame = t[1]
@@ -2537,24 +2536,24 @@ def getActionValues(action):
25372536
return result
25382537
elif actionType == "Morph":
25392538
info = action[2]
2540-
q = string.split(info, ";")
2541-
p = string.split(q[0], " ")
2542-
r = string.split(q[1], " ")
2539+
q = info.split(";")
2540+
p = q[0].split(" ")
2541+
r = q[1].split(" ")
25432542
morphName = p[len(p) - 1]
25442543
direction = r[len(r) - 1]
25452544

25462545
result = (startFrame, endFrame, actionType, morphName, direction)
25472546
return result
25482547
elif actionType == "Scene Set":
25492548
info = action[2]
2550-
q = string.split(info, " ")
2549+
q = info.split(" ")
25512550
sceneName = q[len(q) - 1]
25522551

25532552
result = (startFrame, endFrame, actionType, sceneName)
25542553
return result
25552554
elif actionType == "Zoom":
25562555
info = action[2]
2557-
q = string.split(info, " ")
2556+
q = info.split(" ")
25582557
if len(q) == 2:
25592558
amtZoom = q[1]
25602559
else:
@@ -2569,21 +2568,21 @@ def getActionValues(action):
25692568
return result
25702569
elif actionType == "Rotation":
25712570
info = action[2]
2572-
q = string.split(info, ";")
2573-
p = string.split(q[0], " ")
2574-
r = string.split(q[1], " ")
2571+
q = info.split(";")
2572+
p = q[0].split(" ")
2573+
r = q[1].split(" ")
25752574
axis = p[1]
25762575
degrees = r[2]
25772576

25782577
result = (startFrame, endFrame, actionType, axis, degrees)
25792578
return result
25802579
elif actionType == "Fading":
25812580
info = action[2]
2582-
q = string.split(info, ";")
2583-
p = string.split(q[0], " ")
2584-
r = string.split(q[1], " ")
2585-
s = string.split(q[2], " ")
2586-
u = string.split(q[3], " ")
2581+
q = info.split(";")
2582+
p = q[0].split(" ")
2583+
r = q[1].split(" ")
2584+
s = q[2].split(" ")
2585+
u = q[3].split(" ")
25872586
molecule = p[len(p) - 1]
25882587
representation = r[len(r) - 1]
25892588
fadeFrom = s[len(s) - 1]
@@ -2596,10 +2595,10 @@ def getActionValues(action):
25962595
return result
25972596
elif actionType == "Worm":
25982597
info = action[2]
2599-
q = string.split(info, ";")
2600-
p = string.split(q[0], " ")
2601-
r = string.split(q[1], " ")
2602-
s = string.split(r[len(r) - 1], "-")
2598+
q = info.split(";")
2599+
p = q[0].split(" ")
2600+
r = q[1].split(" ")
2601+
s = r[-1].split("-")
26032602
molecule = p[len(p) - 1]
26042603
startAA = s[0]
26052604
endAA = s[1]
@@ -2973,23 +2972,23 @@ def get_frame_states(fstring):
29732972
1:1-10 # this is crap, don't know what happens
29742973
"""
29752974

2976-
t = string.split(fstring, ":")
2975+
t = fstring.split(":")
29772976
frames = t[0] # the first token is frame range
29782977
if len(t) == 2:
29792978
states = t[1] # the second token is state range
29802979
else:
29812980
states = '1' # only state number 1 is used
29822981

29832982
# parse frame substring
2984-
t = string.split(frames, "-")
2983+
t = frames.split("-")
29852984
firstFrame = int(t[0]) # first token is starting frame
29862985
if len(t) == 2:
29872986
lastFrame = int(t[1]) # second token is end frame
29882987
else:
29892988
lastFrame = firstFrame # only one frame is used
29902989

29912990
# parse state substring
2992-
t = string.split(states, "-")
2991+
t = states.split("-")
29932992
firstState = int(t[0]) # first token is starting state
29942993
if len(t) == 2:
29952994
lastState = int(t[1]) # second token is end state

plugins/mtsslWizard.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ class UripLabel:
17481748
numberToFind = {'painstaking': 1000, 'thorough search': 200, 'quick search': 50}
17491749
numberOfTries = {'painstaking': 100000, 'thorough search': 20000, 'quick search': 3000}
17501750
info = "\nFor the Urip label, the vdW restraints are by default set to 'loose' to account for possible polar interactions between the amide bonds and the DNA backbone."
1751-
errorMessage = "Check atom nomenclature. The ribose atoms are sometimes called C2* instead of C2'\nThis can be changed e.g. by 'alter all, name=string.replace(name,\"*\",\"'\")' in PyMOL."
1751+
errorMessage = "Check atom nomenclature. The ribose atoms are sometimes called C2* instead of C2'\nThis can be changed e.g. by 'alter all, name=name.replace(\"*\",\"'\")' in PyMOL."
17521752
trialAtomSphereRadius = 7.5
17531753
exclusionSphereRadius = 5.5
17541754
pdbStr = """HEADER URIPSL\n

poseview.py

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def poseview(ligand='organic inorganic', protein='polymer', width=0, height=0,
8080
print(' poseview: running...')
8181

8282
process = subprocess.Popen(args,
83+
universal_newlines=True,
8384
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
8485
stdout, _ = process.communicate()
8586

0 commit comments

Comments
 (0)