westpa 2022.12__cp313-cp313-macosx_10_13_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 +68 -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 +376 -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 +491 -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-313-darwin.so +0 -0
- westpa/core/binning/assign.py +455 -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 +506 -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-313-darwin.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 +719 -0
- westpa/core/reweight/__init__.py +14 -0
- westpa/core/reweight/_reweight.cpython-313-darwin.so +0 -0
- westpa/core/reweight/matrix.py +126 -0
- westpa/core/segment.py +119 -0
- westpa/core/sim_manager.py +835 -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 +910 -0
- westpa/core/wm_ops.py +43 -0
- westpa/core/yamlcfg.py +391 -0
- westpa/fasthist/__init__.py +34 -0
- westpa/fasthist/_fasthist.cpython-313-darwin.so +0 -0
- westpa/mclib/__init__.py +271 -0
- westpa/mclib/__main__.py +28 -0
- westpa/mclib/_mclib.cpython-313-darwin.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 +153 -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 +361 -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 +96 -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-313-darwin.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 +192 -0
- westpa/westext/wess/ProbAdjust.py +101 -0
- westpa/westext/wess/__init__.py +6 -0
- westpa/westext/wess/wess_driver.py +217 -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.12.dist-info/AUTHORS +22 -0
- westpa-2022.12.dist-info/LICENSE +21 -0
- westpa-2022.12.dist-info/METADATA +193 -0
- westpa-2022.12.dist-info/RECORD +149 -0
- westpa-2022.12.dist-info/WHEEL +6 -0
- westpa-2022.12.dist-info/entry_points.txt +29 -0
- westpa-2022.12.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import h5py
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
from westpa.tools import WESTTool, WESTDataReader, IterRangeSelection, ProgressIndicatorComponent
|
|
5
|
+
|
|
6
|
+
import westpa
|
|
7
|
+
from westpa.core import h5io
|
|
8
|
+
from westpa.core.data_manager import seg_id_dtype, n_iter_dtype, weight_dtype
|
|
9
|
+
from westpa.core.binning import assignments_list_to_table
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class WNTopTool(WESTTool):
|
|
13
|
+
prog = 'w_ntop'
|
|
14
|
+
description = '''\
|
|
15
|
+
Select walkers from bins . An assignment file mapping walkers to
|
|
16
|
+
bins at each timepoint is required (see``w_assign --help`` for further
|
|
17
|
+
information on generating this file). By default, high-weight walkers are
|
|
18
|
+
selected (hence the name ``w_ntop``: select the N top-weighted walkers from
|
|
19
|
+
each bin); however, minimum weight walkers and randomly-selected walkers
|
|
20
|
+
may be selected instead.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
-----------------------------------------------------------------------------
|
|
24
|
+
Output format
|
|
25
|
+
-----------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
The output file (-o/--output, by default "ntop.h5") contains the following
|
|
28
|
+
datasets:
|
|
29
|
+
|
|
30
|
+
``/n_iter`` [iteration]
|
|
31
|
+
*(Integer)* Iteration numbers for each entry in other datasets.
|
|
32
|
+
|
|
33
|
+
``/n_segs`` [iteration][bin]
|
|
34
|
+
*(Integer)* Number of segments in each bin/state in the given iteration.
|
|
35
|
+
This will generally be the same as the number requested with
|
|
36
|
+
``--n/--count`` but may be smaller if the requested number of walkers
|
|
37
|
+
does not exist.
|
|
38
|
+
|
|
39
|
+
``/seg_ids`` [iteration][bin][segment]
|
|
40
|
+
*(Integer)* Matching segments in each iteration for each bin.
|
|
41
|
+
For an iteration ``n_iter``, only the first ``n_iter`` entries are
|
|
42
|
+
valid. For example, the full list of matching seg_ids in bin 0 in the
|
|
43
|
+
first stored iteration is ``seg_ids[0][0][:n_segs[0]]``.
|
|
44
|
+
|
|
45
|
+
``/weights`` [iteration][bin][segment]
|
|
46
|
+
*(Floating-point)* Weights for each matching segment in ``/seg_ids``.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
-----------------------------------------------------------------------------
|
|
50
|
+
Command-line arguments
|
|
51
|
+
-----------------------------------------------------------------------------
|
|
52
|
+
'''
|
|
53
|
+
|
|
54
|
+
def __init__(self):
|
|
55
|
+
super().__init__()
|
|
56
|
+
|
|
57
|
+
self.data_reader = WESTDataReader()
|
|
58
|
+
self.iter_range = IterRangeSelection()
|
|
59
|
+
self.progress = ProgressIndicatorComponent()
|
|
60
|
+
self.output_file = None
|
|
61
|
+
self.assignments_filename = None
|
|
62
|
+
self.output_filename = None
|
|
63
|
+
self.what = None
|
|
64
|
+
self.timepoint = None
|
|
65
|
+
self.count = None
|
|
66
|
+
|
|
67
|
+
def add_args(self, parser):
|
|
68
|
+
self.data_reader.add_args(parser)
|
|
69
|
+
self.iter_range.add_args(parser)
|
|
70
|
+
|
|
71
|
+
igroup = parser.add_argument_group('input options')
|
|
72
|
+
igroup.add_argument(
|
|
73
|
+
'-a',
|
|
74
|
+
'--assignments',
|
|
75
|
+
default='assign.h5',
|
|
76
|
+
help='''Use assignments from the given ASSIGNMENTS file (default: %(default)s).''',
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
sgroup = parser.add_argument_group('selection options')
|
|
80
|
+
sgroup.add_argument(
|
|
81
|
+
'-n',
|
|
82
|
+
'--count',
|
|
83
|
+
type=int,
|
|
84
|
+
default=1,
|
|
85
|
+
help='''Select COUNT walkers from each iteration for each bin (default: %(default)s).''',
|
|
86
|
+
)
|
|
87
|
+
sgroup.add_argument(
|
|
88
|
+
'-t',
|
|
89
|
+
'--timepoint',
|
|
90
|
+
type=int,
|
|
91
|
+
default=-1,
|
|
92
|
+
help='''Base selection on the given TIMEPOINT within each iteration. Default (-1)
|
|
93
|
+
corresponds to the last timepoint.''',
|
|
94
|
+
)
|
|
95
|
+
cgroup = parser.add_mutually_exclusive_group()
|
|
96
|
+
cgroup.add_argument(
|
|
97
|
+
'--highweight',
|
|
98
|
+
dest='select_what',
|
|
99
|
+
action='store_const',
|
|
100
|
+
const='highweight',
|
|
101
|
+
help='''Select COUNT highest-weight walkers from each bin.''',
|
|
102
|
+
)
|
|
103
|
+
cgroup.add_argument(
|
|
104
|
+
'--lowweight',
|
|
105
|
+
dest='select_what',
|
|
106
|
+
action='store_const',
|
|
107
|
+
const='lowweight',
|
|
108
|
+
help='''Select COUNT lowest-weight walkers from each bin.''',
|
|
109
|
+
)
|
|
110
|
+
cgroup.add_argument(
|
|
111
|
+
'--random',
|
|
112
|
+
dest='select_what',
|
|
113
|
+
action='store_const',
|
|
114
|
+
const='random',
|
|
115
|
+
help='''Select COUNT walkers randomly from each bin.''',
|
|
116
|
+
)
|
|
117
|
+
parser.set_defaults(select_what='highweight')
|
|
118
|
+
|
|
119
|
+
ogroup = parser.add_argument_group('output options')
|
|
120
|
+
ogroup.add_argument('-o', '--output', default='ntop.h5', help='''Write output to OUTPUT (default: %(default)s).''')
|
|
121
|
+
self.progress.add_args(parser)
|
|
122
|
+
|
|
123
|
+
def process_args(self, args):
|
|
124
|
+
self.progress.process_args(args)
|
|
125
|
+
self.data_reader.process_args(args)
|
|
126
|
+
with self.data_reader:
|
|
127
|
+
self.iter_range.process_args(args)
|
|
128
|
+
self.what = args.select_what
|
|
129
|
+
self.output_filename = args.output
|
|
130
|
+
self.assignments_filename = args.assignments
|
|
131
|
+
self.count = args.count
|
|
132
|
+
self.timepoint = args.timepoint
|
|
133
|
+
|
|
134
|
+
def go(self):
|
|
135
|
+
self.data_reader.open('r')
|
|
136
|
+
assignments_file = h5py.File(self.assignments_filename, mode='r')
|
|
137
|
+
output_file = h5io.WESTPAH5File(self.output_filename, mode='w')
|
|
138
|
+
pi = self.progress.indicator
|
|
139
|
+
count = self.count
|
|
140
|
+
timepoint = self.timepoint
|
|
141
|
+
|
|
142
|
+
nbins = assignments_file.attrs['nbins'] + 1
|
|
143
|
+
assignments_ds = assignments_file['assignments']
|
|
144
|
+
|
|
145
|
+
iter_start, iter_stop = self.iter_range.iter_start, self.iter_range.iter_stop
|
|
146
|
+
iter_count = iter_stop - iter_start
|
|
147
|
+
h5io.check_iter_range_least(assignments_ds, iter_start, iter_stop)
|
|
148
|
+
nsegs = assignments_file['nsegs'][h5io.get_iteration_slice(assignments_file['nsegs'], iter_start, iter_stop)]
|
|
149
|
+
|
|
150
|
+
output_file.create_dataset('n_iter', dtype=n_iter_dtype, data=list(range(iter_start, iter_stop)))
|
|
151
|
+
|
|
152
|
+
seg_count_ds = output_file.create_dataset('nsegs', dtype=np.uint, shape=(iter_count, nbins))
|
|
153
|
+
matching_segs_ds = output_file.create_dataset(
|
|
154
|
+
'seg_ids',
|
|
155
|
+
shape=(iter_count, nbins, count),
|
|
156
|
+
dtype=seg_id_dtype,
|
|
157
|
+
chunks=h5io.calc_chunksize((iter_count, nbins, count), seg_id_dtype),
|
|
158
|
+
shuffle=True,
|
|
159
|
+
compression=9,
|
|
160
|
+
)
|
|
161
|
+
weights_ds = output_file.create_dataset(
|
|
162
|
+
'weights',
|
|
163
|
+
shape=(iter_count, nbins, count),
|
|
164
|
+
dtype=weight_dtype,
|
|
165
|
+
chunks=h5io.calc_chunksize((iter_count, nbins, count), weight_dtype),
|
|
166
|
+
shuffle=True,
|
|
167
|
+
compression=9,
|
|
168
|
+
)
|
|
169
|
+
what = self.what
|
|
170
|
+
|
|
171
|
+
with pi:
|
|
172
|
+
pi.new_operation('Finding matching segments', extent=iter_count)
|
|
173
|
+
for iiter, n_iter in enumerate(range(iter_start, iter_stop)):
|
|
174
|
+
assignments = np.require(
|
|
175
|
+
assignments_ds[h5io.get_iteration_entry(assignments_ds, n_iter) + np.index_exp[:, timepoint]],
|
|
176
|
+
dtype=westpa.core.binning.index_dtype,
|
|
177
|
+
)
|
|
178
|
+
all_weights = self.data_reader.get_iter_group(n_iter)['seg_index']['weight']
|
|
179
|
+
|
|
180
|
+
# the following Cython function just executes this loop:
|
|
181
|
+
# for iseg in xrange(nsegs[iiter]):
|
|
182
|
+
# segs_by_bin[iseg,assignments[iseg]] = True
|
|
183
|
+
segs_by_bin = assignments_list_to_table(nsegs[iiter], nbins, assignments)
|
|
184
|
+
for ibin in range(nbins):
|
|
185
|
+
segs = np.nonzero(segs_by_bin[:, ibin])[0]
|
|
186
|
+
|
|
187
|
+
seg_count_ds[iiter, ibin] = min(len(segs), count)
|
|
188
|
+
|
|
189
|
+
if len(segs):
|
|
190
|
+
weights = all_weights.take(segs)
|
|
191
|
+
|
|
192
|
+
if what == 'lowweight':
|
|
193
|
+
indices = np.argsort(weights, kind='stable')[:count]
|
|
194
|
+
elif what == 'highweight':
|
|
195
|
+
indices = np.argsort(weights, kind='stable')[::-1][:count]
|
|
196
|
+
else:
|
|
197
|
+
assert what == 'random'
|
|
198
|
+
indices = np.random.permutation(len(weights))
|
|
199
|
+
|
|
200
|
+
matching_segs_ds[iiter, ibin, : len(segs)] = segs.take(indices)
|
|
201
|
+
weights_ds[iiter, ibin, : len(segs)] = weights.take(indices)
|
|
202
|
+
del segs, weights
|
|
203
|
+
|
|
204
|
+
del assignments, segs_by_bin, all_weights
|
|
205
|
+
pi.progress += 1
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def entry_point():
|
|
209
|
+
WNTopTool().main()
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
if __name__ == '__main__':
|
|
213
|
+
entry_point()
|