Skip to content

Commit

Permalink
Python3 support
Browse files Browse the repository at this point in the history
removes print statements without paranthesis and lambda unpacking (PEP3113)
  • Loading branch information
Dario Cambié committed Apr 19, 2020
1 parent 19ef22e commit e072592
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions FiveConf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def main(f, settings):
WasAbove90 = False
rotangle = 2*(0.5*pi-angle)
OldAtomCoords = outAtom.GetVector()
print "Atom " + str(outAtom.GetAtomicNum()) + " will be rotated by " +\
str(rotangle*57.3) + ' degrees'
print("Atom " + str(outAtom.GetAtomicNum()) + " will be rotated by " +\
str(rotangle*57.3) + ' degrees')
RotateAtom(outAtom, AxisAtoms[0], AxisAtoms[1], rotangle)
angle2 = FindRotAngle(AxisAtoms[0], AxisAtoms[1], outAtom, norm)

Expand All @@ -82,7 +82,7 @@ def main(f, settings):
if ((angle2 > 0.5*pi) and WasAbove90) or ((angle2 < 0.5*pi) and not WasAbove90):
#Flip the sign of the rotation angle, restore the coords
#and rotate the atom in the opposite direction
print "Atom was rotated the wrong way, switching the direction"
print("Atom was rotated the wrong way, switching the direction")
rotangle = -rotangle
outAtom.SetVector(OldAtomCoords)
RotateAtom(outAtom, AxisAtoms[0], AxisAtoms[1], rotangle)
Expand All @@ -93,7 +93,7 @@ def main(f, settings):
RotateAtom(atom, AxisAtoms[0], AxisAtoms[1], rotangle)
RotatedAtoms.append(atom)
else:
print "Atom already rotated, skipping"
print("Atom already rotated, skipping")

obconversion.SetOutFormat("sdf")
obconversion.WriteFile(obmol, f[:-4] + 'rot.sdf')
Expand Down Expand Up @@ -228,7 +228,7 @@ def LstSqPlane(atom1, atom2, atom3, atom4):
# Inital guess of the plane
[a0, b0, c0], d0 = FindPlane(atom1, atom2, atom3)

f = lambda (a, b, c, d): PlaneError([atom1, atom2, atom3, atom4], a, b, c, d)
f = lambda a: PlaneError([atom1, atom2, atom3, atom4], a[0], a[1], a[2], a[3])
res = sciopt.minimize(f, (a0, b0, c0, d0), method='nelder-mead')
plane = list(res.x)

Expand Down
4 changes: 2 additions & 2 deletions Karplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def Karplus(f, inputformat):
DihedralHs.append([atom.GetIdx()] + DihedNeighbours)

if len(DihedralHs)==0:
print "No dihedral protons found, Karplus J value prediction " + \
"impossible, quitting."
print("No dihedral protons found, Karplus J value prediction " + \
"impossible, quitting.")
quit()

Jmatrix, Jlabels = CalcJMatrix(obmol, DihedralHs)
Expand Down
10 changes: 5 additions & 5 deletions TreeRenum.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def FindAllPaths(molgraph, start, end, path=[]):
if start == end:
return [path]
if start not in [x[0] for x in molgraph]:
print "No such node in graph"
print("No such node in graph")
return []
paths = []
for node in molgraph[start-1][1:]:
Expand All @@ -26,7 +26,7 @@ def FindAllPaths(molgraph, start, end, path=[]):
def FindTerminatingPaths(molgraph, start, trunk, path=[]):
path = path + [start]
if start not in [x[0] for x in molgraph]:
print "No such node in graph"
print("No such node in graph")
return []
paths = []
for node in molgraph[start-1][1:]:
Expand Down Expand Up @@ -109,7 +109,7 @@ def TreeRenumSDF(f, ExpNMR):
if anum == 6:
NMRmap.append(['C' + str(atom), 'C' + str(i)])
i += 1
print NMRmap
print(NMRmap)
RenumNMR(ExpNMR, NMRmap)


Expand All @@ -118,7 +118,7 @@ def RenumNMR(ExpNMR, NMRmap):
NMRfile = f.read(1000000)
f.close()

print '\nOld NMR file:\n' + NMRfile
print('\nOld NMR file:\n' + NMRfile)

#Replace old atom labels with new atom labels
#tag replacements with '_' to avoid double replacement
Expand All @@ -131,7 +131,7 @@ def RenumNMR(ExpNMR, NMRmap):
#Strip temporary udnerscore tags
NMRfile = NMRfile.replace('_', '')

print '\nNew NMR file:\n' + NMRfile
print('\nNew NMR file:\n' + NMRfile)
f = open(ExpNMR + 'r', 'w')
f.write(NMRfile)
f.close()
Expand Down

0 comments on commit e072592

Please sign in to comment.