Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the new features #40

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.5.1
176 changes: 163 additions & 13 deletions docs/api_reference/python_api_index.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,170 @@
Python API Reference
====================

This is the API reference for the Python client library for the SBMLNetwork package.
Introduction
------------

******************
SBMLNetwork Class
******************
For many biologists, working with SBML models is familiar, but translating them into meaningful visual representations can be challenging. The **SBMLNetwork Python Package** provides an intuitive way to explore SBML-based networks without requiring advanced programming knowledge. It offers structured access to **compartments**, **species**, and **reactions**, each represented with labels, shapes, and curves that reflect SBML concepts. By abstracting away visualization complexities, this API allows users to focus on biological insights rather than rendering details.

.. autoclass:: sbmlnetwork.SBMLNetwork
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
Conceptual Overview of the Network Structure
--------------------------------------------

*****************
Static Functions
*****************
SBMLNetwork visualizes biological networks in a way that mirrors the structure of SBML models. The network is composed of three key components:

- **Compartments**:
Compartments act as containers for biological entities and processes. Each compartment is represented with its own label and shape, and provides direct access to the species and reactions it contains. This mirrors the idea of grouping related elements within a specific cellular or spatial context.

- **Species**:
Species represent individual biological entities, such as molecules or genes, and are depicted as nodes. Each species comes with a label and a shape, and is connected to reactions via curves, visually demonstrating their role in various biological processes.

- **Reactions**:
Reactions capture the interactions between species. Each reaction is labeled and features a central point, from which curves extend to illustrate the flow of interactions. These curves may consist of multiple segments and include arrowheads to indicate directionality. Reactions also provide access to the associated species, emphasizing the dynamic connectivity within the network.

This hierarchical structure is designed to align with the intuitive understanding of SBML models, allowing users to easily navigate and visualize the complex interplay between different biological elements.

Breakdown of Components
-----------------------


This diagram illustrates how the API components are structured, making it easier to understand their relationships and roles in the visualization of SBML-based networks.
The high-level API is organized into a clear, hierarchical structure. Below are the diagrams of the components and their relationships:

Network
^^^^^^^

.. graphviz::
:caption: High-Level API Architecture

digraph sbml_network {
rankdir=TB;
node [shape=record, style=rounded, fontname=Helvetica];

Network [label="Network"];
Compartments [
label=<
<table border="0" cellborder="0" cellpadding="5">
<tr>
<td>Compartments</td>
</tr>
<tr>
<td><font point-size="10">- Shapes</font></td>
</tr>
<tr>
<td><font point-size="10">- Labels</font></td>
</tr>
</table>
>,
shape=record,
style=rounded,
URL="http://compartments-info.com",
tooltip="Click for more compartment details"
];
Species [
label=<
<table border="0" cellborder="0" cellpadding="5">
<tr>
<td>Species</td>
</tr>
<tr>
<td><font point-size="10">- Shapes</font></td>
</tr>
<tr>
<td><font point-size="10">- Labels</font></td>
</tr>
</table>
>,
shape=record,
style=rounded,
URL="http://species-info.com",
tooltip="Click for more species details"
];
Reactions [
label=<
<table border="0" cellborder="0" cellpadding="5">
<tr>
<td>Reactions</td>
</tr>
<tr>
<td><font point-size="10">- Center</font></td>
</tr>
<tr>
<td><font point-size="10">- Labels</font></td>
</tr>
</table>
>,
shape=record,
style=rounded,
URL="http://reactions-info.com",
tooltip="Click for more reaction details"
];
Curves [
label=<
<table border="0" cellborder="0" cellpadding="5">
<tr>
<td>Curves</td>
</tr>
<tr>
<td><font point-size="10">- Segments</font></td>
</tr>
<tr>
<td><font point-size="10">- Arrowheads</font></td>
</tr>
</table>
>,
shape=record,
style=rounded,
URL="http://curves-info.com",
tooltip="Click for more curve details"
];
Labels [
label=<
<table border="0" cellborder="0" cellpadding="5">
<tr>
<td>Labels</td>
</tr>
<tr>
<td><font point-size="10">- Text</font></td>
</tr>
<tr>
<td><font point-size="10">- Position</font></td>
</tr>
</table>
>,
shape=record,
style=rounded,
URL="http://labels-info.com",
tooltip="Click for more label details"
];
Shapes [
label=<
<table border="0" cellborder="0" cellpadding="5">
<tr>
<td>Shapes</td>
</tr>
<tr>
<td><font point-size="10">- Type</font></td>
</tr>
<tr>
<td><font point-size="10">- Size</font></td>
</tr>
</table>
>,
shape=record,
style=rounded,
URL="http://shapes-info.com",
tooltip="Click for more shape details"
];

Network -> Compartments;
Compartments -> Labels;
Compartments -> Shapes;
Network -> Species;
Species -> Labels;
Species -> Shapes;
Network -> Reactions;
Reactions -> Curves;



}

.. autofunction:: sbmlnetwork.load
87 changes: 87 additions & 0 deletions src/bindings/python/ctypes/libsbmlnetwork.py.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,58 @@ class LibSBMLNetwork:
"""
return lib.c_api_setSpeciesReferenceCurveSegmentBasePoint2Y(self.sbml_object, str(reaction_id).encode(), ctypes.c_double(y), reaction_glyph_index, species_reference_index, curve_segment_index, layout_index)

def makeSpeciesReferenceVisible(self, reaction_id, reaction_glyph_index=0, species_reference_index=0, layout_index=0):
"""
Makes the SpeciesReference with the given reaction_id, reaction_glyph_index, species_reference_index, and layout_index in the given SBMLDocument visible

:Parameters:

- reaction_id (string): a string that determines the id of the Reaction
- reaction_glyph_index (int): an integer that determines the index of the ReactionGlyph in the given SBMLDocument
- species_reference_index (int): an integer that determines the index of the SpeciesReference in the given SBMLDocument
- layout_index (int, optional): an integer (default: 0) that determines the index of the Layout object in the given SBMLDocument

:Returns:

true on success and false if the SpeciesReference could not be made visible
"""
return lib.c_api_makeSpeciesReferenceVisible(self.sbml_object, str(reaction_id).encode(), reaction_glyph_index, species_reference_index, layout_index)

def makeSpeciesReferenceInvisible(self, reaction_id, reaction_glyph_index=0, species_reference_index=0, layout_index=0):
"""
Makes the SpeciesReference with the given reaction_id, reaction_glyph_index, species_reference_index, and layout_index in the given SBMLDocument invisible

:Parameters:

- reaction_id (string): a string that determines the id of the Reaction
- reaction_glyph_index (int): an integer that determines the index of the ReactionGlyph in the given SBMLDocument
- species_reference_index (int): an integer that determines the index of the SpeciesReference in the given SBMLDocument
- layout_index (int, optional): an integer (default: 0) that determines the index of the Layout object in the given SBMLDocument

:Returns:

true on success and false if the SpeciesReference could not be made invisible
"""
return lib.c_api_makeSpeciesReferenceInvisible(self.sbml_object, str(reaction_id).encode(), reaction_glyph_index, species_reference_index, layout_index)

def isSpeciesReferenceVisible(self, reaction_id, reaction_glyph_index=0, species_reference_index=0, layout_index=0):
"""
Returns whether the SpeciesReference with the given reaction_id, reaction_glyph_index, species_reference_index, and layout_index in the given SBMLDocument is visible

:Parameters:

- reaction_id (string): a string that determines the id of the Reaction
- reaction_glyph_index (int): an integer that determines the index of the ReactionGlyph in the given SBMLDocument
- species_reference_index (int): an integer that determines the index of the SpeciesReference in the given SBMLDocument
- layout_index (int, optional): an integer (default: 0) that determines the index of the Layout object in the given SBMLDocument

:Returns:

true if the SpeciesReference with the given reaction_id, reaction_glyph_index, species_reference_index, and layout_index in the given SBMLDocument is visible and false otherwise
"""
lib.c_api_isSpeciesReferenceVisible.restype = ctypes.c_bool
return lib.c_api_isSpeciesReferenceVisible(self.sbml_object, str(reaction_id).encode(), reaction_glyph_index, species_reference_index, layout_index)

def isSetSpeciesReferenceLineColor(self, reaction_id, reaction_glyph_index=0, species_reference_index=0, layout_index=0):
"""
Returns whether the line color of the SpeciesReference with the given reaction_id, reaction_glyph_index, species_reference_index, and layout_index in the given SBMLDocument is set
Expand Down Expand Up @@ -10343,6 +10395,41 @@ class LibSBMLNetwork:
"""
return lib.c_api_setGeometricShapeFillColor(self.sbml_object, str(id).encode(), str(fill_color).encode(), geometric_shape_index, graphical_object_index, layout_index)

def setGeometricShapeFillColorAsGradient(self, id, stop_colors = [], stop_offsets = [], gradient_type = "linear", geometric_shape_index=0, graphical_object_index=0, layout_index=0):
"""
Sets the fill color of the GeometricShape object with the given index associated with the model entity with the given id in the given SBMLDocument as a gradient

:Parameters:

- id (string): a string that determines the id of the model entity
- stop_colors (list, optional): a list of strings that determines the stop colors of the gradient
- stop_offsets (list, optional): a list of floats that determines the stop offsets of the gradient
- gradient_type (string, optional): a string that determines the type of the gradient
- geometric_shape_index (int, optional): an integer (default: 0) that determines the index of the GeometricShape object associated with the model entity with the given id in the given SBMLDocument
- graphical_object_index (int, optional): an integer (default: 0) that determines the index of the GraphicalObject in the given SBMLDocument
- layout_index (int, optional): an integer (default: 0) that determines the index of the Layout object in the given SBMLDocument

:Returns:

true on success and false if the fill color of the GraphicalObject could not be set
"""
if len(stop_colors) != len(stop_offsets):
raise ValueError("The number of stop colors list and stop offsets list should be the same")

stop_colors_ptr = None
if stop_colors is not None:
stop_colors_ptr = (ctypes.c_char_p * len(stop_colors))()
for i in range(len(stop_colors)):
stop_colors_ptr[i] = ctypes.c_char_p(stop_colors[i].encode())

stop_offsets_ptr = None
if stop_offsets is not None:
stop_offsets_ptr = (ctypes.c_double * len(stop_offsets))()
for i in range(len(stop_offsets)):
stop_offsets_ptr[i] = ctypes.c_double(stop_offsets[i])

return lib.c_api_setGeometricShapeFillColorAsGradient(self.sbml_object, str(id).encode(), str(gradient_type).encode(), stop_colors_ptr, stop_offsets_ptr, ctypes.c_int(len(stop_colors)), geometric_shape_index, graphical_object_index, layout_index)

def isSetGeometricShapeX(self, id, geometric_shape_index=0, graphical_object_index=0, layout_index=0):
"""
Returns whether the x-coordinate of the GeometricShape object with the given index associated with the model entity with the given id in the given SBMLDocument is set
Expand Down
3 changes: 3 additions & 0 deletions src/bindings/python/ctypes/sbmlnetwork/requirements.txt.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
libsbmlnetwork>=${LIBSBMLNETWORK_DOTTED_VERSION}
networkinfotranslator>=${LIBSBMLNETWORK_DOTTED_VERSION}
pillow
tellurium
matplotlib

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .align import HorizontalAlign, VerticalAlign, CircleAlign
from .data_integration import Fluxes
Loading
Loading