Skip to content

Commit

Permalink
Rebuild documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hmedina committed Mar 27, 2024
1 parent 0cdc405 commit 2beed3b
Show file tree
Hide file tree
Showing 17 changed files with 613 additions and 375 deletions.
8 changes: 4 additions & 4 deletions docs/KaSaAn/core/KappaEntity.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h1 class="title">Module <code>KaSaAn.core.KappaEntity</code></h1>
def __eq__(self, other) -&gt; bool:
# as the kappa_expression has been canonicalized, it is sufficient for equality testing
# the bulk of this method is just type-checking
if type(other) is str:
if isinstance(other, str):
# if other is a string, make it into an instance of my class
other = self.__class__(other)
return True if self._kappa_expression == other._kappa_expression else False
Expand All @@ -81,7 +81,7 @@ <h1 class="title">Module <code>KaSaAn.core.KappaEntity</code></h1>

def __lt__(self, other) -&gt; bool:
# make it a Kappa-whatever-this-is if it&#39;s not one already
if not type(other) is type(self):
if type(other) is not type(self):
other = self.__class__(other)
# as kappa_expression have been canonicalized, they&#39;re sufficient for comparison testing (i.e. alphabetically)
return True if self._kappa_expression &lt; other._kappa_expression else False</code></pre>
Expand Down Expand Up @@ -130,7 +130,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
def __eq__(self, other) -&gt; bool:
# as the kappa_expression has been canonicalized, it is sufficient for equality testing
# the bulk of this method is just type-checking
if type(other) is str:
if isinstance(other, str):
# if other is a string, make it into an instance of my class
other = self.__class__(other)
return True if self._kappa_expression == other._kappa_expression else False
Expand All @@ -149,7 +149,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>

def __lt__(self, other) -&gt; bool:
# make it a Kappa-whatever-this-is if it&#39;s not one already
if not type(other) is type(self):
if type(other) is not type(self):
other = self.__class__(other)
# as kappa_expression have been canonicalized, they&#39;re sufficient for comparison testing (i.e. alphabetically)
return True if self._kappa_expression &lt; other._kappa_expression else False</code></pre>
Expand Down
328 changes: 183 additions & 145 deletions docs/KaSaAn/core/KappaMultiAgentGraph.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/KaSaAn/core/KappaSite.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ <h1 class="title">Module <code>KaSaAn.core.KappaSite</code></h1>
&#34;&#34;&#34;&#34;&#34;&#34;

# we can&#39;t satisfy ports with counters
if type(query) is KappaCounter:
if isinstance(query, KappaCounter):
raise PortParseError(&#39;Can not check for containment of supplied counter &lt;&#39; + query +
&#39;&gt; in port &lt;&#39; + self._kappa_expression + &#39;&gt;&#39;)
# make it a KappaPort if it&#39;s not one already
elif not type(query) is KappaPort:
elif not isinstance(query, KappaPort):
query = KappaPort(query)
# check if item is satisfied by self, Kappa-wise
if self._int_operand or self._bond_operand: # if self has an operation, issue warning
Expand Down Expand Up @@ -636,11 +636,11 @@ <h2 id="bond-state-truth-table">Bond State Truth Table</h2>
&#34;&#34;&#34;&#34;&#34;&#34;

# we can&#39;t satisfy ports with counters
if type(query) is KappaCounter:
if isinstance(query, KappaCounter):
raise PortParseError(&#39;Can not check for containment of supplied counter &lt;&#39; + query +
&#39;&gt; in port &lt;&#39; + self._kappa_expression + &#39;&gt;&#39;)
# make it a KappaPort if it&#39;s not one already
elif not type(query) is KappaPort:
elif not isinstance(query, KappaPort):
query = KappaPort(query)
# check if item is satisfied by self, Kappa-wise
if self._int_operand or self._bond_operand: # if self has an operation, issue warning
Expand Down
148 changes: 101 additions & 47 deletions docs/KaSaAn/core/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/KaSaAn/functions/find_snapshot_names.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1 class="title">Module <code>KaSaAn.functions.find_snapshot_names</code></h1>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="KaSaAn.functions.find_snapshot_names.find_snapshot_names"><code class="name flex">
<span>def <span class="ident">find_snapshot_names</span></span>(<span>target_directory: Union[pathlib.Path, str] = '.', name_pattern: str = 'snap*.ka') ‑> List[str]</span>
<span>def <span class="ident">find_snapshot_names</span></span>(<span>target_directory: Union[str, pathlib.Path] = '.', name_pattern: str = 'snap*.ka') ‑> List[str]</span>
</code></dt>
<dd>
<div class="desc"><p>Given a target directory (default <code>./</code>), and a snapshot naming scheme (default <code>snap*.ka</code>), return a list of
Expand Down
70 changes: 55 additions & 15 deletions docs/KaSaAn/functions/graph_largest_complex_composition.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ <h1 class="title">Module <code>KaSaAn.functions.graph_largest_complex_compositio
import numpy
import warnings
from operator import itemgetter
from typing import Dict, List, Tuple, Set
from typing import Dict, List, Tuple, Set, Union

from KaSaAn.core import KappaAgent

from ..functions.agent_color_assignment import colorize_observables
from ..core import KappaComplex, KappaSnapshot
Expand Down Expand Up @@ -89,7 +91,7 @@ <h1 class="title">Module <code>KaSaAn.functions.graph_largest_complex_compositio
return fig


def process_snapshot_helper(snapshot_name: str, patterns_requested: Set[KappaComplex] = None) -&gt; Tuple[float, dict]:
def process_snapshot_helper(snapshot_name: str, patterns_requested: Set[Union[KappaAgent, KappaComplex]] = None) -&gt; Tuple[float, Dict[Union[KappaAgent, KappaComplex], int]]:
&#34;&#34;&#34;Helper function to process snapshots and extract an arbitrary compositon.&#34;&#34;&#34;
snap = KappaSnapshot(snapshot_name)
big_o_mers = snap.get_largest_complexes()
Expand All @@ -102,7 +104,7 @@ <h1 class="title">Module <code>KaSaAn.functions.graph_largest_complex_compositio
lc_complex, _ = big_o_mers[0]
# filter out agents if requested
if patterns_requested:
filtered_composition = {}
filtered_composition: Dict[Union[KappaAgent, KappaComplex], int] = {}
for ka_pattern in patterns_requested:
filtered_composition[ka_pattern] = lc_complex.get_number_of_embeddings(ka_pattern)
lc_composition = filtered_composition
Expand All @@ -112,8 +114,13 @@ <h1 class="title">Module <code>KaSaAn.functions.graph_largest_complex_compositio


def snapshot_list_to_plot_matrix(
snapshot_names, patterns_requested: Dict = None, thread_number: int = 1,
stack_order: str = list(_stacked_plot_methods.keys())[0]) -&gt; Tuple[List[float], numpy.ndarray, List[KappaComplex]]:
snapshot_names: List[str],
patterns_requested: Dict = None,
thread_number: int = 1,
stack_order: str = list(_stacked_plot_methods.keys())[0]) -&gt; Tuple[
List[float],
numpy.ndarray,
List[Union[KappaAgent, KappaComplex, Union[KappaAgent, KappaComplex]]]]:
&#34;&#34;&#34;See file under `KaSaAn.scripts` for usage.&#34;&#34;&#34;

if stack_order not in _stacked_plot_methods.keys():
Expand All @@ -123,7 +130,7 @@ <h1 class="title">Module <code>KaSaAn.functions.graph_largest_complex_compositio
snap_times = []
holding_struct = {}
if patterns_requested:
pattern_keys: Set[KappaComplex] = patterns_requested.keys()
pattern_keys: Set[Union[KappaAgent, KappaComplex]] = patterns_requested.keys()
else:
pattern_keys = None
# iterate over the snapshots
Expand Down Expand Up @@ -153,10 +160,24 @@ <h1 class="title">Module <code>KaSaAn.functions.graph_largest_complex_compositio
# obtain and sort the superset of patterns; used for defining the number of lines to plot
# a pattern may not have been present in a snapshot, so we need to fill in a zero at some
# point for that specific snapshot time
# in cases where the requested patterns contain KappaAgents and KappaComplexes, the list
# can&#39;t be sorted at once, so they are sorted separately, then concatenated
all_patterns = set()
for compo in lc_compositions:
all_patterns.update(set(compo.keys()))
all_patterns = sorted(all_patterns)
if any(isinstance(n, KappaAgent) for n in all_patterns) and any(isinstance(n, KappaComplex) for n in all_patterns):
agent_patterns = []
complex_patterns = []
for some_p in all_patterns:
if isinstance(some_p, KappaAgent):
agent_patterns.append(some_p)
elif isinstance(some_p, KappaComplex):
complex_patterns.append(some_p)
else:
raise ValueError(&#39;Unexpected type {} from color scheme! Expected KappaAgent or KappaComplex&#39;.format(type(some_p)))
all_patterns = sorted(agent_patterns) + sorted(complex_patterns)
else:
all_patterns = sorted(all_patterns)

# create matrix for plotting, with alphabetical agent sorting
plot_matrix = numpy.full([len(all_patterns), len(lc_compositions)], numpy.nan, dtype=int)
Expand Down Expand Up @@ -200,15 +221,15 @@ <h1 class="title">Module <code>KaSaAn.functions.graph_largest_complex_compositio
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="KaSaAn.functions.graph_largest_complex_composition.process_snapshot_helper"><code class="name flex">
<span>def <span class="ident">process_snapshot_helper</span></span>(<span>snapshot_name: str, patterns_requested: Set[KaSaAn.core.KappaComplex.KappaComplex] = None) ‑> Tuple[float, dict]</span>
<span>def <span class="ident">process_snapshot_helper</span></span>(<span>snapshot_name: str, patterns_requested: Set[Union[KaSaAn.core.KappaAgent.KappaAgent, KaSaAn.core.KappaComplex.KappaComplex]] = None) ‑> Tuple[float, Dict[Union[KaSaAn.core.KappaAgent.KappaAgent, KaSaAn.core.KappaComplex.KappaComplex], int]]</span>
</code></dt>
<dd>
<div class="desc"><p>Helper function to process snapshots and extract an arbitrary compositon.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def process_snapshot_helper(snapshot_name: str, patterns_requested: Set[KappaComplex] = None) -&gt; Tuple[float, dict]:
<pre><code class="python">def process_snapshot_helper(snapshot_name: str, patterns_requested: Set[Union[KappaAgent, KappaComplex]] = None) -&gt; Tuple[float, Dict[Union[KappaAgent, KappaComplex], int]]:
&#34;&#34;&#34;Helper function to process snapshots and extract an arbitrary compositon.&#34;&#34;&#34;
snap = KappaSnapshot(snapshot_name)
big_o_mers = snap.get_largest_complexes()
Expand All @@ -221,7 +242,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
lc_complex, _ = big_o_mers[0]
# filter out agents if requested
if patterns_requested:
filtered_composition = {}
filtered_composition: Dict[Union[KappaAgent, KappaComplex], int] = {}
for ka_pattern in patterns_requested:
filtered_composition[ka_pattern] = lc_complex.get_number_of_embeddings(ka_pattern)
lc_composition = filtered_composition
Expand All @@ -231,7 +252,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
</details>
</dd>
<dt id="KaSaAn.functions.graph_largest_complex_composition.snapshot_list_to_plot_matrix"><code class="name flex">
<span>def <span class="ident">snapshot_list_to_plot_matrix</span></span>(<span>snapshot_names, patterns_requested: Dict = None, thread_number: int = 1, stack_order: str = 'first_in_first_out') ‑> Tuple[List[float], numpy.ndarray, List[KaSaAn.core.KappaComplex.KappaComplex]]</span>
<span>def <span class="ident">snapshot_list_to_plot_matrix</span></span>(<span>snapshot_names: List[str], patterns_requested: Dict = None, thread_number: int = 1, stack_order: str = 'first_in_first_out') ‑> Tuple[List[float], numpy.ndarray, List[Union[KaSaAn.core.KappaAgent.KappaAgent, KaSaAn.core.KappaComplex.KappaComplex]]]</span>
</code></dt>
<dd>
<div class="desc"><p>See file under <code><a title="KaSaAn.scripts" href="../scripts/index.html">KaSaAn.scripts</a></code> for usage.</p></div>
Expand All @@ -240,8 +261,13 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<span>Expand source code</span>
</summary>
<pre><code class="python">def snapshot_list_to_plot_matrix(
snapshot_names, patterns_requested: Dict = None, thread_number: int = 1,
stack_order: str = list(_stacked_plot_methods.keys())[0]) -&gt; Tuple[List[float], numpy.ndarray, List[KappaComplex]]:
snapshot_names: List[str],
patterns_requested: Dict = None,
thread_number: int = 1,
stack_order: str = list(_stacked_plot_methods.keys())[0]) -&gt; Tuple[
List[float],
numpy.ndarray,
List[Union[KappaAgent, KappaComplex, Union[KappaAgent, KappaComplex]]]]:
&#34;&#34;&#34;See file under `KaSaAn.scripts` for usage.&#34;&#34;&#34;

if stack_order not in _stacked_plot_methods.keys():
Expand All @@ -251,7 +277,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
snap_times = []
holding_struct = {}
if patterns_requested:
pattern_keys: Set[KappaComplex] = patterns_requested.keys()
pattern_keys: Set[Union[KappaAgent, KappaComplex]] = patterns_requested.keys()
else:
pattern_keys = None
# iterate over the snapshots
Expand Down Expand Up @@ -281,10 +307,24 @@ <h2 class="section-title" id="header-functions">Functions</h2>
# obtain and sort the superset of patterns; used for defining the number of lines to plot
# a pattern may not have been present in a snapshot, so we need to fill in a zero at some
# point for that specific snapshot time
# in cases where the requested patterns contain KappaAgents and KappaComplexes, the list
# can&#39;t be sorted at once, so they are sorted separately, then concatenated
all_patterns = set()
for compo in lc_compositions:
all_patterns.update(set(compo.keys()))
all_patterns = sorted(all_patterns)
if any(isinstance(n, KappaAgent) for n in all_patterns) and any(isinstance(n, KappaComplex) for n in all_patterns):
agent_patterns = []
complex_patterns = []
for some_p in all_patterns:
if isinstance(some_p, KappaAgent):
agent_patterns.append(some_p)
elif isinstance(some_p, KappaComplex):
complex_patterns.append(some_p)
else:
raise ValueError(&#39;Unexpected type {} from color scheme! Expected KappaAgent or KappaComplex&#39;.format(type(some_p)))
all_patterns = sorted(agent_patterns) + sorted(complex_patterns)
else:
all_patterns = sorted(all_patterns)

# create matrix for plotting, with alphabetical agent sorting
plot_matrix = numpy.full([len(all_patterns), len(lc_compositions)], numpy.nan, dtype=int)
Expand Down
15 changes: 8 additions & 7 deletions docs/KaSaAn/functions/observable_plotter.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ <h1 class="title">Module <code>KaSaAn.functions.observable_plotter</code></h1>
</summary>
<pre><code class="python">#!/usr/bin/env python3

from typing import List, Tuple
from pathlib import Path
from typing import List, Optional, Tuple, Union
import ast
import csv
import matplotlib.axes as mpa
import numpy as np


def observable_file_reader(file_name: str = &#39;data.csv&#39;) -&gt; Tuple[list, np.ndarray]:
def observable_file_reader(file_name: Union[str, Path] = &#39;data.csv&#39;) -&gt; Tuple[list, np.ndarray]:
&#34;&#34;&#34;Function parses a kappa output file, e.g. &lt;data.csv&gt;, and returns the legend and numeric data.&#34;&#34;&#34;
# read the header, skipping UUID and command recipe, extract legend entries
with open(file_name, &#39;r&#39;, newline=&#39;&#39;) as csv_file:
Expand All @@ -49,7 +50,7 @@ <h1 class="title">Module <code>KaSaAn.functions.observable_plotter</code></h1>


def observable_list_axis_annotator(obs_axis: mpa.Axes, data: Tuple[list, np.ndarray],
vars_indexes: List[int], vars_names: List[str], vars_exprs: List[str],
vars_indexes: Optional[List[int]], vars_names: Optional[List[str]], vars_exprs: Optional[List[str]],
axis_x_log: bool = False, axis_y_log: bool = False,
diff_toggle: bool = False, add_legend: bool = True) -&gt; mpa.Axes:
&#34;&#34;&#34;Function plots a parsed kappa output file, e.g. &lt;data.csv&gt;, and returns a matplotlib figure object. See file
Expand Down Expand Up @@ -153,15 +154,15 @@ <h1 class="title">Module <code>KaSaAn.functions.observable_plotter</code></h1>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="KaSaAn.functions.observable_plotter.observable_file_reader"><code class="name flex">
<span>def <span class="ident">observable_file_reader</span></span>(<span>file_name: str = 'data.csv') ‑> Tuple[list, numpy.ndarray]</span>
<span>def <span class="ident">observable_file_reader</span></span>(<span>file_name: Union[str, pathlib.Path] = 'data.csv') ‑> Tuple[list, numpy.ndarray]</span>
</code></dt>
<dd>
<div class="desc"><p>Function parses a kappa output file, e.g. <data.csv>, and returns the legend and numeric data.</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def observable_file_reader(file_name: str = &#39;data.csv&#39;) -&gt; Tuple[list, np.ndarray]:
<pre><code class="python">def observable_file_reader(file_name: Union[str, Path] = &#39;data.csv&#39;) -&gt; Tuple[list, np.ndarray]:
&#34;&#34;&#34;Function parses a kappa output file, e.g. &lt;data.csv&gt;, and returns the legend and numeric data.&#34;&#34;&#34;
# read the header, skipping UUID and command recipe, extract legend entries
with open(file_name, &#39;r&#39;, newline=&#39;&#39;) as csv_file:
Expand All @@ -175,7 +176,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
</details>
</dd>
<dt id="KaSaAn.functions.observable_plotter.observable_list_axis_annotator"><code class="name flex">
<span>def <span class="ident">observable_list_axis_annotator</span></span>(<span>obs_axis: matplotlib.axes._axes.Axes, data: Tuple[list, numpy.ndarray], vars_indexes: List[int], vars_names: List[str], vars_exprs: List[str], axis_x_log: bool = False, axis_y_log: bool = False, diff_toggle: bool = False, add_legend: bool = True) ‑> matplotlib.axes._axes.Axes</span>
<span>def <span class="ident">observable_list_axis_annotator</span></span>(<span>obs_axis: matplotlib.axes._axes.Axes, data: Tuple[list, numpy.ndarray], vars_indexes: Optional[List[int]], vars_names: Optional[List[str]], vars_exprs: Optional[List[str]], axis_x_log: bool = False, axis_y_log: bool = False, diff_toggle: bool = False, add_legend: bool = True) ‑> matplotlib.axes._axes.Axes</span>
</code></dt>
<dd>
<div class="desc"><p>Function plots a parsed kappa output file, e.g. <data.csv>, and returns a matplotlib figure object. See file
Expand All @@ -185,7 +186,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
<span>Expand source code</span>
</summary>
<pre><code class="python">def observable_list_axis_annotator(obs_axis: mpa.Axes, data: Tuple[list, np.ndarray],
vars_indexes: List[int], vars_names: List[str], vars_exprs: List[str],
vars_indexes: Optional[List[int]], vars_names: Optional[List[str]], vars_exprs: Optional[List[str]],
axis_x_log: bool = False, axis_y_log: bool = False,
diff_toggle: bool = False, add_legend: bool = True) -&gt; mpa.Axes:
&#34;&#34;&#34;Function plots a parsed kappa output file, e.g. &lt;data.csv&gt;, and returns a matplotlib figure object. See file
Expand Down
Loading

0 comments on commit 2beed3b

Please sign in to comment.