本文整理汇总了Python中MolKit.molecule.AtomSet.uniq方法的典型用法代码示例。如果您正苦于以下问题:Python AtomSet.uniq方法的具体用法?Python AtomSet.uniq怎么用?Python AtomSet.uniq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MolKit.molecule.AtomSet
的用法示例。
在下文中一共展示了AtomSet.uniq方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: removeNeighbors
# 需要导入模块: from MolKit.molecule import AtomSet [as 别名]
# 或者: from MolKit.molecule.AtomSet import uniq [as 别名]
def removeNeighbors(self, atDict):
#filter out at-itself and at-bondedat up to 1:4
#NB keys could be hydrogens OR donors
for at in atDict.keys():
closeAts = atDict[at]
bondedAts = AtomSet([])
for b in at.bonds:
###at2 = b.neighborAtom(at)
at2 = b.atom1
if id(at2)==id(at): at2 = b.atom2
bondedAts.append(at2)
#9/13 remove this:
##also remove 1-3
for b2 in at2.bonds:
at3 = b2.atom1
if id(at3)==id(at2): at3 = b.atom2
#at3 = b2.neighborAtom(at2)
if id(at3)!=id(at):
bondedAts.append(at3)
#for b3 in at3.bonds:
#at4 = b2.neighborAtom(at3)
#if at4!=at and at4!=at2:
#bondedAts.append(at4)
bondedAts = bondedAts.uniq()
goodAts = []
for i in range(len(closeAts)):
cAt = closeAts[i]
if cAt not in bondedAts:
goodAts.append(cAt)
if len(goodAts):
atDict[at] = goodAts
else:
del atDict[at]
return atDict
示例2: setAromaticCarbons
# 需要导入模块: from MolKit.molecule import AtomSet [as 别名]
# 或者: from MolKit.molecule.AtomSet import uniq [as 别名]
def setAromaticCarbons(self, molecule, cutoff=None, debug=False):
assert len(molecule.allAtoms.bonds[0])
if cutoff:
if cutoff!=self.cutoff:
old_aromCs = molecule.allAtoms.get(lambda x:\
(x.element=='C' and x.autodock_element=='A'))
if old_aromCs is not None and len(old_aromCs)!=0:
if debug: print "resetting ", len(old_aromCs), " prior aromCs"
self.set_carbon_names(old_aromCs, 'C')
self.cutoff = cutoff
typed_atoms = molecule.allAtoms.get(lambda x: hasattr(x, 'autodock_element'))
currentAromCs = AtomSet()
if typed_atoms is not None and len(typed_atoms)==len(molecule.allAtoms):
currentAromCs = molecule.allAtoms.get(lambda x: (x.element=='C' and x.autodock_element=='A'))
if debug:
if currentAromCs is not None and len(currentAromCs):
print "now: ", len(currentAromCs)
else:
print "now: no aromCs"
aromBnds = self.aromBndSel.select(molecule.allAtoms.bonds[0],
self.cutoff)
aromBndAts = self.aromBndSel.getAtoms(aromBnds)
result = AtomSet()
changed = AtomSet()
if len(aromBndAts):
aromCs = AtomSet(filter(lambda x: x.element=='C', \
aromBndAts))
aromCs = aromCs.uniq()
if len(aromCs)>len(result):
result = aromCs
if debug:
print "len(aromCs)=", len(aromCs)
changed = self.set_carbon_names(aromCs, 'A')
#if len(changed)>len(result):
# result = changed
#return result
return changed