def get_bad(mol, gaff_atoms, amber_atoms, non_std_atom_indexes): """Computes the atoms involved in bonds, angles and dihedrals spanning both the non standard residue specified and and the rest of the protein. Returns mixed amber-gaff, gaff-gaff and amber-amber combinations""" from cc_notebook import unwind std_nn_ind = unwind([[n for n in mol.graph.neighbors[i] if n not in non_std_atom_indexes] for i in non_std_atom_indexes]) nstd_nn_ind = [[n for n in mol.graph.neighbors[i] if n in non_std_atom_indexes] for i in std_nn_ind] std_nnn_ind = [[n for n in mol.graph.neighbors[i] if n not in non_std_atom_indexes] for i in std_nn_ind] nstd_nnn_ind = [[n for n in mol.graph.neighbors[i] if n in non_std_atom_indexes] for i in unwind(nstd_nn_ind)] amb_std_nn = [amber_atoms[i] for i in std_nn_ind] amb_std_nnn = [[amber_atoms[i] for i in nnn_ind] for nnn_ind in std_nnn_ind] gaff_std_nn = [gaff_atoms[i] for i in std_nn_ind] gaff_std_nnn = [[gaff_atoms[i] for i in nnn_ind] for nnn_ind in std_nnn_ind] amb_nstd_nn = [[amber_atoms[i] for i in nn_ind] for nn_ind in nstd_nn_ind] amb_nstd_nnn = [[amber_atoms[i] for i in nnn_ind] for nnn_ind in nstd_nnn_ind] gaff_nstd_nn = [[gaff_atoms[i] for i in nn_ind] for nn_ind in nstd_nn_ind] gaff_nstd_nnn = [[gaff_atoms[i] for i in nnn_ind] for nnn_ind in nstd_nnn_ind] bonds, gbonds, abonds = [], [], [] for i in range(len(amb_std_nn)): for k in range(len(gaff_nstd_nn[i])): bonds.append([amb_std_nn[i], gaff_nstd_nn[i][k]]) gbonds.append([gaff_std_nn[i], gaff_nstd_nn[i][k]]) abonds.append([amb_std_nn[i], amb_nstd_nn[i][k]]) dihedrals, gdihedrals, adihedrals = [], [], [] for i in range(len(amb_std_nn)): for j in range(len(amb_std_nnn[i])): for k in range(len(gaff_nstd_nn[i])): for l in range(len(gaff_nstd_nnn[i])): dihedrals.append([amb_std_nnn[i][j], amb_std_nn[i], gaff_nstd_nn[i][k], gaff_nstd_nnn[i][l]]) gdihedrals.append([gaff_std_nnn[i][j], gaff_std_nn[i], gaff_nstd_nn[i][k], gaff_nstd_nnn[i][l]]) adihedrals.append([amb_std_nnn[i][j], amb_std_nn[i], amb_nstd_nn[i][k], amb_nstd_nnn[i][l]]) angles, gangles, aangles = [], [], [] for i in range(len(dihedrals)): ang1, ang2 = dihedrals[i][0:-1], dihedrals[i][1:] if ang1 not in angles: angles.append(ang1) gangles.append(gdihedrals[i][0:-1]) aangles.append(adihedrals[i][0:-1]) if ang2 not in angles: angles.append(ang2) gangles.append(gdihedrals[i][1:]) aangles.append(adihedrals[i][1:]) return {'mixed':[bonds, angles, dihedrals], 'gaff': [gbonds, gangles, gdihedrals] , 'amber': [abonds, aangles, adihedrals]}
def get_ht_ind(mol, non_std_atom_indexes): """returns the head and the tail index of the nonstandard residue specified""" from cc_notebook import unwind std_nn_ind = unwind([[n for n in mol.graph.neighbors[i] if n not in non_std_atom_indexes] for i in non_std_atom_indexes]) nstd_nn_ind = [[n for n in mol.graph.neighbors[i] if n in non_std_atom_indexes] for i in std_nn_ind] return unwind(nstd_nn_ind) - non_std_atom_indexes[0]