def radical_group_dct(gra): """ return a dictionary of lists of groups attached each radical """ gra = without_fractional_bonds(gra) groups = {} rads = list(sing_res_dom_radical_atom_keys(gra)) atms = atoms(gra) for rad in rads: key = atms[rad][0] if key in groups: groups[atms[rad][0]] += atom_groups(gra, rad) else: groups[atms[rad][0]] = atom_groups(gra, rad) return groups
def radical_groups(gra): """ returns a list of lists of groups attached each radical """ gra = without_fractional_bonds(gra) groups = [] rads = sing_res_dom_radical_atom_keys(gra) for rad in rads: groups.append(atom_groups(gra, rad)) return groups
def radical_dissociation_prods(gra, pgra1): """ given a dissociation product, determine the other product """ gra = without_fractional_bonds(gra) pgra2 = None rads = sing_res_dom_radical_atom_keys(gra) adj_atms = atoms_neighbor_atom_keys(gra) # adj_idxs = tuple(adj_atms[rad] for rad in rads) for rad in rads: for adj in adj_atms[rad]: for group in atom_groups(gra, adj, stereo=False): if isomorphism(group, pgra1, backbone_only=True): pgra2 = remove_atoms(gra, atom_keys(group)) # pgra2 = remove_bonds(pgra2, bond_keys(group)) if bond_keys(group) in pgra2: pgra2 = remove_bonds(pgra2, bond_keys(group)) return (pgra1, pgra2)
def radical_dissociation_products(gra, pgra1): """ For a given species, determine the products of a dissociation occuring around a radical site. We assume one of the dissociation products is known, and we attempt to find the corresponding product. Currently, we assume that the input pgra1 is appropriately stereolabeled. :param gra: species undergoing dissociation :type gra: automol.graph object :param pgra1: one of the known products of dissociation :type pgra1: automol.graph object :rtype: tuple(automol.graph.object) """ # Remove gractional bonds for functions to work gra = without_fractional_bonds(gra) # Attempt to find a graph of product corresponding to pgra1 pgra2 = None for rad in sing_res_dom_radical_atom_keys(gra): for adj in atoms_neighbor_atom_keys(gra)[rad]: for group in atom_groups(gra, adj, stereo=False): if isomorphism(group, pgra1, backbone_only=True): pgra2 = remove_atoms(gra, atom_keys(group)) if bond_keys(group) in pgra2: pgra2 = remove_bonds(pgra2, bond_keys(group)) # If pgra2 is ID'd, rebuild the two product graphs with stereo labels if pgra2 is not None: keys2 = atom_keys(pgra2) idx_gra = to_index_based_stereo(gra) idx_pgra2 = subgraph(idx_gra, keys2, stereo=True) pgra2 = from_index_based_stereo(idx_pgra2) return pgra1, pgra2