mirror of
https://github.com/nwchemgit/nwchem.git
synced 2026-07-28 22:25:48 -04:00
fixes for flake8
This commit is contained in:
parent
bc08e3879f
commit
28cfb44ed4
16 changed files with 145 additions and 144 deletions
|
|
@ -21,8 +21,8 @@ class GenericAtom(object):
|
|||
|
||||
if d:
|
||||
if type(d) is not type({}):
|
||||
print "wrong type ", type(d)
|
||||
print "expecting", type({})
|
||||
print("wrong type ", type(d))
|
||||
print("expecting", type({}))
|
||||
sys.exit(1)
|
||||
else:
|
||||
self.dct = d
|
||||
|
|
@ -77,15 +77,15 @@ if __name__ == '__main__':
|
|||
aline4="ATOM 2 O1 -0.985 -1.156 1.840 -0.80 O"
|
||||
|
||||
a=GenericAtom.fromPDBrecord(aline2)
|
||||
print a.groupTag()
|
||||
print a.coord
|
||||
print a.dct
|
||||
print(a.groupTag())
|
||||
print(a.coord)
|
||||
print(a.dct )
|
||||
b=GenericAtom.fromPDBrecord(aline3)
|
||||
print b.coord
|
||||
print b.dct
|
||||
print GenericAtom.bondlength(a,b),GenericAtom.bonded(a,b)
|
||||
print a.covRadius()+b.covRadius()
|
||||
print(b.coord)
|
||||
print(b.dct )
|
||||
print(GenericAtom.bondlength(a,b),GenericAtom.bonded(a,b))
|
||||
print(a.covRadius()+b.covRadius())
|
||||
c=GenericAtom.fromPDBrecord(aline1)
|
||||
print GenericAtom.bondlength(a,c),GenericAtom.bonded(a,c)
|
||||
print(GenericAtom.bondlength(a,c),GenericAtom.bonded(a,c))
|
||||
c=GenericAtom.fromPDBrecord(aline4)
|
||||
print c.groupTag()
|
||||
print(c.groupTag())
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class AtomParams():
|
|||
try:
|
||||
return d[s1.group(1)],s1.group(1)
|
||||
except KeyError:
|
||||
print "Cannot match name", a
|
||||
print("Cannot match name", a)
|
||||
sys.exit(1)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -517,7 +517,7 @@ class AtomParams():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print AtomParams.fullName(' H1 ')
|
||||
print AtomParams.vdwRadius('h')
|
||||
print(AtomParams.fullName(' H1 '))
|
||||
print(AtomParams.vdwRadius('h'))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ class GenericAtom(object):
|
|||
|
||||
if d:
|
||||
if type(d) is not type({}):
|
||||
print "wrong type ", type(d)
|
||||
print "expecting", type({})
|
||||
print("wrong type ", type(d))
|
||||
print("expecting", type({}))
|
||||
sys.exit(1)
|
||||
else:
|
||||
self.dct = d
|
||||
|
|
@ -145,20 +145,20 @@ if __name__ == '__main__':
|
|||
# aline4="ATOM 2 O1 -0.985 -1.156 1.840 -0.80 O"
|
||||
#
|
||||
# a=GenericAtom.fromPDBrecord(aline2)
|
||||
# print a.groupTag()
|
||||
# print a.coord
|
||||
# print a.dct
|
||||
# print(a.groupTag())
|
||||
# print(a.coord)
|
||||
# print(a.dct )
|
||||
# b=GenericAtom.fromPDBrecord(aline3)
|
||||
# print b.coord
|
||||
# print b.dct
|
||||
# print GenericAtom.bondlength(a,b),GenericAtom.bonded(a,b)
|
||||
# print a.covRadius()+b.covRadius()
|
||||
# print(b.coord)
|
||||
# print(b.dct )
|
||||
# print(GenericAtom.bondlength(a,b),GenericAtom.bonded(a,b))
|
||||
# print(a.covRadius()+b.covRadius())
|
||||
# c=GenericAtom.fromPDBrecord(aline1)
|
||||
# print GenericAtom.bondlength(a,c),GenericAtom.bonded(a,c)
|
||||
# print(GenericAtom.bondlength(a,c),GenericAtom.bonded(a,c))
|
||||
# c=GenericAtom.fromPDBrecord(aline4)
|
||||
# print c.groupTag()
|
||||
# print(c.groupTag())
|
||||
aline6="O1 -0.985 -1.156 1.140 0.0 0.0 "
|
||||
aline5="O1 -0.985 -1.156 "
|
||||
d=GenericAtom.fromXYZrecord(aline6)
|
||||
d.translate([1.0,1.0,1.0])
|
||||
print d
|
||||
print(d)
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ class GenericResidue(object):
|
|||
r = GenericAtom.bondlength(a1, a2)
|
||||
if r < rOH:
|
||||
plist.append([a1,a2])
|
||||
# print "plist",plist
|
||||
# print("plist",plist)
|
||||
for a1,a2 in plist:
|
||||
if a1.elemName()=='H':
|
||||
res1,res2=res2,res1
|
||||
|
|
@ -217,7 +217,7 @@ class GenericResidue(object):
|
|||
r = GenericAtom.bondlength(a1, a2)
|
||||
if r < rOH:
|
||||
plist.append([a1,a2])
|
||||
# print "plist",plist
|
||||
# print("plist",plist)
|
||||
for a1,a2 in plist:
|
||||
if a1.elemName()=='H':
|
||||
res1,res2=res2,res1
|
||||
|
|
@ -277,7 +277,7 @@ class GenericResidue(object):
|
|||
# return False
|
||||
# a3 = res2.get_bonded(a2, 'O')[0]
|
||||
# angle = GenericAtom.angle(a1, a2, a3)
|
||||
# print r,angle
|
||||
# print(r,angle)
|
||||
# return angle>OHO
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -286,7 +286,7 @@ class GenericResidue(object):
|
|||
for a1 in res1.byFilter():
|
||||
for a2 in res2.byFilter():
|
||||
dr=min(dr,GenericAtom.bondlength(a1, a2))
|
||||
print dr,a1.name(),a2.name()
|
||||
print(dr,a1.name(),a2.name())
|
||||
return dr
|
||||
|
||||
def byElement(self,name):
|
||||
|
|
@ -309,33 +309,33 @@ if __name__ == '__main__':
|
|||
# aline2 = "ATOM 1 I1 IO3 1 -1.555 -0.350 0.333 1.39 I"
|
||||
#
|
||||
# res0 = GenericResidue()
|
||||
# print res0
|
||||
# print(res0)
|
||||
# a = GenericAtom.fromPDBrecord(aline2)
|
||||
# print a
|
||||
# print(a)
|
||||
# res0.AddAtom(a)
|
||||
# print res0.size()
|
||||
# print(res0.size())
|
||||
|
||||
res0 = GenericResidue.fromPDBfile("io3.pdb")
|
||||
print res0
|
||||
print(res0)
|
||||
|
||||
res1 = GenericResidue.fromPDBfile("h2o-1.pdb")
|
||||
print res1.signature()
|
||||
print res0.signature()
|
||||
print(res1.signature())
|
||||
print(res0.signature())
|
||||
res1.guess_name()
|
||||
print res1.name
|
||||
print(res1.name)
|
||||
res0.guess_name()
|
||||
print res0.name
|
||||
print(res0.name)
|
||||
|
||||
print "distance test"
|
||||
print("distance test")
|
||||
(r,a1,a2)=GenericResidue.distance(res0, res1)
|
||||
print r, a1.name(), a2.name()
|
||||
print res1.get_bonded(a2, "O")
|
||||
print(r, a1.name(), a2.name())
|
||||
print(res1.get_bonded(a2, "O"))
|
||||
name = None
|
||||
print (filter(lambda a: name is None or a.elemName()==name,res1.atoms ))
|
||||
print GenericResidue.hbonded(res0,res1)
|
||||
print "HERE COMES PDB RECORD"
|
||||
print res0.toPDBrecord(1)
|
||||
print((filter(lambda a: name is None or a.elemName()==name,res1.atoms )))
|
||||
print(GenericResidue.hbonded(res0,res1))
|
||||
print("HERE COMES PDB RECORD")
|
||||
print(res0.toPDBrecord(1))
|
||||
# b = ResAtom.fromPDBrecord(aline1)
|
||||
# res0.AddAtom(a)
|
||||
# res0.AddAtom(b)
|
||||
# print res0.toPDBrecord(atom_start=1)
|
||||
# print(res0.toPDBrecord(atom_start=1))
|
||||
|
|
|
|||
|
|
@ -126,10 +126,10 @@ class MySystem(object):
|
|||
G=nx.MultiDiGraph()
|
||||
for i,r in enumerate(self.reslist):
|
||||
G.add_node(i+1,name=r.name)
|
||||
print G.nodes()
|
||||
print(G.nodes())
|
||||
solvent = [n for n,d in G.nodes_iter(data=True) if d['name'] in ['WAT','HOH','WTR' ]]
|
||||
solute = [n for n,d in G.nodes_iter(data=True) if d['name'] not in ['WAT','HOH','WTR' ]]
|
||||
print "solute",solute
|
||||
print("solute",solute)
|
||||
|
||||
nr = len(self.reslist)
|
||||
for i in range(nr):
|
||||
|
|
@ -149,18 +149,18 @@ class MySystem(object):
|
|||
if GenericResidue.spec_bonded(ri, rj):
|
||||
G.add_edge(j+1,i+1,name="special")
|
||||
|
||||
print "all",[(u,v) for u,v,d in G.edges_iter(data=True)]
|
||||
print("all",[(u,v) for u,v,d in G.edges_iter(data=True)] )
|
||||
esolute = [(u,v,d) for u,v,d in G.edges_iter(data=True) if (u in solute or v in solute) and d['name']=='hbond' ]
|
||||
print "solute-solute",esolute
|
||||
print("solute-solute",esolute)
|
||||
|
||||
esolute2 = [(u,v) for u,v,d in G.edges_iter(data=True) if (u in solute or v in solute) and d['name']=='hbond2' ]
|
||||
print "double solute",esolute2
|
||||
print("double solute",esolute2)
|
||||
|
||||
esolvent= [(u,v) for u,v,d in G.edges_iter(data=True) if (u in solvent and v in solvent) and d['name']=='hbond']
|
||||
print "solvent-solvent",esolvent
|
||||
print("solvent-solvent",esolvent )
|
||||
|
||||
especial= [(u,v) for u,v,d in G.edges_iter(data=True) if d['name']=='special' ]
|
||||
print especial
|
||||
print(especial )
|
||||
|
||||
G=nx.relabel_nodes(G,lambda x: str(x))
|
||||
pos0=nx.spectral_layout(G)
|
||||
|
|
@ -188,7 +188,7 @@ class MySystem(object):
|
|||
# T=nx.dfs_tree(G)
|
||||
# print(sorted(T.edges(data=True)))
|
||||
nx.write_dot(G,"shell.dot")
|
||||
# print "density=",nx.density(G)
|
||||
# print("density=",nx.density(G))
|
||||
nx.write_gml(G, "test.gml")
|
||||
# plt.show() # display
|
||||
# return G
|
||||
|
|
@ -200,10 +200,10 @@ class MySystem(object):
|
|||
G=nx.MultiGraph()
|
||||
for i,r in enumerate(self.reslist):
|
||||
G.add_node(i+1,name=r.name)
|
||||
print G.nodes()
|
||||
print(G.nodes())
|
||||
solvent = [n for n,d in G.nodes_iter(data=True) if d['name'] in ['WAT','HOH','WTR' ]]
|
||||
solute = [n for n,d in G.nodes_iter(data=True) if d['name'] not in ['WAT','HOH','WTR' ]]
|
||||
print "solute",solute
|
||||
print("solute",solute)
|
||||
|
||||
h = self.hbond_matrix1()
|
||||
nr = numpy.size(h,0)
|
||||
|
|
@ -217,18 +217,18 @@ class MySystem(object):
|
|||
elif GenericResidue.spec_bonded(self.reslist[i], self.reslist[j]):
|
||||
G.add_edge(i+1,j+1,name="special")
|
||||
|
||||
print "all",[(u,v) for u,v,d in G.edges_iter(data=True)]
|
||||
print("all",[(u,v) for u,v,d in G.edges_iter(data=True)] )
|
||||
esolute = [(u,v) for u,v,d in G.edges_iter(data=True) if (u in solute or v in solute) and d['name']=='hbond' ]
|
||||
print esolute
|
||||
print(esolute)
|
||||
|
||||
esolute2 = [(u,v) for u,v,d in G.edges_iter(data=True) if (u in solute or v in solute) and d['name']=='hbond2' ]
|
||||
print esolute2
|
||||
print(esolute2)
|
||||
|
||||
esolvent= [(u,v) for u,v,d in G.edges_iter(data=True) if (u in solvent and v in solvent) and d['name']=='hbond']
|
||||
print esolvent
|
||||
print(esolvent )
|
||||
|
||||
especial= [(u,v) for u,v,d in G.edges_iter(data=True) if d['name']=='special' ]
|
||||
print especial
|
||||
print(especial )
|
||||
|
||||
pos0=nx.spectral_layout(G)
|
||||
pos=nx.spring_layout(G,iterations=500,pos=pos0)
|
||||
|
|
@ -254,7 +254,7 @@ class MySystem(object):
|
|||
# T=nx.dfs_tree(G)
|
||||
# print(sorted(T.edges(data=True)))
|
||||
# nx.write_dot(G,"shell.dot")
|
||||
# print "density=",nx.density(G)
|
||||
# print("density=",nx.density(G))
|
||||
|
||||
# plt.show() # display
|
||||
# return G
|
||||
|
|
@ -311,7 +311,7 @@ class MySystem(object):
|
|||
G=nx.Graph()
|
||||
for i,r in enumerate(self.reslist):
|
||||
G.add_node(i+1,name=r.name)
|
||||
print G.nodes()
|
||||
print(G.nodes())
|
||||
|
||||
|
||||
h = self.hbond_matrix()
|
||||
|
|
@ -319,7 +319,7 @@ class MySystem(object):
|
|||
for i in range(nr):
|
||||
for j in range(i+1,nr):
|
||||
if GenericResidue.touching(self.reslist[i], self.reslist[j],2.8):
|
||||
print 'adding edge',i+1,j+1
|
||||
print('adding edge',i+1,j+1)
|
||||
G.add_edge(i+1,j+1,name="special")
|
||||
|
||||
# pos0=nx.spectral_layout(G)
|
||||
|
|
@ -415,8 +415,8 @@ class MySystem(object):
|
|||
|
||||
def info(self):
|
||||
for tag,res in self.residues.iteritems():
|
||||
print tag
|
||||
print res
|
||||
print(tag )
|
||||
print(res )
|
||||
|
||||
if __name__ == '__main__':
|
||||
# sim0 = MySystem("test")
|
||||
|
|
@ -430,23 +430,23 @@ if __name__ == '__main__':
|
|||
|
||||
#
|
||||
sim1 = MySystem.from_file("w10-11.xyz")
|
||||
print sim1.num_hbonds(rOH=2.18, HOH=138)
|
||||
print(sim1.num_hbonds(rOH=2.18, HOH=138))
|
||||
# sim1.create_graph_directed("test.png")
|
||||
# sim1.toPDBfile("shell-1.pdb")
|
||||
# sim1.create_graph("shell.png")
|
||||
# G=sim1.graph()
|
||||
# print nx.density(G)
|
||||
# print sim1.num_hbonds()[0]
|
||||
# print(nx.density(G))
|
||||
# print(sim1.num_hbonds()[0])
|
||||
# dm=sim1.dist_matrix(2.8)
|
||||
# chain0=[0]
|
||||
# level=2
|
||||
# chain1=[]
|
||||
# print dm
|
||||
# print(dm)
|
||||
# for i in chain0:
|
||||
# for j in range(i+1,25):
|
||||
# if dm[i][j]==1:
|
||||
# chain1.append([i,j])
|
||||
# print chain1
|
||||
# print(chain1)
|
||||
#
|
||||
# chain0=chain1
|
||||
# chain1=[]
|
||||
|
|
@ -455,7 +455,7 @@ if __name__ == '__main__':
|
|||
# for j in range(i+1,25):
|
||||
# if dm[i][j]==1:
|
||||
# chain1.append([i,j])
|
||||
# print chain1
|
||||
# print(chain1)
|
||||
#
|
||||
# slist=set()
|
||||
# while len(slist)<15:
|
||||
|
|
@ -469,7 +469,7 @@ if __name__ == '__main__':
|
|||
# for i,s in enumerate(slist):
|
||||
# filename = "cw9-%d.pdb"%(i)
|
||||
# comment="-".join(["%s" % el for el in s])
|
||||
# print s,filename,comment
|
||||
# print(s,filename,comment)
|
||||
# sim1.toPDBfile1(filename,s,comment)
|
||||
|
||||
# it = iter(slist)
|
||||
|
|
@ -479,7 +479,7 @@ if __name__ == '__main__':
|
|||
# nx.draw_spring(H)
|
||||
# plt.show()
|
||||
|
||||
print "finished"
|
||||
print("finished")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
|
@ -488,17 +488,17 @@ if __name__ == '__main__':
|
|||
# sim2 = MySystem.fromPDBfile("test.pdb")
|
||||
# sim3 = MySystem.fromXYZfile("w2-test.xyz")
|
||||
# sim3.groupAtoms()
|
||||
# print sim1.residues["XYZ"]
|
||||
# print(sim1.residues["XYZ"])
|
||||
# sim1.connectAtoms()
|
||||
|
||||
|
||||
# G=nx.Graph(hbond)
|
||||
#
|
||||
# for i in range(nr):
|
||||
# print i+1, hbond[i], sum(hbond[i])
|
||||
# print(i+1, hbond[i], sum(hbond[i]))
|
||||
#
|
||||
# print nx.connected_components(G)
|
||||
# print nx.clustering(G)
|
||||
# print(nx.connected_components(G))
|
||||
# print(nx.clustering(G))
|
||||
# nx.write_dot(G,'file.dot')
|
||||
# pos=nx.spring_layout(G)
|
||||
# colors=range(20)
|
||||
|
|
@ -506,10 +506,10 @@ if __name__ == '__main__':
|
|||
# nx.draw_spring(G)
|
||||
# plt.show()
|
||||
# plt.savefig("path.png")
|
||||
# print "looking for cliques"
|
||||
# print list(nx.find_cliques(G))
|
||||
# print nx.number_connected_components(G)
|
||||
# print sorted(nx.degree(G).values())
|
||||
# print("looking for cliques")
|
||||
# print(list(nx.find_cliques(G)))
|
||||
# print(nx.number_connected_components(G))
|
||||
# print(sorted(nx.degree(G).values()))
|
||||
#
|
||||
# sim1.toPDBfile("mytest.pdb")
|
||||
# try:
|
||||
|
|
@ -520,22 +520,22 @@ if __name__ == '__main__':
|
|||
#
|
||||
# L=nx.generalized_laplacian(G)
|
||||
# e=eigenvalues(L)
|
||||
# print e
|
||||
# print "pagerank"
|
||||
# print(e)
|
||||
# print("pagerank")
|
||||
# d= nx.degree(G)
|
||||
# for w in sorted(d, key=d.get, reverse=True):
|
||||
# print w, d[w]
|
||||
# print(w, d[w])
|
||||
|
||||
# T=nx.minimum_spanning_tree(G)
|
||||
# print(sorted(T.edges(data=True)))
|
||||
# print(nx.cycle_basis(G))
|
||||
# nx.draw_spring(G)
|
||||
# plt.show()
|
||||
# print len(hbond)
|
||||
# print(len(hbond))
|
||||
|
||||
# sim1.info()
|
||||
# r=list(sim1.residues.itervalues())
|
||||
# print r
|
||||
# print(r)
|
||||
|
||||
# sim1 = MySystem.fromPDBfile("test.pdb")
|
||||
#
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ def extract_random_clusters(filename,nres,prefix=None,nconf=15,with_residues=Non
|
|||
|
||||
reslist.add(tuple(sorted(alist)))
|
||||
|
||||
print reslist
|
||||
print(reslist)
|
||||
|
||||
for i,s in enumerate(reslist):
|
||||
filename = "%s-%d.pdb"%(prefix,i)
|
||||
comment="-".join(["%s" % el for el in s])
|
||||
sim1.toPDBfile1(filename,s,comment)
|
||||
print "generated cluster",s,"as",filename
|
||||
print("generated cluster",s,"as",filename)
|
||||
|
||||
|
||||
|
||||
|
|
@ -63,4 +63,4 @@ def make_unique(seq, idfun=None):
|
|||
if __name__ == '__main__':
|
||||
extract_random_clusters("shell-1.pdb",11,with_residues=[0,1,2])
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class PDBAtomParser(object):
|
|||
|
||||
@staticmethod
|
||||
def record(name,buf):
|
||||
# print inspect.getsource(PDBAtomParser.recordName)
|
||||
# print(inspect.getsource(PDBAtomParser.recordName) )
|
||||
ir=PDBAtomParser.irec[name]
|
||||
atype=PDBAtomParser.atype[name]
|
||||
value = buf[ir[0]:ir[1]]
|
||||
|
|
@ -82,11 +82,11 @@ if __name__ == '__main__':
|
|||
aline2="ATOM 588 GLU -13.363 -4.163 -2.372 1.00 0.00"
|
||||
aline3="ATTM 588 GLU -13.363 -4.163 -2.372 1.00 0.00"
|
||||
|
||||
print PDBAtomParser.record("name",aline2)
|
||||
print PDBAtomParser.record("name",aline1)
|
||||
print PDBAtomParser.getDict(aline1)
|
||||
print PDBAtomParser.getDict(aline2)
|
||||
print PDBAtomParser.getDict(aline3)
|
||||
print(PDBAtomParser.record("name",aline2) )
|
||||
print(PDBAtomParser.record("name",aline1) )
|
||||
print(PDBAtomParser.getDict(aline1))
|
||||
print(PDBAtomParser.getDict(aline2))
|
||||
print(PDBAtomParser.getDict(aline3))
|
||||
|
||||
|
||||
# 1 - 6 Record name "ATOM "
|
||||
|
|
@ -120,4 +120,4 @@ if __name__ == '__main__':
|
|||
# ATOM 294 2HG GLU 18 -13.518 -3.769 0.084 1.00 0.00 H
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class PDBAtomRecord(object):
|
|||
returns value of the "name" field in the provided "buf" buffer
|
||||
always returns None value if buffer is not of ATOM or HETATM type
|
||||
'''
|
||||
# print inspect.getsource(PDBAtomRecord.fieldName)
|
||||
# print(inspect.getsource(PDBAtomRecord.fieldName) )
|
||||
if not PDBAtomRecord.test(buf):
|
||||
return None
|
||||
ir=PDBAtomRecord.irec[name]
|
||||
|
|
@ -91,12 +91,12 @@ if __name__ == '__main__':
|
|||
aline2="ATOM 588 GLU -13.363 -4.163 -2.372 1.00 0.00"
|
||||
aline3="ATTM 588 GLU -13.363 -4.163 -2.372 1.00 0.00"
|
||||
|
||||
print PDBAtomRecord.field("name",'')
|
||||
print PDBAtomRecord.field("name",aline3)
|
||||
print PDBAtomRecord.dct(aline1)
|
||||
print PDBAtomRecord.dct(aline2)
|
||||
print PDBAtomRecord.dct(aline3)
|
||||
print PDBAtomRecord.dct('')
|
||||
print(PDBAtomRecord.field("name",'') )
|
||||
print(PDBAtomRecord.field("name",aline3) )
|
||||
print(PDBAtomRecord.dct(aline1))
|
||||
print(PDBAtomRecord.dct(aline2))
|
||||
print(PDBAtomRecord.dct(aline3))
|
||||
print(PDBAtomRecord.dct(''))
|
||||
|
||||
|
||||
# 1 - 6 Record name "ATOM "
|
||||
|
|
@ -130,4 +130,4 @@ if __name__ == '__main__':
|
|||
# ATOM 294 2HG GLU 18 -13.518 -3.769 0.084 1.00 0.00 H
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -99,25 +99,25 @@ class ResAtom(Atom):
|
|||
|
||||
if __name__ == '__main__':
|
||||
|
||||
print "creating first atom"
|
||||
print("creating first atom")
|
||||
aline1="ATOM 588 1HG GLU 18 -13.363 -4.163 -2.372 1.00 0.00 H"
|
||||
print aline1
|
||||
print(aline1)
|
||||
a = ResAtom.fromPDBrecord(aline1)
|
||||
print "it should come out as this"
|
||||
print a
|
||||
print("it should come out as this")
|
||||
print(a)
|
||||
aline2="ATOM 589 2HG GLU 18 -12.634 -3.023 -3.475 1.00 0.00 H"
|
||||
|
||||
print "creating second atom"
|
||||
print("creating second atom")
|
||||
aline2="ATOM 589 2HG GLU 18 -12.634 -3.023 -3.475 1.00 0.00 H"
|
||||
print aline2
|
||||
print(aline2)
|
||||
b = ResAtom.fromPDBrecord(aline2)
|
||||
print "it should come out as this"
|
||||
print b
|
||||
print("it should come out as this")
|
||||
print(b)
|
||||
|
||||
print "The distance between these two atoms is", Atom.bondlength(a, b)
|
||||
print("The distance between these two atoms is", Atom.bondlength(a, b))
|
||||
|
||||
print "PDB record for second atom with starting index 5 and resid 23"
|
||||
print b.toPDBrecord(id_atom=5,id_res=23)
|
||||
print("PDB record for second atom with starting index 5 and resid 23" )
|
||||
print(b.toPDBrecord(id_atom=5,id_res=23))
|
||||
|
||||
|
||||
# PDB ATOM RECORD FORMAT
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class Residue:
|
|||
self.name = a.resname
|
||||
else:
|
||||
if a.resname != self.name:
|
||||
print "different names for the same residue index"
|
||||
print("different names for the same residue index")
|
||||
sys.exit(1)
|
||||
self.atoms.append(a)
|
||||
|
||||
|
|
@ -61,4 +61,4 @@ if __name__ == '__main__':
|
|||
b = ResAtom.fromPDBrecord(aline1)
|
||||
res0.AddAtom(a)
|
||||
res0.AddAtom(b)
|
||||
print res0.toPDBrecord(id_atom=4)
|
||||
print(res0.toPDBrecord(id_atom=4))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class AtomDictionary():
|
|||
try:
|
||||
return d[s1.group(1)],s1.group(1)
|
||||
except KeyError:
|
||||
print "Cannot match name", a
|
||||
print("Cannot match name", a)
|
||||
sys.exit(1)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -517,7 +517,7 @@ class AtomDictionary():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print AtomDictionary.fullName(' H1 ')
|
||||
print AtomDictionary.vdwRadius('h')
|
||||
print(AtomDictionary.fullName(' H1 '))
|
||||
print(AtomDictionary.vdwRadius('h'))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,12 +65,12 @@ if __name__ == '__main__':
|
|||
try:
|
||||
b = Atom.fromPDBrecord(aline1)
|
||||
except SystemExit:
|
||||
print "error reading PDB line"
|
||||
print("error reading PDB line")
|
||||
sys.exit(1)
|
||||
try:
|
||||
a = Atom.fromPDBrecord(aline2)
|
||||
except SystemExit:
|
||||
print "error reading PDB line"
|
||||
print("error reading PDB line")
|
||||
sys.exit(1)
|
||||
print "bondlength is", Atom.bondlength(a,b)
|
||||
print "finished I am"
|
||||
print("bondlength is", Atom.bondlength(a,b))
|
||||
print("finished I am")
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class MyResidue:
|
|||
|
||||
def AddAtom(self,a1):
|
||||
self.atoms.append(a1)
|
||||
print self.atoms
|
||||
print(self.atoms)
|
||||
|
||||
if __name__ == '__main__':
|
||||
res0 = MyResidue("test")
|
||||
|
|
@ -36,9 +36,9 @@ if __name__ == '__main__':
|
|||
try:
|
||||
b = Atom.fromPDBrecord(aline1)
|
||||
except SystemExit:
|
||||
print "error reading PDB line"
|
||||
print("error reading PDB line")
|
||||
sys.exit(1)
|
||||
res0.AddAtom(b)
|
||||
# a = Atom.fromPDBrecord(aline2)
|
||||
# sim0.AddAtom(a)
|
||||
print res0
|
||||
print(res0)
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ if __name__ == '__main__':
|
|||
try:
|
||||
b = ResAtom.fromPDBrecord(aline1)
|
||||
except SystemExit:
|
||||
print "error reading PDB line"
|
||||
print("error reading PDB line")
|
||||
sys.exit(1)
|
||||
sim0.AddAtom(b)
|
||||
a = ResAtom.fromPDBrecord(aline2)
|
||||
sim0.AddAtom(a)
|
||||
sim1 = MySystem.fromPDBfile("test.pdb")
|
||||
print sim1.residues
|
||||
print(sim1.residues)
|
||||
|
||||
|
||||
# def AddAtom1(self,a1):
|
||||
|
|
@ -73,7 +73,7 @@ if __name__ == '__main__':
|
|||
# rmap[a1.resid]["atoms"]=[]
|
||||
# rmap[a1.resid]["name"]=a1.resname
|
||||
# if rmap[a1.resid]["name"]!=a1.resname:
|
||||
# print "different names for the same residue index"
|
||||
# print("different names for the same residue index")
|
||||
# sys.exit(1)
|
||||
# rmap[a1.resid]["atoms"].append(a1)
|
||||
# print "added atom", a1.resid
|
||||
# print "added atom", a1.resid
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ Created on Feb 4, 2012
|
|||
'''
|
||||
import math
|
||||
from numpy import array
|
||||
from functools import reduce
|
||||
|
||||
class Vector:
|
||||
def __init__(self, coord=[],name="Vector"):
|
||||
|
|
@ -24,7 +25,7 @@ class Vector:
|
|||
__rmul__ = __mul__
|
||||
|
||||
def __repr__(self):
|
||||
return `self.coord`
|
||||
return repr(self.coord)
|
||||
|
||||
def norm1(self, start=0):
|
||||
return reduce(lambda x,y: x + abs(y), self.coord, start)
|
||||
|
|
@ -45,17 +46,17 @@ class Vector:
|
|||
|
||||
def test():
|
||||
x = Vector([2, 4, 6])
|
||||
print x + 3, 3 + x
|
||||
print x * 4, 4 * x
|
||||
print x.norm1(), x.prod()
|
||||
print(x + 3, 3 + x)
|
||||
print(x * 4, 4 * x)
|
||||
print(x.norm1(), x.prod())
|
||||
|
||||
y = Vector([1, 2, 3])
|
||||
print x + y
|
||||
print x * y
|
||||
print x * y * 2
|
||||
print x * y * x
|
||||
print(x + y)
|
||||
print(x * y)
|
||||
print(x * y * 2)
|
||||
print(x * y * x)
|
||||
|
||||
z = Vector([1,1,1])
|
||||
print z.length(), math.sqrt(3.0), z.size
|
||||
print(z.length(), math.sqrt(3.0), z.size)
|
||||
|
||||
if __name__ == '__main__': test() # run my self-test code
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Vector(object):
|
|||
if __name__ == '__main__':
|
||||
a = Vector(1.0,1.0,0.0)
|
||||
b = Vector(1.0,1.0,0.0)
|
||||
print a
|
||||
print(a)
|
||||
c=a-b
|
||||
print c
|
||||
print "Length ", c.length()
|
||||
print(c)
|
||||
print("Length ", c.length())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue