當前位置: 首頁>>代碼示例>>Python>>正文


Python openbabel.OBAtomAtomIter方法代碼示例

本文整理匯總了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 
開發者ID:atomistic-machine-learning,項目名稱:G-SchNet,代碼行數:27,代碼來源:utility_classes.py

示例2: neighbors

# 需要導入模塊: import openbabel [as 別名]
# 或者: from openbabel import OBAtomAtomIter [as 別名]
def neighbors(self):
        return [Atom(a) for a in OBAtomAtomIter(self.OBAtom)] 
開發者ID:oddt,項目名稱:oddt,代碼行數:4,代碼來源:ob.py

示例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 
開發者ID:protwis,項目名稱:protwis,代碼行數:46,代碼來源:legacy_functions.py


注:本文中的openbabel.OBAtomAtomIter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。