htmd.metricdatagenerator module#
- class htmd.metricdatagenerator.MetricDataGenerator(fulldata: MetricData, model: Model | None = None, is_adaptive: bool = False)#
Bases:
objectGenerate synthetic trajectories from existing projected data.
Given a clustered
MetricDataobject (and optionally a Markov state model), this class produces new synthetic trajectories by resampling frames from the clusters of the original data. The variousnewTrajectories*methods implement different resampling strategies.- Parameters:
fulldata (
MetricDataobject) – The clustered MetricData object from which to sample frames.model (
Modelobject, optional) – A Markov state model built on fulldata. Required for the MSM-based sampling strategies.is_adaptive (bool) – If True, starting frames are drawn from the first epoch of an adaptive sampling run.
- newMetricData(datasource: MetricData, trajectories: list | None = None, olddata: MetricData | None = None) MetricData#
Convert generated trajectory indexes into a new MetricData object.
- Parameters:
datasource (
MetricDataobject) – The MetricData object from which to collect projections and references for the sampled frames.trajectories (list, optional) – A list of trajectories, each given as trajectory index-frame pairs (such as those returned by the
newTrajectories*methods).olddata (
MetricDataobject, optional) – If given, the new data is appended to this object and the merged object is returned.
- Returns:
data – A MetricData object containing the generated trajectories.
- Return type:
MetricDataobject
- newTrajectoriesClusterJumping(simlen: int, ntraj: int, startFrames: list | ndarray | None = None, jumpprob: float = 0.1) list#
Generate trajectories by advancing one frame at a time with random cluster jumps.
At each step the trajectory advances one frame ahead. With probability jumpprob (or when the end of the current trajectory is reached) it jumps to a random frame of the same cluster to continue sampling.
- Parameters:
simlen (int) – The length (in frames) of each new trajectory.
ntraj (int) – The number of new trajectories to generate.
startFrames (list or np.ndarray, optional) – Starting frames as trajectory index-frame pairs. If None, starting frames are picked automatically.
jumpprob (float) – The per-frame probability of jumping to a new frame within the same cluster.
- Returns:
ret – One array per new trajectory, each row a trajectory index-frame pair.
- Return type:
list of np.ndarray
- newTrajectoriesFiller(simlen: int, ntraj: int, startFrames: list | ndarray | None = None) list#
Generate trajectories by chaining cluster pieces until the length is reached.
Starting from a frame, it appends pieces sampled from the corresponding clusters until each trajectory reaches simlen frames.
- Parameters:
- Returns:
ret – One array per new trajectory, each row a trajectory index-frame pair.
- Return type:
list of np.ndarray
- newTrajectoriesMSM(simlen: int, ntraj: int, startFrames: list | ndarray | None = None) list#
Generate new synthetic trajectories sampled from the Markov state model.
At each step the next microstate is drawn from the transition probability matrix of the model, and a random frame of the corresponding cluster is selected.
- Parameters:
- Returns:
ret – One array per new trajectory, each row a trajectory index-frame pair.
- Return type:
list of np.ndarray
- newTrajectoriesSimple(simlen: int, ntraj: int, startFrames: list | ndarray | None = None) list#
Generate trajectories by sampling whole pieces from a cluster.
For each respawning conformation, selects a random trajectory from the conformations in its cluster.
- Parameters:
- Returns:
ret – One array per new trajectory, each row a trajectory index-frame pair.
- Return type:
list of np.ndarray