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])
# 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) # Check that the total probability of basis states adds to one tprob = sum(bstate.probability for bstate in basis_states) if abs(1.0 - tprob) > len(basis_states) * EPS: pscale = 1 / tprob log.warning( 'Basis state probabilities do not add to unity; rescaling by {:g}' .format(pscale)) for bstate in basis_states: bstate.probability *= pscale
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: 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 basis_states: # Check that the total probability of basis states adds to one tprob = sum(bstate.probability for bstate in basis_states) if abs(1.0 - tprob) > len(basis_states) * EPS: pscale = 1/tprob log.warning('Basis state probabilities do not add to unity; rescaling by {:g}'.format(pscale)) for bstate in basis_states: bstate.probability *= pscale # Assign progress coordinates to basis states sim_manager.get_bstate_pcoords(basis_states, n_iter) data_manager.create_ibstate_group(basis_states, n_iter) sim_manager.report_basis_states(basis_states)