本文整理汇总了Python中openbabel.OBAtomAtomIter方法的典型用法代码示例。如果您正苦于以下问题:Python openbabel.OBAtomAtomIter方法的具体用法?Python openbabel.OBAtomAtomIter怎么用?Python openbabel.OBAtomAtomIter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openbabel
的用法示例。
在下文中一共展示了openbabel.OBAtomAtomIter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_connectivity
# 需要导入模块: import openbabel [as 别名]
# 或者: from openbabel import OBAtomAtomIter [as 别名]
def get_connectivity(self):
'''
Retrieve the connectivity matrix of the molecule.
Returns:
numpy.ndarray: (n_atoms x n_atoms) array containing the pairwise bond orders
between atoms (0 for no bond).
'''
if self._connectivity is None:
# get connectivity matrix
connectivity = np.zeros((self.n_atoms, len(self.numbers)))
for atom in ob.OBMolAtomIter(self.get_obmol()):
index = atom.GetIdx() - 1
# loop over all neighbors of atom
for neighbor in ob.OBAtomAtomIter(atom):
idx = neighbor.GetIdx() - 1
bond_order = neighbor.GetBond(atom).GetBO()
#print(f'{index}-{idx}: {bond_order}')
# do not count bonds between two hydrogen atoms
if (self.numbers[index] == 1 and self.numbers[idx] == 1
and bond_order > 0):
bond_order = 0
connectivity[index, idx] = bond_order
self._connectivity = connectivity
return self._connectivity
示例2: neighbors
# 需要导入模块: import openbabel [as 别名]
# 或者: from openbabel import OBAtomAtomIter [as 别名]
def neighbors(self):
return [Atom(a) for a in OBAtomAtomIter(self.OBAtom)]
示例3: get_hydrogen_from_aa
# 需要导入模块: import openbabel [as 别名]
# 或者: from openbabel import OBAtomAtomIter [as 别名]
def get_hydrogen_from_aa(residueid):
class AAselect(Select):
def accept_residue(self, residue):
# print residue.get_full_id()[3][1],residueid
if str(residue.get_full_id()[3][1]) == residueid:
return 1
else:
return 0
ptemp = PDBParser(QUIET=True)
stemp = ptemp.get_structure(
pdbname, projectdir + 'pdbs/' + pdbname + '.pdb')
temp_aa_id = residueid
io = PDBIO()
io.set_structure(stemp)
io.save(projectdir + 'temp/' + residueid + '.pdb', AAselect())
mol = pybel.readfile("pdb", projectdir + 'temp/' +
residueid + '.pdb').next()
mol.OBMol.AddHydrogens(False, True, 7.4)
# print hetflag
donors = []
for atom in mol:
if getattr(atom, 'OBAtom').IsHbondDonor():
chargevector = Vector(getattr(atom, 'coords'))
# print getattr(atom,'type')," is Donor",chargevector
temphatoms = []
for neighbor in pybel.ob.OBAtomAtomIter(atom.OBAtom):
neighbor = pybel.Atom(neighbor)
if getattr(neighbor, 'type') == "H":
# print "neighbor
# Atom",getattr(neighbor,'type'),"Coords:",getattr(neighbor,'coords')
temphatoms.append(Vector(getattr(neighbor, 'coords')))
donors.append([getattr(atom, 'type'), chargevector, temphatoms,getattr(atom, 'OBAtom').IsHbondAcceptor()])
if getattr(atom, 'OBAtom').IsHbondAcceptor():
chargevector = Vector(getattr(atom, 'coords'))
#print getattr(atom, 'type'),chargevector,'acceptor!'
return donors