def generate_exclusion_idxs(mol, scale12, scale13, scale14): """ Generate exclusions for a mol based on the all pairs shortest path. We always take the convention that exclusions for smaller distances override those of longer distances. Parameters ---------- mol: Chem.ROMol romol scale12: float bond scales scale13: float angle scales scale14: float torsions scales """ exclusions = {} g = convert_to_nx(mol) for path in nx.all_pairs_shortest_path_length(g, cutoff=3): src = path[0] for dst, length in path[1].items(): if length == 0: continue else: if length == 1: scale = scale12 elif length == 2: scale = scale13 elif length == 3: scale = scale14 else: assert 0 exclusions[sort_tuple((src, dst))] = scale idxs = list(exclusions.keys()) scales = list(exclusions.values()) return np.array(idxs, dtype=np.int32), np.array(scales, dtype=np.float64)
def generate_vd_idxs(mol, smirks): """ Generate bonded indices using a valence dict. The indices generated are assumed to be reversible. i.e. reversing the indices evaluates to an identical energy. This is not intended to be used for ImproperTorsions. """ vd = {} for p_idx, patt in enumerate(smirks): matches = match_smirks(mol, patt) for m in matches: sorted_m = sort_tuple(m) vd[sorted_m] = p_idx bond_idxs = np.array(list(vd.keys()), dtype=np.int32) param_idxs = np.array(list(vd.values()), dtype=np.int32) return bond_idxs, param_idxs