Пример #1
0
def make_starshape():
        u = make_Universe()
        bonds = []
        for seg in range(5):
            segbase = seg * 25
            for res in range(5):
                # offset for atoms in this res
                base = segbase + 5 * res
                bonds.append((0 + base, 1 + base))
                bonds.append((1 + base, 2 + base))
                bonds.append((1 + base, 3 + base))
                bonds.append((1 + base, 4 + base))
                if not res == 4:  # last res doesn't link onwards
                    bonds.append((4 + base, 5 + base))
        u.add_TopologyAttr(Bonds(bonds))
        return u
Пример #2
0
 def universe(self):
     universe = mda.Universe(Make_Whole)
     bondlist = [(0, 1), (1, 2), (1, 3), (1, 4), (4, 5), (4, 6), (4, 7)]
     universe.add_TopologyAttr(Bonds(bondlist))
     return universe
Пример #3
0
 def _load_bonds(self):
     # Load some bonds into Universe, not required for all tests
     bondlist = [(0, 1), (1, 2), (1, 3), (1, 4), (4, 5), (4, 6), (4, 7)]
     self.u.add_TopologyAttr(Bonds(bondlist))
Пример #4
0
    def parse(self):
        """
        Access ESPResSo data and return the topology object.

        Returns
        -------

        top : :class:`MDAnalysis.core.topology.Topology`
            a topology object

        """
        espresso = self.kwargs['espresso']

        names = []
        atomtypes = []
        masses = []
        charges = []
        bonds = []
        angles = []
        dihedrals = []

        for p in espresso.part:
            names.append("A" + repr(p.type))
            atomtypes.append("T" + repr(p.type))
            masses.append(p.mass)
            charges.append(p.q)
            for bond in p.bonds:
                partner_ids = bond[1:]
                n_partner = len(partner_ids)
                if n_partner == 1:
                    bonds.append((p.id, partner_ids[0]))
                elif n_partner == 2:
                    angles.append((partner_ids[0], p.id, partner_ids[1]))
                elif n_partner == 3:
                    dihedrals.append(
                        (partner_ids[0], p.id, partner_ids[1], partner_ids[2]))
                else:
                    continue
        natoms = len(espresso.part)
        attrs = [
            Atomnames(np.array(names, dtype=object)),
            Atomids(np.arange(natoms) + 1),
            Atomtypes(np.array(atomtypes, dtype=object)),
            Masses(masses),
            Resids(np.array([1])),
            Resnums(np.array([1])),
            Segids(np.array(['System'], dtype=object)),
            AltLocs(np.array([' '] * natoms, dtype=object)),
            Resnames(np.array(['R'], dtype=object)),
            Occupancies(np.zeros(natoms)),
            Tempfactors(np.zeros(natoms)),
            ICodes(np.array([' '], dtype=object)),
            Charges(np.array(charges)),
            Bonds(bonds),
            Angles(angles),
            Dihedrals(dihedrals)
        ]

        top = Topology(natoms, 1, 1, attrs=attrs)

        return top