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


Python Project.save方法代码示例

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


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

示例1: run

# 需要导入模块: from msmbuilder import Project [as 别名]
# 或者: from msmbuilder.Project import save [as 别名]
def run(traj_dir, conf_filename, project_filename, iext):
    logger.info("Rebuilding project.")
    file_list = glob.glob(traj_dir + "/trj*%s" % iext)
    num_traj = len(file_list)

    traj_lengths = np.zeros(num_traj, 'int')
    traj_paths = []

    if not os.path.exists(conf_filename):
        raise(IOError("Cannot find conformation file %s" % conf_filename))

    file_list = sorted(file_list, key=utils.keynat)
    for i, filename in enumerate(file_list):
        traj_lengths[i] = len(md.open(filename))
        traj_paths.append(filename)

    records = {
        "conf_filename": conf_filename,
        "traj_lengths": traj_lengths,
        "traj_paths": traj_paths,
        "traj_errors": [None for i in xrange(num_traj)],
        "traj_converted_from": [[] for i in xrange(num_traj)]
    }

    p = Project(records)
    p.save(project_filename)
    logger.info("Wrote %s" % project_filename)
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:29,代码来源:RebuildProject.py

示例2: save

# 需要导入模块: from msmbuilder import Project [as 别名]
# 或者: from msmbuilder.Project import save [as 别名]
    def save(self):
        "Save the trajs as a n MSMBuilder project"
        
        traj_dir = pjoin(self.project_dir, 'Trajectories')
        if not os.path.exists(traj_dir):
            os.makedirs(traj_dir)

        t = Trajectory.load_trajectory_file(self.conf_filename)

        traj_paths = []
        for i, xyz in enumerate(self.trajectories):
            t['IndexList'] = None # bug in msmbuilder
            t['XYZList'] = xyz

            traj_paths.append(pjoin(traj_dir, 'trj%d.lh5' % i))
            t.save(traj_paths[-1])

        p = Project({'conf_filename': os.path.abspath(self.conf_filename),
            'traj_lengths': self.n_frames*np.ones(self.n_trajs),
            'traj_paths': [os.path.abspath(e) for e in traj_paths],
            'traj_converted_from': [[] for i in range(self.n_trajs)],
            'traj_errors': [None for i in range(self.n_trajs)],
            }, project_dir=self.project_dir, validate=True)
        p.save(pjoin(self.project_dir,'Project.yaml'))

        # just check again
        p = Project.load_from(pjoin(self.project_dir,'Project.yaml'))
        p._validate()
        assert np.all((p.load_traj(0)['XYZList'] - self.trajectories[0])**2 < 1e-6)
开发者ID:rmcgibbo,项目名称:diffusion,代码行数:31,代码来源:create_project.py

示例3: run

# 需要导入模块: from msmbuilder import Project [as 别名]
# 或者: from msmbuilder.Project import save [as 别名]
def run(traj_dir, conf_filename, project_filename):
    logger.info("Rebuilding project.")
    file_list = glob.glob(traj_dir + "/trj*.lh5")
    num_traj = len(file_list)
    
    traj_lengths = np.zeros(num_traj,'int')
    traj_paths = []
    
    file_list = sorted(file_list, key=utils.keynat)
    for i,filename in enumerate(file_list):
        traj_lengths[i] = Trajectory.load_trajectory_file(filename,JustInspect=True)[0]
        traj_paths.append(filename)    
    
    records = {
    "conf_filename":conf_filename,
    "traj_lengths":traj_lengths,
    "traj_paths":traj_paths,
    "traj_errors": [None for i in xrange(num_traj)],
    "traj_converted_from":[[] for i in xrange(num_traj)]           
    }
    
    p = Project(records)
    p.save(project_filename)
    logger.info("Wrote %s" % project_filename)
开发者ID:kyleabeauchamp,项目名称:msmbuilder-legacy,代码行数:26,代码来源:RebuildProject.py

示例4: xrange

# 需要导入模块: from msmbuilder import Project [as 别名]
# 或者: from msmbuilder.Project import save [as 别名]
parser = arglib.ArgumentParser()
parser.add_argument('traj_dir', help='Directory to find trajectory files.')
parser.add_argument('conf_fn', help='Conformation filename that has the same atom names and residue IDs, etc. as the trajectories.')
parser.add_argument('output', default='./ProjectInfo.yaml', help='Output filename [ ./ProjectInfo.yaml ]')

args = parser.parse_args()

traj_list = [ os.path.join(args.traj_dir, fn) for fn in os.listdir(args.traj_dir)]

traj_list.sort(key=utils.keynat) # = list.sort(traj_list, key=utils.keynat)
print traj_list

traj_lens = []

for i in xrange(len(traj_list)):
    
    print i
    shape = Trajectory.load_from_hdf(traj_list[i], JustInspect=True)
    traj_lens.append(shape[0])

records = { 'conf_filename' : args.conf_fn,
            'traj_lengths' : traj_lens,
            'traj_paths' : traj_list,
            'traj_converted_from' : [[] for fn in traj_list],
            'traj_errors' : [None for fn in traj_list]
          }

project = Project(records=records)

project.save(args.output)
开发者ID:schwancr,项目名称:schwancr_bin,代码行数:32,代码来源:proj_from_trajs.py

示例5: len

# 需要导入模块: from msmbuilder import Project [as 别名]
# 或者: from msmbuilder.Project import save [as 别名]
not_too_short_inds = np.where( traj_lens >= ( args.min_length + args.trim_first ) )[0]

os.mkdir( os.path.join( args.write_dir, 'Trajectories' ) )
print "Will limit this project to %d trajectories." % len( not_too_short_inds )
for i in xrange( len( not_too_short_inds ) ):
   print "Copying trajectory %d -> %d (length=%d)" % ( not_too_short_inds[i], i, Proj.traj_lengths[ not_too_short_inds[i] ] - args.trim_first )
   trj0 = tables.openFile( Proj.traj_filename( not_too_short_inds[i] ) )
   trj1 = tables.openFile( os.path.abspath( os.path.join( args.write_dir, 'Trajectories', '%s%d%s'% ('trj',i, '.lh5' ) ) ), 'w' )
   #os.system( 'ln -s %s %s' % ( trj0, trj1 ) )
   #os.symlink( trj0, trj1 )
   
   for n0 in trj0.iterNodes('/'):
      if n0.name != 'XYZList':
         trj0.copyNode( where='/', name=n0.name, newparent=trj1.root )
      else:
         temp_ary = n0[ args.trim_first : ]
         io.saveh( trj1, XYZList=temp_ary )

   trj0.close()
   trj1.close()

new_records = {'conf_filename': Proj.conf_filename.split('/')[-1], 
           'traj_lengths': Proj.traj_lengths[ not_too_short_inds ] - args.trim_first,
           'traj_paths': Proj._traj_paths[ : len( not_too_short_inds ) ], # This works because they're named relatively and they are re-numbered
           'traj_converted_from': Proj._traj_converted_from[ not_too_short_inds ],
           'traj_errors': Proj._traj_errors[ not_too_short_inds ] }
new_proj_dir = args.write_dir
# Copy the trajectories
New_Proj = Project( new_records, project_dir = new_proj_dir )
New_Proj.save( os.path.join( args.write_dir, 'ProjectInfo.yaml' ) )
开发者ID:schwancr,项目名称:schwancr_bin,代码行数:32,代码来源:new_project.py


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