Exemplo n.º 1
0
def refTop():
    return topology.Topology(
        3, 2, 2,
        attrs = [
            ta.Atomnames(TA_FILLER[object]),
            ta.Masses(TA_FILLER[float]),
            ta.Resids(TA_FILLER[int]),
            ta.Bonds(TA_FILLER['bond']),
        ],
        atom_resindex=np.array([0, 0, 1]),
        residue_segindex=np.array([0, 1])
    )
Exemplo n.º 2
0
 def setUp(self):
     names = self.names = ta.Atomnames(
         np.array(['A', 'B', 'C'], dtype=object))
     types = self.types = ta.Atomtypes(np.array(['X', 'Y', 'Z'],
                                                dtype=object),
                                       guessed=True)
     resids = self.resids = ta.Resids(np.array([1]))
     resnames = self.resnames = ta.Resnames(np.array(['ABC'], dtype=object),
                                            guessed=True)
     self.top = Topology(n_atoms=3,
                         n_res=1,
                         attrs=[names, types, resids, resnames])
Exemplo n.º 3
0
def make_resids(size):
    """Resids 1 and upwards"""
    import MDAnalysis.core.topologyattrs as ta
    na, nr, ns = size
    return ta.Resids(np.arange(nr, dtype=np.int64) + 1)
Exemplo n.º 4
0
    def _apply_map(self, mapping):
        """Apply the mapping scheme to the beads.

        Parameters
        ----------
        mapping : dict
            Mapping definitions per bead/

        Returns
        -------
        :class:`~MDAnalysis.core.topology.Topology` defining the new universe.
        """
        # Allocate arrays
        _beads = []
        atomnames = []
        atomids = []
        resids = []
        resnames = []
        segids = []
        charges = []
        masses = []

        residues = self.atu.atoms.split("residue")
        select_residues = enumerate(
            itertools.product(residues, viewitems(mapping)))
        for i, (res, (name, selection)) in select_residues:
            if name != "CB":
                bead = res.select_atoms(selection)
            else:
                bead = res.select_atoms(
                    selection.get(res.resname[0],
                                  "hsidechain and not name H*"))
            if bead:
                _beads.append(bead)
                atomnames.append(name)
                atomids.append(i)
                resids.append(bead.resids[0])
                resnames.append(bead.resnames[0])
                segids.append(bead.segids[0].split("_")[-1])
                try:
                    charges.append(bead.total_charge())
                except AttributeError:
                    charges.append(0.)
                masses.append(bead.total_mass())

        _beads = np.array(_beads)
        n_atoms = len(_beads)

        # Atom
        # _beads = topattrs._Beads(_beads)
        vdwradii = np.zeros_like(atomids)
        vdwradii = topologyattrs.Radii(vdwradii)
        atomids = topologyattrs.Atomids(np.asarray(atomids))
        atomnames = topologyattrs.Atomnames(
            np.asarray(atomnames, dtype=np.object))
        atomtypes = topologyattrs.Atomtypes(
            np.asarray(np.arange(n_atoms) + 100))
        charges = topologyattrs.Charges(np.asarray(charges))
        masses = topologyattrs.Masses(np.asarray(masses))

        # Residue
        # resids, resnames
        segids = np.asarray(segids, dtype=np.object)
        resids = np.asarray(resids)
        resnames = np.asarray(resnames, dtype=np.object)
        residx, (new_resids, new_resnames, new_segids) = topbase.change_squash(
            (resids, ), (resids, resnames, segids))

        # transform from atom:Rid to atom:Rix
        residueids = topologyattrs.Resids(new_resids)
        residuenums = topologyattrs.Resnums(new_resids.copy())
        residuenames = topologyattrs.Resnames(new_resnames)

        # Segment
        segidx, (perseg_segids, ) = topbase.change_squash((new_segids, ),
                                                          (new_segids, ))
        segids = topologyattrs.Segids(perseg_segids)

        # Setup topology
        top = topology.Topology(len(atomids),
                                len(new_resids),
                                len(segids),
                                attrs=[
                                    atomids, atomnames, atomtypes, charges,
                                    masses, vdwradii, residueids, residuenums,
                                    residuenames, segids
                                ],
                                atom_resindex=residx,
                                residue_segindex=segidx)
        return top
Exemplo n.º 5
0
 def resids(self):
     return ta.Resids(np.array([1]))