mol = sys.add_macromolecule(inseq, "VDR", initialize_apo=False) # Import data datasets = hxio.import_HDXWorkbench( workbench_file, # Workbench input file macromolecule=mol, sequence=None, # FASTA sequence string sigma0=sigma0 ) # The initial estimate for experimental SD in % deuterium untis. print(datasets) # Add data to molecule states and initialize models for s in range(len(mol.get_states())): print(s) state = mol.get_states()[s] state.add_dataset(datasets[s]) output_model = state.set_output_model( model.ResidueGridModel(state, grid_size=num_exp_bins)) sys.output.initialize_output_model_file(state, output_model.pf_grids) sampler = sampling.MCSampler(sys, sigma_sample_level="timepoint") # First, run a short minimization step sampler.run(250, 0.0001) sampler.run(annealing_steps, 1) #sampler.residue_sampler.set_adjacency(True, 4) sampler.run(annealing_steps, 0.5) #sampler.residue_sampler.set_adjacency(True, 3) sampler.run(annealing_steps, 0.3) # This temperature tends to sit around 15% MC acceptance rate, which seems to be good. sampler.run(nsteps, 0.3, write=True)
pep = dataset.create_peptide(inseq, 1) for d in dat.keys(): tp = pep.add_timepoint(d) for r in dat[d]: tp.add_replicate(r, 1) state.add_dataset(dataset) sys.get_output().write_datasets() output_model = model.ResidueGridModel(state, grid_size=num_exp_bins) state.set_output_model(output_model) sys.output.initialize_output_model_file(state, output_model.pf_grids) sampler = sampling.MCSampler(sys, sigma_sample_level=None) # First, run a short minimization step #sampler.run(50, 0.0001) for pep in dataset.get_peptides(): for tp in pep.get_timepoints(): #try: i = tp.get_replicates()[0] rep_score = -1 * math.log( state.scoring_function.replicate_score( tp.get_model_deuteration() / pep.num_observable_amides * 100, tp.get_replicates()[0].deut, tp.get_sigma())) print pep.sequence, tp.time, tp.get_model_deuteration( ) / pep.num_observable_amides * 100, tp.get_replicates( )[0].deut, tp.get_score(), rep_score, "|", tp.get_sigma( ), -1 * math.log(
ds.calculate_intrinsic_rates() ds.calculate_observable_rate_bounds() ds.max_rate = ds.get_max_rate() # Add data to molecule states and initialize models for s in range(len(mol.get_states())): state = mol.get_states()[s] mod = model.ResidueGridModel(state, grid_size=num_exp_bins) output_model = state.set_output_model(mod) state.initialize() sys.output.initialize_output_model_file(state, output_model.pf_grids) sys.get_output().write_datasets() sampler = sampling.MCSampler(sys, sigma_sample_level=None, pct_moves=100) # Slowly cool system print "Anneal 1" sampler.run(annealing_steps, 100, find_temperature=False) print "Anneal 2" # Optional modification of the number of grid points that the residue can shift (default is 5) # (False) allows for any bin in the sampling space to be chosen at random for i in range(5): sampler.run(annealing_steps, 50, find_temperature=False) #sampler.residue_sampler.set_adjacency(True, 3) sampler.run(annealing_steps, 20, find_temperature=False) sampler.run(annealing_steps, 10, find_temperature=False) sampler.residue_sampler.set_adjacency(True, 4) sampler.run(annealing_steps, 5, find_temperature=False)
conditions=None, # A data.Conditions object specifying pH, Temp, etc... None uses a standard set of conditions error_estimate=2.0, # The initial estimate for experimental SD in % deuterium untis. n_fastamides=2, # Number of fast exchanging N-terminal amides offset=offset) # Numbering offset between data and FASTA file. (positive or negative integer) # Add data to molecule state state.add_dataset(dataset) state2.add_dataset(dataset) sys.output.write_datasets() output_model = model.ResidueGridModel(state, grid_size=num_exp_bins) state.set_output_model(output_model) state2.set_output_model(output_model) sampler = sampling.MCSampler(sys, pct_moves = 20, sigma_sample_level="timepoint") sys.output.initialize_output_model_file(state, output_model.pf_grids) sys.output.initialize_output_model_file(state2, output_model.pf_grids) sampler.run(nsteps, 2.0, write=True) pof = analysis.ParseOutputFile(outputdir + "/models_scores_sigmas-Apo.dat", state) pof2 = analysis.ParseOutputFile(outputdir + "/models_scores_sigmas-Apo2.dat", state2) pof.generate_datasets() pof2.generate_datasets() #pof.calculate_random_sample_convergence() #pof2.calculate_random_sample_convergence() conv = analysis.Convergence(pof, pof2)
om = model.ResidueGridModel(state, grid_size=num_exp_bins) s.set_output_model(om) s.add_dataset(dataset) states.append(s) output_models.append(om) sys.output.initialize_output_model_file(state, om.pf_grids) #sampler = sampling.EnumerationSampler(sys) #sampler.run(write=True) #pof = analysis.ParseOutputFile(outputdir + "/models_scores_sigmas-Apo.dat", state) sys.output.change_output_directory(output_dir_sample) #sys.output.initialize_output_model_file(state, output_model.pf_grids) sampler = sampling.MCSampler(sys) sampler.run(10000, 2.0, write=True) pof = analysis.ParseOutputFile( output_dir_sample + "/models_scores_sigmas-Apo.dat", states[0]) pof1 = analysis.ParseOutputFile( output_dir_sample + "/models_scores_sigmas-Apo1.dat", states[1]) pof2 = analysis.ParseOutputFile( output_dir_sample + "/models_scores_sigmas-Apo2.dat", states[2]) pof3 = analysis.ParseOutputFile( output_dir_sample + "/models_scores_sigmas-Apo3.dat", states[3]) plots.plot_residue_protection_factors([pof, pof1, pof2, pof3], num_best_models=1000, sort_sectors=True, show=True)