westpa 2022.10__cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of westpa might be problematic. Click here for more details.
- westpa/__init__.py +14 -0
- westpa/_version.py +21 -0
- westpa/analysis/__init__.py +5 -0
- westpa/analysis/core.py +746 -0
- westpa/analysis/statistics.py +27 -0
- westpa/analysis/trajectories.py +360 -0
- westpa/cli/__init__.py +0 -0
- westpa/cli/core/__init__.py +0 -0
- westpa/cli/core/w_fork.py +152 -0
- westpa/cli/core/w_init.py +230 -0
- westpa/cli/core/w_run.py +77 -0
- westpa/cli/core/w_states.py +212 -0
- westpa/cli/core/w_succ.py +99 -0
- westpa/cli/core/w_truncate.py +59 -0
- westpa/cli/tools/__init__.py +0 -0
- westpa/cli/tools/ploterr.py +506 -0
- westpa/cli/tools/plothist.py +706 -0
- westpa/cli/tools/w_assign.py +596 -0
- westpa/cli/tools/w_bins.py +166 -0
- westpa/cli/tools/w_crawl.py +119 -0
- westpa/cli/tools/w_direct.py +547 -0
- westpa/cli/tools/w_dumpsegs.py +94 -0
- westpa/cli/tools/w_eddist.py +506 -0
- westpa/cli/tools/w_fluxanl.py +378 -0
- westpa/cli/tools/w_ipa.py +833 -0
- westpa/cli/tools/w_kinavg.py +127 -0
- westpa/cli/tools/w_kinetics.py +96 -0
- westpa/cli/tools/w_multi_west.py +414 -0
- westpa/cli/tools/w_ntop.py +213 -0
- westpa/cli/tools/w_pdist.py +515 -0
- westpa/cli/tools/w_postanalysis_matrix.py +82 -0
- westpa/cli/tools/w_postanalysis_reweight.py +53 -0
- westpa/cli/tools/w_red.py +486 -0
- westpa/cli/tools/w_reweight.py +780 -0
- westpa/cli/tools/w_select.py +226 -0
- westpa/cli/tools/w_stateprobs.py +111 -0
- westpa/cli/tools/w_trace.py +599 -0
- westpa/core/__init__.py +0 -0
- westpa/core/_rc.py +673 -0
- westpa/core/binning/__init__.py +55 -0
- westpa/core/binning/_assign.cpython-312-x86_64-linux-gnu.so +0 -0
- westpa/core/binning/assign.py +449 -0
- westpa/core/binning/binless.py +96 -0
- westpa/core/binning/binless_driver.py +54 -0
- westpa/core/binning/binless_manager.py +190 -0
- westpa/core/binning/bins.py +47 -0
- westpa/core/binning/mab.py +427 -0
- westpa/core/binning/mab_driver.py +54 -0
- westpa/core/binning/mab_manager.py +198 -0
- westpa/core/data_manager.py +1694 -0
- westpa/core/extloader.py +74 -0
- westpa/core/h5io.py +995 -0
- westpa/core/kinetics/__init__.py +24 -0
- westpa/core/kinetics/_kinetics.cpython-312-x86_64-linux-gnu.so +0 -0
- westpa/core/kinetics/events.py +147 -0
- westpa/core/kinetics/matrates.py +156 -0
- westpa/core/kinetics/rate_averaging.py +266 -0
- westpa/core/progress.py +218 -0
- westpa/core/propagators/__init__.py +54 -0
- westpa/core/propagators/executable.py +715 -0
- westpa/core/reweight/__init__.py +14 -0
- westpa/core/reweight/_reweight.cpython-312-x86_64-linux-gnu.so +0 -0
- westpa/core/reweight/matrix.py +126 -0
- westpa/core/segment.py +119 -0
- westpa/core/sim_manager.py +830 -0
- westpa/core/states.py +359 -0
- westpa/core/systems.py +93 -0
- westpa/core/textio.py +74 -0
- westpa/core/trajectory.py +330 -0
- westpa/core/we_driver.py +908 -0
- westpa/core/wm_ops.py +43 -0
- westpa/core/yamlcfg.py +391 -0
- westpa/fasthist/__init__.py +34 -0
- westpa/fasthist/__main__.py +110 -0
- westpa/fasthist/_fasthist.cpython-312-x86_64-linux-gnu.so +0 -0
- westpa/mclib/__init__.py +264 -0
- westpa/mclib/__main__.py +28 -0
- westpa/mclib/_mclib.cpython-312-x86_64-linux-gnu.so +0 -0
- westpa/oldtools/__init__.py +4 -0
- westpa/oldtools/aframe/__init__.py +35 -0
- westpa/oldtools/aframe/atool.py +75 -0
- westpa/oldtools/aframe/base_mixin.py +26 -0
- westpa/oldtools/aframe/binning.py +178 -0
- westpa/oldtools/aframe/data_reader.py +560 -0
- westpa/oldtools/aframe/iter_range.py +200 -0
- westpa/oldtools/aframe/kinetics.py +117 -0
- westpa/oldtools/aframe/mcbs.py +146 -0
- westpa/oldtools/aframe/output.py +39 -0
- westpa/oldtools/aframe/plotting.py +90 -0
- westpa/oldtools/aframe/trajwalker.py +126 -0
- westpa/oldtools/aframe/transitions.py +469 -0
- westpa/oldtools/cmds/__init__.py +0 -0
- westpa/oldtools/cmds/w_ttimes.py +358 -0
- westpa/oldtools/files.py +34 -0
- westpa/oldtools/miscfn.py +23 -0
- westpa/oldtools/stats/__init__.py +4 -0
- westpa/oldtools/stats/accumulator.py +35 -0
- westpa/oldtools/stats/edfs.py +129 -0
- westpa/oldtools/stats/mcbs.py +89 -0
- westpa/tools/__init__.py +33 -0
- westpa/tools/binning.py +472 -0
- westpa/tools/core.py +340 -0
- westpa/tools/data_reader.py +159 -0
- westpa/tools/dtypes.py +31 -0
- westpa/tools/iter_range.py +198 -0
- westpa/tools/kinetics_tool.py +340 -0
- westpa/tools/plot.py +283 -0
- westpa/tools/progress.py +17 -0
- westpa/tools/selected_segs.py +154 -0
- westpa/tools/wipi.py +751 -0
- westpa/trajtree/__init__.py +4 -0
- westpa/trajtree/_trajtree.cpython-312-x86_64-linux-gnu.so +0 -0
- westpa/trajtree/trajtree.py +117 -0
- westpa/westext/__init__.py +0 -0
- westpa/westext/adaptvoronoi/__init__.py +3 -0
- westpa/westext/adaptvoronoi/adaptVor_driver.py +214 -0
- westpa/westext/hamsm_restarting/__init__.py +3 -0
- westpa/westext/hamsm_restarting/example_overrides.py +35 -0
- westpa/westext/hamsm_restarting/restart_driver.py +1165 -0
- westpa/westext/stringmethod/__init__.py +11 -0
- westpa/westext/stringmethod/fourier_fitting.py +69 -0
- westpa/westext/stringmethod/string_driver.py +253 -0
- westpa/westext/stringmethod/string_method.py +306 -0
- westpa/westext/weed/BinCluster.py +180 -0
- westpa/westext/weed/ProbAdjustEquil.py +100 -0
- westpa/westext/weed/UncertMath.py +247 -0
- westpa/westext/weed/__init__.py +10 -0
- westpa/westext/weed/weed_driver.py +182 -0
- westpa/westext/wess/ProbAdjust.py +101 -0
- westpa/westext/wess/__init__.py +6 -0
- westpa/westext/wess/wess_driver.py +207 -0
- westpa/work_managers/__init__.py +57 -0
- westpa/work_managers/core.py +396 -0
- westpa/work_managers/environment.py +134 -0
- westpa/work_managers/mpi.py +318 -0
- westpa/work_managers/processes.py +187 -0
- westpa/work_managers/serial.py +28 -0
- westpa/work_managers/threads.py +79 -0
- westpa/work_managers/zeromq/__init__.py +20 -0
- westpa/work_managers/zeromq/core.py +641 -0
- westpa/work_managers/zeromq/node.py +131 -0
- westpa/work_managers/zeromq/work_manager.py +526 -0
- westpa/work_managers/zeromq/worker.py +320 -0
- westpa-2022.10.dist-info/AUTHORS +22 -0
- westpa-2022.10.dist-info/LICENSE +21 -0
- westpa-2022.10.dist-info/METADATA +183 -0
- westpa-2022.10.dist-info/RECORD +150 -0
- westpa-2022.10.dist-info/WHEEL +6 -0
- westpa-2022.10.dist-info/entry_points.txt +29 -0
- westpa-2022.10.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from westpa.core.data_manager import weight_dtype
|
|
6
|
+
from westpa.tools import WESTMasterCommand, WESTParallelTool
|
|
7
|
+
|
|
8
|
+
from westpa.core import h5io
|
|
9
|
+
from westpa.core.kinetics import sequence_macro_flux_to_rate, WKinetics
|
|
10
|
+
|
|
11
|
+
from westpa.tools.kinetics_tool import WESTKineticsBase, AverageCommands
|
|
12
|
+
|
|
13
|
+
from westpa.mclib import mcbs_ci_correl, _1D_simple_eval_block, _2D_simple_eval_block
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# From w_stateprobs
|
|
17
|
+
from westpa.core.binning import accumulate_state_populations_from_labeled
|
|
18
|
+
|
|
19
|
+
log = logging.getLogger('w_direct')
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# This block is responsible for submitting a set of calculations to be bootstrapped over for a particular type of calculation.
|
|
23
|
+
# A property which wishes to be calculated should adhere to this format.
|
|
24
|
+
def _rate_eval_block(iblock, start, stop, nstates, data_input, name, mcbs_alpha, mcbs_nsets, mcbs_acalpha, do_correl, mcbs_enable):
|
|
25
|
+
# Our rate estimator is a little more complex, so we've defined a custom evaluation block for it,
|
|
26
|
+
# instead of just using the block evalutors that we've imported.
|
|
27
|
+
results = []
|
|
28
|
+
for istate in range(nstates):
|
|
29
|
+
for jstate in range(nstates):
|
|
30
|
+
if istate == jstate:
|
|
31
|
+
continue
|
|
32
|
+
kwargs = {'istate': istate, 'jstate': jstate}
|
|
33
|
+
# Why are we sending in the total population dataset, instead of a sliced one?
|
|
34
|
+
# It's a requirement of our estimator; we need to pull from any given i to j state in order to properly normalize
|
|
35
|
+
# and avoid i to j rate constants which are affected by a third state k.
|
|
36
|
+
# That is, we need the populations for both i and j, and it's easier to just send in the entire dataset.
|
|
37
|
+
dataset = {'dataset': data_input['dataset'][:, istate, jstate], 'pops': data_input['pops']}
|
|
38
|
+
ci_res = mcbs_ci_correl(
|
|
39
|
+
dataset,
|
|
40
|
+
estimator=sequence_macro_flux_to_rate,
|
|
41
|
+
alpha=mcbs_alpha,
|
|
42
|
+
n_sets=mcbs_nsets,
|
|
43
|
+
autocorrel_alpha=mcbs_acalpha,
|
|
44
|
+
subsample=np.mean,
|
|
45
|
+
do_correl=do_correl,
|
|
46
|
+
mcbs_enable=mcbs_enable,
|
|
47
|
+
estimator_kwargs=kwargs,
|
|
48
|
+
)
|
|
49
|
+
results.append((name, iblock, istate, jstate, (start, stop) + ci_res))
|
|
50
|
+
|
|
51
|
+
return results
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# The old w_kinetics
|
|
55
|
+
class DKinetics(WESTKineticsBase, WKinetics):
|
|
56
|
+
subcommand = 'init'
|
|
57
|
+
default_kinetics_file = 'direct.h5'
|
|
58
|
+
default_output_file = 'direct.h5'
|
|
59
|
+
help_text = 'calculate state-to-state kinetics by tracing trajectories'
|
|
60
|
+
description = '''\
|
|
61
|
+
Calculate state-to-state rates and transition event durations by tracing
|
|
62
|
+
trajectories.
|
|
63
|
+
|
|
64
|
+
A bin assignment file (usually "assign.h5") including trajectory labeling
|
|
65
|
+
is required (see "w_assign --help" for information on generating this file).
|
|
66
|
+
|
|
67
|
+
This subcommand for w_direct is used as input for all other w_direct
|
|
68
|
+
subcommands, which will convert the flux data in the output file into
|
|
69
|
+
average rates/fluxes/populations with confidence intervals.
|
|
70
|
+
|
|
71
|
+
-----------------------------------------------------------------------------
|
|
72
|
+
Output format
|
|
73
|
+
-----------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
The output file (-o/--output, by default "direct.h5") contains the
|
|
76
|
+
following datasets:
|
|
77
|
+
|
|
78
|
+
``/conditional_fluxes`` [iteration][state][state]
|
|
79
|
+
*(Floating-point)* Macrostate-to-macrostate fluxes. These are **not**
|
|
80
|
+
normalized by the population of the initial macrostate.
|
|
81
|
+
|
|
82
|
+
``/conditional_arrivals`` [iteration][stateA][stateB]
|
|
83
|
+
*(Integer)* Number of trajectories arriving at state *stateB* in a given
|
|
84
|
+
iteration, given that they departed from *stateA*.
|
|
85
|
+
|
|
86
|
+
``/total_fluxes`` [iteration][state]
|
|
87
|
+
*(Floating-point)* Total flux into a given macrostate.
|
|
88
|
+
|
|
89
|
+
``/arrivals`` [iteration][state]
|
|
90
|
+
*(Integer)* Number of trajectories arriving at a given state in a given
|
|
91
|
+
iteration, regardless of where they originated.
|
|
92
|
+
|
|
93
|
+
``/duration_count`` [iteration]
|
|
94
|
+
*(Integer)* The number of event durations recorded in each iteration.
|
|
95
|
+
|
|
96
|
+
``/durations`` [iteration][event duration]
|
|
97
|
+
*(Structured -- see below)* Event durations for transition events ending
|
|
98
|
+
during a given iteration. These are stored as follows:
|
|
99
|
+
|
|
100
|
+
istate
|
|
101
|
+
*(Integer)* Initial state of transition event.
|
|
102
|
+
fstate
|
|
103
|
+
*(Integer)* Final state of transition event.
|
|
104
|
+
duration
|
|
105
|
+
*(Floating-point)* Duration of transition, in units of tau.
|
|
106
|
+
weight
|
|
107
|
+
*(Floating-point)* Weight of trajectory at end of transition, **not**
|
|
108
|
+
normalized by initial state population.
|
|
109
|
+
|
|
110
|
+
Because state-to-state fluxes stored in this file are not normalized by
|
|
111
|
+
initial macrostate population, they cannot be used as rates without further
|
|
112
|
+
processing. The ``w_direct kinetics`` command is used to perform this normalization
|
|
113
|
+
while taking statistical fluctuation and correlation into account. See
|
|
114
|
+
``w_direct kinetics --help`` for more information. Target fluxes (total flux
|
|
115
|
+
into a given state) require no such normalization.
|
|
116
|
+
|
|
117
|
+
-----------------------------------------------------------------------------
|
|
118
|
+
Command-line options
|
|
119
|
+
-----------------------------------------------------------------------------
|
|
120
|
+
'''
|
|
121
|
+
|
|
122
|
+
def __init__(self, parent):
|
|
123
|
+
super().__init__(parent)
|
|
124
|
+
|
|
125
|
+
def open_files(self):
|
|
126
|
+
self.output_file = h5io.WESTPAH5File(self.output_filename, 'a', creating_program=True)
|
|
127
|
+
h5io.stamp_creator_data(self.output_file)
|
|
128
|
+
self.assignments_file = h5io.WESTPAH5File(self.assignments_filename, 'r') # , driver='core', backing_store=False)
|
|
129
|
+
if not self.iter_range.check_data_iter_range_least(self.assignments_file):
|
|
130
|
+
raise ValueError('assignments data do not span the requested iterations')
|
|
131
|
+
|
|
132
|
+
def go(self):
|
|
133
|
+
pi = self.progress.indicator
|
|
134
|
+
with pi:
|
|
135
|
+
self.w_kinetics()
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# The old w_kinavg
|
|
139
|
+
class DKinAvg(AverageCommands):
|
|
140
|
+
subcommand = 'kinetics'
|
|
141
|
+
help_text = 'Generates rate and flux values from a WESTPA simulation via tracing.'
|
|
142
|
+
default_kinetics_file = 'direct.h5'
|
|
143
|
+
description = '''\
|
|
144
|
+
Calculate average rates/fluxes and associated errors from weighted ensemble
|
|
145
|
+
data. Bin assignments (usually "assign.h5") and kinetics data (usually
|
|
146
|
+
"direct.h5") data files must have been previously generated (see
|
|
147
|
+
"w_assign --help" and "w_direct init --help" for information on
|
|
148
|
+
generating these files).
|
|
149
|
+
|
|
150
|
+
The evolution of all datasets may be calculated, with or without confidence
|
|
151
|
+
intervals.
|
|
152
|
+
|
|
153
|
+
-----------------------------------------------------------------------------
|
|
154
|
+
Output format
|
|
155
|
+
-----------------------------------------------------------------------------
|
|
156
|
+
|
|
157
|
+
The output file (-o/--output, usually "direct.h5") contains the following
|
|
158
|
+
dataset:
|
|
159
|
+
|
|
160
|
+
/avg_rates [state,state]
|
|
161
|
+
(Structured -- see below) State-to-state rates based on entire window of
|
|
162
|
+
iterations selected.
|
|
163
|
+
|
|
164
|
+
/avg_total_fluxes [state]
|
|
165
|
+
(Structured -- see below) Total fluxes into each state based on entire
|
|
166
|
+
window of iterations selected.
|
|
167
|
+
|
|
168
|
+
/avg_conditional_fluxes [state,state]
|
|
169
|
+
(Structured -- see below) State-to-state fluxes based on entire window of
|
|
170
|
+
iterations selected.
|
|
171
|
+
|
|
172
|
+
If --evolution-mode is specified, then the following additional datasets are
|
|
173
|
+
available:
|
|
174
|
+
|
|
175
|
+
/rate_evolution [window][state][state]
|
|
176
|
+
(Structured -- see below). State-to-state rates based on windows of
|
|
177
|
+
iterations of varying width. If --evolution-mode=cumulative, then
|
|
178
|
+
these windows all begin at the iteration specified with
|
|
179
|
+
--start-iter and grow in length by --step-iter for each successive
|
|
180
|
+
element. If --evolution-mode=blocked, then these windows are all of
|
|
181
|
+
width --step-iter (excluding the last, which may be shorter), the first
|
|
182
|
+
of which begins at iteration --start-iter.
|
|
183
|
+
|
|
184
|
+
/target_flux_evolution [window,state]
|
|
185
|
+
(Structured -- see below). Total flux into a given macro state based on
|
|
186
|
+
windows of iterations of varying width, as in /rate_evolution.
|
|
187
|
+
|
|
188
|
+
/conditional_flux_evolution [window,state,state]
|
|
189
|
+
(Structured -- see below). State-to-state fluxes based on windows of
|
|
190
|
+
varying width, as in /rate_evolution.
|
|
191
|
+
|
|
192
|
+
The structure of these datasets is as follows:
|
|
193
|
+
|
|
194
|
+
iter_start
|
|
195
|
+
(Integer) Iteration at which the averaging window begins (inclusive).
|
|
196
|
+
|
|
197
|
+
iter_stop
|
|
198
|
+
(Integer) Iteration at which the averaging window ends (exclusive).
|
|
199
|
+
|
|
200
|
+
expected
|
|
201
|
+
(Floating-point) Expected (mean) value of the observable as evaluated within
|
|
202
|
+
this window, in units of inverse tau.
|
|
203
|
+
|
|
204
|
+
ci_lbound
|
|
205
|
+
(Floating-point) Lower bound of the confidence interval of the observable
|
|
206
|
+
within this window, in units of inverse tau.
|
|
207
|
+
|
|
208
|
+
ci_ubound
|
|
209
|
+
(Floating-point) Upper bound of the confidence interval of the observable
|
|
210
|
+
within this window, in units of inverse tau.
|
|
211
|
+
|
|
212
|
+
stderr
|
|
213
|
+
(Floating-point) The standard error of the mean of the observable
|
|
214
|
+
within this window, in units of inverse tau.
|
|
215
|
+
|
|
216
|
+
corr_len
|
|
217
|
+
(Integer) Correlation length of the observable within this window, in units
|
|
218
|
+
of tau.
|
|
219
|
+
|
|
220
|
+
Each of these datasets is also stamped with a number of attributes:
|
|
221
|
+
|
|
222
|
+
mcbs_alpha
|
|
223
|
+
(Floating-point) Alpha value of confidence intervals. (For example,
|
|
224
|
+
*alpha=0.05* corresponds to a 95% confidence interval.)
|
|
225
|
+
|
|
226
|
+
mcbs_nsets
|
|
227
|
+
(Integer) Number of bootstrap data sets used in generating confidence
|
|
228
|
+
intervals.
|
|
229
|
+
|
|
230
|
+
mcbs_acalpha
|
|
231
|
+
(Floating-point) Alpha value for determining correlation lengths.
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
-----------------------------------------------------------------------------
|
|
235
|
+
Command-line options
|
|
236
|
+
-----------------------------------------------------------------------------
|
|
237
|
+
'''
|
|
238
|
+
|
|
239
|
+
def w_kinavg(self):
|
|
240
|
+
pi = self.progress.indicator
|
|
241
|
+
# pi = None
|
|
242
|
+
|
|
243
|
+
# We're initializing the various datasets...
|
|
244
|
+
self.open_files()
|
|
245
|
+
self.open_assignments()
|
|
246
|
+
# Obviously, this is for the conditional and total fluxes. This is really all we need to sort for this.
|
|
247
|
+
cond_fluxes = h5io.IterBlockedDataset(self.kinetics_file['conditional_fluxes'])
|
|
248
|
+
cond_fluxes.cache_data()
|
|
249
|
+
total_fluxes = h5io.IterBlockedDataset(self.kinetics_file['total_fluxes'])
|
|
250
|
+
|
|
251
|
+
# This is necessary for both color and state populations...
|
|
252
|
+
# ... but we also need this for the kinetics calculations.
|
|
253
|
+
pops = h5io.IterBlockedDataset(self.assignments_file['labeled_populations'])
|
|
254
|
+
pops.cache_data()
|
|
255
|
+
pops.data = pops.data.sum(axis=2)
|
|
256
|
+
|
|
257
|
+
submit_kwargs = dict(
|
|
258
|
+
pi=pi, nstates=self.nstates, start_iter=self.start_iter, stop_iter=self.stop_iter, step_iter=self.step_iter
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
# Calculate averages for the simulation, then report, if necessary.
|
|
262
|
+
|
|
263
|
+
submit_kwargs['dataset'] = {'dataset': cond_fluxes, 'pops': pops}
|
|
264
|
+
avg_rates = self.run_calculation(
|
|
265
|
+
eval_block=_rate_eval_block, name='Rate Evolution', dim=2, do_averages=True, **submit_kwargs
|
|
266
|
+
)
|
|
267
|
+
self.output_file.replace_dataset('avg_rates', data=avg_rates[1])
|
|
268
|
+
|
|
269
|
+
submit_kwargs['dataset'] = {'dataset': cond_fluxes}
|
|
270
|
+
avg_conditional_fluxes = self.run_calculation(
|
|
271
|
+
eval_block=_2D_simple_eval_block, name='Conditional Flux Evolution', dim=2, do_averages=True, **submit_kwargs
|
|
272
|
+
)
|
|
273
|
+
self.output_file.replace_dataset('avg_conditional_fluxes', data=avg_conditional_fluxes[1])
|
|
274
|
+
|
|
275
|
+
submit_kwargs['dataset'] = {'dataset': total_fluxes}
|
|
276
|
+
avg_total_fluxes = self.run_calculation(
|
|
277
|
+
eval_block=_1D_simple_eval_block, name='Target Flux Evolution', dim=1, do_averages=True, **submit_kwargs
|
|
278
|
+
)
|
|
279
|
+
self.output_file.replace_dataset('avg_total_fluxes', data=avg_total_fluxes[1])
|
|
280
|
+
|
|
281
|
+
# Now, print them!
|
|
282
|
+
|
|
283
|
+
# We've returned an average, but it still exists in a timeslice format. So we need to return the 'last' value.
|
|
284
|
+
if self.display_averages:
|
|
285
|
+
self.print_averages(avg_total_fluxes[1], '\nfluxes into macrostates:', dim=1)
|
|
286
|
+
self.print_averages(avg_conditional_fluxes[1], '\nfluxes from state to state:', dim=2)
|
|
287
|
+
self.print_averages(avg_rates[1], '\nrates from state to state:', dim=2)
|
|
288
|
+
|
|
289
|
+
# Do a bootstrap evolution.
|
|
290
|
+
submit_kwargs['dataset'] = {'dataset': cond_fluxes, 'pops': pops}
|
|
291
|
+
rate_evol = self.run_calculation(eval_block=_rate_eval_block, name='Rate Evolution', dim=2, **submit_kwargs)
|
|
292
|
+
self.output_file.replace_dataset('rate_evolution', data=rate_evol, shuffle=True, compression=9)
|
|
293
|
+
|
|
294
|
+
submit_kwargs['dataset'] = {'dataset': cond_fluxes}
|
|
295
|
+
rate_evol = self.run_calculation(
|
|
296
|
+
eval_block=_2D_simple_eval_block, name='Conditional Flux Evolution', dim=2, **submit_kwargs
|
|
297
|
+
)
|
|
298
|
+
self.output_file.replace_dataset('conditional_flux_evolution', data=rate_evol, shuffle=True, compression=9)
|
|
299
|
+
|
|
300
|
+
submit_kwargs['dataset'] = {'dataset': total_fluxes}
|
|
301
|
+
rate_evol = self.run_calculation(eval_block=_1D_simple_eval_block, name='Target Flux Evolution', dim=1, **submit_kwargs)
|
|
302
|
+
self.output_file.replace_dataset('target_flux_evolution', data=rate_evol, shuffle=True, compression=9)
|
|
303
|
+
|
|
304
|
+
def go(self):
|
|
305
|
+
pi = self.progress.indicator
|
|
306
|
+
with pi:
|
|
307
|
+
self.w_kinavg()
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
# The old w_stateprobs
|
|
311
|
+
class DStateProbs(AverageCommands):
|
|
312
|
+
subcommand = 'probs'
|
|
313
|
+
help_text = 'Calculates color and state probabilities via tracing.'
|
|
314
|
+
default_kinetics_file = 'direct.h5'
|
|
315
|
+
description = '''\
|
|
316
|
+
Calculate average populations and associated errors in state populations from
|
|
317
|
+
weighted ensemble data. Bin assignments, including macrostate definitions,
|
|
318
|
+
are required. (See "w_assign --help" for more information).
|
|
319
|
+
|
|
320
|
+
-----------------------------------------------------------------------------
|
|
321
|
+
Output format
|
|
322
|
+
-----------------------------------------------------------------------------
|
|
323
|
+
|
|
324
|
+
The output file (-o/--output, usually "direct.h5") contains the following
|
|
325
|
+
dataset:
|
|
326
|
+
|
|
327
|
+
/avg_state_probs [state]
|
|
328
|
+
(Structured -- see below) Population of each state across entire
|
|
329
|
+
range specified.
|
|
330
|
+
|
|
331
|
+
/avg_color_probs [state]
|
|
332
|
+
(Structured -- see below) Population of each ensemble across entire
|
|
333
|
+
range specified.
|
|
334
|
+
|
|
335
|
+
If --evolution-mode is specified, then the following additional datasets are
|
|
336
|
+
available:
|
|
337
|
+
|
|
338
|
+
/state_pop_evolution [window][state]
|
|
339
|
+
(Structured -- see below). State populations based on windows of
|
|
340
|
+
iterations of varying width. If --evolution-mode=cumulative, then
|
|
341
|
+
these windows all begin at the iteration specified with
|
|
342
|
+
--start-iter and grow in length by --step-iter for each successive
|
|
343
|
+
element. If --evolution-mode=blocked, then these windows are all of
|
|
344
|
+
width --step-iter (excluding the last, which may be shorter), the first
|
|
345
|
+
of which begins at iteration --start-iter.
|
|
346
|
+
|
|
347
|
+
/color_prob_evolution [window][state]
|
|
348
|
+
(Structured -- see below). Ensemble populations based on windows of
|
|
349
|
+
iterations of varying width. If --evolution-mode=cumulative, then
|
|
350
|
+
these windows all begin at the iteration specified with
|
|
351
|
+
--start-iter and grow in length by --step-iter for each successive
|
|
352
|
+
element. If --evolution-mode=blocked, then these windows are all of
|
|
353
|
+
width --step-iter (excluding the last, which may be shorter), the first
|
|
354
|
+
of which begins at iteration --start-iter.
|
|
355
|
+
|
|
356
|
+
The structure of these datasets is as follows:
|
|
357
|
+
|
|
358
|
+
iter_start
|
|
359
|
+
(Integer) Iteration at which the averaging window begins (inclusive).
|
|
360
|
+
|
|
361
|
+
iter_stop
|
|
362
|
+
(Integer) Iteration at which the averaging window ends (exclusive).
|
|
363
|
+
|
|
364
|
+
expected
|
|
365
|
+
(Floating-point) Expected (mean) value of the observable as evaluated within
|
|
366
|
+
this window, in units of inverse tau.
|
|
367
|
+
|
|
368
|
+
ci_lbound
|
|
369
|
+
(Floating-point) Lower bound of the confidence interval of the observable
|
|
370
|
+
within this window, in units of inverse tau.
|
|
371
|
+
|
|
372
|
+
ci_ubound
|
|
373
|
+
(Floating-point) Upper bound of the confidence interval of the observable
|
|
374
|
+
within this window, in units of inverse tau.
|
|
375
|
+
|
|
376
|
+
stderr
|
|
377
|
+
(Floating-point) The standard error of the mean of the observable
|
|
378
|
+
within this window, in units of inverse tau.
|
|
379
|
+
|
|
380
|
+
corr_len
|
|
381
|
+
(Integer) Correlation length of the observable within this window, in units
|
|
382
|
+
of tau.
|
|
383
|
+
|
|
384
|
+
Each of these datasets is also stamped with a number of attributes:
|
|
385
|
+
|
|
386
|
+
mcbs_alpha
|
|
387
|
+
(Floating-point) Alpha value of confidence intervals. (For example,
|
|
388
|
+
*alpha=0.05* corresponds to a 95% confidence interval.)
|
|
389
|
+
|
|
390
|
+
mcbs_nsets
|
|
391
|
+
(Integer) Number of bootstrap data sets used in generating confidence
|
|
392
|
+
intervals.
|
|
393
|
+
|
|
394
|
+
mcbs_acalpha
|
|
395
|
+
(Floating-point) Alpha value for determining correlation lengths.
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
-----------------------------------------------------------------------------
|
|
399
|
+
Command-line options
|
|
400
|
+
-----------------------------------------------------------------------------
|
|
401
|
+
'''
|
|
402
|
+
|
|
403
|
+
def calculate_state_populations(self, pops):
|
|
404
|
+
# ... but then this is how the state populations are done.
|
|
405
|
+
# This was taken, more or less, from the old w_stateprobs
|
|
406
|
+
iter_count = self.stop_iter - self.start_iter
|
|
407
|
+
all_state_pops = np.empty((iter_count, self.nstates + 1), weight_dtype)
|
|
408
|
+
iter_state_pops = np.empty((self.nstates + 1,), weight_dtype)
|
|
409
|
+
avg_state_pops = np.zeros((self.nstates + 1,), weight_dtype)
|
|
410
|
+
pops.cache_data(max_size='available')
|
|
411
|
+
state_map = self.assignments_file['state_map'][...]
|
|
412
|
+
try:
|
|
413
|
+
for iiter, n_iter in enumerate(range(self.start_iter, self.stop_iter)):
|
|
414
|
+
iter_state_pops.fill(0)
|
|
415
|
+
labeled_pops = pops.iter_entry(n_iter)
|
|
416
|
+
accumulate_state_populations_from_labeled(labeled_pops, state_map, iter_state_pops, check_state_map=False)
|
|
417
|
+
all_state_pops[iiter] = iter_state_pops
|
|
418
|
+
avg_state_pops += iter_state_pops
|
|
419
|
+
del labeled_pops
|
|
420
|
+
finally:
|
|
421
|
+
pops.drop_cache()
|
|
422
|
+
|
|
423
|
+
state_pops = h5io.IterBlockedDataset.empty_like(pops)
|
|
424
|
+
state_pops.data = all_state_pops
|
|
425
|
+
return state_pops
|
|
426
|
+
|
|
427
|
+
def w_stateprobs(self):
|
|
428
|
+
pi = self.progress.indicator
|
|
429
|
+
|
|
430
|
+
self.open_files()
|
|
431
|
+
self.open_assignments()
|
|
432
|
+
# So far, we definitely need this boilerplate...
|
|
433
|
+
# pi.new_operation('Reading data')
|
|
434
|
+
|
|
435
|
+
# This is necessary for both color and state populations...
|
|
436
|
+
pops = h5io.IterBlockedDataset(self.assignments_file['labeled_populations'])
|
|
437
|
+
|
|
438
|
+
state_pops = self.calculate_state_populations(pops)
|
|
439
|
+
|
|
440
|
+
# This now sorts it for the color populations
|
|
441
|
+
pops.cache_data()
|
|
442
|
+
pops.data = pops.data.sum(axis=2)
|
|
443
|
+
|
|
444
|
+
submit_kwargs = dict(
|
|
445
|
+
pi=pi,
|
|
446
|
+
nstates=self.nstates,
|
|
447
|
+
start_iter=self.start_iter,
|
|
448
|
+
stop_iter=self.stop_iter,
|
|
449
|
+
step_iter=self.step_iter,
|
|
450
|
+
eval_block=_1D_simple_eval_block,
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
# Calculate and print averages
|
|
454
|
+
submit_kwargs['dataset'] = {'dataset': pops}
|
|
455
|
+
color_evol_avg = self.run_calculation(name='Color Probability Evolution', dim=1, do_averages=True, **submit_kwargs)
|
|
456
|
+
self.output_file.replace_dataset('avg_color_probs', data=color_evol_avg[1], shuffle=True, compression=9)
|
|
457
|
+
|
|
458
|
+
submit_kwargs['dataset'] = {'dataset': state_pops}
|
|
459
|
+
state_evol_avg = self.run_calculation(name='State Probability Evolution', dim=1, do_averages=True, **submit_kwargs)
|
|
460
|
+
self.output_file.replace_dataset(name='avg_state_probs', data=state_evol_avg[1], shuffle=True, compression=9)
|
|
461
|
+
|
|
462
|
+
# Print!
|
|
463
|
+
if self.display_averages:
|
|
464
|
+
self.print_averages(color_evol_avg[1], '\naverage color probabilities:', dim=1)
|
|
465
|
+
self.print_averages(state_evol_avg[1], '\naverage state probabilities:', dim=1)
|
|
466
|
+
|
|
467
|
+
# Now, do a bootstrap evolution
|
|
468
|
+
submit_kwargs['dataset'] = {'dataset': pops}
|
|
469
|
+
pop_evol = self.run_calculation(name='Color Probability Evolution', dim=1, **submit_kwargs)
|
|
470
|
+
self.output_file.replace_dataset('color_prob_evolution', data=pop_evol, shuffle=True, compression=9)
|
|
471
|
+
|
|
472
|
+
submit_kwargs['dataset'] = {'dataset': state_pops}
|
|
473
|
+
pop_evol = self.run_calculation(name='State Probability Evolution', dim=1, **submit_kwargs)
|
|
474
|
+
self.output_file.replace_dataset(name='state_pop_evolution', data=pop_evol, shuffle=True, compression=9)
|
|
475
|
+
|
|
476
|
+
def go(self):
|
|
477
|
+
pi = self.progress.indicator
|
|
478
|
+
with pi:
|
|
479
|
+
self.w_stateprobs()
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
# Just a convenience class to run everything.
|
|
483
|
+
class DAll(DStateProbs, DKinAvg, DKinetics):
|
|
484
|
+
subcommand = 'all'
|
|
485
|
+
help_text = 'Runs the full suite, including the tracing of events.'
|
|
486
|
+
default_kinetics_file = 'direct.h5'
|
|
487
|
+
description = '''\
|
|
488
|
+
A convenience function to run init/kinetics/probs. Bin assignments,
|
|
489
|
+
including macrostate definitions, are required. (See
|
|
490
|
+
"w_assign --help" for more information).
|
|
491
|
+
|
|
492
|
+
For more information on the individual subcommands this subs in for, run
|
|
493
|
+
w_direct {init/kinetics/probs} --help.
|
|
494
|
+
|
|
495
|
+
-----------------------------------------------------------------------------
|
|
496
|
+
Command-line options
|
|
497
|
+
-----------------------------------------------------------------------------
|
|
498
|
+
'''
|
|
499
|
+
|
|
500
|
+
def go(self):
|
|
501
|
+
# One minor issue; as this stands now, since it's inheriting from all the other classes, it needs
|
|
502
|
+
# a kinetics file to instantiate the other attributes. We'll need to modify how the loading works, there.
|
|
503
|
+
pi = self.progress.indicator
|
|
504
|
+
with pi:
|
|
505
|
+
self.w_kinetics()
|
|
506
|
+
self.w_kinavg()
|
|
507
|
+
self.w_stateprobs()
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
# Just a convenience class to average the observables.
|
|
511
|
+
class DAverage(DStateProbs, DKinAvg):
|
|
512
|
+
subcommand = 'average'
|
|
513
|
+
help_text = 'Averages and returns fluxes, rates, and color/state populations.'
|
|
514
|
+
default_kinetics_file = 'direct.h5'
|
|
515
|
+
description = '''\
|
|
516
|
+
A convenience function to run kinetics/probs. Bin assignments,
|
|
517
|
+
including macrostate definitions, are required. (See
|
|
518
|
+
"w_assign --help" for more information).
|
|
519
|
+
|
|
520
|
+
For more information on the individual subcommands this subs in for, run
|
|
521
|
+
w_direct {kinetics/probs} --help.
|
|
522
|
+
|
|
523
|
+
-----------------------------------------------------------------------------
|
|
524
|
+
Command-line options
|
|
525
|
+
-----------------------------------------------------------------------------
|
|
526
|
+
'''
|
|
527
|
+
|
|
528
|
+
def go(self):
|
|
529
|
+
pi = self.progress.indicator
|
|
530
|
+
with pi:
|
|
531
|
+
self.w_kinavg()
|
|
532
|
+
self.w_stateprobs()
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
class WDirect(WESTMasterCommand, WESTParallelTool):
|
|
536
|
+
prog = 'w_direct'
|
|
537
|
+
# subcommands = [AvgTraceSubcommand,AvgMatrixSubcommand]
|
|
538
|
+
subcommands = [DKinetics, DAverage, DKinAvg, DStateProbs, DAll]
|
|
539
|
+
subparsers_title = 'direct kinetics analysis schemes'
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
def entry_point():
|
|
543
|
+
WDirect().main()
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
if __name__ == '__main__':
|
|
547
|
+
entry_point()
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from warnings import warn
|
|
5
|
+
from westpa.tools import WESTTool, WESTDataReader
|
|
6
|
+
from westpa.core.segment import Segment
|
|
7
|
+
|
|
8
|
+
log = logging.getLogger('w_dumpsegs')
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class WDumpSegs(WESTTool):
|
|
12
|
+
prog = 'w_dumpsegs'
|
|
13
|
+
description = '''\
|
|
14
|
+
Dump segment data as text. This is very inefficient, so this tool should be used
|
|
15
|
+
as a last resort (use hdfview/h5ls to look at data, and access HDF5 directly for
|
|
16
|
+
significant analysis tasks).
|
|
17
|
+
'''
|
|
18
|
+
|
|
19
|
+
def __init__(self):
|
|
20
|
+
super().__init__()
|
|
21
|
+
self.data_reader = WESTDataReader()
|
|
22
|
+
self.n_iter = None
|
|
23
|
+
self.output_file = None
|
|
24
|
+
self.print_pcoords = False
|
|
25
|
+
|
|
26
|
+
def add_args(self, parser):
|
|
27
|
+
self.data_reader.add_args(parser)
|
|
28
|
+
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
'-p',
|
|
31
|
+
'--print-pcoords',
|
|
32
|
+
dest='print_pcoords',
|
|
33
|
+
action='store_true',
|
|
34
|
+
help='print initial and final progress coordinates for each segment',
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
'-i', '--iteration', dest='n_iter', type=int, help='Use data from iteration N_ITER (default: last complete iteration)'
|
|
38
|
+
)
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
'-o', '--output', dest='output_file', help='Store output in OUTPUT_FILE (default: write to standard output).'
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def process_args(self, args):
|
|
44
|
+
self.data_reader.process_args(args)
|
|
45
|
+
self.data_reader.open()
|
|
46
|
+
self.n_iter = args.n_iter or self.data_reader.current_iteration - 1
|
|
47
|
+
self.output_file = open(args.output_file, 'wt') if args.output_file else sys.stdout
|
|
48
|
+
self.print_pcoords = args.print_pcoords
|
|
49
|
+
|
|
50
|
+
def go(self):
|
|
51
|
+
segments = self.data_reader.get_segments(self.n_iter)
|
|
52
|
+
|
|
53
|
+
max_seg_id_len = len(str(max(segment.seg_id for segment in segments)))
|
|
54
|
+
max_status_name_len = max(list(map(len, iter(Segment.status_names.values()))))
|
|
55
|
+
max_endpoint_type_len = max(list(map(len, iter(Segment.endpoint_type_names.values()))))
|
|
56
|
+
max_n_parents_len = len(str(max(len(segment.wtg_parent_ids) for segment in segments)))
|
|
57
|
+
|
|
58
|
+
report_line = (
|
|
59
|
+
'{segment.n_iter:d} {segment.seg_id:{max_seg_id_len}d} {segment.weight:20.14g}'
|
|
60
|
+
+ ' {status_name:{max_status_name_len}s} ({segment.status})'
|
|
61
|
+
+ ' {segment.walltime:<12.6g} {segment.cputime:<12.6g}'
|
|
62
|
+
+ ' {endpoint_type_name:{max_endpoint_type_len}s} ({segment.endpoint_type})'
|
|
63
|
+
+ ' {n_parents:{max_n_parents_len}d} {segment.parent_id:{max_seg_id_len}d} {parents_str}'
|
|
64
|
+
+ '\n'
|
|
65
|
+
)
|
|
66
|
+
pcoord_lines = ' pcoord[0] = {init_pcoord}\n pcoord[-1] = {final_pcoord}' + '\n'
|
|
67
|
+
for _seg_id, segment in enumerate(segments):
|
|
68
|
+
parents_str = '[' + ', '.join(map(str, sorted(segment.wtg_parent_ids))) + ']'
|
|
69
|
+
init_pcoord_str = '[' + ', '.join('{pcval:<12.6g}'.format(pcval=float(pce)) for pce in segment.pcoord[0]) + ']'
|
|
70
|
+
final_pcoord_str = '[' + ', '.join('{pcval:<12.6g}'.format(pcval=float(pce)) for pce in segment.pcoord[-1]) + ']'
|
|
71
|
+
self.output_file.write(
|
|
72
|
+
report_line.format(
|
|
73
|
+
segment=segment,
|
|
74
|
+
status_name=segment.status_names[segment.status],
|
|
75
|
+
endpoint_type_name=segment.endpoint_type_names[segment.endpoint_type],
|
|
76
|
+
parents_str=parents_str,
|
|
77
|
+
n_parents=len(segment.wtg_parent_ids),
|
|
78
|
+
max_seg_id_len=max_seg_id_len,
|
|
79
|
+
max_status_name_len=max_status_name_len,
|
|
80
|
+
max_endpoint_type_len=max_endpoint_type_len,
|
|
81
|
+
max_n_parents_len=max_n_parents_len,
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
if self.print_pcoords:
|
|
85
|
+
self.output_file.write(pcoord_lines.format(init_pcoord=init_pcoord_str, final_pcoord=final_pcoord_str))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def entry_point():
|
|
89
|
+
warn('w_dumpsegs is being deprecated.')
|
|
90
|
+
WDumpSegs().main()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if __name__ == '__main__':
|
|
94
|
+
entry_point()
|