<commit_before># WESTPAnalysis

This package provides an API for analyzing weighted-ensemble simulation data generated using the [WESTPA](http://westpa.github.io/westpa/) framework.

*This package is currently in pre-alpha phase.*
 
## Getting Started

```py
from westpanalysis import WESTDataset
```
A `WESTDataset` provides a view over a WESTPA HDF5 simulation data file.
```py
dataset = WESTDataset('west.h5')
```

### How To

Iterate over simulation iterations and segments:
```py
for iteration in dataset.iterations:
    for segment in iteration.segments:
        ...
```

Retrieve a particular segment:
```py
segment = dataset.iteration(10).segment(4)
```

Get the weight and progress coordinate values of a segment:
```py
weight, pcoords = segment.weight, segment.pcoords
```

Get the parent and children of a segment:
```py
parent, children = segment.parent, segment.children
```

Get the trace (ancestral line) of a segment:
```py
trace = segment.trace()
```

### Loading Segment Trajectories

To enable loading segment trajectories, set the `seg_traj_loader` attribute
of the dataset. An example using [MDTraj](https://www.mdtraj.org) might look like this:
```py
import mdtraj

def load_segment_traj(iteration_number, segment_index):
    return mdtraj.load(
        f'traj_segs/{iteration_number:06d}/{segment_index:06d}.h5')

dataset.segment_traj_loader = load_segment_traj
```

Then the trajectory of a segment can be loaded using
```py
segment_traj = segment.trajectory()
```

and the trajectory of its trace can be loaded using
```py
trace_traj = segment.trace_trajectory()
```
<commit_msg>Revised README.<commit_after># WESTPAnalysis

This package provides an API for analyzing weighted-ensemble simulation data generated using the [WESTPA](http://westpa.github.io/westpa/) framework.

*This package is currently in pre-alpha phase.*
 
## Getting Started

```py
from westpanalysis import WESTDataset
```
A `WESTDataset` provides a view over a WESTPA HDF5 simulation data file.
```py
dataset = WESTDataset('west.h5')
```

### How To

Iterate over simulation iterations and segments:
```py
for iteration in dataset.iterations:
    for segment in iteration.segments:
        ...
```

Retrieve a particular segment:
```py
segment = dataset.iteration(10).segment(4)
```

Get the weight and progress coordinate values of a segment:
```py
weight, pcoords = segment.weight, segment.pcoords
```

Get the parent and children of a segment:
```py
parent, children = segment.parent, segment.children
```

Get the trace (ancestral line) of a segment:
```py
trace = segment.trace()
```

### Loading Segment Trajectories

To enable loading segment trajectories, set the `segment_traj_loader` attribute
of the dataset. An example using [MDTraj](https://www.mdtraj.org) might look like this:
```py
import mdtraj

def load_segment_traj(iteration_number, segment_index):
    return mdtraj.load(
        f'traj_segs/{iteration_number:06d}/{segment_index:06d}/seg.h5')

dataset.segment_traj_loader = load_segment_traj
```

Then the trajectory of a segment can be loaded using
```py
segment_traj = segment.trajectory()
```

and the trajectory of its trace can be loaded using
```py
trace_traj = segment.trace_trajectory()
```

{'fraction_non_alphanumeric': 0.1093847110006215, 'fraction_numerical': 0.006215040397762586, 'mean_word_length': 4.961111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4055953', 'n_tokens_mistral': 1038, 'n_tokens_neox': 975, 'n_words': 339}