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


Python Trajectory.init_pdb方法代码示例

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


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

示例1: _generate_equilibration_job

# 需要导入模块: from msmbuilder import Trajectory [as 别名]
# 或者: from msmbuilder.Trajectory import init_pdb [as 别名]
def _generate_equilibration_job():
    """Generate a single equilibration job from the first forcefield
    
    No parameters -- reads from the database and from the Project file to get info.
    
    Returns
    -------
    traj : models.Trajectory
        An unsaved trajectory. Note that we "attach" the conformation that we want
        to start from to the object as traj.init_pdb.
    """
        
    logger.info('Constructing initial equilibration job')
    conf = msmbuilder.Trajectory.load_from_pdb(Project().pdb_topology_file)
        
        
    if Project().starting_confs_lh5 is None:
        # start from pdb_topology_file
        # copy to a new location so that the 'conf' can be deleted without
        # looseing our topology file
        logger.info('Using pdb topolgy to start equlibration run')
        name = 'equilibration, starting from pdb toplogy'
    else:
        num_frames = msmbuilder.Trajectory.load_from_lhdf(Project().starting_confs_lh5, JustInspect=True)[0]
        r = np.random.randint(num_frames)
        xyz = msmbuilder.Trajectory.read_lhdf_frame(Project().starting_confs_lh5, r)
        conf['XYZList'] = np.array([xyz])
        logger.info('Using frame %s of starting_confs_lh5 (%s) to start equilibration run' % (r, Project().starting_confs_lh5))
        name = 'equilibration, starting from frame %s of starting_confs_lh5 (%s)' %  (r, Project().starting_confs_lh5) 
        
    forcefield = Session.query(Forcefield).first()
    
    trj = Trajectory(forcefield=forcefield,
                     name=name, mode='Equilibration')
    trj.init_pdb = conf
    return trj
开发者ID:pandegroup,项目名称:msmaccelerator,代码行数:38,代码来源:Brain.py

示例2: generate_job

# 需要导入模块: from msmbuilder import Trajectory [as 别名]
# 或者: from msmbuilder.Trajectory import init_pdb [as 别名]
def generate_job():
    """Generate a single job from the most recent MSMs
    
    No parameters -- reads from the database and from the Project file to get
    info.
    
    Returns
    -------
    traj : models.Trajectory
        An unsaved trajectory. Note that we "attach" the conformation that we want
        to start from to the object as traj.init_pdb.
    """
    
    # get the most recent build round
    msmgroup = Session.query(MSMGroup).order_by(MSMGroup.id.desc()).first()
    if msmgroup is None:
        return _generate_equilibration_job()
    
    # select the forcefield to shoot with
    msm_i = multinomial([msm.model_selection_weight for msm in msmgroup.markov_models])
    model_to_shoot_with = msmgroup.markov_models[msm_i]
    forcefield = model_to_shoot_with.forcefield
    
    # select the microstate to pull from
    selected_microstate = multinomial(model_to_shoot_with.microstate_selection_weights)
    
    # select the conformation to start from uniformly over all the confs
    # in that microstate. Note that these confs count come from any of the
    # forcefields. This is why its critical to have the joint clustering
    confs_per_model = []
    for msm in msmgroup.markov_models:
        n_confs = 0
        
        # it is possible that there is no inverse_assignments if this round
        # was done before any trajs were run in this ff
        # its also possible that this state was only populated by one of the ffs,
        # and sense you can't pickle defaultdicts (they have lambda), msm.inv_assignments
        # is a regular dict
        if os.path.exists(msm.inverse_assignments_fn):
            msm.inv_assignmnets = load_file(msm.inverse_assignments_fn)
            if selected_microstate in msm.inv_assignmnets:
                n_confs = len(msm.inv_assignmnets[selected_microstate])

        confs_per_model.append(n_confs)

    model_to_draw_from = msmgroup.markov_models[multinomial(confs_per_model)]
    trjs, frames = model_to_draw_from.inv_assignmnets[selected_microstate]
    r = np.random.randint(len(trjs))
    #import IPython as ip; ip.embed()
    trj_i, frame_i = trjs[r], frames[r]
    
    conf =  model_to_draw_from.trajectories[trj_i].extract_wet_frame(frame_i)
    
    logger.info('Drew conformation from %s, shooting in %s', model_to_draw_from.forcefield.name, forcefield.name)
    if forcefield == model_to_draw_from.forcefield:
        # we're shooting in the same forcefield the conf was generated in
        t = Trajectory(
            forcefield=forcefield,
            name='Started from round {}, microstate {} (ff {}, trj {}, frame {}) -- continuing in same ff'.format(msmgroup.id, selected_microstate, model_to_draw_from.forcefield.name, trj_i, frame_i),
            mode='Production')

    else:
        # we're shooting in a new forcefield
        # SHOULD WE DO EQUILIBRATION INSTEAD OF PRODUCTION?
        # TJL sayz yes, we definitely should
        # ======
        t = Trajectory(
            forcefield=forcefield,
            name='Started from round {}, microstate {} (ff {}, trj {}, frame {}) -- switching forcfields'.format(msmgroup.id,  selected_microstate, model_to_draw_from.forcefield.name, trj_i, frame_i),
            mode='Production')
        
    t.initialized_from_id = model_to_draw_from.trajectories[trj_i].id
    t.initialized_from_frame = int(frame_i)
        
    # this just "attaches" the conf object to t. the Trajectory model doesn't
    # actually have an init_pdb field -- in the submit method of QMaster we'll
    # save this conf to a file on disk
    t.init_pdb = conf
    return t 
开发者ID:pandegroup,项目名称:msmaccelerator,代码行数:81,代码来源:Brain.py


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