本文整理匯總了Python中MolKit.molecule.AtomSet.bl方法的典型用法代碼示例。如果您正苦於以下問題:Python AtomSet.bl方法的具體用法?Python AtomSet.bl怎麽用?Python AtomSet.bl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MolKit.molecule.AtomSet
的用法示例。
在下文中一共展示了AtomSet.bl方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getDonors
# 需要導入模塊: from MolKit.molecule import AtomSet [as 別名]
# 或者: from MolKit.molecule.AtomSet import bl [as 別名]
def getDonors(self, nodes, paramDict):
donorList = paramDict['donorTypes']
#print 'donorList=', donorList
# currently this is a set of hydrogens
hats = AtomSet(nodes.get(lambda x: x.element=='H'))
#hats are optional: if none, process donors
# if there are hats: dAts are all atoms bonded to all hydrogens
if hats:
dAts = AtomSet([])
for at in hats:
for b in at.bonds:
at2 = b.atom1
if id(at2)==id(at): at2 = b.atom2
dAts.append(at2)
#dAts.append(b.neighborAtom(at))
else:
dAts = nodes
#get the sp2 hybridized possible donors which are all ns
sp2 = []
for t in ['Nam', 'Ng+', 'Npl']:
if t in donorList:
sp2.append(t)
#ntypes = ['Nam', 'Ng+', 'Npl']
sp2DAts = None
if len(sp2):
sp2DAts = AtomSet(dAts.get(lambda x, sp2=sp2: x.babel_type in sp2))
hsp2 = AtomSet([])
if sp2DAts:
if hats:
hsp2 = AtomSet(hats.get(lambda x, sp2DAts=sp2DAts:x.bonds[0].atom1 \
in sp2DAts or x.bonds[0].atom2 in sp2DAts))
if sp2DAts:
#remove any sp2 N atoms which already have 3 bonds not to hydrogens
n2Dons = AtomSet(sp2DAts.get(lambda x: x.element=='N'))
if n2Dons:
n2Dons.bl=0
for at in n2Dons:
for b in at.bonds:
if type(b.bondOrder)==type(2):
at.bl = at.bl + b.bondOrder
else:
at.bl = at.bl + 2
#allow that there might already be a hydrogen
nH = at.findHydrogens()
at.bl = at.bl - len(nH)
badAts = AtomSet(n2Dons.get(lambda x: x.bl>2))
if badAts:
sp2DAts = sp2DAts - badAts
delattr(n2Dons,'bl')
#get the sp3 hybridized possible donors
sp3 = []
for t in ['N3+', 'S3', 'O3']:
if t in donorList:
sp3.append(t)
n3DAts = None
if 'N3+' in sp3:
n3DAts = AtomSet(dAts.get(lambda x: x.babel_type=='N3+'))
o3DAts = None
if 'O3' in sp3:
o3DAts = AtomSet(dAts.get(lambda x: x.babel_type=='O3'))
if o3DAts:
#remove any O3 atoms which already have 2 bonds not to hydrogens
badO3s = AtomSet([])
for at in o3DAts:
if len(at.bonds)<2: continue
if len(at.findHydrogens()): continue
else:
badO3s.append(at)
if len(badO3s):
o3DAts = o3DAts - badO3s
s3DAts = None
if 'S3' in sp3:
s3DAts = AtomSet(dAts.get(lambda x: x.babel_type=='S3'))
sp3DAts = AtomSet([])
for item in [n3DAts, o3DAts, s3DAts]:
if item:
sp3DAts = sp3DAts + item
hsp3 = AtomSet([])
if sp3DAts:
if hats:
hsp3 = AtomSet(hats.get(lambda x, sp3DAts=sp3DAts:x.bonds[0].atom1 \
in sp3DAts or x.bonds[0].atom2 in sp3DAts))
hsp = hsp2 + hsp3
#print 'hsp=', hsp.name
#print 'sp2DAts=', sp2DAts.name
#print 'sp3DAts=', sp3DAts.name
return hsp, sp2DAts, sp3DAts