openpathsampling.orderparameter.OP_Function¶
- class openpathsampling.orderparameter.OP_Function(name, fcn, **kwargs)¶
Make any function fcn into an OrderParameter.
>>> # To create an order parameter which calculates the dihedral formed >>> # by atoms [7,9,15,17] (psi in Ala dipeptide): >>> import mdtraj as md >>> psi_atoms = [6,8,14,16] >>> psi_orderparam = OP_Function("psi", md.compute_dihedrals, >>> trajdatafmt="mdtraj", >>> indices=[psi_atoms]) >>> print psi_orderparam( traj.md() )
- __init__(name, fcn, **kwargs)¶
Parameters: name : str
fcn : function
kwargs :
named arguments which should be given to fcn (for example, the atoms which define a specific distance/angle)
Notes
We may decide that it is better not to use the trajdatafmt trick, and to instead create separate wrapper classes for each supported trajformat.
Methods
__init__(name, fcn, **kwargs) Parameters: clear(() -> None. Remove all items from D.) copy(() -> a shallow copy of D) existing(objs) Find a subset of indices that are present in the cache flush_unstorable() Will remove all snapshots from all caches that a not stored at the time from_dict([my_dict]) fromkeys(...) v defaults to None. get((k[,d]) -> D[k] if k in D, ...) has_key((k) -> True if D has a key k, else False) items(() -> list of D’s (key, value) pairs, ...) iteritems(() -> an iterator over the (key, ...) iterkeys(() -> an iterator over the keys of D) itervalues(...) keys(() -> list of D’s keys) missing(objs) Find a subset of indices that are NOT present in the cache pop((k[,d]) -> v, ...) If key is not found, d is returned if given, otherwise KeyError is raised popitem(() -> (k, v), ...) 2-tuple; but raise KeyError if D is empty. push() setdefault((k[,d]) -> D.get(k,d), ...) sync([store, flush_storable]) Sync this orderparameter with attached storages to_dict() update(([E, ...) If E present and has a .keys() method, does: for k in E: D[k] = E[k] values(() -> list of D’s values) viewitems(...) viewkeys(...) viewvalues(...) Attributes
dictable use_unique - clear() → None. Remove all items from D.¶
- copy() → a shallow copy of D¶
- existing(objs)¶
Find a subset of indices that are present in the cache
Parameters: indices : list of int
the initial list of indices to be tested
Returns: existing : list of int
the subset of indices present in the cache
- flush_unstorable()¶
Will remove all snapshots from all caches that a not stored at the time
This is mainly used to speed up things when it is clear that all the snapshots so far used (in orderparameters) that have NOT been saved will only be temporary. It does not break anything but if you want to save ops for such a snapshot later you have to save the snapshot and then call op(snapshot) to get it to storage.
E.g., When you run a bootstrapping then you create lots of samples and compute their orderparameters without ever wanting to save these. The problem is that theoretically you could and the storage keeps track of all potential orderparameters that could be saved. Since the only way to determine which of the cached values can be stored when sync is called is to search all cached snapshots we want to avoid doing that for snapshots where we know that these will not be saved. This function does this, by removing all snapshots from the caches that are not yet stored and thus removing the necessity to check them everytime you want to sync. Thus the goal is to keep the storage cache small. At best empty after each safe.
- static fromkeys(S[, v]) → New dict with keys from S and values equal to v.¶
v defaults to None.
- get(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
- has_key(k) → True if D has a key k, else False¶
- items() → list of D's (key, value) pairs, as 2-tuples¶
- iteritems() → an iterator over the (key, value) items of D¶
- iterkeys() → an iterator over the keys of D¶
- itervalues() → an iterator over the values of D¶
- keys() → list of D's keys¶
- missing(objs)¶
Find a subset of indices that are NOT present in the cache
Parameters: indices : list of int
the initial list of indices to be tested
Returns: existing : list of int
the subset of indices NOT present in the cache
- pop(k[, d]) → v, remove specified key and return the corresponding value.¶
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem() → (k, v), remove and return some (key, value) pair as a¶
2-tuple; but raise KeyError if D is empty.
- setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D¶
- sync(store=None, flush_storable=True)¶
Sync this orderparameter with attached storages
Parameters: store : OrderparameterStore or None
the store to be used, otherwise all underlying storages are synced
flush_storable : bool
if False the store will be synced and information about data that could not be stored are kept in the caches so that they can potentially (when the associated snapshots have been stored) be synced later. This is safer in the sense that you will not loose any computed result, but on the other hand might induce an overhead since the list of not yet saved snapshot can be very large and needs to be searched EVERYTIME the store is saved. If possible you should use True (default) here and eventually recompute lost data (which is done automatically).
- update([E, ]**F) → None. Update D from dict/iterable E and F.¶
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() → list of D's values¶
- viewitems() → a set-like object providing a view on D's items¶
- viewkeys() → a set-like object providing a view on D's keys¶
- viewvalues() → an object providing a view on D's values¶