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)

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;

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.

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-[] (default: default output size), or set by the users with a list containing two elements indicating the size of the image [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; or ‘ellipsis’ will show ‘….’ if the text is too long to fit the node.

Examples:

sd.draw()

sd.draw(output_fileName = ‘output.pdf’)

sd.draw(setImageSize = [1000, 1000], output_fileName = ‘output.png’)

sd.draw(scale = 2., output_fileName = ‘output.jpg’)

sd.draw(output_fileName = ‘output.png’, reactionLineType = ‘straight’, longText = ‘ellipsis’)

sd.draw(output_fileName = ‘output.png’, reactionLineType = ‘bezier’, showBezierHandles = True, showReactionIds = True, showReversible = True)

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)

This method returns the current model as an SBML string.

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.

SBMLDiagrams.load.exportGraphML(self, output_fileName='output')

Export an output file in the basic GraphML format.

Args:

output_fileName: str - the exported GraphML file name (default: ‘output’).

Returns:

GraphML file.