mirror of
https://github.com/nwchemgit/nwchem.git
synced 2026-07-29 06:35:39 -04:00
updates
This commit is contained in:
parent
ca01bed956
commit
c8e4bd7ea6
1 changed files with 70 additions and 20 deletions
|
|
@ -40,7 +40,17 @@ class GenericAtom(object):
|
|||
if d:
|
||||
return cls(d)
|
||||
return None
|
||||
|
||||
|
||||
@classmethod
|
||||
def fromXYZrecord(cls,aline):
|
||||
atomstr = string.split(aline)[0:4]
|
||||
if len(atomstr) < 4:
|
||||
return None
|
||||
|
||||
name = atomstr[0]
|
||||
coord=[float(x) for x in atomstr[1:]]
|
||||
return cls({"grouptag":"XYZ", "coord":coord,"name":name})
|
||||
|
||||
@staticmethod
|
||||
def bondlength(a1,a2):
|
||||
dr=a1.coord-a2.coord
|
||||
|
|
@ -57,9 +67,44 @@ class GenericAtom(object):
|
|||
Default values of "UNK" and "0" are used should
|
||||
residue name and residue id be absent
|
||||
'''
|
||||
tag = self.dct.get("grouptag")
|
||||
if tag is None:
|
||||
resname = self.dct.get("resname","UNK").strip()
|
||||
resid = str(self.dct.get("resid",0)).strip()
|
||||
tag ="_".join((resname,resid))
|
||||
|
||||
return tag
|
||||
|
||||
def setGroupTag(self,tag):
|
||||
'''
|
||||
returns that identifies group association of an atom
|
||||
based on residue name and residue id (e.g. "ASP_1")
|
||||
Default values of "UNK" and "0" are used should
|
||||
residue name and residue id be absent
|
||||
'''
|
||||
self.dct["grouptag"]=tag
|
||||
|
||||
def resTag(self):
|
||||
'''
|
||||
returns that identifies res association of an atom
|
||||
based on residue name and residue id (e.g. "ASP_1")
|
||||
'''
|
||||
|
||||
resname = self.dct.get("resname","UNK").strip()
|
||||
resid = str(self.dct.get("resid",0)).strip()
|
||||
return "_".join((resname,resid))
|
||||
tag ="_".join((resname,resid))
|
||||
|
||||
return tag
|
||||
def setBond(self,i):
|
||||
'''
|
||||
returns that identifies group association of an atom
|
||||
based on residue name and residue id (e.g. "ASP_1")
|
||||
Default values of "UNK" and "0" are used should
|
||||
residue name and residue id be absent
|
||||
'''
|
||||
bond = self.dct.setdefault("bond",set())
|
||||
bond.add(i)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return str(self.dct) + " " + str(self.coord)
|
||||
|
|
@ -71,21 +116,26 @@ class GenericAtom(object):
|
|||
return dr <= (a1.covRadius()+a2.covRadius())
|
||||
|
||||
if __name__ == '__main__':
|
||||
aline1="ATOM 588 1HG GLU 18 -13.363 -4.163 -2.372 1.00 0.00 H"
|
||||
aline2="ATOM 1 I1 IO3 1 -1.555 -0.350 0.333 1.39 I"
|
||||
aline3="ATOM 2 O1 IO3 1 -0.985 -1.156 1.840 -0.80 O"
|
||||
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
|
||||
b=GenericAtom.fromPDBrecord(aline3)
|
||||
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)
|
||||
c=GenericAtom.fromPDBrecord(aline4)
|
||||
print c.groupTag()
|
||||
# aline1="ATOM 588 1HG GLU 18 -13.363 -4.163 -2.372 1.00 0.00 H"
|
||||
# aline2="ATOM 1 I1 IO3 1 -1.555 -0.350 0.333 1.39 I"
|
||||
# aline3="ATOM 2 O1 IO3 1 -0.985 -1.156 1.840 -0.80 O"
|
||||
# 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
|
||||
# b=GenericAtom.fromPDBrecord(aline3)
|
||||
# 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)
|
||||
# c=GenericAtom.fromPDBrecord(aline4)
|
||||
# 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)
|
||||
print d
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue