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


Python Snapshot.construct方法代码示例

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


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

示例1: snapshot_from_pdb

# 需要导入模块: from snapshot import Snapshot [as 别名]
# 或者: from snapshot.Snapshot import construct [as 别名]
def snapshot_from_pdb(pdb_file, simple_topology=False):
    """
    Construct a Snapshot from the first frame in a pdb file without velocities

    Parameters
    ----------
    pdb_file : str
        The filename of the .pdb file to be used
    simple_topology : bool
        if `True` only a simple topology with n_atoms will be created.
        This cannot be used with complex CVs but loads and stores very fast

    Returns
    -------
    :class:`openpathsampling.engines.Snapshot`
        the constructed Snapshot

    """
    pdb = md.load(pdb_file)
    velocities = np.zeros(pdb.xyz[0].shape)

    if simple_topology:
        topology = Topology(*pdb.xyz[0].shape)
    else:
        topology = MDTrajTopology(pdb.topology)

    snapshot = Snapshot.construct(
        coordinates=u.Quantity(pdb.xyz[0], u.nanometers),
        box_vectors=u.Quantity(pdb.unitcell_vectors[0], u.nanometers),
        velocities=u.Quantity(velocities, u.nanometers / u.picoseconds),
        engine=FileEngine(topology, pdb_file)
    )

    return snapshot
开发者ID:,项目名称:,代码行数:36,代码来源:

示例2: _build_current_snapshot

# 需要导入模块: from snapshot import Snapshot [as 别名]
# 或者: from snapshot.Snapshot import construct [as 别名]
    def _build_current_snapshot(self):
        # TODO: Add caching for this and mark if changed

        state = self.simulation.context.getState(getPositions=True,
                                                 getVelocities=True,
                                                 getEnergy=True)

        snapshot = Snapshot.construct(
            coordinates=state.getPositions(asNumpy=True),
            box_vectors=state.getPeriodicBoxVectors(asNumpy=True),
            velocities=state.getVelocities(asNumpy=True),
            engine=self
        )

        return snapshot
开发者ID:,项目名称:,代码行数:17,代码来源:

示例3: snapshot_from_testsystem

# 需要导入模块: from snapshot import Snapshot [as 别名]
# 或者: from snapshot.Snapshot import construct [as 别名]
def snapshot_from_testsystem(testsystem, simple_topology=False):
    """
    Construct a Snapshot from openmm topology and state objects

    Parameters
    ----------
    testsystem : openmmtools.Topology
        The filename of the .pdb file to be used
    simple_topology : bool
        if `True` only a simple topology with n_atoms will be created.
        This cannot be used with complex CVs but loads and stores very fast

    Returns
    -------
    :class:`openpathsampling.engines.Snapshot`
        the constructed Snapshot

    """

    velocities = u.Quantity(
        np.zeros(testsystem.positions.shape), u.nanometers / u.picoseconds)

    if simple_topology:
        topology = Topology(*testsystem.positions.shape)
    else:
        topology = MDTrajTopology(md.Topology.from_openmm(testsystem.topology))

    box_vectors = \
        np.array([
            v / u.nanometers for v in
            testsystem.system.getDefaultPeriodicBoxVectors()]) * u.nanometers

    snapshot = Snapshot.construct(
        coordinates=testsystem.positions,
        box_vectors=box_vectors,
        velocities=velocities,
        engine=OpenMMToolsTestsystemEngine(topology, testsystem.name)
    )

    return snapshot
开发者ID:,项目名称:,代码行数:42,代码来源:

示例4: empty_snapshot_from_openmm_topology

# 需要导入模块: from snapshot import Snapshot [as 别名]
# 或者: from snapshot.Snapshot import construct [as 别名]
def empty_snapshot_from_openmm_topology(topology, simple_topology=False):
    """
    Return an empty snapshot from an openmm.Topology object

    Velocities will be set to zero.

    Parameters
    ----------
    topology : openmm.Topology
        the topology representing the structure and number of atoms
    simple_topology : bool
        if `True` only a simple topology with n_atoms will be created.
        This cannot be used with complex CVs but loads and stores very fast

    Returns
    -------
    openpathsampling.engines.Snapshot
        the complete snapshot with zero coordinates and velocities

    """
    n_atoms = topology.n_atoms

    if simple_topology:
        topology = Topology(n_atoms, 3)
    else:
        topology = MDTrajTopology(md.Topology.from_openmm(topology))

    snapshot = Snapshot.construct(
        coordinates=u.Quantity(np.zeros((n_atoms, 3)), u.nanometers),
        box_vectors=u.Quantity(topology.setUnitCellDimensions(), u.nanometers),
        velocities=u.Quantity(
            np.zeros((n_atoms, 3)), u.nanometers / u.picoseconds),
        engine=TopologyEngine(topology)
    )

    return snapshot
开发者ID:,项目名称:,代码行数:38,代码来源:


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