CytoViewer#

class biopax-explorer.graph.view.CytoViewer(graph, gtype='NX')[source]#

Bases: object

A wrapper for the cytoscape.js jupyter widget.

Methods

addStyle(cstyle)

Adds additional style to the final style settings.

defineEdgeLabel([attlist, separator, attName])

Defines the label attribute for edges.

defineEdgeLabelImpl()

Defines the label attribute for edges based on defined attributes and separator.

defineNodeLabel([attlist, separator, attName])

Defines the label attribute for nodes.

defineNodeLabelImpl()

Defines the label attribute for nodes based on defined attributes and separator.

defineShapes()

Defines the possible shapes for node representation.

defineViewer()

Defines the viewer for displaying the graph.

define_default_style(nodeLabel, edgeLabel)

Defines the default style settings for nodes and edges.

display([nodeLabel, edgeLabel])

Displays the graph with specified node and edge labels.

from_graphtool(g)

Converts a graph-tool graph to a CytoViewer graph.

from_json(data)

Loads graph data from JSON format.

from_networkx(g)

Converts a NetworkX graph to a CytoViewer graph.

generate_node_selector()

Generates node selector styles based on defined color schemes.

generate_web_colors(start_color, end_color, ...)

Generates a list of web colors between two specified colors.

initStyle(nodeLabel, edgeLabel)

Initializes the style settings for the graph nodes and edges.

initViewFromGraph()

Initializes the viewer from the provided graph.

layout(layoutname)

Sets the layout for graph visualization.

nodeSelector(attribute_key, attribute_value)

Selects nodes in the graph based on the specified attribute key and value, and applies a custom style to them.

select_list_alternatively(a, b, c, d, e, x)

Selects a list from the provided lists alternately based on the value of x.

style(cstyle)

Sets the final style settings.

tooltip(tooltip)

Sets the tooltip source for graph elements.

gf2nx

Methods Summary

addStyle(cstyle)

Adds additional style to the final style settings.

defineEdgeLabel([attlist, separator, attName])

Defines the label attribute for edges.

defineEdgeLabelImpl()

Defines the label attribute for edges based on defined attributes and separator.

defineNodeLabel([attlist, separator, attName])

Defines the label attribute for nodes.

defineNodeLabelImpl()

Defines the label attribute for nodes based on defined attributes and separator.

defineShapes()

Defines the possible shapes for node representation.

defineViewer()

Defines the viewer for displaying the graph.

define_default_style(nodeLabel, edgeLabel)

Defines the default style settings for nodes and edges.

display([nodeLabel, edgeLabel])

Displays the graph with specified node and edge labels.

from_graphtool(g)

Converts a graph-tool graph to a CytoViewer graph.

from_json(data)

Loads graph data from JSON format.

from_networkx(g)

Converts a NetworkX graph to a CytoViewer graph.

generate_node_selector()

Generates node selector styles based on defined color schemes.

generate_web_colors(start_color, end_color, ...)

Generates a list of web colors between two specified colors.

gf2nx(g)

initStyle(nodeLabel, edgeLabel)

Initializes the style settings for the graph nodes and edges.

initViewFromGraph()

Initializes the viewer from the provided graph.

layout(layoutname)

Sets the layout for graph visualization.

nodeSelector(attribute_key, attribute_value)

Selects nodes in the graph based on the specified attribute key and value, and applies a custom style to them.

select_list_alternatively(a, b, c, d, e, x)

Selects a list from the provided lists alternately based on the value of x.

style(cstyle)

Sets the final style settings.

tooltip(tooltip)

Sets the tooltip source for graph elements.

Methods Documentation

addStyle(cstyle)[source]#

Adds additional style to the final style settings.

Args:

cstyle (list): List of dictionaries representing additional style settings.

Returns:

None

defineEdgeLabel(attlist=['name'], separator=' ', attName='elabel')[source]#

Defines the label attribute for edges.

Args:

attlist (list): List of edge attributes to include in the label. separator (str): Separator to use between attribute values. attName (str): Name of the label attribute.

Returns:

None

defineEdgeLabelImpl()[source]#

Defines the label attribute for edges based on defined attributes and separator.

Returns:

None

defineNodeLabel(attlist=['name'], separator=' ', attName='nlabel')[source]#

Defines the label attribute for nodes.

Args:

attlist (list): List of node attributes to include in the label. separator (str): Separator to use between attribute values. attName (str): Name of the label attribute.

Returns:

None

defineNodeLabelImpl()[source]#

Defines the label attribute for nodes based on defined attributes and separator.

Returns:

None

defineShapes()[source]#

Defines the possible shapes for node representation.

Returns:

list: List of strings representing node shapes.

defineViewer()[source]#

Defines the viewer for displaying the graph.

Returns:

cyto.CytoscapeWidget: The cytoscape.js widget for graph visualization.

define_default_style(nodeLabel, edgeLabel)[source]#

Defines the default style settings for nodes and edges.

Args:

nodeLabel (str): The label attribute for nodes. edgeLabel (str): The label attribute for edges.

Returns:

list: List of dictionaries representing default style settings.

display(nodeLabel='nlabel', edgeLabel='elabel')[source]#

Displays the graph with specified node and edge labels.

Args:

nodeLabel (str): Label attribute for nodes. edgeLabel (str): Label attribute for edges.

Returns:

cyto.CytoscapeWidget: The cytoscape.js widget displaying the graph.

from_graphtool(g)[source]#

Converts a graph-tool graph to a CytoViewer graph.

Args:

graph (Graph): The input graph-tool graph.

Returns:

cyto.CytoscapeWidget: The CytoViewer graph.

from_json(data)[source]#

Loads graph data from JSON format.

Args:

data (str): JSON data representing the graph.

Returns:

None

from_networkx(g)[source]#

Converts a NetworkX graph to a CytoViewer graph.

Args:

graph (nx.Graph): The input NetworkX graph.

Returns:

cyto.CytoscapeWidget: The CytoViewer graph.

generate_node_selector()[source]#

Generates node selector styles based on defined color schemes.

Returns:

list: List of dictionaries representing node selector styles.

generate_web_colors(start_color, end_color, num_colors)[source]#

Generates a list of web colors between two specified colors.

Args:

start_color (str): The starting color. end_color (str): The ending color. steps (int): The number of steps.

Returns:

List[str]: A list of web colors.

gf2nx(g)[source]#
initStyle(nodeLabel, edgeLabel)[source]#

Initializes the style settings for the graph nodes and edges.

Args:

nodeLabel (str): The label attribute for nodes. edgeLabel (str): The label attribute for edges.

initViewFromGraph()[source]#

Initializes the viewer from the provided graph.

layout(layoutname)[source]#

Sets the layout for graph visualization.

Args:

layoutname (str): Name of the layout.

Returns:

None

nodeSelector(attribute_key, attribute_value, operator='IN', color='red')[source]#

Selects nodes in the graph based on the specified attribute key and value, and applies a custom style to them.

Args:

attribute_key (str): The key of the attribute to filter nodes by. attribute_value (str): The value of the attribute to filter nodes by. operator (str, optional): The comparison operator to use for filtering.

Defaults to “IN”. Can be “IN” for “inclusion” or “EQ” for “equality”.

color (str, optional): The color to apply to the selected nodes. Defaults to “red”.

Returns:

list: A list of custom styles applied to the selected nodes.

select_list_alternatively(a, b, c, d, e, x)[source]#

Selects a list from the provided lists alternately based on the value of x.

Args:

a, b, c, d, e (list): Lists to select from. x (int): Value used for selection.

Returns:

list: The selected list.

style(cstyle)[source]#

Sets the final style settings.

Args:

cstyle (list): List of dictionaries representing final style settings.

Returns:

None

tooltip(tooltip)[source]#

Sets the tooltip source for graph elements.

Args:

tooltip (str): Tooltip source.

Returns:

None