예제 #1
0
    def _fb_potential2restraints(self, inputdir):
        from moleculekit.molecule import Molecule
        restraints = list()

        fb_box = np.array(self.fb_box)
        # convert fb_box to width
        width = list(
            np.concatenate(
                np.diff(np.array([fb_box[::2], fb_box[1::2]]), axis=0)))

        # If fb_box is not symmetrical
        if not np.all(fb_box[::2] == -fb_box[1::2]):
            # convert fb_box and fb_reference to fbcentre and width
            mol = Molecule(os.path.join(inputdir, self.acemd.structure))
            mol.read(os.path.join(inputdir, self.acemd.coordinates))
            fb_refcentre = mol.get(
                'coords', sel=self.fb_reference).mean(axis=0).squeeze()

            fbcentre = list(
                np.around(
                    np.mean(np.array([fb_box[::2], fb_box[1::2]]), axis=0) +
                    fb_refcentre, 3))
            restraints.append(
                GroupRestraint(self.fb_selection,
                               width, [(self.fb_k, 0)],
                               fbcentre=fbcentre))
        else:
            restraints.append(
                GroupRestraint(self.fb_selection,
                               width, [(self.fb_k, 0)],
                               fbcentresel=self.fb_reference))

        return restraints
예제 #2
0
    def test_acemd3(self):
        from htmd.util import tempname
        from htmd.home import home
        from htmd.units import convert
        from glob import glob
        import os
        from htmd.mdengine.acemd.acemd import GroupRestraint

        eq = Equilibration()
        eq.runtime = 4
        eq.timeunits = "ns"
        eq.temperature = 300
        eq.restraintsteps = convert(
            eq.timeunits, "timesteps", eq.runtime, timestep=eq.acemd.timestep
        )
        ligres = GroupRestraint(
            "resname MOL and noh",
            [42, 38, 1],
            [(5, 0)],
            fbcentre=[-0.178, -0.178, 29.195],
        )
        eq.restraints = eq.defaultEquilRestraints(1000000) + [ligres]
        tmpdir = tempname()
        eq.write(
            home(dataDir=os.path.join("test-protocols", "build", "protLig")), tmpdir
        )

        # Compare with reference
        refdir = home(
            dataDir=os.path.join(
                "test-protocols", "equilibration", "acemd3", "protLig", "prerun"
            )
        )
        files = [os.path.basename(f) for f in glob(os.path.join(refdir, "*"))]
        self._compareResultFolders(refdir, tmpdir, "protLig")