当前位置: 首页>>代码示例>>Python>>正文


Python PDBFile.writeFooter方法代码示例

本文整理汇总了Python中simtk.openmm.app.PDBFile.writeFooter方法的典型用法代码示例。如果您正苦于以下问题:Python PDBFile.writeFooter方法的具体用法?Python PDBFile.writeFooter怎么用?Python PDBFile.writeFooter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simtk.openmm.app.PDBFile的用法示例。


在下文中一共展示了PDBFile.writeFooter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __del__

# 需要导入模块: from simtk.openmm.app import PDBFile [as 别名]
# 或者: from simtk.openmm.app.PDBFile import writeFooter [as 别名]
 def __del__(self):
     if self._topology is not None:
         PDBFile.writeFooter(self._topology, self._out)
     self._out.close()
开发者ID:Omegaice,项目名称:openmm,代码行数:6,代码来源:pdbreporter.py

示例2: __del__

# 需要导入模块: from simtk.openmm.app import PDBFile [as 别名]
# 或者: from simtk.openmm.app.PDBFile import writeFooter [as 别名]
 def __del__(self):
     PDBFile.writeFooter(self._topology, self._out)
     self._out.close()
开发者ID:alex-virodov,项目名称:openmm,代码行数:5,代码来源:pdbreporter.py

示例3: integrate

# 需要导入模块: from simtk.openmm.app import PDBFile [as 别名]
# 或者: from simtk.openmm.app.PDBFile import writeFooter [as 别名]

#.........这里部分代码省略.........
                context.setParameter(parameter_name, 1)

        # Compute initial potential of alchemical state.
        initial_potential = self.beta * context.getState(getEnergy=True).getPotentialEnergy()
        if np.isnan(initial_potential):
            raise NaNException("Initial potential of 'insert' operation is NaN (unmodified potential was %.3f kT, alchemical potential was %.3f kT before changing lambda)" % (unmodified_potential, alchemical_potential))
        from perses.tests.utils import compute_potential_components
        #print("initial potential before '%s' : %f kT" % (direction, initial_potential))
        #print("initial potential components:   %s" % str(compute_potential_components(context))) # DEBUG

        # Take a single integrator step since all switching steps are unrolled in NCMCAlchemicalIntegrator.
        try:
            # Write PDB file if requested.
            if self.write_pdb_interval:
                if direction == 'insert':
                    topology = topology_proposal.new_topology
                    indices = topology_proposal.unique_new_atoms
                else:
                    topology = topology_proposal.old_topology
                    indices = topology_proposal.unique_old_atoms

                # Write atom indices that are changing
                import pickle
                filename = 'ncmc-%s-%d-atomindices.pkl' % (direction, self.nattempted)
                outfile = open(filename, 'wb')
                pickle.dump(indices, outfile)
                outfile.close()

                from simtk.openmm.app import PDBFile
                filename = 'ncmc-%s-%d.pdb' % (direction, self.nattempted)
                outfile = open(filename, 'w')
                PDBFile.writeHeader(topology, file=outfile)
                modelIndex = 0
                PDBFile.writeModel(topology, context.getState(getPositions=True).getPositions(asNumpy=True), file=outfile, modelIndex=modelIndex)
                try:
                    for step in range(self.nsteps):
                        integrator.step(1)
                        if (step+1)%self.write_pdb_interval == 0:
                            modelIndex += 1
                            PDBFile.writeModel(topology, context.getState(getPositions=True).getPositions(asNumpy=True), file=outfile, modelIndex=modelIndex)
                except ValueError as e:
                    # System is exploding and coordinates won't fit in PDB ATOM fields
                    print(e)

                PDBFile.writeFooter(topology, file=outfile)
                outfile.close()
            else:
                integrator.step(self.nsteps)

        except Exception as e:
            # Trap NaNs as a special exception (allowing us to reject later, if desired)
            if str(e) == "Particle coordinate is nan":
                raise NaNException(str(e))
            else:
                raise e

        # Set final context parameters.
        if direction == 'insert':
            for parameter_name in available_parameters:
                context.setParameter(parameter_name, 1)
        elif direction == 'delete':
            for parameter_name in available_parameters:
                context.setParameter(parameter_name, 0)

        # Compute final potential of alchemical state.
        final_potential = self.beta * context.getState(getEnergy=True).getPotentialEnergy()
        if np.isnan(final_potential):
            raise NaNException("Final potential of 'delete' operation is NaN")
        #print("final potential before '%s' : %f kT" % (direction, final_potential))
        #print("final potential components: %s" % str(compute_potential_components(context))) # DEBUG
        #print('')

        # Store final positions and log acceptance probability.
        final_positions = context.getState(getPositions=True).getPositions(asNumpy=True)
        logP_NCMC = integrator.getLogAcceptanceProbability(context)
        # DEBUG
        logging.debug("NCMC logP %+10.1f | initial_total_energy %+10.1f kT | final_total_energy %+10.1f kT." % (logP_NCMC, integrator.getGlobalVariableByName('initial_total_energy'), integrator.getGlobalVariableByName('final_total_energy')))
        # Clean up NCMC switching integrator.
        del context, integrator

        # Compute contribution from transforming real system to/from alchemical system.
        logP_alchemical_correction = self._computeAlchemicalCorrection(unmodified_system, alchemical_system, initial_positions, final_positions, direction=direction)

        # Compute total logP
        logP = logP_NCMC + logP_alchemical_correction

        # Clean up alchemical system.
        del alchemical_system

        # Select whether to return initial or final potential.
        if direction == 'insert':
            potential = initial_potential
        elif direction == 'delete':
            potential = final_potential

        # Keep track of statistics.
        self.nattempted += 1

        # Return
        return [final_positions, logP, potential]
开发者ID:steven-albanese,项目名称:perses,代码行数:104,代码来源:ncmc_switching.py


注:本文中的simtk.openmm.app.PDBFile.writeFooter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。