restraintmaker.utils package
Submodules
restraintmaker.utils.Types module
restraintmaker.utils.Utilities module
Utilities utilities contains functions and definitions that are usefull to all modules in the restraintmaker project
- class restraintmaker.utils.Utilities.Atom(elem, id, name, x, y, z, chain, resn, resi, alt, b, label)
Bases:
tuple
- alt
Alias for field number 9
- b
Alias for field number 10
- chain
Alias for field number 6
- elem
Alias for field number 0
- id
Alias for field number 1
- label
Alias for field number 11
- name
Alias for field number 2
- resi
Alias for field number 8
- resn
Alias for field number 7
- x
Alias for field number 3
- y
Alias for field number 4
- z
Alias for field number 5
- exception restraintmaker.utils.Utilities.BadArgumentException(*args)[source]
Bases:
Exception
A BadArgumentException will be raised by the Filter, Selection and Optimizer classes if their function get-args(…) does not produce arguments in the desired format.
- exception restraintmaker.utils.Utilities.NoOptimalSolutionException(args)[source]
Bases:
Exception
A no optimal solution excpetion will be raised by an Optimizer, if it can not find a solution fulfilling its criteria.
- class restraintmaker.utils.Utilities.RestraintPair(r1, r2, distance)
Bases:
tuple
- distance
Alias for field number 2
- r1
Alias for field number 0
- r2
Alias for field number 1
- restraintmaker.utils.Utilities.check_for_doubles(list: List) bool [source]
Just used for debbuging Checks if a List contains doubles
- Parameters
list (t.List) – Any list
- Returns
Does the list contain doubles?
- Return type
bool
- restraintmaker.utils.Utilities.check_or_convert_argument(input, desired_type, acceptable_values=None)[source]
try to convert should be used in all get_args functions to check the input from the input function and try to convert it if necessary
TODO: Might be even nicer if we do not pass a list of acceptable values but a bool function TODO: Pass name of the variable as arg, so we can get better Error messages ()
- Parameters
input (t.Any) – input as received from the function
desired_type (type) – the needed type
acceptable_values (t.List) – Optional. a List of set Values the input must have.
- Returns
converted input to desired_type
- Return type
type
- Raises
u.BadArgument_Exception – if conversion is not possible or the input is not an acceptable value
- restraintmaker.utils.Utilities.check_restraint_pairs_for_doubles(list)[source]
check_restraint_pairs_for_doubles checks a list of pairs for doubles. Pairs count as doubles if the order of elements is changed.
- Parameters
list (t.List[t.Tuple]) – A list of tuples
- Returns
Does the list contain doubles?
- Return type
bool
- restraintmaker.utils.Utilities.convert_atoms_to_pdb_molecules(atoms: List[restraintmaker.utils.Utilities.Atom]) List[str] [source]
This function converts the atom list into pdb blocks.
- Parameters
atoms (t.List[Atom]) – List of atoms
- Returns
pdb strings of that molecule
- Return type
t.List[str]
- restraintmaker.utils.Utilities.do_nothing(dummy_string: str = '')[source]
does nothing. Can be passed to the *.get_args functions which require a function of a string as parameter. Because it is more readable than lambda x: None
- Parameters
dummy_string (str) – Dummy String to satisfy format
- Return type
NoReturn
- restraintmaker.utils.Utilities.execute_at_different_verbosity(new_verbosity_threshold, func, *args, **kwargs)[source]
- Wrapper function to change the program verbosity during the execution of one function.
@Warning All Errors will be passed on to the calling function. But the verbosity_thresheold will be reset to the previous value in any case.
- Parameters
new_verbosity_threshold (int) – verbosity threshold to be applied duribng the execution of func
func (t.Callable) – Function which should be executed
args (Any)
kwargs (Any)
- Returns
return value of func
- Return type
Any
- restraintmaker.utils.Utilities.find_atom_by_property(atoms: List[restraintmaker.utils.Utilities.Atom], property_value: any, property_name: str = 'id') restraintmaker.utils.Utilities.Atom [source]
find_atom will look for the first atom with the specified property and value
- Parameters
property_value (Any) – value of the property
property_name (str, optional) – name of the property (default: id)
- Returns
returns the atom
- Return type
u.Atom
- Raises
ValueError – if there is no or more than one atom with that id
- restraintmaker.utils.Utilities.get_all_subclasses(parent: type, include_private_sublcasses=False) List[type] [source]
get_all_subclasses returns ALL subclasses of a type, including grandchilder etc.
- Parameters
parent (type) – Parentn class
include_private_sublcasses (bool, optional) – shall privates be included? (default: False)
- Returns
List of all subclasses
- Return type
t.List[type]
- restraintmaker.utils.Utilities.order_atoms_by_molecule(atoms: List[restraintmaker.utils.Utilities.Atom]) Dict[str, List[restraintmaker.utils.Utilities.Atom]] [source]
- Parameters
atoms (t.List[Atom]) – A list of atoms
- Returns
A Dictionary: Molecules names as keys, List of atoms in the molecule as entry
- Return type
t.Dict[t.List[Atom]]
- restraintmaker.utils.Utilities.print(*x: str, mv: int = 0, **kargs)[source]
- print is overridden for the restraintmaker project:
The parameter mv indicates the minimal verbosity at which the statement will still be printed.
- The verobsity threshold of the program can be chagned in utilities.
0 = Print everything, 1 = Debug, 2 = Develop, 3 = Interested user, 4 = disinterested user (Error messages only)
- Parameters
x (Any) – Arguments to be printed
mv (int) – Minimal verbosity at which this statement will still be printed.
- Return type
NoReturn