rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print "grid_resolution_factor:", sampled_density.resolution_factor()
print "grid_resolution_factor:", sampled_density.grid_resolution_factor()
def print_structure_factors(SgInfo, adp=0, d_min=2., grid_resolution_factor = 1./3): elements = ("N", "C", "C", "O", "N", "C", "C", "O") xtal = debug_utils.random_structure( SgInfo, elements, volume_per_atom=50., min_distance=1.5, general_positions_only=0, anisotropic_displacement_parameters=adp) if (0): assert SgInfo....
if (not Flags.RandomSeed): debug_utils.set_random_seed(0)
if (not Flags.RandomSeed): debug_utils.set_random_seed(6)
def run(): Flags = debug_utils.command_line_options(sys.argv[1:], ( "RandomSeed", "AllSpaceGroups", "Isotropic", "Anisotropic", )) if (not Flags.RandomSeed): debug_utils.set_random_seed(0) if (not (Flags.Isotropic or Flags.Anisotropic)): Flags.Isotropic = 1 # XXX Flags.Anisotropic = 1 symbols_to_stdout = 0 if (len(sys....
print >> f, ' print >> f, '
if (source_file is not None): print >> f, ' print >> f, ' else: print >> f, '
def write_bin_sh_dispatcher(self, source_file, target_file): f = open(target_file, "w") print >> f, '#! /bin/sh' print >> f, '# LIBTBX_DISPATCHER DO NOT EDIT' print >> f, 'unset PYTHONHOME' print >> f, 'LIBTBX_BUILD="%s"' % self.build_path print >> f, 'export LIBTBX_BUILD' essentials = [("PYTHONPATH", self.pythonpath)]...
for line in source_specific_dispatcher_include( pattern="LIBTBX_PRE_DISPATCHER_INCLUDE_SH", source_file=source_file): print >> f, line
if (source_file is not None): for line in source_specific_dispatcher_include( pattern="LIBTBX_PRE_DISPATCHER_INCLUDE_SH", source_file=source_file): print >> f, line
def write_bin_sh_dispatcher(self, source_file, target_file): f = open(target_file, "w") print >> f, '#! /bin/sh' print >> f, '# LIBTBX_DISPATCHER DO NOT EDIT' print >> f, 'unset PYTHONHOME' print >> f, 'LIBTBX_BUILD="%s"' % self.build_path print >> f, 'export LIBTBX_BUILD' essentials = [("PYTHONPATH", self.pythonpath)]...
for line in source_specific_dispatcher_include( pattern="LIBTBX_POST_DISPATCHER_INCLUDE_SH", source_file=source_file): print >> f, line start_python = False cmd = "" if (source_file.lower().endswith(".py")): cmd += " '"+self.python_exe+"'" if (len(source_specific_dispatcher_include( pattern="LIBTBX_START_PYTHON", sourc...
if (source_file is not None): for line in source_specific_dispatcher_include( pattern="LIBTBX_POST_DISPATCHER_INCLUDE_SH", source_file=source_file): print >> f, line start_python = False cmd = "" if (source_file.lower().endswith(".py")): cmd += " '"+self.python_exe+"'" if (len(source_specific_dispatcher_include( patter...
def write_bin_sh_dispatcher(self, source_file, target_file): f = open(target_file, "w") print >> f, '#! /bin/sh' print >> f, '# LIBTBX_DISPATCHER DO NOT EDIT' print >> f, 'unset PYTHONHOME' print >> f, 'LIBTBX_BUILD="%s"' % self.build_path print >> f, 'export LIBTBX_BUILD' essentials = [("PYTHONPATH", self.pythonpath)]...
exception_handling_params=None):
exception_handling_params=None, log=None):
def run_c_plus_plus(target_evaluator, termination_params=None, core_params=None, exception_handling_params=None): if (termination_params is None): termination_params = termination_parameters() if (core_params is None): core_params = core_parameters() if (exception_handling_params is None): exception_handling_params = e...
if (is_converged(f)): break
if (is_converged(f)): if (log is not None): print >> log, "lbfgs minimizer stop: drop_convergence_test" break
def run_c_plus_plus(target_evaluator, termination_params=None, core_params=None, exception_handling_params=None): if (termination_params is None): termination_params = termination_parameters() if (core_params is None): core_params = core_parameters() if (exception_handling_params is None): exception_handling_params = e...
libtbx_env = libtbx.config.env() dist_root = libtbx_env.under_dist("libtbx", "..")
libtbx_env = libtbx.env.cache dist_root = libtbx.env.under_dist("libtbx", "..")
def run(target_root): cwd = os.getcwd() abs_target_root = os.path.normpath(os.path.abspath(os.path.join( target_root))) libtbx_env = libtbx.config.env() dist_root = libtbx_env.under_dist("libtbx", "..") for package in ["libtbx"] + libtbx_env.package_list: for package_suf in libtbx.config.package_pair( name=package).pri...
.type = bool shake_biso = None .type = float set_biso = None .type = float set_biso_random = False .type = bool set_biso_to_wilson_b = False
def show_times(out = None): if(out is None): out = sys.stdout total = time_adp_refinement_py if(total > 0.01): print >> out, "ADP refinement:" print >> out, " time spent in adp_refinement.py = %-7.2f" % time_adp_refinement_py return total
def show_summary(self, f=None):
def show_summary(self, f=None, prefix=""):
def show_summary(self, f=None): if (f is None): f = sys.stdout print >> f, "max %.6g" % (self.max()) print >> f, "min %.6g" % (self.min()) print >> f, "mean %.6g" % (self.mean()) print >> f, "sigma %.6g" % (self.sigma())
print >> f, "max %.6g" % (self.max()) print >> f, "min %.6g" % (self.min()) print >> f, "mean %.6g" % (self.mean()) print >> f, "sigma %.6g" % (self.sigma())
print >> f, prefix + "max %.6g" % (self.max()) print >> f, prefix + "min %.6g" % (self.min()) print >> f, prefix + "mean %.6g" % (self.mean()) print >> f, prefix + "sigma %.6g" % (self.sigma())
def show_summary(self, f=None): if (f is None): f = sys.stdout print >> f, "max %.6g" % (self.max()) print >> f, "min %.6g" % (self.min()) print >> f, "mean %.6g" % (self.mean()) print >> f, "sigma %.6g" % (self.sigma())
class crystal_gridding:
class crystal_gridding(object):
def as_CObjectZYX(map_unit_cell, first, last, apply_sigma_scaling=True): return ext.as_CObjectZYX(map_unit_cell, first, last, apply_sigma_scaling)
class peak_search_parameters:
class peak_search_parameters(object):
def peak_search(self, parameters, map, verify_symmetry=True): if (verify_symmetry): assert self._tags.verify(map) if (map.accessor().is_padded()): map = copy(map, flex.grid(map.focus())) grid_peaks = peak_list( data=map, tags=self._tags.tag_array(), peak_search_level=parameters.peak_search_level(), max_peaks=parameters...
class cluster_site_info:
class cluster_site_info(object):
def max_clusters(self): return self._max_clusters
class peak_cluster_analysis:
class peak_cluster_analysis(object):
def __init__(self, peak_list_index, grid_index, grid_height, site, height): self.peak_list_index = peak_list_index self.grid_index = grid_index self.grid_height = grid_height self.site = site self.height = height
check = (rw>rf or abs(rw-rf) <= rwrf_delta or rw > 45. or abs(r_work-rw) <= 5.)
check = (rw>rf or abs(rw-rf) <= rwrf_delta or rw > 45.)
def update_solvent_and_scale(fmodel, pdb, hkl, out): try: status = None params = bss.solvent_and_scale_params() params.b_sol_min=0.0 params.b_sol_max=200.0 params.k_sol_min=0.0 params.k_sol_max=1.5 fmodel.update_solvent_and_scale(params = params, verbose = -1) r_work = fmodel.r_work()*100 r_free = fmodel.r_free()*100 r...
miller_native)
miller_native).map_to_asu()
def __init__(self, miller_native, miller_derivative, use_intensities=True, use_weights=True, moment_based=True, max_depth=10, target_neighbours=1000, sphere=1, out=None):
miller_derivative)
miller_derivative).map_to_asu()
def __init__(self, miller_native, miller_derivative, use_intensities=True, use_weights=True, moment_based=True, max_depth=10, target_neighbours=1000, sphere=1, out=None):
"""
def __init__(self, miller_native, miller_derivative, use_intensities=True, use_weights=True, moment_based=True, max_depth=10, target_neighbours=1000, sphere=1, out=None):
self.native.change_of_basis_op_to_minimum_cell() )
self.native.change_of_basis_op_to_minimum_cell() ).set_observation_type( self.native ).map_to_asu()
def __init__(self, miller_native, miller_derivative, use_intensities=True, use_weights=True, moment_based=True, max_depth=10, target_neighbours=1000, sphere=1, out=None):
self.derivative.change_of_basis_op_to_minimum_cell() )
self.derivative.change_of_basis_op_to_minimum_cell() ).set_observation_type( self.derivative ).map_to_asu()
def __init__(self, miller_native, miller_derivative, use_intensities=True, use_weights=True, moment_based=True, max_depth=10, target_neighbours=1000, sphere=1, out=None):
self.derivative = self.derivative.customized_copy( data=self.derivative.data()*scales, sigmas = self.derivative.sigmas()*scales ).set_observation_type( self.derivative)
self.der_primset = self.der_primset.customized_copy( data=self.der_primset.data()*scales, sigmas = self.der_primset.sigmas()*scales).set_observation_type( self.der_primset) self.derivative = self.der_primset.change_basis( self.derivative.change_of_basis_op_to_minimum_cell().inverse() )\ .set_observation_type( sel...
def __init__(self, miller_native, miller_derivative, use_intensities=True, use_weights=True, moment_based=True, max_depth=10, target_neighbours=1000, sphere=1, out=None):
if (len(args) > 0 and element not in args): continue
def run(file_name, args, cutoff, max_n_terms, six_term=00000, full_fits=None, params=None, plots_dir="itvc_fits_plots", verbose=0): timer = user_plus_sys_time() tab = itvc_section61_io.read_table6111(file_name) if (params is None): params = cctbx.eltbx.gaussian_fit.fit_parameters( max_n_terms=max_n_terms) chunk_n = 1 c...
st = st.split() if(indices.size() > 0 and len(st) != len(keys_updated)): break if(len(st) == len(keys_updated)): try: try_h = st[h_i].replace("-","").strip().isdigit() try_k = st[k_i].replace("-","").strip().isdigit() try_l = st[l_i].replace("-","").strip().isdigit() is_digits = try_h and try_k and try_l h_ = int(st[h_...
if(proceed): st = st.split() if(indices.size() > 0 and len(st) != len(keys_updated)): break if(len(st) == len(keys_updated)): try: try_h = st[h_i].replace("-","").strip().isdigit() try_k = st[k_i].replace("-","").strip().isdigit() try_l = st[l_i].replace("-","").strip().isdigit() is_digits = try_h and try_k and try_l h...
def run(args): pdb = args[0] hkl = args[1] err = open("_error_"+pdb[-8:-4],"w") proceed = True data = flex.double() sigmas = flex.double() indices = flex.miller_index() flags_ = [] flags = flex.bool() try: cs = crystal_symmetry_from_any.extract_from(pdb) except Exception, e: proceed = False print >> err, "Cannot_e...
result = self.raw_copy() if (label != None): result.label = label if (site != None): result.site = site if (u != None): result.u = u if (occupancy != None): result.occupancy = occupancy if (caasf != None): result.caasf = caasf if (fp_fdp != None): result.fp_fdp = fp_fdp return result
assert u == None or b == None if (b != None): u = adptbx.b_as_u(b) if (label == None): label = self.label if (site == None): site = self.site if (u == None): if (self.anisotropic_flag): u = self.u_star else: u = self.u_iso if (occupancy == None): occupancy = self.occupancy if (caasf == None): caasf = self.caasf if (fp_...
def _scatterer_copy(self, label=None, site=None, u=None, occupancy=None, caasf=None, fp_fdp=None): result = self.raw_copy() if (label != None): result.label = label if (site != None): result.site = site if (u != None): result.u = u if (occupancy != None): result.occupancy = occupancy if (caasf != None): result.caasf = ...
if (self.similarity_cb_op is None): return []
self.double_cosets = None if (self.similarity_cb_op is not None): common_lattice_group = lat_sym_1 for s in lat_sym_2.build_derived_acentric_group().change_basis( self.similarity_cb_op ): try: common_lattice_group.expand_smx(s) except RunTimeError: common_lattice_group=None if common_lattice_group is not None: common...
def __init__(self, xs1, xs2, relative_length_tolerance=0.05, absolute_angle_tolerance=10, max_delta=3.0, anomalous_flag=True, out=None): # first we have to go to the niggli setting self.cb_op_to_n_1 = xs1.change_of_basis_op_to_niggli_cell() self.cb_op_to_n_2 = xs2.change_of_basis_op_to_niggli_cell()
common_lattice_group = lat_sym_1 for s in lat_sym_2.build_derived_acentric_group().change_basis( self.similarity_cb_op ): try: common_lattice_group.expand_smx(s) except RunTimeError: return [] common_lattice_group.make_tidy()
h1 = int_sym_1.build_derived_acentric_group().make_tidy() h2 = int_sym_2.build_derived_acentric_group().change_basis( self.similarity_cb_op ).make_tidy()
def __init__(self, xs1, xs2, relative_length_tolerance=0.05, absolute_angle_tolerance=10, max_delta=3.0, anomalous_flag=True, out=None): # first we have to go to the niggli setting self.cb_op_to_n_1 = xs1.change_of_basis_op_to_niggli_cell() self.cb_op_to_n_2 = xs2.change_of_basis_op_to_niggli_cell()
h1 = int_sym_1.build_derived_acentric_group().make_tidy() h2 = int_sym_2.build_derived_acentric_group().change_basis( self.similarity_cb_op ).make_tidy() self.double_cosets = cosets.double_cosets( common_lattice_group, h1, h2, )
self.double_cosets = cosets.double_cosets( common_lattice_group, h1, h2, )
def __init__(self, xs1, xs2, relative_length_tolerance=0.05, absolute_angle_tolerance=10, max_delta=3.0, anomalous_flag=True, out=None): # first we have to go to the niggli setting self.cb_op_to_n_1 = xs1.change_of_basis_op_to_niggli_cell() self.cb_op_to_n_2 = xs2.change_of_basis_op_to_niggli_cell()
for coset in self.double_cosets.double_cosets: result.append( sgtbx.change_of_basis_op(coset[0])*self.similarity_cb_op )
if self.double_cosets is not None: for coset in self.double_cosets.double_cosets: result.append( sgtbx.change_of_basis_op(coset[0])*self.similarity_cb_op )
def cb_ops_in_niggli_setting(self): result=[] for coset in self.double_cosets.double_cosets: result.append( sgtbx.change_of_basis_op(coset[0])*self.similarity_cb_op ) return result
print >> s, ' doskey libtbx.%ssetpaths="%s\\%ssetpaths.bat" $*' % ( un, self.bin_path, un)
print >> s, ' doskey libtbx.%ssetpaths=%s\\%ssetpaths.bat $*' % ( un, self.build_path, un)
def write_setpaths_bat(self): setpaths_path = self.under_build("setpaths.bat") unsetpaths_path = self.under_build("unsetpaths.bat") s = open_info(setpaths_path) u = open_info(unsetpaths_path) update_path = windows_update_path(self, s, u) for f in s, u: print >> f, '@ECHO off' print >> f, 'if not exist "%s" goto fatal_e...
print >> s, ' set %s="%s"' % ("LIBTBX_BUILD", self.build_path)
print >> s, ' set %s=%s' % ("LIBTBX_BUILD", self.build_path)
def write_setpaths_bat(self): setpaths_path = self.under_build("setpaths.bat") unsetpaths_path = self.under_build("unsetpaths.bat") s = open_info(setpaths_path) u = open_info(unsetpaths_path) update_path = windows_update_path(self, s, u) for f in s, u: print >> f, '@ECHO off' print >> f, 'if not exist "%s" goto fatal_e...
print >> s, ' set %s="%s"' % (var_name, path)
print >> s, ' set %s=%s' % (var_name, path)
def write_setpaths_bat(self): setpaths_path = self.under_build("setpaths.bat") unsetpaths_path = self.under_build("unsetpaths.bat") s = open_info(setpaths_path) u = open_info(unsetpaths_path) update_path = windows_update_path(self, s, u) for f in s, u: print >> f, '@ECHO off' print >> f, 'if not exist "%s" goto fatal_e...
rogues.sigmas(),
sigmas,
def make_log_model(self, log_message, flags, ll_gain, p_values, f_model, alpha, beta,plot_out=None): header = ("Index", "d-spacing", "F_obs", "F_model", "2(LL-gain)", "p-value", "alpha", "beta", "centric") table="No outliers were found" rows = [] rogues = self.miller_obs.select( ~flags.data() ) p_array = p_values.selec...
if (unit_cell is None):
if (unit_cell is not None): self.unit_cell = unit_cell else:
def __call__(self, option, opt, value, parser): if (opt == "--unit_cell"): unit_cell = None try: unit_cell = uctbx.unit_cell(value) except: pass if (unit_cell is None): crystal_symmetry = crystal_symmetry_from_any.extract_from(value) if ( crystal_symmetry is None or crystal_symmetry.unit_cell() is None): raise Option...
self.unit_cell = unit_cell
self.unit_cell = crystal_symmetry.unit_cell()
def __call__(self, option, opt, value, parser): if (opt == "--unit_cell"): unit_cell = None try: unit_cell = uctbx.unit_cell(value) except: pass if (unit_cell is None): crystal_symmetry = crystal_symmetry_from_any.extract_from(value) if ( crystal_symmetry is None or crystal_symmetry.unit_cell() is None): raise Option...
if (space_group_info is None):
if (space_group_info is not None): self.space_group_info = space_group_info else:
def __call__(self, option, opt, value, parser): if (opt == "--unit_cell"): unit_cell = None try: unit_cell = uctbx.unit_cell(value) except: pass if (unit_cell is None): crystal_symmetry = crystal_symmetry_from_any.extract_from(value) if ( crystal_symmetry is None or crystal_symmetry.unit_cell() is None): raise Option...
self.space_group_info = space_group_info
self.space_group_info = crystal_symmetry.space_group_info()
def __call__(self, option, opt, value, parser): if (opt == "--unit_cell"): unit_cell = None try: unit_cell = uctbx.unit_cell(value) except: pass if (unit_cell is None): crystal_symmetry = crystal_symmetry_from_any.extract_from(value) if ( crystal_symmetry is None or crystal_symmetry.unit_cell() is None): raise Option...
self.ml_murray_rust = ml_murray_rust( normalized_intensities, twin_law.operator.as_double_array()[0:9], out ) if ncs_test: self.ml_murry_rust_with_ncs = ml_murray_rust_with_ncs( normalized_intensities, twin_law.operator.as_double_array()[0:9], out, n_ncs_bins, miller_calc)
self.ml_murray_rust=None if normalized_intensities.sigmas() is not None: self.ml_murray_rust = ml_murray_rust( normalized_intensities, twin_law.operator.as_double_array()[0:9], out ) if ncs_test: self.ml_murry_rust_with_ncs = ml_murray_rust_with_ncs( normalized_intensities, twin_law.operator.as_double_array()[0:9], ou...
def __init__(self, twin_law, miller_array, out=None, verbose=0, miller_calc=None, normalized_intensities=None, ncs_test=None, n_ncs_bins=None):
self.twin_results.murray_rust_alpha.append( twin_item.ml_murray_rust.estimated_alpha)
if twin_item.ml_murray_rust is not None: self.twin_results.murray_rust_alpha.append( twin_item.ml_murray_rust.estimated_alpha) else: self.twin_results.murray_rust_alpha.append(None)
def __init__(self, nz_test, wilson_ratios, l_test, translational_pseudo_symmetry=None, twin_law_related_test=None, symmetry_issues=None,
ml_murray_rust_plot = data_plots.plot_data( plot_title = 'Likelihood based twin fraction estimation for possible twin law '\ +possible_twin_laws.operators[ii].operator.r().as_hkl(), x_label = 'alpha', y_label = '-Log[Likelihood]', x_data = tmp_twin_law_stuff.ml_murray_rust.twin_fraction, y_data = tmp_twin_law_stuff.ml_...
if tmp_twin_law_stuff.ml_murray_rust is not None: ml_murray_rust_plot = data_plots.plot_data( plot_title = 'Likelihood based twin fraction estimation for possible twin law '\ +possible_twin_laws.operators[ii].operator.r().as_hkl(), x_label = 'alpha', y_label = '-Log[Likelihood]', x_data = tmp_twin_law_stuff.ml_murray_r...
def __init__(self, miller_array, d_star_sq_low_limit=None, d_star_sq_high_limit=None, d_hkl_for_l_test=None, normalise=True, ## If normalised is true, normalisation is done out=None, out_plots = None, verbose = 1, miller_calc=None, additional_parameters=None):
self.iso, auto_kernel=True, n_term=options.n_terms)
self.iso, auto_kernel=True, n_term=options.number_of_terms_in_normalisation_curve)
def __init__(self, ano, iso, options, out=None): if out == None: out = sys.stdout
self.ano, auto_kernel=True, n_term=options.n_terms)
self.ano, auto_kernel=True, n_term=options.number_of_terms_in_normalisation_curve)
def __init__(self, ano, iso, options, out=None): if out == None: out = sys.stdout
column_root_label='FSIR,SIGMAFSIR')
column_root_label='FSIR')
def run(args): if len(args)==0: print "no help available" elif ( "--help" in args ): print "no help available" elif ( "--h" in args ): print "no help available" else: log = multi_out() if (not "--quiet" in args): log.register(label="stdout", file_object=sys.stdout) string_buffer = StringIO() string_buffer_plots = Stri...
"sgtbxdriver": ("sgtbxdriver",) + lib,
"sgtbxdriver": ("sgtbxdriver",) + lib + ("uctbx",),
def dependencies(self):
"sgtbx": ("sgtbxmodule",) + lib + ("bpl_utils", "boost_array_bpl"),
"sgtbx": ("sgtbxmodule",) + lib + ("bpl_utils", "boost_array_bpl", "uctbx"),
def dependencies(self):
i_sym = asu_mappings.find_i_sym(i_seq=n.i_seq, rt_mx=n.rt_mx) if (i_sym > 0 or i_sym == 0 and i_seq_pivot < n.i_seq):
i_sym = asu_mappings.find_i_sym( i_seq=n.i_seq, rt_mx=rt_mx_pivot.multiply(n.rt_mx)) if (i_shell == 1): assert i_sym >= 0 if (i_sym > 0 or (i_sym == 0 and i_seq_pivot < n.i_seq)):
def coordination_sequences(structure, proxies, n_shells=10, coseq_terms=None): scatterers = structure.scatterers() pair_lists = [[] for i in xrange(scatterers.size())] for proxy in proxies.proxies: pair = proxy.pair pair_lists[pair.i_seq].append(pair) if (pair.j_sym == 0): pair_lists[pair.j_seq].append(pair) assert lis...
bond_registries = []
def coordination_sequences_sorted(structure, proxies, n_shells=10): scatterers = structure.scatterers() print "sorted_proxies.proxies.size():", \ proxies.sorted_proxies.proxies.size() print "sorted_proxies.sym_proxies.size():", \ proxies.sorted_proxies.sym_proxies.size() if (proxies.sorted_proxies.proxies.size() > 0): ...
bond_reg = bond_registry()
def coordination_sequences_sorted(structure, proxies, n_shells=10): scatterers = structure.scatterers() print "sorted_proxies.proxies.size():", \ proxies.sorted_proxies.proxies.size() print "sorted_proxies.sym_proxies.size():", \ proxies.sorted_proxies.sym_proxies.size() if (proxies.sorted_proxies.proxies.size() > 0): ...
bond_registries.append(bond_reg)
def coordination_sequences_sorted(structure, proxies, n_shells=10): scatterers = structure.scatterers() print "sorted_proxies.proxies.size():", \ proxies.sorted_proxies.proxies.size() print "sorted_proxies.sym_proxies.size():", \ proxies.sorted_proxies.sym_proxies.size() if (proxies.sorted_proxies.proxies.size() > 0): ...
if (i_shell <= 3): bond_reg.start_next_shell() for n in nodes_next: i_sym = asu_mappings.find_i_sym(i_seq=n.i_seq, rt_mx=n.rt_mx) if (i_sym > 0 or i_sym == 0 and i_seq_pivot < n.i_seq): bond_reg.enter_sym((n.i_seq, i_sym)) bond_registries.append(bond_reg)
def coordination_sequences_sorted(structure, proxies, n_shells=10): scatterers = structure.scatterers() print "sorted_proxies.proxies.size():", \ proxies.sorted_proxies.proxies.size() print "sorted_proxies.sym_proxies.size():", \ proxies.sorted_proxies.sym_proxies.size() if (proxies.sorted_proxies.proxies.size() > 0): ...
parameter_scope = 'scaling.input.xray_data'
parameter_scope = 'scaling.input.xray_data', parameter_name = 'obs_labels'
def run(command_name, args): if len(args)==0: print_help() elif ( "--help" in args ): print_help() elif ( "--h" in args ): print_help() else: log = multi_out() if (not "--quiet" in args): log.register(label="stdout", file_object=sys.stdout) string_buffer = StringIO() string_buffer_plots = StringIO() log.register(label...
parameter_scope = 'scaling.input.xray_data'
parameter_scope = 'scaling.input.xray_data', parameter_name = 'calc_labels'
def run(command_name, args): if len(args)==0: print_help() elif ( "--help" in args ): print_help() elif ( "--h" in args ): print_help() else: log = multi_out() if (not "--quiet" in args): log.register(label="stdout", file_object=sys.stdout) string_buffer = StringIO() string_buffer_plots = StringIO() log.register(label...
for module in self.module_list: if (module.has_top_level_cvs_directory()): python_dispatchers.append("python") break
if (self.want_python_dispatcher()): python_dispatchers.append("python")
def refresh(self): self.assemble_pythonpath() self.write_setpath_files() self.pickle() if (self.is_ready_for_build()): self.write_SConstruct() if (os.name != "nt"): self.write_run_tests_csh() self.clear_bin_directory() if (not os.path.isdir(self.bin_path)): os.makedirs(self.bin_path) python_dispatchers = ["libtbx.pytho...
dict.__getitem__(self, key)
return dict.__getitem__(self, key)
def __getattr__(self, key): dict.__getitem__(self, key)
print item
def tls_from_u_cart(xray_structure, tlsos_initial, tls_selections, number_of_macro_cycles = 100, max_iterations = 100): uc = xray_structure.unit_cell() xray_structure.tidy_us(u_min = 1.e-9) ueq = xray_structure.extract_u_iso_or_u_equiv() assert (ueq < 0.0).count(True) == 0 u_cart = xray_structure.scatterers().e...
print refine_T print "*"*50
def tls_from_u_cart(xray_structure, tlsos_initial, tls_selections, number_of_macro_cycles = 100, max_iterations = 100): uc = xray_structure.unit_cell() xray_structure.tidy_us(u_min = 1.e-9) ueq = xray_structure.extract_u_iso_or_u_equiv() assert (ueq < 0.0).count(True) == 0 u_cart = xray_structure.scatterers().e...
uc = fmodel.xray_structure.unit_cell() u_cart = fmodel.xray_structure.scatterers().extract_u_cart(uc) for tls_selection, tlso in zip(selections, tlsos): print "."*50 print tlso.t print t_from_u_cart(u_cart.select(tls_selection), 1.e-6)
def __init__(self, fmodel, model, selections, refine_T, refine_L, refine_S, number_of_macro_cycles, max_number_of_iterations, start_tls_value = None, run_finite_differences_test = False, eps = 1.e-6, out = None): if(out is None): out = sys.stdout prefix = "TLS refinement:" fmodel.show_targets(text = prefix+" start mode...
if (not name.endswith(".mtz")): continue
if (not name.lower().endswith(".mtz")): continue
def walk_callback(arg, top, names): exercise_function, out = arg for name in names: if (not name.endswith(".mtz")): continue file_name = os.path.normpath(os.path.join(top, name)) print >> out, "Processing:", file_name exercise_function(file_name=file_name, out=out) exercise_function.raise_if_all_tests_ran_at_least_once...
help="Visit all MTZ file.")
help="Visit all MTZ files")
def exercise(): command_line = (iotbx_option_parser() .option(None, "--verbose", action="store_true", dest="verbose") .option(None, "--forever", action="store_true", dest="forever", help="Infinite loop, for detection of memory leaks") .option(None, "--walk", action="store", type="string", dest="walk", metavar="ROOT_DIR...
def __init__(self, python_exe, precall_commands=None):
def __init__(self, python_exe, precall_commands):
def __init__(self, python_exe, precall_commands=None): self.python_exe = python_exe self.precall_commands = precall_commands
def create_driver(python_exe, target_dir, package_name, source_dir, file_name):
def create_driver(python_exe, precall_commands, target_dir, package_name, source_dir, file_name):
def create_driver(python_exe, target_dir, package_name, source_dir, file_name): source_file = norm(join(source_dir, file_name)) if (not isfile(source_file)): return if (file_name.lower().startswith("__init__.py")): return if (file_name.lower().endswith(".pyc")): return if (file_name[0] == "."): return target_file = nor...
action = create_bin_sh_dispatcher(python_exe=python_exe)
action = create_bin_sh_dispatcher( python_exe=python_exe, precall_commands=precall_commands)
def create_driver(python_exe, target_dir, package_name, source_dir, file_name): source_file = norm(join(source_dir, file_name)) if (not isfile(source_file)): return if (file_name.lower().startswith("__init__.py")): return if (file_name.lower().endswith(".pyc")): return if (file_name[0] == "."): return target_file = nor...
def create_drivers(python_exe, target_dir, package_name, source_dir):
def create_drivers(python_exe, precall_commands, target_dir, package_name, source_dir):
def create_drivers(python_exe, target_dir, package_name, source_dir): if (not isdir(source_dir)): return print "Processing:", source_dir for file_name in os.listdir(source_dir): create_driver( python_exe=python_exe, target_dir=target_dir, package_name=package_name, source_dir=source_dir, file_name=file_name)
def create_python_dispatchers(libtbx_env, target_dir, python_exe): precall_commands = assemble_dispatcher_precall_commands(libtbx_env)
def create_python_dispatchers(libtbx_env, target_dir, python_exe, precall_commands):
def create_python_dispatchers(libtbx_env, target_dir, python_exe): precall_commands = assemble_dispatcher_precall_commands(libtbx_env) for file_name in ("libtbx.python", "python"): target_file = norm(join(target_dir, file_name)) if (os.name == "nt"): target_file += ".exe" action = shutil.copyfile else: action = create_...
libtbx_env, target_dir, libtbx_env.LIBTBX_PYTHON_EXE)
libtbx_env=libtbx_env, target_dir=target_dir, python_exe=libtbx_env.LIBTBX_PYTHON_EXE, precall_commands=precall_commands)
def run(): libtbx_env = libtbx.config.env() target_dir = norm(join(libtbx_env.LIBTBX_BUILD, "libtbx/bin")) if (not isdir(target_dir)): os.makedirs(target_dir) create_python_dispatchers( libtbx_env, target_dir, libtbx_env.LIBTBX_PYTHON_EXE) for dist_path in libtbx_env.dist_paths.values(): package_name = os.path.basename...
self.raw = (raw_record + " " * 80)[:80]
self.raw = (raw_record.rstrip() + " " * 80)[:80]
def __init__(self, raw_record, line_number=None, strict=00000): self.raw = (raw_record + " " * 80)[:80] self.line_number = line_number self.strict = strict self.record_name = (self.raw)[:6].upper().strip() if (self.record_name == "REMARK"): try: n = int(self.raw[7:10]) except: self.record_name += "_UNKNOWN" else: self....
flags = f_obs.generate_r_free_flags(fraction=0.05, max_free=2000)
flags = f_obs.generate_r_free_flags(fraction=0.01, max_free=2000)
def exercise_2(eps = 1.e-6):
def f_model(self): tmp_f_model = self.f_atoms.customized_copy( data = self.data_core.f_model() ) return tmp_f_model
def __init__(self, f_obs_array=None, free_array=None, xray_structure=None, scaling_parameters=None, mask_parameters=None, out=None, twin_law=None, start_fraction=0.1, n_refl_bin=2000, d_min_fudge=0.95): self.out = out if self.out is None: self.out = sys.stdout self.twin_fraction_object = twin_fraction_object(twin_fract...
tmp = self.xray_structure.structure_factors( anomalous_flag=self.f_obs_array.anomalous_flag(), d_min = self.f_obs_array.d_min()*self.d_min_fudge )
if self.miller_set is None: point_group_symmetry = crystal.symmetry( space_group = self.xs.space_group().build_derived_point_group(), unit_cell = self.xs.unit_cell() ) self.miller_set = miller.build_set( crystal_symmetry = point_group_symmetry, anomalous_flag = self.f_obs_array.anomalous_flag(), d_min = self.f_obs_ar...
def update_f_atoms(self): """Get f calc from the xray structure""" tmp = self.xray_structure.structure_factors( anomalous_flag=self.f_obs_array.anomalous_flag(), d_min = self.f_obs_array.d_min()*self.d_min_fudge ) self.f_atoms = tmp.f_calc() if self.miller_set is None: self.miller_set = tmp.miller_set()
"fftbx": (("fftbxmodule",), ("cctbx_bpl1",)),
"fftbx": (("fftbxmodule",), ("cctbx_misc", "cctbx_bpl1",)),
def dependencies(self):
or (name == "dispatcher_front_end.exe" and os.name == "nt")
or (name == "windows_dispatcher.exe" and os.name == "nt")
def copy_dist_files(dist_copy, dirname, names): if (dirname.lower().endswith("cvs")): cvs_entries = libtbx.path.norm_join(dirname, "Entries") if (os.path.isfile(cvs_entries)): return create_target_dir = True for file_name in names: name = file_name.lower() if ( name == "libtbx_config" or (name == "dispatcher_front_en...
def write_dispatcher(self, source_dir, file_name, suppress_warning):
def write_dispatcher(self, source_dir, file_name, suppress_warning, infix=""):
def write_dispatcher(self, source_dir, file_name, suppress_warning): source_file = libtbx.path.norm_join(source_dir, file_name) if (not os.path.isfile(source_file)): return file_name_lower = file_name.lower() if (file_name_lower.startswith("__init__.py")): return if (file_name_lower.endswith(".pyc")): return if (file_n...
target_file = self.name
target_file = self.name + infix
def write_dispatcher(self, source_dir, file_name, suppress_warning): source_file = libtbx.path.norm_join(source_dir, file_name) if (not os.path.isfile(source_file)): return file_name_lower = file_name.lower() if (file_name_lower.startswith("__init__.py")): return if (file_name_lower.endswith(".pyc")): return if (file_n...
def process_python_command_line_scripts(self, source_dir, prefix=" "):
def process_python_command_line_scripts(self, source_dir, prefix=" ", infix=""):
def process_python_command_line_scripts(self, source_dir, prefix=" "): print prefix+'Processing: %s' % show_string(source_dir) for file_name in os.listdir(source_dir): if (not file_name.endswith(".py")): continue self.write_dispatcher( source_dir=source_dir, file_name=file_name, suppress_warning=False)
suppress_warning=False)
suppress_warning=False, infix=infix)
def process_python_command_line_scripts(self, source_dir, prefix=" "): print prefix+'Processing: %s' % show_string(source_dir) for file_name in os.listdir(source_dir): if (not file_name.endswith(".py")): continue self.write_dispatcher( source_dir=source_dir, file_name=file_name, suppress_warning=False)
auto_synomyms.append(atom_name[1:] + atom[0])
auto_synomyms.append(atom_name[1:] + atom_name[0])
def _get_mappings(self, mon_lib_srv): self.monomer_atom_dict = atom_dict = self.monomer.atom_dict() processed_atom_names = {} self.expected_atom_i_seqs = {} self.unexpected_atom_i_seqs = {} self.ignored_atom_i_seqs = {} self.duplicate_atom_i_seqs = {} is_rna_dna = (self.monomer.chem_comp.group == "rna_dna_placeholder" ...
assert_is_compatible_unit_cell=False
assert_is_compatible_unit_cell=False,
def make_new_xs(self, mat): # make new lattice new_basis = self.basis*mat.as_float() new_uc = uctbx.unit_cell( orthogonalization_matrix = new_basis )
cb_op = sgtbx.change_of_basis_op(sgtbx.rt_mx( sgtbx.rot_mx(tmp_gen[0])))
cb_op = sgtbx.change_of_basis_op(sgtbx.rt_mx( sgtbx.rot_mx(tmp_gen[0]))).inverse()
def __init__(self, xs_a, xs_b, max_delta=2.0, out=None, relative_length_tolerance=0.05, absolute_angle_tolerance=10.0, order=1):
"Overmerging pseudo-symmetric or twinned data, as well as bad data quality might be"
"Overmerging pseudo-symmetric or twinned data, intenisty to amplitude conversion problems"
def analyse_intensity_stats(self): if self.twin_results.maha_l >= self.maha_l_cut: if self.twin_results.l_mean < 0.5 : print >> self.twinning_verdict, \ "The results of the L-test indicate that the intensity statistics" print >> self.twinning_verdict, \ "are significantly different then is expected from good to reasona...
"possible reasons. It could be worthwhile considering reprocessing the data."
" as well as bad data quality might be possible reasons." print >> self.twinning_verdict, \ "It could be worthwhile considering reprocessing the data."
def analyse_intensity_stats(self): if self.twin_results.maha_l >= self.maha_l_cut: if self.twin_results.l_mean < 0.5 : print >> self.twinning_verdict, \ "The results of the L-test indicate that the intensity statistics" print >> self.twinning_verdict, \ "are significantly different then is expected from good to reasona...
else:
if self.twin_results.n_twin_laws > 0:
def analyse_intensity_stats(self): if self.twin_results.maha_l >= self.maha_l_cut: if self.twin_results.l_mean < 0.5 : print >> self.twinning_verdict, \ "The results of the L-test indicate that the intensity statistics" print >> self.twinning_verdict, \ "are significantly different then is expected from good to reasona...
print >> out, "Statistics depending on twin laws"
if len(self.twin_laws)>0: print >> out, "Statistics depending on twin laws"
def show(self,out=None): if out is None: out = sys.stdout print >> out print >> out print >> out print >> out print >> out, "--------------------------------------------------------------" print >> out, "Twinning and intensity statistics summary (acentric data):" print >> out print >> out, "Statistics independent of tw...
m = re.match( r'sg=\s*(\S+)\s*a=\s*(\S+)\s*b=\s*(\S+)\s*c=\s*(\S+)' + r'\s*alpha=\s*(\S+)\s*beta=\s*(\S+)\s*gamma=\s*(\S+)', line) if (m): p.unit_cell = uctbx.unit_cell( [float(m.group(i+2)) for i in xrange(6)])
m = re.match(r'\{===>\}\s*sg=\s*"(\S+)"\s*;', line) if (m):
def multi_sdb_parser(lines, file_name=None): # Parser for one or more cns sdb files. # Lines interpreted: # {+ file: heavy_search_1.sdb +} # sg= P6 a= 116.097 b= 116.097 c= 44.175 alpha= 90 beta= 90 gamma= 120 # {===>} site.action_1="refine"; # {===>} site.segid_1="SITE"; site.type_1="SE"; # {===>} site.x_1=1...
else: m = re.match(r'\{===>\}\s*sg=\s*"(\S+)"\s*;', line) if (m): p.space_group_info = sgtbx.space_group_info(m.group(1))
def multi_sdb_parser(lines, file_name=None): # Parser for one or more cns sdb files. # Lines interpreted: # {+ file: heavy_search_1.sdb +} # sg= P6 a= 116.097 b= 116.097 c= 44.175 alpha= 90 beta= 90 gamma= 120 # {===>} site.action_1="refine"; # {===>} site.segid_1="SITE"; site.type_1="SE"; # {===>} site.x_1=1...
if (table == "it1992"): assert d_min == 0 or d_min <= 1/4. if (table == "wk1995"): assert d_min == 0 or d_min <= 1/12.
if (table == "it1992"): assert d_min == 0 or d_min >= 1/4. if (table == "wk1995"): assert d_min == 0 or d_min >= 1/12.
def scattering_dict(self, custom_dict=None, d_min=None, table=None): assert table in [None, "n_gaussian", "it1992", "wk1995"] if (table == "it1992"): assert d_min == 0 or d_min <= 1/4. if (table == "wk1995"): assert d_min == 0 or d_min <= 1/12. if ( self._scattering_dict_is_out_of_date or custom_dict is not None or d...
number_of_iterations = 30000000 for optimized in [False, True]: t0 = time.time() qerf.loop_for_timings(number_of_iterations, optimized=optimized) print "very_quick_erf*%d optimized=%s: %.2f s" % ( number_of_iterations, str(optimized), time.time()-t0) number_of_iterations = 10000000 for optimized in [False, True]: t0 = ...
def test_luts(): qerf = mmtbx.scaling.very_quick_erf(0.001) qeio = mmtbx.scaling.quick_ei0(5000) for i in xrange(-1000,1000): x=i/100.0 assert approx_equal( qerf.erf(x), sm.erf(x), eps=1e-5 ) if (x>=0): assert approx_equal( qeio.ei0(x), math.exp(-x)*sm.bessel_i0(x) , eps=1e-5 )
self.f_obs_test.setup_binner_counting_sorted(reflections_per_bin= self.test_ref_in_bin)
self.f_obs_test.setup_binner(reflections_per_bin= self.test_ref_in_bin)
def __init__(self,f_obs, f_calc, test_ref_in_bin, flags, interpolation): adopt_init_args(self, locals()) # # icent - array contains 0 for acentric reflections and >0 integer # for centric reflections # epsilon - array contains the correction factors for intensity # they are equal to how many times the ...
try: os.remove(target_file_ext) except OSError: try: os.remove(target_file_ext+".old") except OSError: pass try: os.rename(target_file_ext, target_file_ext+".old") except OSError: pass
remove_or_rename(target_file_ext)
def write_dispatcher(self, source_file, target_file): if (os.name == "nt"): action = self.write_win32_dispatcher ext = ".exe" else: action = self.write_bin_sh_dispatcher ext = "" try: os.chmod(source_file, 0755) except OSError: pass target_file_ext = target_file + ext try: os.remove(target_file_ext) except OSError: try...
self.write_dispatcher(
self.write_dispatcher_in_bin(
def refresh(self): self.assemble_pythonpath() self.write_setpath_files() if (len(self.missing_for_build) == 0): self.write_SConstruct() if (os.name != "nt"): self.write_run_tests_csh() if (not os.path.isdir(self.bin_path)): os.makedirs(self.bin_path) for file_name in ("libtbx.python", "python"): self.write_dispatcher( ...
target_file=libtbx.path.norm_join(self.bin_path, file_name))
target_file=file_name)
def refresh(self): self.assemble_pythonpath() self.write_setpath_files() if (len(self.missing_for_build) == 0): self.write_SConstruct() if (os.name != "nt"): self.write_run_tests_csh() if (not os.path.isdir(self.bin_path)): os.makedirs(self.bin_path) for file_name in ("libtbx.python", "python"): self.write_dispatcher( ...
child_stderr.close()
if (child_stderr is not None): child_stderr.close()
def __init__(self, command, stdin_lines=None, join_stdout_stderr=False, bufsize=-1): self.command = command self.join_stdout_stderr = join_stdout_stderr if (join_stdout_stderr): child_stdin, child_stdout = os.popen4(command, "t", bufsize) child_stderr = None else: child_stdin, child_stdout, child_stderr = os.popen3(com...
parameter_scope):
parameter_scope, parameter_name="labels"):
def get_xray_data(self, file_name, labels, ignore_all_zeros, parameter_scope): miller_arrays = self.get_miller_arrays(file_name=file_name) data_scores = get_xray_data_scores( miller_arrays=miller_arrays, ignore_all_zeros=ignore_all_zeros) i = select_array( parameter_name=parameter_scope+".labels", labels=labels, miller...
parameter_name=parameter_scope+".labels",
parameter_name=parameter_scope+"."+parameter_name,
def get_xray_data(self, file_name, labels, ignore_all_zeros, parameter_scope): miller_arrays = self.get_miller_arrays(file_name=file_name) data_scores = get_xray_data_scores( miller_arrays=miller_arrays, ignore_all_zeros=ignore_all_zeros) i = select_array( parameter_name=parameter_scope+".labels", labels=labels, miller...
parameter_scope):
parameter_scope, parameter_name="labels"):
def get_experimental_phases(self, file_name, labels, ignore_all_zeros, parameter_scope): miller_arrays = self.get_miller_arrays(file_name=file_name) data_scores = get_experimental_phases_scores( miller_arrays=miller_arrays, ignore_all_zeros=ignore_all_zeros) i = select_array( parameter_name=parameter_scope+".labels", l...
parameter_name=parameter_scope+".labels",
parameter_name=parameter_scope+"."+parameter_name,
def get_experimental_phases(self, file_name, labels, ignore_all_zeros, parameter_scope): miller_arrays = self.get_miller_arrays(file_name=file_name) data_scores = get_experimental_phases_scores( miller_arrays=miller_arrays, ignore_all_zeros=ignore_all_zeros) i = select_array( parameter_name=parameter_scope+".labels", l...
print "%7.4f" % flex.mean(data),
else: print "%7.4f" % flex.mean(data),
def show_average_of_binned_data(binned_data_list): l = len(binned_data_list[0].binner.bin_legend(0)) print " "*(l-9), "average:", for binned_data in binned_data_list: data = flex.double() for d in binned_data.data[1:-1]: if (d is not None): data.append(d) if (data.size() == 0): print " "*7, print "%7.4f" % flex.mean(da...
if (isfile(target_file)):
if (isfile(target_file) or islink(target_file)):
def create_python_dispatchers(target_dir, python_exe): for file_name in ("libtbx.python", "python"): target_file = norm(join(target_dir, file_name)) if (os.name == "nt"): target_file += ".exe" action = shutil.copyfile else: action = os.symlink if (isfile(target_file)): try: os.remove(target_file) except OSError: pass e...
label, n_terms)
label, last_fit.n_terms()-1)
def decremental_fits(label, null_fit, full_fit=None, params=None, plots_dir=None, verbose=0): if (params is None): params = fit_parameters() results = [] last_fit = scitbx.math.gaussian.fit( null_fit.table_x(), null_fit.table_y(), null_fit.table_sigmas(), full_fit) while (last_fit.n_terms() > 1): good_min = scitbx.math...
n_terms=n_terms,
n_terms=good_min.final_gaussian_fit.n_terms(),
def decremental_fits(label, null_fit, full_fit=None, params=None, plots_dir=None, verbose=0): if (params is None): params = fit_parameters() results = [] last_fit = scitbx.math.gaussian.fit( null_fit.table_x(), null_fit.table_y(), null_fit.table_sigmas(), full_fit) while (last_fit.n_terms() > 1): good_min = scitbx.math...
label=label+"_%d"%n_terms,
label=label+"_%d"%good_min.final_gaussian_fit.n_terms(),
def decremental_fits(label, null_fit, full_fit=None, params=None, plots_dir=None, verbose=0): if (params is None): params = fit_parameters() results = [] last_fit = scitbx.math.gaussian.fit( null_fit.table_x(), null_fit.table_y(), null_fit.table_sigmas(), full_fit) while (last_fit.n_terms() > 1): good_min = scitbx.math...