Network¶
-
SBMLDiagrams.
load
(sbmlstr)¶ Load SBML string for further processing, i.e. read, edit, visualize the SBML string or export it as an updated SBML string.
- Args:
sbmlstr: str-the SBML string.
-
SBMLDiagrams.load.
hasLayout
(self)¶ Returns True if the current SBML model has layout/redner information.
- Returns:
flag: bool-true (there is layout) or false (there is no layout).
-
SBMLDiagrams.load.
autolayout
(self, layout='spring', scale=200.0, k=1.0, iterations=100, graphvizProgram='dot')¶ Autolayout the node positions using networkX library.
layout: str-the layout name from networkX, which can be one of the following:
spring (default): positioning nodes using Fruchterman-Reingold force-directed algorithm;
spectral: positioning the nodes using the eigenvectors of the graph Laplacian;
random: positioning nodes randomly;
circular: positioning nodes on a circle;
graphviz: positioning the nodes using Graphiz.
scale (applies to “spring”, “spectral”, “circular”): float-Scale factor for positions. The nodes are positioned in a box of size scale in each dim centered at center.
k (applies to “spring”): float-Optimal distance between nodes. Increase this value to move nodes farther apart.
iterations (applies to “spring”): int-maximum number of iterations to use during the calculation.
graphvizProgram (applies to “graphviz”): str-name of Graphviz layout program.
dot (default): “hierarchical” or layered drawings of directed graphs. This is the default tool to use if edges have directionality.
neato: “spring model’’ layouts. This is the default tool to use if the graph is not too large (about 100 nodes) and you don’t know anything else about it. Neato attempts to minimize a global energy function, which is equivalent to statistical multi-dimensional scaling.
fdp: “spring model’’ layouts similar to those of neato, but does this by reducing forces rather than working with energy.
sfdp: multiscale version of fdp for the layout of large graphs.
twopi: radial layouts, after Graham Wills 97. Nodes are placed on concentric circles depending their distance from a given root node.
circo: circular layout, after Six and Tollis 99, Kauffman and Wiese 02. This is suitable for certain diagrams of multiple cyclic structures, such as certain telecommunications networks.
-
SBMLDiagrams.load.
draw
(self, setImageSize='', scale=1.0, output_fileName='', reactionLineType='bezier', showBezierHandles=False, showReactionIds=False, showReversible=False, longText='auto-font')¶ Draw to a PNG/JPG/PDF file.
- Args:
setImageSize: list-containing two elements indicating the size of the image (if bitmap) [width, height].
scale: float-determines the figure output size = scale * default output size. Increasing the scale will make the resolution higher.
output_fileName: str-filename: ‘’ (default: will not save the file), or eg ‘fileName.png’. Allowable extensions include ‘.png’, ‘.jpg’, or ‘pdf’.
reactionLineType: str-type of the reaction line: ‘straight’ or ‘bezier’ (default). If there is no layout information from the SBML file, all reaction lines will look like straight lines even when using ‘bezier’ curves.
showBezierHandles: bool-show the Bezier handles (True) or not (False as default).
showReactionIds: bool-show the reaction ids (True) or not (False as default).
showReversible: bool-show whether the reaction is reversible (True) or not (False as default).
longText: str-‘auto-font’(default) will automatically decrease the font size to fit the current dimensions of the node; ‘ellipsis’ will show ‘….’ if the text is too long to fit the node.
-
SBMLDiagrams.load.
getNetworkTopLeftCorner
(self)¶ Returns the top left-hand corner of the network from the SBML string.
- Returns:
position: a Point object with attributes x and y representing the x/y position of the top-left hand corner of the network.
- Examples:
p = sd.getNetworkTopLeftConer()
print(p.x, p.y)
-
SBMLDiagrams.load.
getNetworkBottomRightCorner
(self)¶ Returns the bottom right-hand corner of the network from the SBML string.
- Returns:
position: a Point object with attributes x and y representing the x/y position of the bottom-right hand corner of the network.
- Examples:
p = sd.getNetworkBottomRightConer()
print(p.x, p.y)
-
SBMLDiagrams.load.
getNetworkSize
(self)¶ Returns the size of the network.
- Returns:
size: a Point object with attributes x and y representing the width and height of the network.
- Examples:
p = sd.getNetworkSize()
print (‘Width = ‘, p.x, ‘Height = ‘, p.y)
-
SBMLDiagrams.load.
export
(self)¶ Generates an SBML string for the current model.
- Returns:
SBMLStr_layout_render: str-the string of the output sbml file.
-
SBMLDiagrams.load.
getColorStyle
(self)¶ Returns an object representing the current color style.
- Returns:
The current color style.
- Examples:
la.getColorStyle().getStyleName()
-
SBMLDiagrams.load.
getColorStyleJson
(self, filename=None)¶ Get the current color style in json format and save to a json file if need be.
- Returns:
The current color style. in json format
-
SBMLDiagrams.load.
setColorStyle
(self, style)¶ Set the color style.
- Args:
style: can be either the “default” string or a new color class
-
SBMLDiagrams.
animate
(start, end, points, r, thick_changing_rate, sbmlStr=None, frame_per_second=10, show_digit=True, bar_dimension=10, 50, numDigit=4, folderName='animation', outputName='output', horizontal_offset=15, vertical_offset=9, text_color=0, 0, 0, 200, savePngs=False, showImage=False, user_reaction_line_color=None)¶ Animate to an mp4 file.
- Args:
start: start point for the simulation.
end: end point for the simulation.
points: total points for the simulation.
r: tellurium loada object.
thick_changing_rate: thickness for the arrow, smaller means thinner.
sbmlStr: sbml layout information if any.
frame_per_second: number of frames per second of the ouput video.
show_digit: if show digits.
bar_dimension: width and height of the bar.
numDigit: number of digits displayed.
folderName: output folder name.
outputName: ouput video name.
horizontal_offset: horizontal_offset of the bar from the node.
vertical_offset: vertical offset of text from the node.
text_color: color for the text.
savePngs: if save all the pngs used for video generation.
showImage: if display all the generated pngs in console.
user_reaction_line_color: user defined reaction line color.
-
SBMLDiagrams.
loadColorStyle
(filename)¶ Load the color style information from a JSON file. Note that the color style named default couldn’t be changed.
- Args:
filename: str-input json file name. Refer to the example in “Tutorial”.
- Returns:
res: dictionary with the key of style name and the value with its corresponding style object.