Пример #1
0
    def __init__(self,
                 topology,
                 selstr=None,
                 deg=False,
                 cossin=False,
                 periodic=True):
        indices = indices_phi(topology)

        if not selstr:
            self._phi_inds = indices
        else:
            self._phi_inds = indices[np.in1d(indices[:, 1],
                                             topology.select(selstr),
                                             assume_unique=True)]

        indices = indices_psi(topology)
        if not selstr:
            self._psi_inds = indices
        else:
            self._psi_inds = indices[np.in1d(indices[:, 1],
                                             topology.select(selstr),
                                             assume_unique=True)]

        # alternate phi, psi pairs (phi_1, psi_1, ..., phi_n, psi_n)
        dih_indexes = np.array(
            list(phi_psi
                 for phi_psi in zip(self._phi_inds, self._psi_inds))).reshape(
                     -1, 4)

        super(BackboneTorsionFeature, self).__init__(topology,
                                                     dih_indexes,
                                                     deg=deg,
                                                     cossin=cossin,
                                                     periodic=periodic)
Пример #2
0
def _dihedral_indices(top: md.Topology, which: str) -> np.ndarray:
    indices = [indices_phi(top),
               indices_psi(top)]
    if which == 'all':
        indices.extend([indices_chi1(top),
                         indices_chi2(top),
                         indices_chi3(top),
                         indices_chi4(top),
                         indices_chi5(top)])
    indices = np.vstack(indices)
    assert indices.shape[1] == 4
    return indices