Beispiel #1
0
def test_guess_impropers():
    u = make_starshape()

    ag = u.atoms[:5]

    u.add_TopologyAttr(Angles(guessers.guess_angles(ag.bonds)))

    vals = guessers.guess_improper_dihedrals(ag.angles)
    assert_equal(len(vals), 12)
Beispiel #2
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