mmtbx.ions.svm.utils module¶
Utility functions used within this module.
- mmtbx.ions.svm.utils.filter_svm_outputs(chem_env, scatter_env, predictions)¶
Applies a simple set of filters to the accepted ions that might match a given chemical and scattering environment to help catch corner cases where the SVM might fail.
- Parameters:
chem_env (mmtbx.ions.environment.ChemicalEnvironment)
scatter_env (mmtbx.ions.environment.ScatteringEnvironment)
- Return type:
- mmtbx.ions.svm.utils.iterate_sites(pdb_hierarchy, split_sites=False, res_filter=None)¶
Returns a generator iterating over all atoms in pdb_hierarchy. Optionally skips sites with alternate conformations and can filter by residue name.
- Parameters:
pdb_hierarchy (iotbx.pdb.hierarchy.root)
split_sites (bool, optional) – Indicates whether to iterate over sites with alternate conformations, by default they are not included.
res_filter (list of str, optional) – List of residue names to include, by default, all residues are examined.
- Return type:
generator of iotbx.pdb.hierarchy.atom
- mmtbx.ions.svm.utils.scale_to(matrix, source, target)¶
Given an upper and lower bound for each row of matrix, scales the values to be within the range specified by target.
- Parameters:
- Returns:
matrix – The matrix with scaled values.
- Return type:
numpy.array of float
Examples
>>> from mmtbx.ions.svm.utils import scale_to >>> import numpy as np >>> matrix = np.array([[0, 1, 2], [2, 3, 4], [1, 2, 3]]) >>> source = (np.array([2, 3, 4]), np.array([0, 1, 2])) >>> target = (0, 1) >>> scale_to(matrix, source, target) array([[ 1. , 1. , 1. ], [ 0. , 0. , 0. ], [ 0.5, 0.5, 0.5]])