Ejemplo n.º 1
0
    def write(self, inputdir, outputdir):
        """ Write the equilibration protocol

        Writes the equilibration protocol and files into a folder for execution
        using files inside the inputdir directory

        Parameters
        ----------
        inputdir : str
            Path to a directory containing the files produced by a build process.
        outputdir : str
            Directory where to write the equilibration setup files.

        Examples
        --------
        >>> md = Equilibration()
        >>> md.write('./build','./equil')
        """
        self._findFiles(inputdir)
        self._amberFixes()

        from htmd.units import convert
        numsteps = convert(self.timeunits,
                           'timesteps',
                           self.runtime,
                           timestep=self.acemd.timestep)
        self.acemd.temperature = self.temperature
        self.acemd.thermostattemp = self.temperature
        self.acemd.run = str(numsteps)

        if self.constraintsteps is None:
            constrsteps = int(numsteps / 2)
        else:
            constrsteps = int(self.constraintsteps)

        # Adding the default restraints of the equilibration
        restraints = list()
        restraints.append(
            AtomRestraint('protein and noh and not name CA', 0,
                          [(0.1, 0), (0, constrsteps)]))
        restraints.append(
            AtomRestraint('protein and name CA', 0, [(1, 0),
                                                     (0, constrsteps)]))
        if self.restraints is not None:
            restraints += self.restraints
        self.acemd.restraints = restraints

        if self.acemd.celldimension is None and self.acemd.extendedsystem is None:
            inmol = Molecule(os.path.join(inputdir, self.acemd.coordinates))
            coords = inmol.get('coords', sel='water')
            if coords.size == 0:  # It's a vacuum simulation
                coords = inmol.get('coords', sel='all')
                dim = np.max(coords, axis=0) - np.min(coords, axis=0)
                dim = dim + 12.
            else:
                dim = np.max(coords, axis=0) - np.min(coords, axis=0)
            self.acemd.celldimension = '{} {} {}'.format(
                dim[0], dim[1], dim[2])
        if self.useconstantratio:
            self.acemd.useconstantratio = 'on'
        self.acemd.setup(inputdir, outputdir, overwrite=True)
Ejemplo n.º 2
0
    # Compare with reference
    refdir = home(dataDir=os.path.join('test-equilibration', pdbid, 'prerun'))
    files = [os.path.basename(f) for f in glob(os.path.join(refdir, '*'))]
    match, mismatch, error = filecmp.cmpfiles(refdir,
                                              tmpdir,
                                              files,
                                              shallow=False)

    if len(mismatch) != 0 or len(error) != 0 or len(match) != len(files):
        raise RuntimeError(
            'Different results produced by Equilibration.write for '
            'test {} between {} and {} in files {}.'.format(
                pdbid, refdir, tmpdir, mismatch))

    # from htmd.protocols.production_v5 import ProductionAcemd3, GroupRestraint, AtomRestraint
    r = list()
    r.append(
        GroupRestraint('segid P2',
                       5, [(10, '10ns'), (5, '15ns'), (0, '20ns')],
                       axes='z'))
    r.append(
        AtomRestraint('segid P1 and name CA', 0.1, [(10, '10ns'), (5, '15ns'),
                                                    (0, '20ns')]))

    eq = EquilibrationAcemd3()
    eq.runtime = 4
    eq.timeunits = 'ns'
    eq.temperature = 300
    eq.restraints = r
    # eq.write('/workspace5/pablo/bound_KIX_cMYB/1_build/2-struct/', '/tmp/testdir2/')