def random_data(B_add=35, n_residues=585.0, d_min=3.5): unit_cell = uctbx.unit_cell( (81.0, 81.0, 61.0, 90.0, 90.0, 120.0) ) xtal = crystal.symmetry(unit_cell, " P 3 ") ## In P3 I do not have to worry about centrics or reflections with different ## epsilons. miller_set = miller.build_set( crystal_symmetry = xtal, anomalous_flag = False, d_min = d_min) ## Now make an array with d_star_sq values d_star_sq = miller_set.d_spacings().data() d_star_sq = 1.0/(d_star_sq*d_star_sq) asu = {"H":8.0*n_residues*1.0, "C":5.0*n_residues*1.0, "N":1.5*n_residues*1.0, "O":1.2*n_residues*1.0} scat_info = absolute_scaling.scattering_information( asu_contents = asu, fraction_protein=1.0, fraction_nucleic=0.0) scat_info.scat_data(d_star_sq) gamma_prot = scat_info.gamma_tot sigma_prot = scat_info.sigma_tot_sq ## The number of residues is multriplied by the Z of the spacegroup protein_total = sigma_prot * (1.0+gamma_prot) ## add a B-value of 35 please protein_total = protein_total*flex.exp(-B_add*d_star_sq/2.0) ## Now that has been done, ## We can make random structure factors normalised_random_intensities = \ random_transform.wilson_intensity_variate(protein_total.size()) random_intensities = normalised_random_intensities*protein_total*math.exp(6) std_dev = random_intensities*5.0/100.0 noise = random_transform.normal_variate(N=protein_total.size()) noise = noise*std_dev random_intensities=noise+random_intensities ## STuff the arrays in the miller array miller_array = miller.array(miller_set, data=random_intensities, sigmas=std_dev) miller_array=miller_array.set_observation_type( xray.observation_types.intensity()) miller_array = miller_array.f_sq_as_f() return (miller_array)
def random_data(B_add=35, n_residues=585.0, d_min=3.5): unit_cell = uctbx.unit_cell((81.0, 81.0, 61.0, 90.0, 90.0, 120.0)) xtal = crystal.symmetry(unit_cell, " P 3 ") ## In P3 I do not have to worry about centrics or reflections with different ## epsilons. miller_set = miller.build_set(crystal_symmetry=xtal, anomalous_flag=False, d_min=d_min) ## Now make an array with d_star_sq values d_star_sq = miller_set.d_spacings().data() d_star_sq = 1.0 / (d_star_sq * d_star_sq) asu = { "H": 8.0 * n_residues * 1.0, "C": 5.0 * n_residues * 1.0, "N": 1.5 * n_residues * 1.0, "O": 1.2 * n_residues * 1.0 } scat_info = absolute_scaling.scattering_information(asu_contents=asu, fraction_protein=1.0, fraction_nucleic=0.0) scat_info.scat_data(d_star_sq) gamma_prot = scat_info.gamma_tot sigma_prot = scat_info.sigma_tot_sq ## The number of residues is multriplied by the Z of the spacegroup protein_total = sigma_prot * (1.0 + gamma_prot) ## add a B-value of 35 please protein_total = protein_total * flex.exp(-B_add * d_star_sq / 2.0) ## Now that has been done, ## We can make random structure factors normalised_random_intensities = \ random_transform.wilson_intensity_variate(protein_total.size()) random_intensities = normalised_random_intensities * protein_total * math.exp( 6) std_dev = random_intensities * 5.0 / 100.0 noise = random_transform.normal_variate(N=protein_total.size()) noise = noise * std_dev random_intensities = noise + random_intensities ## STuff the arrays in the miller array miller_array = miller.array(miller_set, data=random_intensities, sigmas=std_dev) miller_array = miller_array.set_observation_type( xray.observation_types.intensity()) miller_array = miller_array.f_sq_as_f() return (miller_array)
def exercise_wilson_intensity_variate(): data = rt.wilson_intensity_variate(N=1000000) mu1 = flex.mean(data) mu2 = flex.mean(data * data) assert approx_equal(mu1, 1.000, eps=0.02) assert approx_equal(mu2, 2.000, eps=0.04)
def exercise_wilson_intensity_variate(): data = rt.wilson_intensity_variate(N=1000000) mu1 = flex.mean(data) mu2 = flex.mean(data*data) assert approx_equal(mu1,1.000,eps=0.02) assert approx_equal(mu2,2.000,eps=0.04)