General helper functions#
Small helper and utilities functions that don’t fit anywhere else.
- maicos.lib.util.DOI_LIST = {'10.1021/acs.jpca.0c04063': 'Carlson, S. et al., J. Phys. Chem. A 124, (2020).', '10.1021/acs.jpcb.9b09269': 'Loche, P. et al., J. Phys. Chem. B 123, (2019).', '10.1103/PhysRevE.92.032718': '1. Schaaf, C. et al., Phys. Rev. E 92, (2015).', '10.1103/PhysRevLett.117.048001': 'Schlaich, A. et al., Phys. Rev. Lett. 117, (2016).'}#
references associated with MAICoS
- maicos.lib.util.atomgroup_header(AtomGroup)[source]#
Return a string containing infos about the AtomGroup.
Infos include the total number of atoms, the including residues and the number of residues. Useful for writing output file headers.
- maicos.lib.util.bin(a, bins)[source]#
Average array values in bins for easier plotting.
Note: “bins” array should contain the INDEX (integer) where that bin begins
- maicos.lib.util.charge_neutral(filter)[source]#
Raise a Warning when AtomGroup is not charge neutral.
Class Decorator to raise an Error/Warning when AtomGroup in an AnalysisBase class is not charge neutral. The behaviour of the warning can be controlled with the filter attribute. If the AtomGroup’s corresponding universe is non-neutral an ValueError is raised.
- Parameters:
filter (str) – Filter type to control warning filter Common values are: “error” or “default” See warnings.simplefilter for more options.
- maicos.lib.util.citation_reminder(*dois)[source]#
Prints citations in order to remind users to give due credit.
- Parameters:
dois (list) – dois associated with the method which calls this. Possible dois are registered in
maicos.lib.util.DOI_LIST
.- Returns:
cite – formatted citation reminders
- Return type:
- maicos.lib.util.correlation_analysis(timeseries)[source]#
Timeseries correlation analysis.
Analyses a timeseries for correlation and prints a warning if the correlation time is larger than the step size.
- Parameters:
timeseries (numpy.ndarray) – Array of (possibly) correlated data.
- Returns:
corrtime – Estimated correlation time of timeseries.
- Return type:
np.float64
- maicos.lib.util.get_cli_input()[source]#
Return a proper formatted string of the command line input.
- maicos.lib.util.get_compound(atomgroup, return_index=False)[source]#
Returns the highest order topology attribute.
The order is “molecules”, “fragments”, “residues”. If the topology contains none of those attributes, an AttributeError is raised. Optionally, the indices of the attribute as given by molnums, fragindices or resindices respectively are also returned.
- Parameters:
atomgroup (MDAnalysis.core.groups.AtomGroup) – atomgroup taken for weight calculation
return_index (bool, optional) – If True, also return the indices the corresponding topology attribute.
- Returns:
compound (string) – Name of the topology attribute.
index (ndarray, optional) – The indices of the topology attribute.
- Raises:
AttributeError – atomgroup is missing any connection information”
- maicos.lib.util.render_docs(func: Callable) Callable [source]#
Replace all template phrases in the functions docstring.
- Parameters:
func (callable) – The callable (function, class) where the phrase old should be replaced.
- Returns:
callable with replaced phrase
- Return type:
Callable
- maicos.lib.util.trajectory_precision(trajectory, dim=2)[source]#
Detect the precision of a trajectory.
- Parameters:
trajectory (MDAnalysis trajectory) – Trajectory from which the precision is detected.
dim (int, optional) – Dimension along which the precision is detected.
- Returns:
precision – Precision of each frame of the trajectory.
If the trajectory has a high precision, its resolution will not be detected, and a value of 1e-4 is returned.
- Return type:
array