本文整理匯總了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