mmtbx.utils package

Module contents

Library of convenience functions for working with models and reflection data. This contains a number of routines used in phenix.refine and related programs, mainly concerned with the repetitive process of loading model and data files and initializing the appropriate objects. Note that if you are writing a program that uses similar inputs, it may be significantly easier to use the unified input handling encapsulated in mmtbx.command_line, which wraps much of the functionality in mmtbx.utils while hiding the messy details.

mmtbx.utils.assert_model_is_consistent(model)
mmtbx.utils.assert_water_is_consistent(model)
mmtbx.utils.assert_xray_structures_equal(x1, x2, selection=None, sites=True, adp=True, occupancies=True, elements=True, scattering_types=True, eps=1e-06, eps_occ=None)
mmtbx.utils.atom_selection(model, string, allow_empty_selection=False)
mmtbx.utils.check_and_set_crystal_symmetry(models=[], map_inps=[], miller_arrays=[], crystal_symmetry=None, ignore_symmetry_conflicts=False, absolute_angle_tolerance=0.01, absolute_length_tolerance=0.01)
mmtbx.utils.compare_hierarchy(hierarchy, scatterers, cell)
class mmtbx.utils.detect_hydrogen_nomenclature_problem(pdb_file, cif_files=())

Bases: object

This allows us to avoid the following problems: 1) a bug in automatic linking which deletes the monomer library definition

for HD22 for an N-linked Asn, even though it may not actually be replaced by a sugar link.

  1. general issues with hydrogen nomenclature

bad_hydrogens
Type:

a list of problematic atom ID strings

n_asn_hd22
Type:

number of inappropriate ASN HD22 atoms

n_hydrogen
Type:

number of hydrogens missing geometry restraints

n_other
Type:

number of non-hydrogen atoms missing geometry restraints

mmtbx.utils.equivalent_sigma_from_cumulative_histogram_match(map_1, map_2, sigma_1, tail_cutoff=3, step=1, verbose=True)
class mmtbx.utils.experimental_data_target_and_gradients(fmodel, alpha_beta=None)

Bases: object

grad_occ()
grad_sites_cart()
group_occupancy_grads(pdb_hierarchy=None, residues_per_window=None, selections=None)
show(log=None)
target()
update_xray_structure(xray_structure, alpha_beta=None)
class mmtbx.utils.extract_box_around_model_and_map(xray_structure=None, map_data=None, box_cushion=None)

Bases: object

apply_mask_inplace(atom_radius)
box_map_coefficients(d_min, shift_back=None)
box_map_coefficients_as_fft_map(d_min, resolution_factor)
cut_and_copy_map(map_data=None)
get_original_cs()
get_shifted_cs()
get_solvent_content()
map_coefficients(d_min, resolution_factor, file_name='box.mtz', scale_max=None, shift_back=None)
origin_shift_grid_units(unit_cell=None, reverse=False)
shift_back(pdb_hierarchy)
shift_map_back(map_data)
shift_map_coeffs_back(map_coeffs)
shift_sites_cart_back(sites_cart)
write_xplor_map(file_name)
mmtbx.utils.extract_tls_and_u_total_from_pdb(f_obs, r_free_flags, xray_structure, tls_selections, tls_groups)
class mmtbx.utils.f_000(xray_structure=None, unit_cell_volume=None, solvent_fraction=None, mean_solvent_density=0.35)

Bases: object

mmtbx.utils.find_overlapping_selections(selections, selection_strings)

Given a list of atom selections (scitbx.array_family.flex.bool arrays) and corresponding selection strings, inspect the selections to determine whether any two arrays overlap. Returns a tuple of the first pair of selection strings found to overlap, or None if all selections are unique.

class mmtbx.utils.fmodel_from_xray_structure(xray_structure, f_obs=None, params=None, r_free_flags_fraction=None, add_sigmas=False, twin_law=None, twin_fraction=None, target='ml', out=None, merge_r_free_flags=None, use_custom_scattering_dictionary=False)

Bases: object

Sorry_high_resolution_is_not_defined()
write_to_file(file_name, obs_type='amplitudes')
mmtbx.utils.fmodel_manager(f_obs, i_obs=None, xray_structure=None, r_free_flags=None, f_mask=None, f_calc=None, ignore_r_free_flags=False, target_name='ml', k_mask=None, k_anisotropic=None, hl_coeff=None, epsilons=None, use_f_model_scaled=False, twin_law=None, alpha_beta_params=None, sf_and_grads_accuracy_params=<libtbx.phil.scope_extract object>, mask_params=None, max_number_of_resolution_bins=None, n_resolution_bins_output=None)
mmtbx.utils.fmodel_manager2(f_obs, r_free_flags, abcd, xray_structure, twin_law, ignore_r_free_flags, mask_params, mtz_object=None, data_type=None)

This makes a basic fmodel manager. alpha_beta_params, sf_and_grads_accuracy_params, mask_params, tNCS epsilons, target_name should be set separately if needed.

mmtbx.utils.fmodel_simple(f_obs, xray_structures, scattering_table, r_free_flags=None, target_name='ml', bulk_solvent_and_scaling=True, bss_params=None, mask_params=None, twin_laws=None, skip_twin_detection=False, twin_switch_tolerance=2.0, outliers_rejection=True, bulk_solvent_correction=True, anisotropic_scaling=True, log=None)
mmtbx.utils.get_atom_selection(pdb_file_name, selection_string, iselection=False)
mmtbx.utils.get_atom_selections(model=None, selection_strings=None, iselection=True, one_group_per_residue=False, allow_empty_selection=False, hydrogens_only=False, one_selection_array=False, parameter_name=None)
class mmtbx.utils.guess_observation_type(f_obs, label, xray_structure, r_free_flags=None)

Bases: object

data_size = 500
find_best(results)
get_r_factor(f_obs, f_calc, scattering_table, xray_structure, twin_switch_tolerance, skip_twin_detection)
mtz_object()
mmtbx.utils.limit_frac_min_frac_max(frac_min, frac_max)
mmtbx.utils.model_from_sites_cart(sites_cart, atom_name='CA', resname='GLY', chain_id='A', b_iso=30.0, occ=1.0, scatterer='C', crystal_symmetry=None)
mmtbx.utils.optimize_h(fmodel, mon_lib_srv, pdb_hierarchy=None, model=None, log=None, verbose=True)
mmtbx.utils.pdb_inp_from_multiple_files(pdb_files, log)
mmtbx.utils.print_header(line, out=None)
mmtbx.utils.print_programs_start_header(log, text)
class mmtbx.utils.process_command_line_args(args, cmd_cs=None, master_params=None, log=None, home_scope=None, absolute_angle_tolerance=0.01, absolute_length_tolerance=0.01, suppress_symmetry_related_errors=False)

Bases: object

get_reflection_file_server()
class mmtbx.utils.process_pdb_file_srv(crystal_symmetry=None, pdb_parameters=None, pdb_interpretation_params=None, stop_for_unknowns=None, log=None, cif_objects=None, cif_parameters=None, mon_lib_srv=None, ener_lib=None, use_neutron_distances=False)

Bases: object

process_pdb_files(pdb_file_names=None, raw_records=None, pdb_inp=None, hierarchy=None, allow_missing_symmetry=False)
mmtbx.utils.remove_selections(selection, other, size)
class mmtbx.utils.run_reduce_with_timeout(stdin_lines, parameters='', file_name=None, override_auto_timeout_with=None, join_stdout_stderr=False, stdout_splitlines=True, bufsize=-1)

Bases: fully_buffered_subprocess

as_pdb_hierarchy()
mmtbx.utils.set_log(args, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, replace_stderr=True)
class mmtbx.utils.set_map_to_value(map_data, xray_structure, atom_radius, value)

Bases: object

write_xplor_map(file_name)
mmtbx.utils.setup_scattering_dictionaries(scattering_table, xray_structure, d_min, log=None, all_chain_proxies=None)
class mmtbx.utils.shift_origin(map_data=None, pdb_hierarchy=None, xray_structure=None, crystal_symmetry=None, ncs_object=None, origin_grid_units=None, n_xyz=None)

Bases: object

get_original_cs()
shift_back(pdb_hierarchy)
write_map_file(file_name)
write_model_file(file_name)
class mmtbx.utils.states(pdb_hierarchy, xray_structure=None, counter=0)

Bases: object

add(sites_cart=None, hierarchy=None)
write(file_name, crystal_symmetry=None)
mmtbx.utils.switch_rotamers(pdb_hierarchy, mode, accept_allowed=True, selection=None, mon_lib_srv=None, rotamer_manager=None)
class mmtbx.utils.xray_structures_from_processed_pdb_file(processed_pdb_file, scattering_table, d_min, log=None)

Bases: object

Submodules

mmtbx.utils.fab_elbow_angle module

class mmtbx.utils.fab_elbow_angle.fab_elbow_angle(pdb_hierarchy, chain_id_light='L', chain_id_heavy='H', limit_light=107, limit_heavy=113)

Bases: object

cross_product_as_unit_axis(a, b)
get_angle(vec1, vec2, larger=True)

retrun the larger angle between vec1 and vec2

get_eigenvector(eigen)

Get the eigen vector for eigen value 1 and normalize it

get_pdb_chains()

Create seperate pdb hierarchy for each on the chains we want to align

get_transformation(fixed_selection, moving_selection)
norm_vec(start, end)

retruns normalized vector that starts at “stat” and ends at “end”

select_str(chain_ID_H, limit_H, chain_ID_L, limit_L)

create selection strings for the heavy and light chains separating the variable and constant parts of the chains

mmtbx.utils.ncs_utils module

mmtbx.utils.rotatable_bonds module

mmtbx.utils.rotatable_bonds.axes_and_atoms_aa_specific(residue, mon_lib_srv, remove_clusters_with_all_h=False, include_labels=False, tardy_model=None, log=None)
mmtbx.utils.rotatable_bonds.tardy_model_one_residue(residue, mon_lib_srv, log=None)