io.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:ommprotocol 作者: insilichem 项目源码 文件源码
def prepare_handler(cfg):
    """
    Load all files into single object.
    """
    positions, velocities, box = None, None, None
    _path = cfg['_path']
    forcefield = cfg.pop('forcefield', None)
    topology = sanitize_path_for_file(cfg.pop('topology'), _path)

    if 'checkpoint' in cfg:
        restart_path = sanitize_path_for_file(cfg['checkpoint'], _path)
        restart = Restart.load(restart_path)
        positions = restart.positions
        velocities = restart.velocities
        box = restart.box

    if 'positions' in cfg:
        positions_path = sanitize_path_for_file(cfg.pop('positions'), _path)
        positions = Positions.load(positions_path)
        box = BoxVectors.load(positions_path)

    if 'velocities' in cfg:
        velocities_path = sanitize_path_for_file(cfg.pop('velocities'), _path)
        velocities = Velocities.load(velocities_path)

    if 'box' in cfg:
        box_path = sanitize_path_for_file(cfg.pop('box'), _path)
        box = BoxVectors.load(box_path)

    options = {}
    for key in 'positions velocities box forcefield'.split():
        value = locals()[key]
        if value is not None:
            options[key] = value

    return SystemHandler.load(topology, **options)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号