def get_components_neighbors(mol, atoms): atoms = list(atoms) for idx in atoms: idx, = idx A = mol.GetAtomWithIdx(idx) for B in A.GetNeighbors(): idx_b = B.GetIdx() atom = B.GetAtomicNum() charge = B.GetFormalCharge() bond = Chem.GetBondBetweenAtoms(mol, idx, idx_b) return