Beispiel #1
0
 def _get_box_from_ag_coe(self, ag: prody.AtomGroup):
     coords = ag.getCoords()
     cmax, cmin = coords.max(0), coords.min(0)
     coe = (cmax + cmin) / 2
     size = self._get_box_size_from_ag_and_center(ag, coe)
     origin = coe - size * self.cell / 2
     return origin.astype(float), size.astype(int) + 1
Beispiel #2
0
    def from_prody_atomgroup(
        cls,
        name: ProteinKey,
        protein: pd.AtomGroup,
        split_type: SplitType = SplitType.KMER,
        split_size: int = 16,
        selection: str = "calpha",
        upsample_rate: int = 50,
        moment_types: List[MomentType] = (
            MomentType.O_3,
            MomentType.O_4,
            MomentType.O_5,
            MomentType.F,
        ),
    ):
        """
        Construct MomentInvariants instance from a ProDy AtomGroup object.
        Selects according to `selection` string, (default = alpha carbons)
        `moment_types` determines which moments are calculated.

        Example
        --------
        >>> invariants = MomentInvariants.from_prody_atomgroup(atom_group, split_type=SplitType.RADIUS, moment_types=[MomentType.O_3, MomentType.F, MomentType.phi_7, MomentType.phi_12])
        """
        protein: pd.AtomGroup = protein.select("protein").select(selection)
        coordinates: np.ndarray = protein.getCoords()
        residue_splits = group_indices(protein.getResindices())
        shape = cls(
            name,
            len(residue_splits),
            coordinates,
            residue_splits,
            protein.getIndices(),
            sequence=protein.getSequence(),
            split_type=split_type,
            split_size=split_size,
            upsample_rate=upsample_rate,
            moment_types=moment_types,
        )
        shape._split(split_type)
        return shape
Beispiel #3
0
 def _get_com(self, ag: prody.AtomGroup):
     return ag.getCoords().mean(axis=0)
Beispiel #4
0
 def _get_coe(self, ag: prody.AtomGroup):
     coords = ag.getCoords()
     cmax, cmin = coords.max(0), coords.min(0)
     coe = (cmax + cmin) / 2
     return coe
Beispiel #5
0
 def _get_box_from_ag_com(self, ag: prody.AtomGroup):
     coords = ag.getCoords()
     com = coords.mean(axis=0)
     size = self._get_box_size_from_ag_and_center(ag, com)
     origin = com - size * self.cell / 2
     return origin.astype(float), size.astype(int) + 1