mmtbx.ncs

Submodules

mmtbx.ncs.ligands module

Post-fitting cleanup of ligand positions to match NCS operations present in protein model. This can be used to recover cases where one copy is placed successfully but another misses due to interfering protein atoms, weak density, false positive in empty protein density, etc. It can also accelerate ligand placement for large structures if at least one copy is already placed with high confidence. Should only be used when the initial placement (e.g. LigandFit CC) is sufficiently good.

Usually this will be called via the command mmtbx.apply_ncs_to_ligand.

class mmtbx.ncs.ligands.apply_ligand_ncs(pdb_hierarchy, fmodel, ligand_code, params, atom_selection=None, add_new_ligands_to_pdb=False, only_segid=None, log=None)

Bases: object

Wrapper class; this should be the primary entry point for external calling routines.

Parameters:
  • pdb_hierarchy – initial model with one or more copies of the target ligand

  • fmodel – mmtbx.f_model.manager object corresponding to the model

  • ligand_code – three-letter residue name of ligand

  • params – phil scope_extract object for ncs_ligand_phil

  • atom_selection – selection for reference ligand (default: search for all copies and pick one with the best CC)

  • add_new_ligands_to_pdb – generate combined PDB hierarchy and fmodel with new ligands incorporated

  • only_segid

  • log – filehandle-like object

property n_ligands
write_maps(file_name)
write_pdb(file_name)
mmtbx.ncs.ligands.combine_ligands_and_hierarchy(pdb_hierarchy, ligands, log=None)
mmtbx.ncs.ligands.extract_ligand_residues(pdb_hierarchy, ligand_code, atom_selection=None, only_segid=None)

Extract the atom_group object(s) with given 3-character residue name.

Parameters:
  • pdb_hierarchy – input model

  • ligand_code – 3-letter residue ID

  • atom_selection – optional flex.bool object specifying ligand selection to use

  • only_segid – optional segid which ligand(s) must match

Returns:

list of atom_group objects

class mmtbx.ncs.ligands.get_final_maps_and_cc(fmodel, ligands, params, log)

Bases: object

write_maps(file_name)
class mmtbx.ncs.ligands.group_operators(selection, sele_str, sites_cart)

Bases: object

Object for storing information about NCS relationships relative to an atom selection, i.e. given four identical chains A, B, C, and D, this might store information about chain B and the NCS operators for approximate superpositioning on chains A, C, and D.

add_operator(ops, sele_str)

Save an NCS operator and corresponding atom selection.

distance_from_center(sites)

Compute the distance between centers-of-mass of this selection and the given sites. Used to determine ligand-protein chain relationships.

show_summary(out=None, prefix='')

Print out selections and NCS operators.

mmtbx.ncs.ligands.remove_clashing_atoms(xray_structure, pdb_hierarchy, ligands, params, log)

Since the transformed ligands will very frequently overlap with existing atoms, these need to be deleted if we are confident about the new positions.

mmtbx.ncs.ligands.resid_str(atom)
class mmtbx.ncs.ligands.sample_operators(pdb_hierarchy, fmodel, ncs_operators, ligands, params, log=None)

Bases: object

Determines an appropriate “reference” ligand, and samples the density around sites transformed by each operator, applying the best operator to the other ligand copies if meeting cutoff criteria.

get_new_fcalc_map(sites_new, i_seqs)
get_sites_cc(atoms, sites=None)
setup_maps()

Create 2mFo-DFc, mFo-DFc, and Fc maps.

mmtbx.ncs.ligands.xyz_distance(xyz1, xyz2)

mmtbx.ncs.ncs module

mmtbx.ncs.ncs.abs(aa)
mmtbx.ncs.ncs.crystal_symmetry_to_ncs(crystal_symmetry=None)
mmtbx.ncs.ncs.euler_frac_to_rot_trans(euler_values, frac, unit_cell)
mmtbx.ncs.ncs.generate_ncs_ops(symmetry=None, must_be_consistent_with_space_group_number=None, helical_rot_deg=None, helical_trans_z_angstrom=None, op_max=None, two_fold_along_x=None, include_helical_symmetry=None, max_helical_ops_to_check=None, require_helical_or_point_group_symmetry=None, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)
mmtbx.ncs.ncs.get_c_symmetry(n=None, is_d=False, two_fold_along_x=None, ncs_name=None)
mmtbx.ncs.ncs.get_d_symmetry(n=None, two_fold_along_x=True, ncs_name=None)
mmtbx.ncs.ncs.get_helical_symmetry(helical_rot_deg=None, helical_trans_z_angstrom=None, max_ops=None)
mmtbx.ncs.ncs.get_ncs_from_text(text=None, text_is_ncs_spec=None, rotate_about_z=None, rotate_about_y=None, rotate_about_new_y=None, ncs_name=None, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)
mmtbx.ncs.ncs.get_rot_y(rot_deg=None)
mmtbx.ncs.ncs.get_rot_z(rot_deg=None)
mmtbx.ncs.ncs.is_identity(r, t, tol=0.01)
mmtbx.ncs.ncs.is_in_range(z, z_min, z_max)
mmtbx.ncs.ncs.is_same_transform(r1, t1, r2, t2, tol_r=0.02, abs_tol_t=2.0, rel_tol_t=0.05)
class mmtbx.ncs.ncs.ncs(exclude_h=None, exclude_d=None)

Bases: object

add_cc_list(cc_list)
add_identity_op()
add_source_info(source_info)
adjust_magnification(magnification=None)
apply_ncs_to_sites(sites_cart=None, ncs_obj=None, exclude_identity=False, ncs_id=None)
as_ncs_spec_string(format='ncs_spec')

shifts to original location and returns text string

change_of_basis(change_of_basis_operator=None, unit_cell=None, new_unit_cell=None)
coordinate_offset(coordinate_offset=None, unit_cell=None, new_unit_cell=None)
deep_copy(change_of_basis_operator=None, unit_cell=None, coordinate_offset=None, scale_factor=None, new_unit_cell=None, ops_to_keep=None, extract_point_group_symmetry=None, hierarchy_to_match_order=None)
display_all(verbose=True, log=None)
extend_helix_operators(z_range=None, tol_z=0.01, max_operators=None)
format_all_for_biomt(log=None, quiet=False, out=None)
format_all_for_group_specification(log=None, quiet=True, out=None, file_name=None)
format_all_for_phenix_refine(quiet=False, out=None, prefix='refinement.pdb_interpretation.ncs_group')

This function is an older version of creating phil for phenix refine, it is modified to replicate a new phil parameters that can handle selection to the level of atoms, “format_phil_for_phenix_refine”.

When it will still can be used in the older form, which allows only residue level selection.

format_all_for_resolve(log=None, quiet=False, out=None, crystal_number=None, skip_identity_if_first=False, ncs_domain_pdb=True)
format_phil_for_ncs(log=None, quiet=False, out=None)

Writes NCS phil selection in NCS format

format_phil_for_phenix_refine(log=None, quiet=False, out=None)

Writes NCS phil selection in phenix_refine format

get_1_char_after_key(line)
get_1_value_after_key(line)
get_3_values_after_key(line)
get_helix_parameters(z_range=None, tol_z=0.01, max_operators=None)
get_ncs_name()
get_res_range_after_key(line)
identity_op_id_in_first_group()
import_ncs_group(ncs_rota_matr=None, center_orth=None, trans_orth=None, chain_residue_id=None, residues_in_common_list=None, rmsd_list=None, ncs_domain_pdb=None, cc=None, source_of_ncs_info=None, ncs_group_object=None)
init_ncs_group()
init_oper()
invert_matrices()
is_helical_along_z(tol_r=0.02, abs_tol_t=2.0, rel_tol_t=0.05)
is_point_group_symmetry(tol_r=0.02, abs_tol_t=2.0, rel_tol_t=0.05)
is_similar_ncs_object(other, tol_r=0.02, abs_tol_t=2.0, rel_tol_t=0.05, allow_self_contained_in_other=True)

Determine if self and other are similar ncs objects ncs groups do not have to be in same order

magnification(scale_factor=None)
map_inside_unit_cell(unit_cell=None)
max_operators()
ncs_from_import(rot_list=None, trans_list=None, invert_matrices=True)
ncs_from_pdb_input_BIOMT(pdb_inp=None, log=None, quiet=False, invert_matrices=True)
ncs_groups()
ncs_oper_in_first_group()
ncs_read()
overall_cc()
overall_note()
overall_rmsd()
read_ncs(file_name=None, lines=[], source_info='', log=None, quiet=False)
rotate_about_y(rot_deg=None, invert_matrices=True)
rotate_about_z(rot_deg=None, invert_matrices=True)
rotate_matrices(rot=None)
save_existing_group_info()
save_ncs_group()
save_oper()
select_first_ncs_group()
select_first_ncs_operator()
set_ncs_name(ncs_name)
set_shift_cart(shift_cart)
set_unit_ncs()
shift_back_cart()
shift_cart()
show_summary(verbose=True, log=None)
sort_by_z_translation(tol_z=0.01)
class mmtbx.ncs.ncs.ncs_group(ncs_rota_matr=None, center_orth=None, trans_orth=None, chain_residue_id=None, source_of_ncs_info=None, rmsd_list=None, ncs_domain_pdb=None, residues_in_common_list=None, cc=None, note=None, exclude_h=None, exclude_d=None)

Bases: object

add_cc(cc)
add_chain_residue_id(chain_residue_id)
add_identity_op()
add_note(note)
add_residues_in_common_list(residues_in_common_list)
add_rmsd_list(rmsd_list)
adjust_magnification(magnification=None)
apply_cob_to_vector(vector=None, change_of_basis_operator=None, coordinate_offset=None, unit_cell=None, new_unit_cell=None)
cc()
centers()
chain_residue_id()
copy_rot_trans(list_of_matrices, list_of_translations, change_of_basis_operator=None, coordinate_offset=None, scale_factor=None, unit_cell=None, new_unit_cell=None)
copy_vector_list(list_of_vectors, change_of_basis_operator=None, coordinate_offset=None, scale_factor=None, unit_cell=None, new_unit_cell=None)
deep_copy(change_of_basis_operator=None, unit_cell=None, coordinate_offset=None, new_unit_cell=None, scale_factor=None, extract_point_group_symmetry=None, ops_to_keep=None, hierarchy_to_match_order=None)
deep_copy_ops_to_keep(ops_to_keep=None)
deep_copy_order(hierarchy_to_match_order=None)
delete_inv()
display_summary(verbose=None)
extend_helix_operators(z_range=None, tol_z=0.01, max_operators=None)
extract_point_group_symmetry(tol_r=None, abs_tol_t=None, rel_tol_t=None)
format_for_biomt(crystal_number=None, skip_identity_if_first=False, ncs_domain_pdb=True)
format_for_phenix_refine(prefix='pdb_interpretation.ncs_group')
format_for_resolve(crystal_number=None, skip_identity_if_first=False, ncs_domain_pdb=True)
format_group_specification()
get_forwards_reverse_helix(r1=None, t1=None, r2=None, t2=None)
get_helix_parameters(tol_z=0.01)
get_helix_theta()
get_helix_z_translation()
get_inverses()
get_new_group(hierarchy_to_match_order=None)
get_order_dict(hierarchy_to_match_order=None)
get_theta_along_z(m0, m1)
get_trans_along_z(t0, t1)
helix_rt_forwards()
helix_rt_reverse()
identity_op_id()
invert_matrices()
is_helical_along_z(tol_z=0.01, tol_r=0.02, abs_tol_t=2.0, rel_tol_t=0.05)
is_point_group_symmetry(tol_r=0.02, abs_tol_t=2.0, rel_tol_t=0.05, symmetry_to_match=None)
is_similar_ncs_group(other, tol_r=0.02, abs_tol_t=2.0, rel_tol_t=0.05, allow_self_contained_in_other=True)

return True if all operations of self match one of other

map_inside_unit_cell(unit_cell=None)
n_ncs_oper()
ncs_domain_pdb()
note()
oper_adds_offset(i1, tol_r=None, abs_tol_t=None, rel_tol_t=None)
print_list(list_of_real)
residues_in_common_list()
rmsd_list()
rota_matrices()
rota_matrices_inv()
rotate_matrices(rot=None)
rotations_translations_forward_euler()
round(value, n_digit)
sort_by_z_translation(tol_z=0.01, allow_negative_z_translation=False)
source_of_ncs_info()
translations_orth()
translations_orth_inv()
mmtbx.ncs.ncs.offset_inside_cell(center, unit_cell, orthogonalize=True)
mmtbx.ncs.ncs.offset_inside_zero_one(x)
mmtbx.ncs.ncs.remove_extra(text)
mmtbx.ncs.ncs.remove_ncs_not_consistent_with_space_group_number(sg_number, ncs_list)
remove ncs ojbect that are not consistent with space_group number

sg_number

NOTE: allows ncs that has higher symmetry than sg_number

mmtbx.ncs.ncs.remove_quotes_from_chain_id(chain_residue_id)
mmtbx.ncs.ncs.remove_single_quotes(text)
mmtbx.ncs.ncs.value(str)

mmtbx.ncs.restraints module

mmtbx.ncs.ncs_utils module

mmtbx.ncs.ncs_utils.apply_transforms(ncs_coordinates, ncs_restraints_group_list, total_asu_length, extended_ncs_selection, round_coordinates=True, center_of_coordinates=None)

Apply transformation to ncs_coordinates, and round the results if round_coordinates is True

Parameters:
  • ncs_coordinates (flex.vec3) – master ncs coordinates

  • ncs_restraints_group_list – list of ncs_restraint_group objects

  • total_asu_length (int) – Complete ASU length extended_ncs_selection (flex.size_t): master ncs and non-ncs related parts

  • center_of_coordinates – when not None, contains the center of coordinate of the master for each ncs copy

Returns:

Asymmetric or biological unit parts that are related via

ncs operations

Return type:

(flex.vec3_double)

mmtbx.ncs.ncs_utils.compute_transform_grad(grad_wrt_xyz, xyz_asu, x, ncs_restraints_group_list)

XXX XXX Consider making it method of class_ncs_restraints_group_list XXX

Compute gradient in respect to the rotation angles and the translation vectors. R = Rx(the)Ry(psi)Rz(phi)

Parameters:
  • grad_wrt_xyz (flex.double) – gradients with respect to xyz.

  • ncs_restraints_group_list – list containing ncs_restraint_group objects

  • transforms_obj (ncs_group_object) – containing information in rotation matrices and to which chains they apply

  • xyz_asu (flex.vec3) – The coordinates sites cart of the complete ASU

  • x (flex double) – The angles, in the form (theta_1,psi_1,phi_1,tx_1,ty_1,tz_1,.. theta_n,psi_n,phi_n,tx_n/s,ty_n/s,tz_n/s)

Returns:

the gradient

Return type:

g (flex.double)

mmtbx.ncs.ncs_utils.flip_atoms_in_ncs_groups(hierarchy, ncs_restraints_group_list, mon_lib_srv=None)

XXX XXX not used, only tested. May have some value. XXX This function will actually modify hierarchy by making necessary flips in ncs-related residues. Flip will be made by exchanging atom coordinates. Will make all copies consistent with master.

mmtbx.ncs.ncs_utils.get_list_of_best_ncs_copy_map_correlation(ncs_groups, xray_structure=None, fmodel=None, map_data=None, d_min=None)

Finds the copy with best map correlation in each ncs group

Returns:

list of the copy with the best map correlation.

(the master copy is 0)

Return type:

best_list (list of int)

mmtbx.ncs.ncs_utils.get_refine_selection(refine_selection=None, number_of_atoms=None)

populate refine_selection with all atoms if no selection is given

mmtbx.ncs.ncs_utils.get_weight(fmodel=None, restraints_manager=None, sites=None, transformations=None, u_iso=None, ncs_restraints_group_list=None, refine_selection=None, minimized_obj=None)

Calculates weights for refinements by slightly shaking the minimized parameters and taking the ratio: (restraint manager grad norm / parameters gradient norm)

When calling this function during refinement macro cycle, the minimized object, “minimized_obj” , may contains fmodel, restraints_manager, refinement type info (sites, transformations, u_iso) and ncs_restraints_group_list.

Parameters:
  • fmodel – F-model object

  • restraints_manager – Restraints manager object

  • sites (bool) – Refine by sites

  • u_iso (bool) – Refine using u_iso

  • transformations (bool) – Refine using transformations rotations, translations (matrix objects):

  • ncs_restraints_group_list – list of ncs_restraint_group objects

  • refine_selection (flex.size_t) – selection of all ncs related copies and non ncs related parts to be included in selection (to be refined)

  • minimized_obj – Minimization object containing all the other parameters above

Return type:

weight (int)

Example: >>>get_weight(minimized_obj=minimized_obj)

or

>>>get_weight(fmodel=fmodel,

restraints_manager=grm, sites=sites, transformations=transformations, u_iso=u_iso, ncs_restraints_group_list=ncs_restraints_group_list, refine_selection=refine_selection)

mmtbx.ncs.ncs_utils.remove_items_from_selection(selection, remove)

Remove a set of atoms from “selection”

Parameters:
Returns:

modified atom selection

Return type:

(flex.size_t)

Examples::

>>>a = flex.size_t([1,2,5,6,4]) >>>r = flex.size_t([2,5]) >>>s = remove_items_from_selection(a,r,10) >>>list(s) [1,6,4]

mmtbx.ncs.ncs_utils.rotation_to_angles(rotation, deg=False)

Get the rotation angles around the axis x,y,z for rotation r Such that r = Rx*Ry*Rz Those angles are the Tait-Bryan angles form of Euler angles

Note that typically there are two solutions, and this function will return only one. In the case that cos(beta) == 0 there are infinite number of solutions, the function returns the one where gamma = 0

Parameters:
  • r – (flex.double) of the form (Rxx,Rxy,Rxz,Ryx,Ryy,Ryz,Rzx,Rzy,Rzz)

  • deg – When False use radians, when True use degrees

Returns:

(alpha, beta, gamma) rotation angles around the x,y,z

Return type:

angles (flex.double)

mmtbx.ncs.ncs_utils.selected_positions(selection, positions)

Returns only the selected indices in the positions specified in “positions” keeping the order

Parameters:
  • selection (flex.size_t) – Atoms selection

  • positions (set or list) – the allowed positions in the selections

Returns:

(selected atoms, atoms, not selected)

Return type:

(flex.size_t, flex.size_t)

Examples::

>>>a = flex.size_t([1,2,5,6,4]) >>>pos = {0,3,4} >>>s,d = selected_positions(a,pos) >>>list(s) [1,6,4] >>>list(d) [2,5]

mmtbx.ncs.ncs_utils.shake_transformations(x, shake_angles_sigma=0.035, shake_translation_sigma=0.5)

XXX XXX Used here in get_weight(). XXX Not clear what relation MTRIX have to this function at all… XXX

Shake rotation matrices and translation vectors of a rotation matrices and translation vectors from the MTRIX records in a PDB file.

Parameters:
  • x (flex.double) – [(alpha_1,beta_1,gamma_1,Tx_1/s,Ty_1/s,Tz_1/s)…]

  • shake_angles_sigma (float) – the sigma (in radians) of the random gaussian shaking of the rotation angles

  • shake_translation_sigma (float) – the sigma (in angstrom) of the random gaussian shaking of the translation

Returns:

The shaken x

Return type:

new_x (flex.double)

Module contents