rkviewer package¶
Subpackages¶
Submodules¶
rkviewer.config module¶
Configuration parameters.
-
class
rkviewer.config.
Color
(r: int, g: int, b: int, a: int = 255)[source]¶ Bases:
object
- Parameters
r (
int
) –g (
int
) –b (
int
) –a (
int
) –
-
a
: int = 255¶
-
b
: int¶
-
classmethod
from_rgb
(val)[source]¶ Create color from RGB hex value: #00BBGGRR
- Parameters
val (
int
) –- Return type
-
g
: int¶
-
r
: int¶
-
class
rkviewer.config.
ColorField
(**kw)[source]¶ Bases:
marshmallow.fields.Field
Field that represents an RGBA color.
To represent the color red, you would write: >>> { “some_color”: [255, 0, 0] }
You may also specify its opacity. To make the color red half transparent: >>> { “some”: [255, 0, 0, 127] }
In short, you may specify four integer arguments RGBA in an array, which the alpha value being optional and defaulting to 255, or fully opaque. Each value must be in range [0, 255].
-
list_field
= <fields.List(dump_default=<marshmallow.missing>, attribute=None, validate=<Length(min=3, max=4, equal=None, error=None)>, required=False, load_only=False, dump_only=False, load_default=<marshmallow.missing>, allow_none=False, error_messages={'required': 'Missing data for required field.', 'null': 'Field may not be null.', 'validator_failed': 'Invalid value.', 'invalid': 'Not a valid list.'})>¶
-
range_validate
= <Range(min=0, max=255, min_inclusive=True, max_inclusive=True, error='RGBA values must be between 0 and 255.')>¶
-
-
class
rkviewer.config.
Dim
(**kwargs)[source]¶ Bases:
marshmallow.fields.Float
Field that represents some real dimension (length).
-
class
rkviewer.config.
Font
(pointSize: int, color: rkviewer.config.Color)[source]¶ Bases:
object
- Parameters
pointSize (
int
) –color (
Color
) –
-
color
: rkviewer.config.Color¶
-
pointSize
: int¶
-
class
rkviewer.config.
Pixel
(**kwargs)[source]¶ Bases:
marshmallow.fields.Integer
Field that represents some length in pixels.
The only current restriction is that this must be a nonnegative integer, or >>> { “some_width”: 23 }
-
class
rkviewer.config.
RootSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
The overall root schema.
-
theme
¶ The theme settings (i.e. colors and dimensions) of the application.
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.config.
RuntimeVariables
(enable_plugins: bool = True)[source]¶ Bases:
object
Variables pertaining to the application runtime
- Parameters
enable_plugins (
bool
) –
-
enable_plugins
: bool = True¶
-
class
rkviewer.config.
ThemeSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
Schema for the overall theme, i.e. appearance, of the application.
-
overall_bg
¶ Overall background color of the application.
-
canvas_bg
¶ Background color of the canvas.
-
toolbar_bg
¶ Background color of the toolbar.
-
btn_bg
¶ Background color of a button
-
btn_fg
¶ Foreground color of a button, ie the color used by the button text
-
btn_hover_bg
¶ BG color of a button when the mouse is hovering over it. By default this should be equal to the normal BG since MSW already provides a faint blue hovering effect. But in the case that btn_border is False, the native hovering effects vanish, so this is needed as a replacement visual indicator.
-
btn_hover_fg
¶ FG color of a button when the mouse is hovering over it. See btn_hover_bg.
-
btn_border
¶ True for border, false for no border
-
canvas_width
¶ Displayed (visible) width of the canvas.
-
real_canvas_width
¶ Actual width of the canvas, some of which may be hidden
-
canvas_height
¶ Displayed (visible) height of the canvas.
-
real_canvas_height
¶ Actual height of the canvas, some of which may be hidden
-
vgap
¶ Vertical gap between toolbars and canvas.
-
hgap
¶ Horizontal gap between toolbars and canvas.
-
canvas_outside_bg
¶ Background color of the part outside of the bounds of canvas.
-
mode_panel_width
¶ Width of the mode selection panel.
-
node_fill
¶ Default node fill color.
-
node_border
¶ Default node border color.
-
node_width
¶ Default node width.
-
node_height
¶ Default node height.
-
node_border_width
¶ Default node border width.
-
node_font_size
¶ Default font size of the node.
-
node_font_color
¶ Default font color of the node.
-
select_outline_width
¶ Width of the selection outlines (i.e. outline around each selected item).
-
select_outline_padding
¶ Padding of the selection outlines.
-
handle_color
¶ ColorField of the Reaction Bezier curves.
-
highlighted_handle_color
¶ ColorField of the Reaction Bezier curves when the cursor hovers over it
-
select_box_padding
¶ Padding of the selection rectangle (i.e. the large rectangle that encompasses all the selected items).
-
select_handle_length
¶ Side length of the squares one uses to resize nodes/compartments.
-
zoom_slider_bg
¶ Background color of the zoom slider.
-
drag_fill
¶ The fill color of the drag selection rectangle.
-
drag_border
¶ The border color of the drag selection rectangle.
-
drag_border_width
¶ The border width of the drag selection rectangle.
-
react_node_padding
¶ The outline padding for nodes prepped as reactants or products.
-
react_node_border_width
¶ The border width for nodes prepped as reactants or products.
-
reactant_border
¶ The outline color for nodes prepped as reactants.
-
product_border
¶ The outline color for nodes prepped as products.
-
reaction_fill
¶ The default fill color of reaction curves.
-
reaction_line_thickness
¶ The default thickness of reaction curves.
-
selected_reaction_fill
¶ The fill color of selected reaction curves.
-
comp_fill
¶ The default fill color of compartments.
-
comp_border
¶ The default border color of compartments.
-
comp_border_width
¶ The default border width of compartments.
-
reaction_radius
¶ The radius of the reaction centroid circles.
-
active_tab_fg
¶ The foreground (font) color of the active tab in a FlatNotebook. There is no option to set the BG color since the BG color is always a brighter version of the toolbar BG.
-
text_field_bg
¶ The background color of text fields.
-
text_field_fg
¶ The foreground (font) color of text fields
-
text_field_border
¶ Whether the border of text fields should be drawn.
TODO more documentation under attributes and link to this document in Help or settings.json
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
rkviewer.config.
get_theme
(theme_attr, convert_color=True)[source]¶ convert_color: if True, convert Color instances to wx.Colour instances automatically
- Return type
Any
-
rkviewer.config.
load_theme_settings
()[source]¶ Reload all settings from the default settings path.
The exceptions are not immediately thrown since the first time the settings are loaded, the app has not been initialized. So we wait until it is, and then display an error dialog if there is a previously recorded error.
-
rkviewer.config.
pop_settings_err
()[source]¶ If there was error when loading the settings JSON, this would be not None. Used by canvas to display a warning message after the window is created.
The error is cleared when this is called.
rkviewer.controller module¶
Implementation of a controller.
-
class
rkviewer.controller.
Controller
(view)[source]¶ Bases:
rkviewer.mvc.IController
A controller class.
This is not strictly adhering to the MVC architecture, since there is not a separate Model interface. Rather, this controller directly interacts with iodine. The model class should be implemented if necessary.
- Parameters
view (
IView
) –
-
add_compartment_g
(neti, compartment)[source]¶ Try to add the given Compartment to the canvas. Return index of added comp.
- Parameters
neti (
int
) –compartment (
Compartment
) –
- Return type
int
-
add_node_g
(neti, node)[source]¶ Add node represented by the given Node variable.
The ‘g’ suffix indicates that this operation creates its own group
- Parameters
neti (
int
) –node (
Node
) –
- Return type
int
-
add_reaction_g
(neti, reaction)[source]¶ Try create a reaction.
- Parameters
neti (
int
) –reaction (
Reaction
) –
- Return type
int
-
get_composite_shape_list
(neti)[source]¶ - Parameters
neti (
int
) –- Return type
List
[CompositeShape
]
-
get_dest_node_handle
(neti, reai, nodei)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –
- Return type
-
get_list_of_compartments
(neti)[source]¶ - Parameters
neti (
int
) –- Return type
List
[Compartment
]
-
get_list_of_node_ids
(neti)[source]¶ Try getting the list of node IDs
- Parameters
neti (
int
) –- Return type
List
[str
]
-
get_nodes_in_compartment
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
List
[int
]
-
get_reaction_modifiers
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
Set
[int
]
-
get_reactions_as_product
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
Set
[int
]
-
get_reactions_as_reactant
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
Set
[int
]
-
get_src_node_handle
(neti, reai, nodei)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –
- Return type
-
new_network
()[source]¶ Create a new network.
Since there is only one tab for now, this merely clears the the current network. Also, does not clear undo stack.
-
view
: rkviewer.mvc.IView¶
rkviewer.events module¶
Custom events dispatched by the canvas.
These events may later be used within a plugin system, where plugins are allowed to bind their own handlers to these events.
-
class
rkviewer.events.
CanvasDidUpdateEvent
[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after the canvas has been updated by the controller.
-
class
rkviewer.events.
DidAddCompartmentEvent
(index: int)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after a compartment has been added.
-
compartment
¶ The Compartment that was added.
- Parameters
index (
int
) –
-
index
: int¶
-
-
class
rkviewer.events.
DidAddNodeEvent
(node: int)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after a node has been added.
-
node
¶ The index of the node that was added.
Note
This event triggers only if the user has performed a drag operation, and not, for example, if the user moved a node in the edit panel.
TODO in the documentation that this event and related ones (and DidDelete-) are emitted before controller.end_group() is called. As an alternative, maybe create a call_after() function similar to wxPython? it should be called in OnIdle() or Refresh()
- Parameters
node (
int
) –
-
node
: int¶
-
-
class
rkviewer.events.
DidAddReactionEvent
(index: int, sources: List[int], targets: List[int])[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after a reaction has been added.
-
reaction
¶ The Reaction that was added.
- Parameters
index (
int
) –sources (
List
[int
]) –targets (
List
[int
]) –
-
index
: int¶
-
sources
: List[int]¶
-
targets
: List[int]¶
-
-
class
rkviewer.events.
DidChangeCompartmentOfNodesEvent
(node_indices: List[int], old_compi: int, new_compi: int, by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after one or more nodes have been moved to a new compartment.
-
node_indices
¶ The list of node indices that changed compartment.
-
old_compi
¶ The old compartment index, -1 for base compartment.
-
new_compi
¶ The new compartment index, -1 for base compartment.
-
by_user
¶ Whether this event was triggered directly by a user action, as opposed to by a plugin.
- Parameters
node_indices (
List
[int
]) –old_compi (
int
) –new_compi (
int
) –by_user (
bool
) –
-
by_user
: bool = True¶
-
new_compi
: int¶
-
node_indices
: List[int]¶
-
old_compi
: int¶
-
-
class
rkviewer.events.
DidCommitDragEvent
(source: Any)[source]¶ Bases:
rkviewer.events.CanvasEvent
Dispatched after any continuously emitted dragging event has concluded.
This is dispatched for any event that is posted in quick intervals while the mouse left button is held while moving, i.e. “dragging” events. This includes: DidMoveNodesEvent, DidMoveCompartmentsEvent, DidResizeNodesEvent, DidResizeCompartmentsEvent, and DidResizeMoveBezierHandlesEvent. This event is emitted after the left mouse button is released, the model is notified of the change, and the action is complete.
- Parameters
source (
Any
) –
-
source
: Any¶
-
class
rkviewer.events.
DidDeleteEvent
(node_indices: Set[int], reaction_indices: Set[int], compartment_indices: Set[int])[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after a node has been deleted.
-
node_indices
¶ The set of nodes (indices )that were deleted.
-
reaction_indices
¶ The set of reactions (indices) that were deleted.
-
compartment_indices
¶ The set of compartment (indices) that were deleted.
- Parameters
node_indices (
Set
[int
]) –reaction_indices (
Set
[int
]) –compartment_indices (
Set
[int
]) –
-
compartment_indices
: Set[int]¶
-
node_indices
: Set[int]¶
-
reaction_indices
: Set[int]¶
-
-
class
rkviewer.events.
DidModifyCompartmentsEvent
(indices: List[int])[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after a property of one or more compartments has been modified, excluding position or size.
For position and size events, see DidMove…Event() and DidResize…Event()
-
indices
¶ The indices of list of compartments that were modified.
- Parameters
indices (
List
[int
]) –
-
indices
: List[int]¶
-
-
class
rkviewer.events.
DidModifyNodesEvent
(indices: List[int], by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after a property of one or more nodes has been modified, excluding position or size.
For position and size events, see DidMove…Event() and DidResize…Event()
-
nodes
¶ The indices of the list of nodes that were modified.
-
by_user
¶ Whether this event was triggered directly by a user action and not, for example, by a plugin.
- Parameters
indices (
List
[int
]) –by_user (
bool
) –
-
by_user
: bool = True¶
-
indices
: List[int]¶
-
-
class
rkviewer.events.
DidModifyReactionEvent
(indices: List[int], by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after a property of one or more nodes has been modified, excluding position.
-
indices
¶ The indices of the list of reactions that were modified.
-
by_user
¶ Whether this event was triggered directly by a user action and not, for example, by a plugin.
- Parameters
indices (
List
[int
]) –by_user (
bool
) –
-
by_user
: bool = True¶
-
indices
: List[int]¶
-
-
class
rkviewer.events.
DidMoveBezierHandleEvent
(net_index: int, reaction_index: int, node_index: int, by_user: bool, direct: bool)[source]¶ Bases:
rkviewer.events.CanvasEvent
Dispatched after a Bezier handle is moved.
-
net_index
¶ The network index.
-
reaction_index
¶ The reaction index.
-
node_index
¶ The index of the node whose Bezier handle moved. -1 if the source centroid handle was moved, or -2 if the dest centroid handle was moved.
-
direct
¶ Automatically true when by_user is False. Otherwise, True if the handle is moved by the user dragging the handle directly, and False if the handle was moved by the user dragging the node associated with that handle.
-
by_user
¶ Whether the event was performed by the user or through a plugin.
- Parameters
net_index (
int
) –reaction_index (
int
) –node_index (
int
) –by_user (
bool
) –direct (
bool
) –
-
by_user
: bool¶
-
direct
: bool¶
-
net_index
: int¶
-
node_index
: int¶
-
reaction_index
: int¶
-
-
class
rkviewer.events.
DidMoveCompartmentsEvent
(compartment_indices: List[int], offset: Union[rkviewer.canvas.geometry.Vec2, List[rkviewer.canvas.geometry.Vec2]], dragged: bool, by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Same as DidMoveNodesEvent but for compartments.
-
compartment_indices
¶ The indices of the compartments that were moved.
-
offset
¶ The position offset. If all compartments were moved by the same offset, then a single Vec2 is given; otherwise, a list of offsets are given, with each offset matching a node.
-
dragged
¶ Whether the resize operation was done by the user dragging, and not, for example, through the form.
-
by_user
¶ Whether the event was performed by the user or through a plugin.
- Parameters
-
by_user
: bool = True¶
-
compartment_indices
: List[int]¶
-
dragged
: bool¶
-
offset
: Union[rkviewer.canvas.geometry.Vec2, List[rkviewer.canvas.geometry.Vec2]]¶
-
-
class
rkviewer.events.
DidMoveNodesEvent
(node_indices: List[int], offset: Union[rkviewer.canvas.geometry.Vec2, List[rkviewer.canvas.geometry.Vec2]], dragged: bool, by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after the position of a node changes but has not been committed to the model.
This event may be called many times, continuously as the user drags a group of nodes. Note that only after the drag operation has ended, is model notified of the move for undo purposes. See DidCommitDragEvent.
-
node_indices
¶ The indices of the nodes that were moved.
-
offset
¶ The position offset. If all nodes were moved by the same offset, then a single Vec2 is given; otherwise, a list of offsets are given, with each offset matching a node.
-
dragged
¶ Whether the resize operation was done by the user dragging, and not, for exmaple, through the form.
-
by_user
¶ Whether the event was performed by the user or through a plugin.
- Parameters
-
by_user
: bool = True¶
-
dragged
: bool¶
-
node_indices
: List[int]¶
-
offset
: Union[rkviewer.canvas.geometry.Vec2, List[rkviewer.canvas.geometry.Vec2]]¶
-
-
class
rkviewer.events.
DidMoveReactionCenterEvent
(net_index: int, reaction_index: int, offset: rkviewer.canvas.geometry.Vec2, dragged: bool)[source]¶ Bases:
rkviewer.events.CanvasEvent
Dispatched after the reaction center is moved by the user.
Note that this is not triggered if the center moved automatically due to nodes moving.
-
net_index
¶ The network index.
-
reaction_index
¶ The reaction index.
-
offset
¶ The amount moved.
-
dragged
¶ Whether the center is moved by the user dragging (it could have been through the form).
- Parameters
net_index (
int
) –reaction_index (
int
) –offset (
Vec2
) –dragged (
bool
) –
-
dragged
: bool¶
-
net_index
: int¶
-
offset
: rkviewer.canvas.geometry.Vec2¶
-
reaction_index
: int¶
-
-
class
rkviewer.events.
DidNewNetworkEvent
[source]¶ Bases:
rkviewer.events.CanvasEvent
Called when the canvas is cleared by choosing “New”.
-
class
rkviewer.events.
DidPaintCanvasEvent
(gc: wx.GraphicsContext)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after the canvas has been painted.
-
gc
¶ The graphics context of the canvas.
- Parameters
gc (
GraphicsContext
) –
-
gc
: wx.GraphicsContext¶
-
-
class
rkviewer.events.
DidRedoEvent
(by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after a redo action is done.
- Parameters
by_user (
bool
) –
-
by_user
: bool = True¶
-
class
rkviewer.events.
DidResizeCompartmentsEvent
(compartment_indices: List[int], ratio: Union[rkviewer.canvas.geometry.Vec2, List[rkviewer.canvas.geometry.Vec2]], dragged: bool, by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after the list of selected compartments has been resized.
-
compartment_indices
¶ The indices of the list of resized compartments.
-
ratio
¶ The resize ratio.
-
dragged
¶ Whether the resize operation was done by the user dragging, and not, for exmaple, through the form.
-
by_user
¶ Whether the event was performed by the user or through a plugin.
- Parameters
-
by_user
: bool = True¶
-
compartment_indices
: List[int]¶
-
dragged
: bool¶
-
ratio
: Union[rkviewer.canvas.geometry.Vec2, List[rkviewer.canvas.geometry.Vec2]]¶
-
-
class
rkviewer.events.
DidResizeNodesEvent
(node_indices: List[int], ratio: rkviewer.canvas.geometry.Vec2, dragged: bool, by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after the list of selected nodes has been resized.
-
node_indices
¶ The indices of the list of resized nodes.
-
ratio
¶ The resize ratio.
-
dragged
¶ Whether the resize operation was done by the user dragging, and not, for exmaple, through the form.
-
by_user
¶ Whether the event was performed by the user or through a plugin.
- Parameters
node_indices (
List
[int
]) –ratio (
Vec2
) –dragged (
bool
) –by_user (
bool
) –
-
by_user
: bool = True¶
-
dragged
: bool¶
-
node_indices
: List[int]¶
-
-
class
rkviewer.events.
DidUndoEvent
(by_user: bool = True)[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after an undo action is done.
- Parameters
by_user (
bool
) –
-
by_user
: bool = True¶
-
class
rkviewer.events.
HandlerChain
[source]¶ Bases:
object
-
append
(handler)[source]¶ - Parameters
handler (
Callable
[[CanvasEvent
],None
]) –- Return type
-
head
: Optional[rkviewer.events.HandlerNode]¶
-
remove
(node)[source]¶ - Parameters
node (
HandlerNode
) –
-
tail
: Optional[rkviewer.events.HandlerNode]¶
-
-
class
rkviewer.events.
HandlerNode
(handler)[source]¶ Bases:
object
- Parameters
handler (
Callable
[[CanvasEvent
],None
]) –
-
handler
: Callable[[rkviewer.events.CanvasEvent], None]¶
-
next_
: Optional[rkviewer.events.HandlerNode]¶
-
prev
: Optional[rkviewer.events.HandlerNode]¶
-
class
rkviewer.events.
SelectionDidUpdateEvent
(node_indices: Set[int], reaction_indices: Set[int], compartment_indices: Set[int])[source]¶ Bases:
rkviewer.events.CanvasEvent
Called after the list of selected nodes and/or reactions has changed.
-
node_indices
¶ The indices of the list of selected nodes.
-
reaction_indices
¶ The indices of the list of selected reactions.
-
compartment_indices
¶ The indices of the list of selected compartments.
- Parameters
node_indices (
Set
[int
]) –reaction_indices (
Set
[int
]) –compartment_indices (
Set
[int
]) –
-
compartment_indices
: Set[int]¶
-
node_indices
: Set[int]¶
-
reaction_indices
: Set[int]¶
-
-
rkviewer.events.
bind_handler
(evt_cls, callback)[source]¶ - Parameters
evt_cls (
Type
[CanvasEvent
]) –callback (
Callable
[[CanvasEvent
],None
]) –
- Return type
int
-
rkviewer.events.
post_event
(evt)[source]¶ # debugging if not str(evt)[:14]==”DidPaintCanvas”:
caller = getframeinfo(stack()[1][0]) print(“%s:%d - %s” % (caller.filename, caller.lineno, str(evt)))
- Parameters
evt (
CanvasEvent
) –
rkviewer.forms module¶
All sorts of form widgets, mainly those used in EditPanel.
-
rkviewer.forms.
AlphaToText
(alpha, prec)[source]¶ Simple helper for converting an alpha value ~[0, 255] to the range [0, 1].
- Parameters
alpha (
Optional
[int
]) – The alpha value in range 0-255. If None, “?” will be returned.precision – The precision of the float string returned.
prec (
int
) –
- Return type
str
-
rkviewer.forms.
ChangePairValue
(ctrl, new_val, prec)[source]¶ Helper for updating the value of a paired number TextCtrl.
The TextCtrl accepts text in the format “X, Y” where X and Y are floats. The control is not updated if the new and old values are identical (considering precision).
- Parameters
ctrl (
TextCtrl
) – The TextCtrl widget.new_val (
Vec2
) – The new pair of floats to update the control with.prec (
int
) – The precision of the numbers. The new value is rounded to this precision.
-
rkviewer.forms.
GetMultiColor
(colors)[source]¶ Helper method for producing one single color from a list of colors.
Editing programs that allows selection of multiple entities usually support editing all of the selected entities at once. When a property of all the selected entities are the same, the displayed value of that property is that single value precisely. However, if they are not the same, usually a “null” or default value is shown on the form. Following this scheme, this helper returns the common color/alpha if all values are the same, or a default value if not.
Note
On Windows the RGB and the alpha are treated as different fields due to the lack of alpha field in the color picker screen. Therefore, the RGB and the alpha fields are considered different fields as far as uniqueness is considered.
- Parameters
colors (
List
[Colour
]) –- Return type
Tuple
[Colour
,Optional
[int
]]
-
rkviewer.forms.
GetMultiEnum
(entries, fallback)[source]¶ Similar to _GetMultiColor, but for enums.
Need to specify a fallback value in case the entries are different.
- Parameters
entries (
List
[Any
]) –
-
rkviewer.forms.
GetMultiFloatText
(values, precision)[source]¶ Returns the common float value if the set has only one element, otherwise return “?”.
See _GetMultiColor for more detail.
- Parameters
values (
Set
[float
]) –precision (
int
) –
- Return type
str
-
rkviewer.forms.
GetMultiInt
(values)[source]¶ Returns the common float value if the set has only one element, otherwise return “?”.
See _GetMultiColor for more detail.
- Parameters
values (
Set
[int
]) –- Return type
Optional
[int
]
-
class
rkviewer.forms.
StoichInfo
(nodei: int, stoich: float)[source]¶ Bases:
object
Helper class that stores node stoichiometry info for reaction form
- Parameters
nodei (
int
) –stoich (
float
) –
-
nodei
: int¶
-
stoich
: float¶
rkviewer.iodine module¶
Iodine Network Object Model.
Original author: RJ Zhou “Forked” from: https://github.com/zrj26/go-NOM Adapted by: Gary Geng
- TODOs
Phase out errCode, or at least provide more detalis in error messages.
-
class
rkviewer.iodine.
AbstractNodeSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
AliasSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
rkviewer.iodine.AbstractNodeSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
CircleSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
rkviewer.iodine.PrimitiveSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
CompartmentSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
CompositeShapeSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
rkviewer.iodine.
CreateBiBi
(neti, reaID, rateLaw, src1i, src2i, dest1i, dest2i, src1Stoich, src2Stoich, dest1Stoich, dest2Stoich)[source]¶ - Parameters
neti (
int
) –reaID (
str
) –rateLaw (
str
) –src1i (
int
) –src2i (
int
) –dest1i (
int
) –dest2i (
int
) –src1Stoich (
float
) –src2Stoich (
float
) –dest1Stoich (
float
) –dest2Stoich (
float
) –
-
rkviewer.iodine.
CreateBiUni
(neti, reaID, rateLaw, src1i, src2i, desti, src1Stoich, src2Stoich, destStoich)[source]¶ - Parameters
neti (
int
) –reaID (
str
) –rateLaw (
str
) –src1i (
int
) –src2i (
int
) –desti (
int
) –src1Stoich (
float
) –src2Stoich (
float
) –destStoich (
float
) –
-
rkviewer.iodine.
CreateUniBi
(neti, reaID, rateLaw, srci, dest1i, dest2i, srcStoich, dest1Stoich, dest2Stoich)[source]¶ - Parameters
neti (
int
) –reaID (
str
) –rateLaw (
str
) –srci (
int
) –dest1i (
int
) –dest2i (
int
) –srcStoich (
float
) –dest1Stoich (
float
) –dest2Stoich (
float
) –
-
class
rkviewer.iodine.
ErrorCode
(value)[source]¶ Bases:
enum.Enum
An enumeration.
-
BAD_STOICH
= -8¶
-
COMPI_NOT_FOUND
= -13¶
-
FILE_ERROR
= -11¶
-
ID_NOT_FOUND
= -2¶
-
ID_REPEAT
= -3¶
-
JSON_ERROR
= -10¶
-
NETI_NOT_FOUND
= -5¶
-
NODEI_NOT_FOUND
= -7¶
-
NODE_NOT_FREE
= -4¶
-
OK
= 0¶
-
OTHER
= -1¶
-
OUT_OF_RANGE
= -12¶
-
REAI_NOT_FOUND
= -6¶
-
STACK_EMPTY
= -9¶
-
-
class
rkviewer.iodine.
FontSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
color
: rkviewer.config.Color¶
-
family
¶ alias of
builtins.str
-
name
: str¶
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
style
: str¶
-
weight
: str¶
-
-
class
rkviewer.iodine.
HexagonSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
rkviewer.iodine.PolygonSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
LineSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
rkviewer.iodine.PrimitiveSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
NetworkSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
NodeSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
rkviewer.iodine.AbstractNodeSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
PolygonSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
rkviewer.iodine.PrimitiveSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
PrimitiveSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
ReactionSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
RectangleSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
rkviewer.iodine.PrimitiveSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
SpeciesNode
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
Represents a species in a reaction.
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
TAbstractNode
[source]¶ Bases:
abc.ABC
-
compi
: int¶
-
index
: int¶
-
nodeLocked
: bool¶
-
position
: rkviewer.canvas.geometry.Vec2¶
-
rectSize
: rkviewer.canvas.geometry.Vec2¶
-
-
class
rkviewer.iodine.
TAliasNode
(index: int, position: rkviewer.canvas.geometry.Vec2, rectSize: rkviewer.canvas.geometry.Vec2, originalIdx: int, nodeLocked: bool, compi: int = - 1)[source]¶ Bases:
rkviewer.iodine.TAbstractNode
- Parameters
-
compi
: int = -1¶
-
index
: int¶
-
nodeLocked
: bool¶
-
originalIdx
: int¶
-
position
: rkviewer.canvas.geometry.Vec2¶
-
rectSize
: rkviewer.canvas.geometry.Vec2¶
-
class
rkviewer.iodine.
TCompartment
(id: str, position: rkviewer.canvas.geometry.Vec2, rectSize: rkviewer.canvas.geometry.Vec2, node_indices: Set[int] = <factory>, volume: float = 1, fillColor: rkviewer.config.Color = Color(r=0, g=247, b=255, a=255), outlineColor: rkviewer.config.Color = Color(r=0, g=106, b=255, a=255), outlineThickness: float = 2)[source]¶ Bases:
object
- Parameters
-
fillColor
: rkviewer.config.Color = Color(r=0, g=247, b=255, a=255)¶
-
id
: str¶
-
node_indices
: Set[int]¶
-
outlineColor
: rkviewer.config.Color = Color(r=0, g=106, b=255, a=255)¶
-
outlineThickness
: float = 2¶
-
position
: rkviewer.canvas.geometry.Vec2¶
-
rectSize
: rkviewer.canvas.geometry.Vec2¶
-
volume
: float = 1¶
-
class
rkviewer.iodine.
TNetwork
(id, nodes=None, reactions=None, compartments=None, parameters=None)[source]¶ Bases:
object
Represents an entire reaction network.
NOTE IMPORTANT whenever any change is made to the code that changes how the network is serialized/deserialized, one must bump the global variable SERIAL_VERSION to reflect that. See NetworkSchema::serialVersion for more information.
- Parameters
id (
str
) –nodes (
Optional
[Dict
[int
,TAbstractNode
]]) –reactions (
Optional
[Dict
[int
,TReaction
]]) –compartments (
Optional
[Dict
[int
,TCompartment
]]) –parameters (
Optional
[Dict
[str
,float
]]) –
-
addCompartment
(comp)[source]¶ - Parameters
comp (
TCompartment
) –- Return type
int
-
addNode
(node)[source]¶ - Parameters
node (
TAbstractNode
) –- Return type
int
-
baseNodes
: Set[int]¶ Set of node indices not in any compartment
-
compartments
: Dict[int, rkviewer.iodine.TCompartment]¶
-
destMap
: DefaultDict[int, MutableSet[int]]¶ Map nodes to reactions of which it is a target
-
id
: str¶
-
lastCompartmentIdx
: int¶
-
lastNodeIdx
: int¶
-
lastReactionIdx
: int¶
-
nodes
: Dict[int, rkviewer.iodine.TAbstractNode]¶
-
parameters
: Dict[str, float]¶
-
reactions
: Dict[int, rkviewer.iodine.TReaction]¶
-
srcMap
: DefaultDict[int, MutableSet[int]]¶ Map nodes to reactions of which it is a source
-
class
rkviewer.iodine.
TNode
(index: int, id: str, position: rkviewer.canvas.geometry.Vec2, rectSize: rkviewer.canvas.geometry.Vec2, floating: bool, nodeLocked: bool, compi: int = -1, shapei: int = 0, shape: rkviewer.canvas.data.CompositeShape = <factory>, concentration: float = 0.0, node_name: str = '', node_SBO: str = '')[source]¶ Bases:
rkviewer.iodine.TAbstractNode
- Parameters
index (
int
) –id (
str
) –position (
Vec2
) –rectSize (
Vec2
) –floating (
bool
) –nodeLocked (
bool
) –compi (
int
) –shapei (
int
) –shape (
CompositeShape
) –concentration (
float
) –node_name (
str
) –node_SBO (
str
) –
-
compi
: int = -1¶
-
concentration
: float = 0.0¶
-
floating
: bool¶
-
id
: str¶
-
index
: int¶
-
nodeLocked
: bool¶
-
node_SBO
: str = ''¶
-
node_name
: str = ''¶
-
position
: rkviewer.canvas.geometry.Vec2¶
-
rectSize
: rkviewer.canvas.geometry.Vec2¶
-
shapei
: int = 0¶
-
class
rkviewer.iodine.
TReaction
(id: str, centerPos: Union[rkviewer.canvas.geometry.Vec2, NoneType] = None, rateLaw: str = '', reactants: Dict[int, ForwardRef('TSpeciesNode')] = <factory>, products: Dict[int, ForwardRef('TSpeciesNode')] = <factory>, fillColor: rkviewer.config.Color = Color(r=255, g=150, b=80, a=255), thickness: float = 3.0, centerHandlePos: rkviewer.canvas.geometry.Vec2 = (0, 0), bezierCurves: bool = True, modifiers: Set[int] = <factory>, tipStyle: rkviewer.canvas.data.ModifierTipStyle = <ModifierTipStyle.CIRCLE: 'circle'>)[source]¶ Bases:
object
- Parameters
id (
str
) –centerPos (
Optional
[Vec2
]) –rateLaw (
str
) –reactants (
Dict
[int
,TSpeciesNode
]) –products (
Dict
[int
,TSpeciesNode
]) –fillColor (
Color
) –thickness (
float
) –centerHandlePos (
Vec2
) –bezierCurves (
bool
) –modifiers (
Set
[int
]) –tipStyle (
ModifierTipStyle
) –
-
bezierCurves
: bool = True¶
-
centerHandlePos
: rkviewer.canvas.geometry.Vec2 = (0, 0)¶
-
centerPos
: Optional[rkviewer.canvas.geometry.Vec2] = None¶
-
fillColor
: rkviewer.config.Color = Color(r=255, g=150, b=80, a=255)¶
-
id
: str¶
-
modifiers
: Set[int]¶
-
products
: Dict[int, rkviewer.iodine.TSpeciesNode]¶
-
rateLaw
: str = ''¶
-
reactants
: Dict[int, rkviewer.iodine.TSpeciesNode]¶
-
thickness
: float = 3.0¶
-
tipStyle
: rkviewer.canvas.data.ModifierTipStyle = 'circle'¶
-
class
rkviewer.iodine.
TSpeciesNode
(stoich: float, handlePos: rkviewer.canvas.geometry.Vec2 = 0, 0)[source]¶ Bases:
object
- Parameters
stoich (
float
) –handlePos (
Vec2
) –
-
handlePos
: rkviewer.canvas.geometry.Vec2 = (0, 0)¶
-
stoich
: float¶
-
class
rkviewer.iodine.
TStack
[source]¶ Bases:
object
-
items
: List[rkviewer.iodine.TNetworkDict]¶
-
push
(netDict)[source]¶ - Parameters
netDict (
TNetworkDict
) –
-
-
class
rkviewer.iodine.
TextSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
TransformSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
marshmallow.schema.Schema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
rkviewer.iodine.
TriangleSchema
(*, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)[source]¶ Bases:
rkviewer.iodine.PolygonSchema
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
rkviewer.iodine.
addAliasNode
(neti, originalIdx, x, y, w, h)[source]¶ - Parameters
neti (
int
) –originalIdx (
int
) –x (
float
) –y (
float
) –w (
float
) –h (
float
) –
- Return type
int
-
rkviewer.iodine.
addCompartment
(neti, compID, x, y, w, h)[source]¶ Create a compartment and add to canvas. Return the index of the compartment added.
- Parameters
neti (
int
) – network index.compID (
str
) – ID of the compartment.x (
float
) – x coordinate of top-left cornery (
float
) – y coordinate of top-left cornerw (
float
) – widthh (
float
) – height
- Return type
int
-
rkviewer.iodine.
addNode
(neti, nodeID, x, y, w, h, floatingNode=True, nodeLocked=False, nodeName='', nodeSBO='')[source]¶ AddNode adds a node to the network errCode - 3: id repeat, 0: ok -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodeID (
str
) –x (
float
) –y (
float
) –w (
float
) –h (
float
) –floatingNode (
bool
) –nodeLocked (
bool
) –nodeName (
str
) –nodeSBO (
str
) –
- Return type
int
-
rkviewer.iodine.
aliasForReaction
(neti, reai, nodei, x, y, w, h)[source]¶ Create an alias for nodei, and replace each instance of nodei in reai with the alias
- Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –x (
float
) –y (
float
) –w (
float
) –h (
float
) –
-
rkviewer.iodine.
clearNetwork
(neti)[source]¶ ClearNetwork clear all nodes and reactions in this network errCode: -5: net index out of range
- Parameters
neti (
int
) –
-
rkviewer.iodine.
clearReactions
(neti)[source]¶ clearReactions clear all reactions in this network errCode: -5: net index out of range
- Parameters
neti (
int
) –
-
rkviewer.iodine.
createReaction
(neti, reaID, sources, targets)[source]¶ createReaction create an empty reacton errCode: -3: id repeat -5: net index out of range
- Parameters
neti (
int
) –reaID (
str
) –sources (
List
[int
]) –targets (
List
[int
]) –
-
rkviewer.iodine.
createUniUni
(neti, reaID, rateLaw, srci, desti, srcStoich, destStoich)[source]¶ - Parameters
neti (
int
) –reaID (
str
) –rateLaw (
str
) –srci (
int
) –desti (
int
) –srcStoich (
float
) –destStoich (
float
) –
-
rkviewer.iodine.
deleteCompartment
(neti, compi)[source]¶ Delete the compartment of the given index in the given network.
- Parameters
neti (
int
) –compi (
int
) –
-
rkviewer.iodine.
deleteNetwork
(neti)[source]¶ DeleteNetwork DeleteNetwork errCode: -5: net index out of range
- Parameters
neti (
int
) –
-
rkviewer.iodine.
deleteNode
(neti, nodei)[source]¶ DeleteNode deletes the node with index. Returns whether there was a node with the given index, i.e. whether a node was deleted.
This does not throw an error due to the possibility of someone deleting nodes in a loop, in which case an original copy may be deleted before its alias, and so when the alias is reached, it no longer exists.
- Parameters
neti (
int
) –nodei (
int
) –
- Return type
bool
-
rkviewer.iodine.
deleteReaction
(neti, reai)[source]¶ deleteReaction delete the reaction with index errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
dumpNetwork
(neti)[source]¶ Dump the network into an object and return it.
- Parameters
neti (
int
) –
-
rkviewer.iodine.
endGroup
()[source]¶ EndGroup used at the end of a group operaction or secondary function.
-
rkviewer.iodine.
getCompartmentFillColor
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
-
rkviewer.iodine.
getCompartmentID
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
str
-
rkviewer.iodine.
getCompartmentOfNode
(neti, nodei)[source]¶ Return the compartment index that the given node is in, or -1 if it is not in any.
- Parameters
neti (
int
) –nodei (
int
) –
- Return type
int
-
rkviewer.iodine.
getCompartmentOutlineColor
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
-
rkviewer.iodine.
getCompartmentOutlineThickness
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
float
-
rkviewer.iodine.
getCompartmentPosition
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
Tuple
[float
,float
]
-
rkviewer.iodine.
getCompartmentSize
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
Tuple
[float
,float
]
-
rkviewer.iodine.
getCompartmentVolume
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
float
-
rkviewer.iodine.
getDestReactions
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
Set
[int
]
-
rkviewer.iodine.
getListOfCompartmentIndices
(neti)[source]¶ - Parameters
neti (
int
) –- Return type
Set
[int
]
-
rkviewer.iodine.
getListOfReactionDestNodes
(neti, reai)[source]¶ getListOfReactionDestNodes getListOfReactionDestNodes in alphabetical order return: non-empty slice : ok, -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
- Return type
List
[int
]
-
rkviewer.iodine.
getListOfReactionDestStoich
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
List
[float
]
-
rkviewer.iodine.
getListOfReactionIndices
(neti)[source]¶ - Parameters
neti (
int
) –- Return type
Set
[int
]
-
rkviewer.iodine.
getListOfReactionSrcNodes
(neti, reai)[source]¶ getListOfReactionSrcNodes getListOfReactionSrcNodes in alphabetical order return: non-empty slice : ok, -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
- Return type
List
[int
]
-
rkviewer.iodine.
getListOfReactionSrcStoich
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
List
[float
]
-
rkviewer.iodine.
getModifierTipStyle
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
-
rkviewer.iodine.
getNetworkID
(neti)[source]¶ GetNetworkID GetID of network errCode: -5: net index out of range
- Parameters
neti (
int
) –
-
rkviewer.iodine.
getNetworkIndex
(netID)[source]¶ return: -2: net id can’t find
- Parameters
netID (
str
) –- Return type
int
-
rkviewer.iodine.
getNodeBorderColor
(neti, nodei)[source]¶ getNodeBorderColor rgba tulple format, rgb range int[0,255] alpha range float[0,1] errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeBorderColorAlpha
(neti, nodei)[source]¶ getNodeBorderColorAlpha getNodeBorderColor alpha value(float) errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeBorderColorRGB
(neti, nodei)[source]¶ getNodeBorderColorRGB getNodeBorderColor rgb int format errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeBorderWidth
(neti, nodei)[source]¶ errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeCenter
(neti, nodei)[source]¶ GetNodeCenter Get the X and Y coordinate of the Center of node errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeConcentration
(neti, nodei)[source]¶ GetNodeConcentration - get the concentration of the node errcode:
-7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeCoordinateAndSize
(neti, nodei)[source]¶ getNodeCoordinateAndSize get the x,y,w,h of the node errCode:-7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeFillColor
(neti, nodei)[source]¶ Return the ‘fill_color’ property of the first primitive in the given node’s composite shape, if there is such a primitive. Otherwise, return None.
This function exists for backwards-compatibility and convenience reasons.
errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeFillColorAlpha
(neti, nodei)[source]¶ getNodeFillColorAlpha getNodeFillColor alpha value(float) errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeFillColorRGB
(neti, nodei)[source]¶ See getNodeFillColor(), except only returns the RGB values
errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeID
(neti, nodei)[source]¶ GetNodeID: Get the id of the node errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeIndex
(neti, nodeID)[source]¶ GetNodeIndex get node index by id errCode: -2: node id not found, -5: net index out of range return: >=0
- Parameters
neti (
int
) –nodeID (
str
) –
-
rkviewer.iodine.
getNodeName
(neti, nodei)[source]¶ GetNodeName: Get the name of the node errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeSBO
(neti, nodei)[source]¶ GetNodeSBO: Get the SBO of the node errCode: -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –nodei (
int
) –
-
rkviewer.iodine.
getNodeShape
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
-
rkviewer.iodine.
getNodeShapeIndex
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
int
-
rkviewer.iodine.
getNodesInCompartment
(neti, compi)[source]¶ Return the list of node indices in the given compartment.
- Parameters
neti (
int
) –compi (
int
) –
- Return type
List
[int
]
-
rkviewer.iodine.
getNumberOfDestNodes
(neti, reai)[source]¶ getNumberOfDestNodes get the DestNode length of Reaction return: non-negative int: ok, -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getNumberOfNodes
(neti)[source]¶ GetNumberOfNodes get the number of nodes in the current network num: >= -5: net index out of range
- Parameters
neti (
int
) –
-
rkviewer.iodine.
getNumberOfReactions
(neti)[source]¶ getNumberOfReactions get the number of reactions in the current Reactionset return: >=0: ok, -5: net index out of range
- Parameters
neti (
int
) –
-
rkviewer.iodine.
getNumberOfSrcNodes
(neti, reai)[source]¶ getNumberOfSrcNodes get the SrcNode length of Reaction return: non-negative int: ok, -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getOriginalIndex
(neti, nodei)[source]¶ Return -1 if the node is an original, or if this is an alias, return the original index.
- Parameters
neti (
int
) –nodei (
int
) –
- Return type
int
-
rkviewer.iodine.
getReactionCenterHandlePosition
(neti, reai)[source]¶ getReactionCenterHandlePosition getReactionCenterHandlePosition errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getReactionCenterPos
(neti, reai)[source]¶ getReactionCenterPos get the center position of the Reaction
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getReactionDestNodeHandlePosition
(neti, reai, destNodeIdx)[source]¶ getReactionDestNodeStoich get the DestNode HandlePosition of Reaction return: positive float : ok, -6: reaction index out of range, -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –destNodeIdx (
int
) –
-
rkviewer.iodine.
getReactionDestNodeStoich
(neti, reai, destNodeIdx)[source]¶ getReactionDestNodeStoich get the DestNode stoichiometry of Reaction return: positive float : ok, -6: reaction index out of range, -7: node index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –destNodeIdx (
int
) –
-
rkviewer.iodine.
getReactionFillColor
(neti, reai)[source]¶ getReactionFillColor rgba tulple format, rgb range int[0,255] alpha range float[0,1] errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getReactionFillColorAlpha
(neti, reai)[source]¶ getReactionFillColorAlpha getReactionFillColorAlpha errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getReactionFillColorRGB
(neti, reai)[source]¶ getReactionFillColorRGB getReactionFillColorRGB errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getReactionID
(neti, reai)[source]¶ getReactionID get the id of Reaction errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getReactionIndex
(neti, reaID)[source]¶ getReactionIndex get reaction index by id return: -2: id can’t find, >=0: ok -5: net index out of range
- Parameters
neti (
int
) –reaID (
str
) –
-
rkviewer.iodine.
getReactionLineThickness
(neti, reai)[source]¶ getReactionLineThickness getReactionLineThickness errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getReactionModifiers
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
Set
[int
]
-
rkviewer.iodine.
getReactionRateLaw
(neti, reai)[source]¶ getReactionRateLaw get the ratelaw of Reaction errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –
-
rkviewer.iodine.
getReactionSrcNodeHandlePosition
(neti, reai, srcNodeIdx)[source]¶ getReactionSrcNodeHandlePosition get the SrcNode HandlePosition of Reaction errCode: -6: reaction index out of range, -5: net index out of range, -7: node index out of range
- Parameters
neti (
int
) –reai (
int
) –srcNodeIdx (
int
) –
-
rkviewer.iodine.
getReactionSrcNodeStoich
(neti, reai, srcNodeIdx)[source]¶ getReactionSrcNodeStoich get the SrcNode stoichiometry of Reaction errCode: -6: reaction index out of range, -5: net index out of range, -7: node index not found
- Parameters
neti (
int
) –reai (
int
) –srcNodeIdx (
int
) –
-
rkviewer.iodine.
getSrcReactions
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
Set
[int
]
-
rkviewer.iodine.
loadNetwork
(net_object)[source]¶ Load the network object (laoded directly from JSON) and add it, returning the network index.
Note
For now this overwrites the network at index 0.
- Return type
int
-
rkviewer.iodine.
newNetwork
(netID)[source]¶ newNetwork Create a new network errCode -3: id repeat, 0 :ok
- Parameters
netID (
str
) –
-
rkviewer.iodine.
removeParameter
(netid, param_id)[source]¶ Remove a network parameter. No change if param_id is not a parameter.
- Parameters
netid (
int
) –param_id (
str
) –
-
rkviewer.iodine.
setCompartmentFillColor
(neti, compi, color)[source]¶ - Parameters
neti (
int
) –compi (
int
) –color (
Color
) –
-
rkviewer.iodine.
setCompartmentID
(neti, compi, id)[source]¶ - Parameters
neti (
int
) –compi (
int
) –id (
str
) –
-
rkviewer.iodine.
setCompartmentOfNode
(neti, nodei, compi)[source]¶ Set the compartment of the node, or remove it from any compartment if -1 is given.
- Parameters
neti (
int
) –nodei (
int
) –compi (
int
) –
-
rkviewer.iodine.
setCompartmentOutlineColor
(neti, compi, color)[source]¶ - Parameters
neti (
int
) –compi (
int
) –color (
Color
) –
-
rkviewer.iodine.
setCompartmentOutlineThickness
(neti, compi, thickness)[source]¶ - Parameters
neti (
int
) –compi (
int
) –thickness (
float
) –
-
rkviewer.iodine.
setCompartmentPosition
(neti, compi, x, y)[source]¶ - Parameters
neti (
int
) –compi (
int
) –x (
float
) –y (
float
) –
-
rkviewer.iodine.
setCompartmentSize
(neti, compi, w, h)[source]¶ - Parameters
neti (
int
) –compi (
int
) –w (
float
) –h (
float
) –
-
rkviewer.iodine.
setCompartmentVolume
(neti, compi, volume)[source]¶ - Parameters
neti (
int
) –compi (
int
) –volume (
float
) –
-
rkviewer.iodine.
setModifierTipStyle
(neti, reai, tipStyle)[source]¶ - Parameters
neti (
int
) –reai (
int
) –tipStyle (
ModifierTipStyle
) –
-
rkviewer.iodine.
setNodeBorderColorAlpha
(neti, nodei, a)[source]¶ setNodeBorderColorAlpha setNodeBorderColorAlpha, alpha is a float between 0 and 1 errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –a (
float
) –
-
rkviewer.iodine.
setNodeBorderColorRGB
(neti, nodei, r, g, b)[source]¶ setNodeBorderColorRGB setNodeBorderColorRGB errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –r (
int
) –g (
int
) –b (
int
) –
-
rkviewer.iodine.
setNodeBorderWidth
(neti, nodei, width)[source]¶ setNodeBorderWidth setNodeBorderWidth errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –width (
float
) –
-
rkviewer.iodine.
setNodeConcentration
(neti, nodei, newConc)[source]¶ setNodeConcentration - sets the concentration of a node errCode -5: net index out of range
-7: node index out of range -12: variable out of range
- Parameters
neti (
int
) –nodei (
int
) –newConc (
float
) –
-
rkviewer.iodine.
setNodeCoordinate
(neti, nodei, x, y, allowNegativeCoordinates=False)[source]¶ setNodeCoordinate setNodeCoordinate errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –x (
float
) –y (
float
) –allowNegativeCoordinates (
bool
) –
-
rkviewer.iodine.
setNodeFillColorAlpha
(neti, nodei, a)[source]¶ setNodeFillColorAlpha setNodeFillColorAlpha errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –a (
float
) –
-
rkviewer.iodine.
setNodeFillColorRGB
(neti, nodei, r, g, b)[source]¶ setNodeFillColorRGB setNodeFillColorRGB errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –r (
int
) –g (
int
) –b (
int
) –
-
rkviewer.iodine.
setNodeFloatingStatus
(neti, nodei, floatingStatus)[source]¶ setNodeFloatingStatus setNodeFloatingStatus errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –floatingStatus (
bool
) –
-
rkviewer.iodine.
setNodeID
(neti, nodei, newID)[source]¶ setNodeID set the id of a node errCode -3: id repeat -5: net index out of range -7: node index out of range
- Parameters
neti (
int
) –nodei (
int
) –newID (
str
) –
-
rkviewer.iodine.
setNodeLockedStatus
(neti, nodei, lockedNode)[source]¶ setNodeLockedStatus setNodeLockedStatus errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –lockedNode (
bool
) –
-
rkviewer.iodine.
setNodeName
(neti, nodei, newName)[source]¶ setNodeName set the name of a node -5: net index out of range -7: node index out of range
- Parameters
neti (
int
) –nodei (
int
) –newName (
str
) –
-
rkviewer.iodine.
setNodePrimitiveProperty
(neti, nodei, prim_index, prop_name, prop_value)[source]¶ Set an individual property of a node’s primitive.
- Parameters
neti (
int
) – The network indexnodei (
int
) – The node indexprim_index (
int
) – The index of the primitive, in the node’s shape. If -1, then update the text primitive instead.prop_name (
str
) – The name of the primitive’s property.prop_value (
Any
) – The value of the primitives’s property
-
rkviewer.iodine.
setNodeSBO
(neti, nodei, newSBO)[source]¶ setNodeSBO set the name of a node -5: net index out of range -7: node index out of range
- Parameters
neti (
int
) –nodei (
int
) –newSBO (
str
) –
-
rkviewer.iodine.
setNodeShapeIndex
(neti, nodei, shapei, preserve_common_fields=True)[source]¶ If preserve_common_fields is True, then preserve common field values such as fill_color, if applicable.
- Parameters
neti (
int
) –nodei (
int
) –shapei (
int
) –
-
rkviewer.iodine.
setNodeSize
(neti, nodei, w, h)[source]¶ setNodeSize setNodeSize errCode: -7: node index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –nodei (
int
) –w (
float
) –h (
float
) –
-
rkviewer.iodine.
setParameter
(netid, param_id, param_value)[source]¶ Add or change network parameter
- Parameters
netid (
int
) –param_id (
str
) –param_value (
float
) –
-
rkviewer.iodine.
setRateLaw
(neti, reai, rateLaw)[source]¶ setRateLaw edit rate law of reaction errCode: -6: reaction index out of range -5: net index out of range
- Parameters
neti (
int
) –reai (
int
) –rateLaw (
str
) –
-
rkviewer.iodine.
setReactionBezierCurves
(neti, reai, bezierCurves)[source]¶ setReactionBezierCurves setReactionBezierCurves errCode: -6: reaction index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –reai (
int
) –bezierCurves (
bool
) –
-
rkviewer.iodine.
setReactionCenterHandlePosition
(neti, reai, centerHandlePosX, centerHandlePosY)[source]¶ setReactionCenterHandlePosition setReactionCenterHandlePosition errCode: -6: reaction index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –reai (
int
) –centerHandlePosX (
float
) –centerHandlePosY (
float
) –
-
rkviewer.iodine.
setReactionCenterPos
(neti, reai, centerPos)[source]¶ setReactionCenterPos set the center position of the Reaction
- Parameters
neti (
int
) –reai (
int
) –centerPos (
Optional
[Vec2
]) –
-
rkviewer.iodine.
setReactionDestNodeHandlePosition
(neti, reai, destNodeIdx, handlePosX, handlePosY)[source]¶ setReactionDestNodeHandlePosition edit HandlePosition by Reaction destNodeID errCode: -6: reaction index out of range, -5: net index out of range, -2: id not found -12: Variable out of range
- Parameters
neti (
int
) –reai (
int
) –destNodeIdx (
int
) –handlePosX (
float
) –handlePosY (
float
) –
-
rkviewer.iodine.
setReactionDestNodeStoich
(neti, reai, destNodeIdx, newStoich)[source]¶ setReactionDestNodeStoich edit Stoich by Reaction destNodeID errCode: -6: reaction index out of range, -5: net index out of range, -7: node index not found, -8: wrong stoich raises ValueError if given node index not a dest node
- Parameters
neti (
int
) –reai (
int
) –destNodeIdx (
int
) –newStoich (
float
) –
-
rkviewer.iodine.
setReactionFillColorAlpha
(neti, reai, a)[source]¶ setReactionFillColorAlpha setReactionFillColorAlpha errCode: -6: reaction index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –reai (
int
) –a (
float
) –
-
rkviewer.iodine.
setReactionFillColorRGB
(neti, reai, R, G, B)[source]¶ setReactionFillColorRGB setReactionFillColorRGB errCode: -6: reaction index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –reai (
int
) –R (
int
) –G (
int
) –B (
int
) –
-
rkviewer.iodine.
setReactionID
(neti, reai, newID)[source]¶ setReactionID edit id of reaction errCode: 0:ok, -6: reaction index out of range -5: net index out of range -3: id repeat
- Parameters
neti (
int
) –reai (
int
) –newID (
str
) –
-
rkviewer.iodine.
setReactionLineThickness
(neti, reai, thickness)[source]¶ setReactionLineThickness setReactionLineThickness errCode: -6: reaction index out of range -5: net index out of range -12: Variable out of range
- Parameters
neti (
int
) –reai (
int
) –thickness (
float
) –
-
rkviewer.iodine.
setReactionModifiers
(neti, reai, modifiers)[source]¶ - Parameters
neti (
int
) –reai (
int
) –modifiers (
Set
[int
]) –
-
rkviewer.iodine.
setReactionSrcNodeHandlePosition
(neti, reai, srcNodeIdx, handlePosX, handlePosY)[source]¶ setReactionSrcNodeHandlePosition edit HandlePosition by Reaction srcNodeID errCode: -6: reaction index out of range, -5: net index out of range, -7: node index not found -12: Variable out of range
- Parameters
neti (
int
) –reai (
int
) –srcNodeIdx (
int
) –handlePosX (
float
) –handlePosY (
float
) –
-
rkviewer.iodine.
setReactionSrcNodeStoich
(neti, reai, srcNodeIdx, newStoich)[source]¶ setReactionSrcNodeStoich edit Stoich by Reaction srcNodeID errCode: -6: reaction index not found, -5: net index not found -7: node index not found, -8: wrong stoich raises ValueError if given node index not a dest node
- Parameters
neti (
int
) –reai (
int
) –srcNodeIdx (
int
) –newStoich (
float
) –
-
rkviewer.iodine.
startGroup
()[source]¶ StartGroup used at the start of a group operaction or secondary function.
-
rkviewer.iodine.
validateNodes
(nodes)[source]¶ - Parameters
nodes (
Dict
[int
,TAbstractNode
]) –
rkviewer.main module¶
rkviewer.mvc module¶
-
exception
rkviewer.mvc.
CompartmentIndexError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
exception
rkviewer.mvc.
FileError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
class
rkviewer.mvc.
IController
[source]¶ Bases:
abc.ABC
The inteface class for a controller
The abc.ABC (Abstract Base Class) is used to enforce the MVC interface more strictly.
The methods with name beginning with Try- are usually called by the RKView after some user input. If the action tried in such a method succeeds, the Controller should request the view to be redrawn; otherwise, an error message might be shown.
-
abstract
add_compartment_g
(neti, compartment)[source]¶ Try to add the given Compartment to the canvas. Return index of added comp.
- Parameters
neti (
int
) –compartment (
Compartment
) –
- Return type
int
-
abstract
add_node_g
(neti, node)[source]¶ Try to add the given Node to the canvas. Return index of the node added.
- Parameters
neti (
int
) –node (
Node
) –
- Return type
int
-
abstract
add_reaction_g
(neti, reaction)[source]¶ - Parameters
neti (
int
) –reaction (
Reaction
) –
- Return type
int
-
abstract
alias_for_reaction
(neti, reai, nodei, pos, size)[source]¶ See Iodine aliasForReaction for documentation
-
abstract
delete_compartment
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
bool
-
abstract
get_compartment_by_index
(neti, compi)[source]¶ - Parameters
neti (
int
) –compi (
int
) –
- Return type
-
abstract
get_compartment_of_node
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
int
-
abstract
get_composite_shape_at
(neti, shapei)[source]¶ - Parameters
neti (
int
) –shapei (
int
) –
- Return type
List
[CompositeShape
]
-
abstract
get_composite_shape_list
(neti)[source]¶ - Parameters
neti (
int
) –- Return type
List
[CompositeShape
]
-
abstract
get_dest_node_handle
(neti, reai, nodei)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –
- Return type
-
abstract
get_dest_node_stoich
(neti, reai, nodei)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –
- Return type
float
-
abstract
get_list_of_compartments
(neti)[source]¶ - Parameters
neti (
int
) –- Return type
List
[Compartment
]
-
abstract
get_list_of_dest_indices
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
List
[int
]
-
abstract
get_list_of_node_ids
(neti)[source]¶ Try getting the list of node IDs
- Parameters
neti (
int
) –- Return type
List
[str
]
-
abstract
get_list_of_src_indices
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
List
[int
]
-
abstract
get_modifier_tip_style
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
-
abstract
get_node_index
(neti, node_id)[source]¶ - Parameters
neti (
int
) –node_id (
str
) –
- Return type
int
-
abstract
get_node_shape_index
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
int
-
abstract
get_nodes_in_compartment
(neti, cmpi)[source]¶ - Parameters
neti (
int
) –cmpi (
int
) –
- Return type
List
[int
]
-
abstract
get_reaction_by_index
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
-
abstract
get_reaction_index
(neti, rxn_id)[source]¶ - Parameters
neti (
int
) –rxn_id (
str
) –
- Return type
int
-
abstract
get_reaction_modifiers
(neti, reai)[source]¶ - Parameters
neti (
int
) –reai (
int
) –
- Return type
List
[int
]
-
abstract
get_reactions_as_product
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
Set
[int
]
-
abstract
get_reactions_as_reactant
(neti, nodei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –
- Return type
Set
[int
]
-
abstract
get_src_node_handle
(neti, reai, nodei)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –
- Return type
-
abstract
get_src_node_stoich
(neti, reai, nodei)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –
- Return type
float
-
abstract
move_compartment
(neti, compi, pos)[source]¶ - Parameters
neti (
int
) –compi (
int
) –pos (
Vec2
) –
-
abstract
move_node
(neti, nodei, pos, allowNegativeCoords=False)[source]¶ Try to move the give node. TODO only accept node ID and new location
- Parameters
neti (
int
) –nodei (
int
) –pos (
Vec2
) –allowNegativeCoords (
bool
) –
- Return type
bool
-
abstract
new_network
()[source]¶ Create a new network.
Since there is only one tab for now, this merely clears the the current network. Also, does not clear undo stack.
-
abstract
rename_compartment
(neti, compi, new_id)[source]¶ - Parameters
neti (
int
) –compi (
int
) –new_id (
str
) –
-
abstract
rename_node
(neti, nodei, new_id)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –new_id (
str
) –
- Return type
bool
-
abstract
rename_reaction
(neti, reai, new_id)[source]¶ - Parameters
neti (
int
) –reai (
int
) –new_id (
str
) –
- Return type
bool
-
abstract
set_center_handle
(neti, reai, pos)[source]¶ - Parameters
neti (
int
) –reai (
int
) –pos (
Vec2
) –
-
abstract
set_compartment_border
(neti, compi, fill)[source]¶ - Parameters
neti (
int
) –compi (
int
) –fill (
Colour
) –
-
abstract
set_compartment_border_width
(neti, compi, width)[source]¶ - Parameters
neti (
int
) –compi (
int
) –width (
float
) –
-
abstract
set_compartment_fill
(neti, compi, fill)[source]¶ - Parameters
neti (
int
) –compi (
int
) –fill (
Colour
) –
-
abstract
set_compartment_of_node
(neti, nodei, compi)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –compi (
int
) –
-
abstract
set_compartment_size
(neti, compi, size)[source]¶ - Parameters
neti (
int
) –compi (
int
) –size (
Vec2
) –
-
abstract
set_compartment_volume
(neti, compi, volume)[source]¶ - Parameters
neti (
int
) –compi (
int
) –volume (
float
) –
-
abstract
set_dest_node_handle
(neti, reai, nodei, pos)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –pos (
Vec2
) –
-
abstract
set_dest_node_stoich
(neti, reai, nodei, stoich)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –stoich (
float
) –
- Return type
bool
-
abstract
set_modifier_tip_style
(neti, reai, style)[source]¶ - Parameters
neti (
int
) –reai (
int
) –style (
ModifierTipStyle
) –
-
abstract
set_node_border_alpha
(neti, nodei, alpha)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –alpha (
int
) –
- Return type
bool
-
abstract
set_node_border_rgb
(neti, nodei, color)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –color (
Colour
) –
- Return type
bool
-
abstract
set_node_border_width
(neti, nodei, width)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –width (
float
) –
- Return type
bool
-
abstract
set_node_fill_alpha
(neti, nodei, alpha)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –alpha (
int
) –
- Return type
bool
-
abstract
set_node_fill_rgb
(neti, nodei, color)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –color (
Colour
) –
- Return type
bool
-
abstract
set_node_floating_status
(neti, nodei, floatingStatus)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –floatingStatus (
bool
) –
-
abstract
set_node_locked_status
(neti, nodei, lockedNode)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –lockedNode (
bool
) –
-
abstract
set_node_primitive_property
(neti, nodei, primitive_index, prop_name, prop_value)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –primitive_index (
int
) –prop_name (
str
) –
-
abstract
set_node_shape_index
(neti, nodei, shapei)[source]¶ - Parameters
neti (
int
) –nodei (
int
) –shapei (
int
) –
-
abstract
set_node_size
(neti, nodei, size)[source]¶ Try to move the give node. TODO only accept node ID and new location
- Parameters
neti (
int
) –nodei (
int
) –size (
Vec2
) –
- Return type
bool
-
abstract
set_reaction_bezier_curves
(neti, reai, bezierCurves)[source]¶ - Parameters
neti (
int
) –reai (
int
) –bezierCurves (
bool
) –
- Return type
-
abstract
set_reaction_center
(neti, reai, center_pos)[source]¶ - Parameters
neti (
int
) –reai (
int
) –center_pos (
Optional
[Vec2
]) –
-
abstract
set_reaction_fill_alpha
(neti, reai, alpha)[source]¶ - Parameters
neti (
int
) –reai (
int
) –alpha (
int
) –
- Return type
bool
-
abstract
set_reaction_fill_rgb
(neti, reai, color)[source]¶ - Parameters
neti (
int
) –reai (
int
) –color (
Colour
) –
- Return type
bool
-
abstract
set_reaction_line_thickness
(neti, reai, thickness)[source]¶ - Parameters
neti (
int
) –reai (
int
) –thickness (
float
) –
- Return type
bool
-
abstract
set_reaction_modifiers
(neti, reai, modifiers)[source]¶ - Parameters
neti (
int
) –reai (
int
) –modifiers (
List
[int
]) –
-
abstract
set_reaction_ratelaw
(neti, reai, ratelaw)[source]¶ - Parameters
neti (
int
) –reai (
int
) –ratelaw (
str
) –
- Return type
bool
-
abstract
set_src_node_handle
(neti, reai, nodei, pos)[source]¶ - Parameters
neti (
int
) –reai (
int
) –nodei (
int
) –pos (
Vec2
) –
-
abstract
-
exception
rkviewer.mvc.
IDNotFoundError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
exception
rkviewer.mvc.
IDRepeatError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
class
rkviewer.mvc.
IView
[source]¶ Bases:
abc.ABC
The inteface class for a controller
The abc.ABC (Abstract Base Class) is used to enforce the MVC interface more strictly.
-
abstract
bind_controller
(controller)[source]¶ Bind the controller. This needs to be called after a controller is created and before any other method is called.
- Parameters
controller (
IController
) –
-
abstract
-
exception
rkviewer.mvc.
JSONError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
exception
rkviewer.mvc.
NetIndexError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
exception
rkviewer.mvc.
NodeIndexError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
exception
rkviewer.mvc.
NodeNotFreeError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
exception
rkviewer.mvc.
ReactionIndexError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
exception
rkviewer.mvc.
StackEmptyError
[source]¶ Bases:
rkviewer.mvc.ModelError
-
exception
rkviewer.mvc.
StoichError
[source]¶ Bases:
rkviewer.mvc.ModelError
rkviewer.plugin_manage module¶
Classes for managing plugins for Canvas.
Note: This file imports stuff from rkviewer.plugin.classes, but usually rkviewer.plugin imports from rkviewer. Beware of circular dependency.
-
class
rkviewer.plugin_manage.
PluginManager
(parent_window, controller)[source]¶ Bases:
object
- Parameters
parent_window (
Window
) –controller (
IController
) –
-
bind_error_callback
(callback)[source]¶ Bind a dialog callback for when there is an error.
If an error occurs before such a callback is bound, it is only logged.
-
callbacks
: Dict[rkviewer.plugin.classes.Plugin, Callable[], None]]¶
-
get_plugins_by_category
()[source]¶ Returns a dictionary that maps each category to the list of plugins.
Each plugin in the lists is a tuple (short_name, bitmap, callback). The
- Return type
Dict
[PluginCategory
,List
[Tuple
[str
,Callable
[[],None
],Optional
[Bitmap
]]]]
-
load_from
(load_dir)[source]¶ Load plugins from the given directory. Returns False if the dir does not exist.
- Parameters
load_dir (
str
) –- Return type
bool
-
make_command_callback
(command)[source]¶ - Parameters
command (
CommandPlugin
) –- Return type
Callable
[[],None
]
-
make_notify
(handler_name)[source]¶ Make event notification function for plugin.
handler_name should be the name of a method defined by Plugin. This would then create a callback function that goes over each plugin and call that function. This callback should be bound to its associated event.
The handler function is called with the event itself as argument.
- Parameters
handler_name (
str
) –
-
make_windowed_callback
(windowed, parent)[source]¶ - Parameters
windowed (
WindowedPlugin
) –parent (
Window
) –
- Return type
Callable
[[],None
]
-
plugins
: List[rkviewer.plugin.classes.Plugin]¶
- Parameters
menu (
Menu
) –
rkviewer.utils module¶
Utility functions
-
class
rkviewer.utils.
ButtonGroup
(callback)[source]¶ Bases:
object
Class for keeping track of a group of buttons, where exactly one of them can be selected.
-
Callback
¶ The callback function type called with ID of the selected button as argument.
- Parameters
callback (
Callable
[[str
],None
]) –
-
AddButton
(button, identifier)[source]¶ Add a button with the given identifier.
When this button is clicked, callback is called with the identifier.
- Parameters
button (
ToggleButton
) –identifier (
Any
) –
-
Callback
= typing.Callable[[str], NoneType]¶
-
-
rkviewer.utils.
convert_position
(fn)[source]¶ Decorator that converts the event position to one that is relative to the receiver.
-
rkviewer.utils.
even_round
(n)[source]¶ Round to the nearest even integer
- Parameters
n (
float
) –- Return type
int
-
rkviewer.utils.
gchain
(*iterables)[source]¶ - Parameters
iterables (
Iterable
[~T]) –- Return type
Iterable
[Tuple
[int
, ~T]]
-
rkviewer.utils.
get_local_path
(relative_path)[source]¶ Get path relative to the executable, or the working dir if not bundled.
-
rkviewer.utils.
no_rzeros
(num, precision)[source]¶ Returns string of the num with the given precision, but with trailing zeros removed.
- Parameters
num (
float
) –precision (
int
) –
- Return type
str
-
rkviewer.utils.
opacity_mul
(color, fraction)[source]¶ - Parameters
color (
Colour
) –fraction (
float
) –
- Return type
Colour
-
rkviewer.utils.
pairwise
(iterable)[source]¶ s -> (s0,s1), (s1,s2), (s2, s3), …
- Parameters
iterable (
Iterable
) –- Return type
Iterable
-
rkviewer.utils.
require_kwargs_on_init
(cls)[source]¶ Force a dataclass’s init function to only work if called with keyword arguments. If parameters are not positional-only, a TypeError is thrown with a helpful message. This function may only be used on dataclasses. This works by wrapping the __init__ function and dynamically replacing it. Therefore, stacktraces for calls to the new __init__ might look a bit strange. Fear not though, all is well. Note: although this may be used as a decorator, this is not advised as IDEs will no longer suggest parameters in the constructor. Instead, this is the recommended usage:
from dataclasses import dataclass @dataclass class Foo: bar: str require_kwargs_on_init(Foo)
- Parameters
cls (
Type
[~_T]) –- Return type
Type
[~_T]
-
rkviewer.utils.
resource_path
(relative_path)[source]¶ Get absolute path to resource, works for dev and PyInstaller.