with work_manager: if work_manager.is_master: # Process target states target_states = [] if args.tstate_file: target_states.extend(TargetState.states_from_file(args.tstate_file, system.pcoord_dtype)) if args.tstates: tstates_strio = cStringIO.StringIO('\n'.join(args.tstates).replace(',', ' ')) target_states.extend(TargetState.states_from_file(tstates_strio, system.pcoord_dtype)) del tstates_strio # Process basis states basis_states = [] if args.bstate_file: basis_states.extend(BasisState.states_from_file(args.bstate_file)) if args.bstates: for bstate_str in args.bstates: fields = bstate_str.split(',') label=fields[0] probability=float(fields[1]) try: auxref = fields[2] except IndexError: auxref = None basis_states.append(BasisState(label=label,probability=probability,auxref=auxref)) if not basis_states: log.error('At least one basis state is required') sys.exit(3)
if args.tstate_file: target_states.extend( TargetState.states_from_file(args.tstate_file, system.pcoord_dtype)) if args.tstates: tstates_strio = io.StringIO('\n'.join(args.tstates).replace( ',', ' ')) target_states.extend( TargetState.states_from_file(tstates_strio, system.pcoord_dtype)) del tstates_strio # Process basis states basis_states = [] if args.bstate_file: basis_states.extend(BasisState.states_from_file(args.bstate_file)) if args.bstates: for bstate_str in args.bstates: fields = bstate_str.split(',') label = fields[0] probability = float(fields[1]) try: auxref = fields[2] except IndexError: auxref = None basis_states.append( BasisState(label=label, probability=probability, auxref=auxref)) if not basis_states:
westpa.rc.process_args(args) system = west.rc.get_system_driver() data_manager = west.rc.get_data_manager() h5file = data_manager.we_h5filename try: os.unlink(h5file) except OSError as e: pass data_manager.prepare_backing() uv = MDAnalysis.Universe(args.template_file) bstate = BasisState('extsim', 1.0, pcoord=[0.0, 0.0, 0.0, 0.0], auxref=args.basis_file, state_id=0) data_manager.create_ibstate_group([bstate]) basis_h5 = h5py.File(args.basis_file, 'r') bs_norm_rmsd = basis_h5['normal_rmsd'][...] min_dist = basis_h5['mindist'][...] bs_side_chain = basis_h5['side_rmsd'][...] bs_ca = basis_h5['ca_rmsd'][...] coord_ds = basis_h5['coords'] all_weight = basis_h5['weight'][...] print('Total weight of all possible structures: {}'.format( all_weight.sum())) all_pcoord = numpy.column_stack( [min_dist, bs_norm_rmsd, bs_ca, bs_side_chain])
if work_manager.is_master: data_manager = westpa.rc.get_data_manager() data_manager.open_backing(mode='a') sim_manager = westpa.rc.get_sim_manager() n_iter = data_manager.current_iteration assert args.mode in ('show', 'replace', 'append') if args.mode == 'show': basis_states = data_manager.get_basis_states(n_iter) if basis_states: bstate_file = sys.stdout if not args.bstate_file else open( args.bstate_file, 'wt') bstate_file.write( '# Basis states for iteration {:d}\n'.format(n_iter)) BasisState.states_to_file(basis_states, bstate_file) target_states = data_manager.get_target_states(n_iter) if target_states: tstate_file = sys.stdout if not args.tstate_file else open( args.tstate_file, 'wt') tstate_file.write( '# Target states for iteration {:d}\n'.format(n_iter)) TargetState.states_to_file(target_states, tstate_file) elif args.mode == 'replace': seg_index = data_manager.get_seg_index(n_iter) if (seg_index['status'] == Segment.SEG_STATUS_COMPLETE).any(): print( 'Iteration {:d} has completed segments; applying new states to iteration {:d}' .format(n_iter, n_iter + 1))
with work_manager: if work_manager.is_master: data_manager = westpa.rc.get_data_manager() data_manager.open_backing(mode='a') sim_manager = westpa.rc.get_sim_manager() n_iter = data_manager.current_iteration assert args.mode in ('show', 'replace', 'append') if args.mode == 'show': basis_states = data_manager.get_basis_states(n_iter) if basis_states: bstate_file = sys.stdout if not args.bstate_file else open(args.bstate_file, 'wt') bstate_file.write('# Basis states for iteration {:d}\n'.format(n_iter)) BasisState.states_to_file(basis_states, bstate_file) target_states = data_manager.get_target_states(n_iter) if target_states: tstate_file = sys.stdout if not args.tstate_file else open(args.tstate_file, 'wt') tstate_file.write('# Target states for iteration {:d}\n'.format(n_iter)) TargetState.states_to_file(target_states, tstate_file) elif args.mode == 'replace': seg_index = data_manager.get_seg_index(n_iter) if (seg_index['status'] == Segment.SEG_STATUS_COMPLETE).any(): print('Iteration {:d} has completed segments; applying new states to iteration {:d}'.format(n_iter,n_iter+1)) n_iter += 1 basis_states = [] if args.bstate_file: