Skip to content

Commit

Permalink
fix: squiggly lines begone (#399)
Browse files Browse the repository at this point in the history
address inconsistencies in types and make sure all code paths are covered

fix: discover correct gromacs data dir for gmx compiled from source

refactor: sort imports

refactor(recipe): make BondOperation and Place regular classes instead
of dataclasses
  • Loading branch information
jmbuhr committed Mar 7, 2024
1 parent 081ae27 commit b1210e4
Show file tree
Hide file tree
Showing 34 changed files with 1,023 additions and 836 deletions.
28 changes: 22 additions & 6 deletions _reference/analysis.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@ For command line usage, run `kimmdy-analysis -h`.
| [plot_energy](#kimmdy.analysis.plot_energy) | Plot GROMACS energy for a KIMMDY run. |
| [plot_rates](#kimmdy.analysis.plot_rates) | Plot rates of all possible reactions for each 'decide_recipe' step. |
| [plot_runtime](#kimmdy.analysis.plot_runtime) | Plot runtime of all tasks. |
| [radical_migration](#kimmdy.analysis.radical_migration) | Plot population of radicals for a KIMMDY run. |
| [radical_population](#kimmdy.analysis.radical_population) | Plot population of radicals for a KIMMDY run. |
| [reaction_participation](#kimmdy.analysis.reaction_participation) | Plot runtime of all tasks. |

### concat_traj { #kimmdy.analysis.concat_traj }

`analysis.concat_traj(dir, filetype, steps, open_vmd=False)`
`analysis.concat_traj(dir, filetype, steps, open_vmd=False, output_group=None)`

Find and concatenate trajectories (.xtc files) from a KIMMDY run into one trajectory.
The concatenated trajectory is centered and pbc corrected.

#### Parameters

| Name | Type | Description | Default |
|------------|-------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|------------|
| `dir` | [str](`str`) | Directory to search for subdirectories | _required_ |
| `steps` | [Union](`typing.Union`)\[[list](`list`)\[[str](`str`)\], [str](`str`)\] | List of steps e.g. ["equilibrium", "production"]. Or a string "all" to return all subdirectories | _required_ |
| `open_vmd` | [bool](`bool`) | Open concatenated trajectory in VMD | `False` |
| Name | Type | Description | Default |
|----------------|-------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|------------|
| `dir` | [str](`str`) | Directory to search for subdirectories | _required_ |
| `steps` | [Union](`typing.Union`)\[[list](`list`)\[[str](`str`)\], [str](`str`)\] | List of steps e.g. ["equilibrium", "production"]. Or a string "all" to return all subdirectories | _required_ |
| `open_vmd` | [bool](`bool`) | Open concatenated trajectory in VMD | `False` |
| `output_group` | [Optional](`typing.Optional`)\[[str](`str`)\] | index group for output. Default is "Protein" for xtc and "System" for trr. | `None` |

### entry_point_analysis { #kimmdy.analysis.entry_point_analysis }

Expand Down Expand Up @@ -129,6 +131,20 @@ Plot runtime of all tasks.
| `datefmt` | [str](`str`) | Date format in the KIMMDY logfile | _required_ |
| `open_plot` | [bool](`bool`) | Open plot in default system viewer. | `False` |

### radical_migration { #kimmdy.analysis.radical_migration }

`analysis.radical_migration(dirs, type='qualitative', cutoff=1)`

Plot population of radicals for a KIMMDY run.

#### Parameters

| Name | Type | Description | Default |
|----------|--------------------------------|--------------------------------------------------------------------------------------------|-----------------|
| `dirs` | [list](`list`)\[[str](`str`)\] | KIMMDY run directories to be analysed. | _required_ |
| `type` | [str](`str`) | How to analyse radical migration. Available are 'qualitative','occurence' and 'min_rate'", | `'qualitative'` |
| `cutoff` | [int](`int`) | Ignore migration between two atoms if it happened less often than the specified value. | `1` |

### radical_population { #kimmdy.analysis.radical_population }

`analysis.radical_population(dir, population_type='frequency', steps='all', select_atoms='protein', open_plot=False, open_vmd=False)`
Expand Down
4 changes: 2 additions & 2 deletions _reference/coordinates.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ Merge one to two Dihedrals or -Types into a Dihedral in free-energy syntax

### merge_top_moleculetypes_slow_growth { #kimmdy.coordinates.merge_top_moleculetypes_slow_growth }

`coordinates.merge_top_moleculetypes_slow_growth(molA, molB, ff, focus_nr=None)`
`coordinates.merge_top_moleculetypes_slow_growth(molA, molB, ff)`

Takes two Topologies and joins them for a smooth free-energy like parameter transition simulation

### merge_top_slow_growth { #kimmdy.coordinates.merge_top_slow_growth }

`coordinates.merge_top_slow_growth(topA, topB, focus_nr=None)`
`coordinates.merge_top_slow_growth(topA, topB)`

Takes two Topologies and joins them for a smooth free-energy like parameter transition simulation.

Expand Down
65 changes: 27 additions & 38 deletions _reference/recipe.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,35 @@ Contains the Reaction Recipe, RecipeStep and RecipeCollection.

### Bind { #kimmdy.recipe.Bind }

`recipe.Bind()`
`recipe.Bind(self, atom_ix_1=None, atom_ix_2=None, atom_id_1=None, atom_id_2=None)`

Change topology to form a bond

#### Parameters

| Name | Type | Description | Default |
|-------------|--------------|-----------------------------------------------------------|------------|
| `atom_ix_1` | [int](`int`) | The index of the first atom. zero-based, by default None | _required_ |
| `atom_ix_2` | [int](`int`) | The index of the second atom. zero-based, by default None | _required_ |
| `atom_id_1` | [str](`str`) | The ID of the first atom. one-based, by default None | _required_ |
| `atom_id_2` | [str](`str`) | The ID of the second atom. one-based, by default None | _required_ |
| Name | Type | Description | Default |
|-------------|--------------|-----------------------------------------------------------|-----------|
| `atom_ix_1` | [int](`int`) | The index of the first atom. zero-based, by default None | `None` |
| `atom_ix_2` | [int](`int`) | The index of the second atom. zero-based, by default None | `None` |
| `atom_id_1` | [str](`str`) | The ID of the first atom. one-based, by default None | `None` |
| `atom_id_2` | [str](`str`) | The ID of the second atom. one-based, by default None | `None` |

### BondOperation { #kimmdy.recipe.BondOperation }

`recipe.BondOperation(_atom_ix_1=field(init=False, repr=False, default=None), _atom_ix_2=field(init=False, repr=False, default=None))`
`recipe.BondOperation(self, atom_ix_1=None, atom_ix_2=None, atom_id_1=None, atom_id_2=None)`

Handle a bond operation on the recipe step.

This class takes in either zero-based indices or one-base IDs for two atoms
This class takes in either zero-based indices or one-base IDs for two atoms.

#### Parameters

| Name | Type | Description | Default |
|-------------|--------------|-----------------------------------------------------------|------------|
| `atom_ix_1` | [int](`int`) | The index of the first atom. zero-based, by default None | _required_ |
| `atom_ix_2` | [int](`int`) | The index of the second atom. zero-based, by default None | _required_ |
| `atom_id_1` | [str](`str`) | The ID of the first atom. one-based, by default None | _required_ |
| `atom_id_2` | [str](`str`) | The ID of the second atom. one-based, by default None | _required_ |
| Name | Type | Description | Default |
|-------------|--------------|-----------------------------------------------------------|-----------|
| `atom_ix_1` | [int](`int`) | The index of the first atom. zero-based, by default None | `None` |
| `atom_ix_2` | [int](`int`) | The index of the second atom. zero-based, by default None | `None` |
| `atom_id_1` | [str](`str`) | The ID of the first atom. one-based, by default None | `None` |
| `atom_id_2` | [str](`str`) | The ID of the second atom. one-based, by default None | `None` |

#### Raises

Expand All @@ -62,18 +62,18 @@ Internally, this class stores the atom indices and converts IDs to indices as ne

### Break { #kimmdy.recipe.Break }

`recipe.Break()`
`recipe.Break(self, atom_ix_1=None, atom_ix_2=None, atom_id_1=None, atom_id_2=None)`

Change topology to break a bond

#### Parameters

| Name | Type | Description | Default |
|-------------|--------------|-----------------------------------------------------------|------------|
| `atom_ix_1` | [int](`int`) | The index of the first atom. zero-based, by default None | _required_ |
| `atom_ix_2` | [int](`int`) | The index of the second atom. zero-based, by default None | _required_ |
| `atom_id_1` | [str](`str`) | The ID of the first atom. one-based, by default None | _required_ |
| `atom_id_2` | [str](`str`) | The ID of the second atom. one-based, by default None | _required_ |
| Name | Type | Description | Default |
|-------------|--------------|-----------------------------------------------------------|-----------|
| `atom_ix_1` | [int](`int`) | The index of the first atom. zero-based, by default None | `None` |
| `atom_ix_2` | [int](`int`) | The index of the second atom. zero-based, by default None | `None` |
| `atom_id_1` | [str](`str`) | The ID of the first atom. one-based, by default None | `None` |
| `atom_id_2` | [str](`str`) | The ID of the second atom. one-based, by default None | `None` |

### CustomTopMod { #kimmdy.recipe.CustomTopMod }

Expand All @@ -89,17 +89,19 @@ A custom recipe step that can be used to define a custom topology modification.

### Place { #kimmdy.recipe.Place }

`recipe.Place(new_coords, _ix_to_place=field(init=False, repr=False, default=None))`
`recipe.Place(self, new_coords, ix_to_place=None, id_to_place=None)`

Change topology and/or coordinates to place an atom.

Either provide the index (ix_to_place) or the ID (id_to_place) of the atom to place.

#### Parameters

| Name | Type | Description | Default |
|---------------|--------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|------------|
| `new_coords` | [tuple](`tuple`)\[[float](`float`), [float](`float`), [float](`float`)\] | New xyz coordinates for atom to place to. Valid for the end point of the recipe timespan. | _required_ |
| `ix_to_place` | [int](`int`) | Index of atom to place. 0-based. | _required_ |
| `id_to_place` | [str](`str`) | Index of atom to place. 1-based | _required_ |
| `ix_to_place` | [int](`int`) | Index of atom to place. 0-based. | `None` |
| `id_to_place` | [str](`str`) | Index of atom to place. 1-based | `None` |

### Recipe { #kimmdy.recipe.Recipe }

Expand All @@ -121,22 +123,9 @@ product state from the educt state.

| Name | Description |
| --- | --- |
| [calc_averages](#kimmdy.recipe.Recipe.calc_averages) | Calulate average rates over some window size |
| [check_consistency](#kimmdy.recipe.Recipe.check_consistency) | Run consistency checks for correct size of variables |
| [combine_with](#kimmdy.recipe.Recipe.combine_with) | Combines this Recipe with another with the same RecipeSteps. |

##### calc_averages { #kimmdy.recipe.Recipe.calc_averages }

`recipe.Recipe.calc_averages(window_size)`

Calulate average rates over some window size

###### Parameters

| Name | Type | Description | Default |
|---------------|--------------|-------------------------------------------------------------------------------|------------|
| `window_size` | [int](`int`) | Size of the window to average over, -1 to average over whole available range. | _required_ |

##### check_consistency { #kimmdy.recipe.Recipe.check_consistency }

`recipe.Recipe.check_consistency()`
Expand Down
2 changes: 1 addition & 1 deletion _reference/runmanager.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ one of IDLE, MD, REACTION, SETUP, DONE.

### get_existing_files { #kimmdy.runmanager.get_existing_files }

`runmanager.get_existing_files(config, section='root')`
`runmanager.get_existing_files(config)`

Initialize latest_files with every existing file defined in config
68 changes: 60 additions & 8 deletions docs/_reference/analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,18 @@ <h2 id="toc-title">On this page</h2>
<ul class="collapse">
<li><a href="#parameters-5" id="toc-parameters-5" class="nav-link" data-scroll-target="#parameters-5">Parameters</a></li>
</ul></li>
<li><a href="#kimmdy.analysis.radical_population" id="toc-kimmdy.analysis.radical_population" class="nav-link" data-scroll-target="#kimmdy.analysis.radical_population">radical_population</a>
<li><a href="#kimmdy.analysis.radical_migration" id="toc-kimmdy.analysis.radical_migration" class="nav-link" data-scroll-target="#kimmdy.analysis.radical_migration">radical_migration</a>
<ul class="collapse">
<li><a href="#parameters-6" id="toc-parameters-6" class="nav-link" data-scroll-target="#parameters-6">Parameters</a></li>
</ul></li>
<li><a href="#kimmdy.analysis.reaction_participation" id="toc-kimmdy.analysis.reaction_participation" class="nav-link" data-scroll-target="#kimmdy.analysis.reaction_participation">reaction_participation</a>
<li><a href="#kimmdy.analysis.radical_population" id="toc-kimmdy.analysis.radical_population" class="nav-link" data-scroll-target="#kimmdy.analysis.radical_population">radical_population</a>
<ul class="collapse">
<li><a href="#parameters-7" id="toc-parameters-7" class="nav-link" data-scroll-target="#parameters-7">Parameters</a></li>
</ul></li>
<li><a href="#kimmdy.analysis.reaction_participation" id="toc-kimmdy.analysis.reaction_participation" class="nav-link" data-scroll-target="#kimmdy.analysis.reaction_participation">reaction_participation</a>
<ul class="collapse">
<li><a href="#parameters-8" id="toc-parameters-8" class="nav-link" data-scroll-target="#parameters-8">Parameters</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
Expand Down Expand Up @@ -548,18 +552,22 @@ <h2 class="anchored" data-anchor-id="functions">Functions</h2>
<td>Plot runtime of all tasks.</td>
</tr>
<tr class="odd">
<td><a href="#kimmdy.analysis.radical_population">radical_population</a></td>
<td><a href="#kimmdy.analysis.radical_migration">radical_migration</a></td>
<td>Plot population of radicals for a KIMMDY run.</td>
</tr>
<tr class="even">
<td><a href="#kimmdy.analysis.radical_population">radical_population</a></td>
<td>Plot population of radicals for a KIMMDY run.</td>
</tr>
<tr class="odd">
<td><a href="#kimmdy.analysis.reaction_participation">reaction_participation</a></td>
<td>Plot runtime of all tasks.</td>
</tr>
</tbody>
</table>
<section id="kimmdy.analysis.concat_traj" class="level3">
<h3 class="anchored" data-anchor-id="kimmdy.analysis.concat_traj">concat_traj</h3>
<p><code>analysis.concat_traj(dir, filetype, steps, open_vmd=False)</code></p>
<p><code>analysis.concat_traj(dir, filetype, steps, open_vmd=False, output_group=None)</code></p>
<p>Find and concatenate trajectories (.xtc files) from a KIMMDY run into one trajectory. The concatenated trajectory is centered and pbc corrected.</p>
<section id="parameters" class="level4">
<h4 class="anchored" data-anchor-id="parameters">Parameters</h4>
Expand Down Expand Up @@ -591,6 +599,12 @@ <h4 class="anchored" data-anchor-id="parameters">Parameters</h4>
<td>Open concatenated trajectory in VMD</td>
<td><code>False</code></td>
</tr>
<tr class="even">
<td><code>output_group</code></td>
<td><a href="https://docs.python.org/3.10/library/typing.html#typing.Optional">Optional</a>[<a href="https://docs.python.org/3.10/library/stdtypes.html#str">str</a>]</td>
<td>index group for output. Default is “Protein” for xtc and “System” for trr.</td>
<td><code>None</code></td>
</tr>
</tbody>
</table>
</section>
Expand Down Expand Up @@ -812,12 +826,50 @@ <h4 class="anchored" data-anchor-id="parameters-5">Parameters</h4>
</table>
</section>
</section>
<section id="kimmdy.analysis.radical_migration" class="level3">
<h3 class="anchored" data-anchor-id="kimmdy.analysis.radical_migration">radical_migration</h3>
<p><code>analysis.radical_migration(dirs, type='qualitative', cutoff=1)</code></p>
<p>Plot population of radicals for a KIMMDY run.</p>
<section id="parameters-6" class="level4">
<h4 class="anchored" data-anchor-id="parameters-6">Parameters</h4>
<table class="table">
<thead>
<tr class="header">
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><code>dirs</code></td>
<td><a href="https://docs.python.org/3.10/library/stdtypes.html#list">list</a>[<a href="https://docs.python.org/3.10/library/stdtypes.html#str">str</a>]</td>
<td>KIMMDY run directories to be analysed.</td>
<td><em>required</em></td>
</tr>
<tr class="even">
<td><code>type</code></td>
<td><a href="https://docs.python.org/3.10/library/stdtypes.html#str">str</a></td>
<td>How to analyse radical migration. Available are ‘qualitative’,‘occurence’ and ‘min_rate’“,</td>
<td><code>'qualitative'</code></td>
</tr>
<tr class="odd">
<td><code>cutoff</code></td>
<td><a href="https://docs.python.org/3.10/library/functions.html#int">int</a></td>
<td>Ignore migration between two atoms if it happened less often than the specified value.</td>
<td><code>1</code></td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="kimmdy.analysis.radical_population" class="level3">
<h3 class="anchored" data-anchor-id="kimmdy.analysis.radical_population">radical_population</h3>
<p><code>analysis.radical_population(dir, population_type='frequency', steps='all', select_atoms='protein', open_plot=False, open_vmd=False)</code></p>
<p>Plot population of radicals for a KIMMDY run.</p>
<section id="parameters-6" class="level4">
<h4 class="anchored" data-anchor-id="parameters-6">Parameters</h4>
<section id="parameters-7" class="level4">
<h4 class="anchored" data-anchor-id="parameters-7">Parameters</h4>
<table class="table">
<thead>
<tr class="header">
Expand Down Expand Up @@ -872,8 +924,8 @@ <h4 class="anchored" data-anchor-id="parameters-6">Parameters</h4>
<h3 class="anchored" data-anchor-id="kimmdy.analysis.reaction_participation">reaction_participation</h3>
<p><code>analysis.reaction_participation(dir, open_plot=False)</code></p>
<p>Plot runtime of all tasks.</p>
<section id="parameters-7" class="level4">
<h4 class="anchored" data-anchor-id="parameters-7">Parameters</h4>
<section id="parameters-8" class="level4">
<h4 class="anchored" data-anchor-id="parameters-8">Parameters</h4>
<table class="table">
<thead>
<tr class="header">
Expand Down
Loading

0 comments on commit b1210e4

Please sign in to comment.