iVis-at-Bilkent/sbgnviz.js

Name: sbgnviz.js

Owner: iVis-at-Bilkent

Description: A web based visualization tool for process description maps in SBGN

Created: 2015-03-18 22:03:25.0

Updated: 2017-11-15 13:56:01.0

Pushed: 2017-12-19 11:34:49.0

Homepage: http://www.cs.bilkent.edu.tr/~ivis/SBGNViz_sample_app/

Size: 21620

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

SBGNViz version 3

SBGNViz is a web application based on Cytoscape.js to visualize the pathway models represented by SBGN Process Description (PD) and Activity Flow (AF) Notation. It accepts the pathway models represented in SBGN-ML format.

Software

SBGNViz is distributed under GNU Lesser General Public License.

A sample application using SBGNViz can be found here. The sample application source codes are available here

Please cite the following when you use SBGNViz.js:

M. Sari, I. Bahceci, U. Dogrusoz, S.O. Sumer, B.A. Aksoy, O. Babur, E. Demir, “SBGNViz: a tool for visualization and complexity management of SBGN process description maps“, PLoS ONE, 10(6), e0128985, 2015.

Default Options
var options = {
  // The path of core library images when sbgnviz is required from npm and the index html 
  // file and node_modules are under the same folder then using the default value is fine
  imgPath: 'node_modules/sbgnviz/src/img',
  // Whether to fit labels to nodes
  fitLabelsToNodes: function () {
    return false;
  },
  // Whether to fit labels to a node's info boxes
  fitLabelsToInfoboxes: function () {
    return false;
  },
  // dynamic label size it may be 'small', 'regular', 'large'
  dynamicLabelSize: function () {
    return 'regular';
  },
  // Whether to infer parent node on load 
  inferNestingOnLoad: function () {
    return false;
  },
  // percentage used to calculate compound paddings
  compoundPadding: function () {
    return 10;
  },
  // The selector of the component containing the sbgn network
  networkContainerSelector: '#sbgn-network-container',
  // Whether the actions are undoable, requires cytoscape-undo-redo extension
  undoable: true
};
SBGNViz Specific Data
odes specific data.
.data('id'); // Id of a node. (Specific to cytoscape.js)
.data('label'); // Label of a node.
.data('parent'); // Parent id of a node. (Specific to cytoscape.js)
BGN specific class of a node. If it ends with 'multimer' it means that this node is a multimer.
.data('class');
.data('clonemarker'); // Whether the node is cloned.
.data('bbox'); // Bounding box of a node includes bbox.x, bbox.y, bbox.w, bbox.h
orts list of a node. A node port includes port.id, port.x, port.y where port.x and port.y are
ercentages relative to node position and size.
.data('ports');
.data('statesandinfos'); // a list of UnitOfInformation and StateVariable objects
n object containing 0 to 4 keys (top, bottom, left, right) pointing to AuxUnitLayout objects
.data('auxunitlayouts');

dges specific data.
.data('id'); // Id of an edge. (Specific to cytoscape.js)
.data('source'); // Id of source node. (Specific to cytoscape.js)
.data('target'); // Id of target node. (Specific to cytoscape.js)
.data('class'); // SBGN specific class of an edge.
.data('cardinality'); // SBGN cardinality of an edge.
he following is set if the edge is connected to its source node by a specific port of that node.
.data('portsource');
he following is set if the edge is connected to its target node by a specific port of that node.
.data('porttarget');
end point positions of an edge. Includes x and y coordinates. This data is to be passed to
dgeBendEditing extension.
.data('bendPointPositions');
API

sbgnviz.register(options) Register with libraries before creating instances

var instance = sbgnviz(options) Creates an extension instance with the given options

instance.getCy() Get the Cytoscape.js instance created for this Sbgnviz.js instance.

instance.expandNodes(nodes) Expand given nodes. Requires expandCollapse extension and considers undoable option.

instance.collapseNodes(nodes) Collapse given nodes. Requires expandCollapse extension and considers undoable option.

instance.expandComplexes() Expands the complex nodes in the graph recursively. Requires expandCollapse extension and considers undoable option.

instance.collapseComplexes() Collapses the complex nodes in the graph recursively. Requires expandCollapse extension and considers undoable option.

instance.collapseAll() Collapses all nodes in the graph recursively. Requires expandCollapse extension and considers undoable option.

instance.expandAll() Expands all nodes in the graph recursively. Requires expandCollapse extension and considers undoable option.

instance.hideNodesSmart(nodes) Extends the given nodes list in a smart way to leave the map intact and hides the resulting list. Requires viewUtilities extension and considers 'undoable' option.

instance.showNodesSmart(nodes) Extends the given nodes list in a smart way to leave the map intact. Then unhides the resulting list and hides others. Requires viewUtilities extension and considers 'undoable' option.

instance.showAll() Unhides all elements. Requires viewUtilities extension and considers 'undoable' option.

instance.deleteElesSimple(eles) Removes the given elements in a simple way. Considers 'undoable' option.

instance.deleteNodesSmart(nodes) Extends the given nodes list in a smart way to leave the map intact and removes the resulting list. Considers 'undoable' option.

instance.highlightSelected(eles) Highlights selected elements. Requires viewUtilities extension and considers 'undoable' option.

instance.highlightNeighbours(nodes) Highlights neighbours of the given nodes. Requires viewUtilities extension and considers 'undoable' option.

instance.highlightProcesses(nodes) Highlights processes of the given nodes. Requires viewUtilities extension and considers 'undoable' option.

instance.searchByLabel(label) Finds the elements whose label includes the given label and highlights processes of those elements. Requires viewUtilities extension and considers 'undoable' option.

instance.removeHighlights() Unhighlights any highlighted element. Requires viewUtilities extension and considers 'undoable' option.

instance.performLayout(layoutOptions, notUndoable) Performs layout by given layoutOptions. Considers 'undoable' option. However, by setting notUndoable parameter to a truthy value you can force an undable layout operation independant of 'undoable' option.

instance.createSbgnml() Creates an sbgnml file content from the exising graph and returns it.

instance.convertSbgnmlToJson(data) Converts given sbgnml data to a json object in a special format (http://js.cytoscape.org/#notation/elements-json) and returns it.

instance.getQtipContent(node) Create the qtip contents of the given node and returns it.

instance.updateGraph(cyGraph) Update the graph by given cyGraph parameter which is a json object including data of cytoscape elements in a special format (http://js.cytoscape.org/#notation/elements-json).

instance.calculatePaddings(paddingPercent) Calculates the paddings for compounds based on dimensions of simple nodes and a specific percentadge. As this percentadge takes the given paddingPercent or compoundPadding option.

instance.recalculatePaddings() Recalculates/refreshes the compound paddings. Aliases instance.refreshPaddings().

instance.saveAsPng(filename) Exports the current graph to a png file. The name of the file is determined by the filename parameter which is 'network.png' by default.

instance.saveAsJpg(filename) Exports the current graph to a jpg file. The name of the file is determined by the filename parameter which is 'network.jpg' by default.

instance.loadSample(filename, folderpath) Loads a sample file whose name and path of containing folder is given.

instance.loadSBGNMLFile(file[, callback]) Loads the given sbgnml file. Optionally apply a callback function upon loading. Callback accepts the file as an xml string as argument.

instance.loadSBGNMLText(textData) Loads a graph from the given text data in sbgnml format.

instance.saveAsSbgnml(filename) Exports the current graph to an sbgnml file with the given filename.

instance.enablePorts() Enable node ports.

instance.disablePorts() Disable node ports.

instance.arePortsEnabled() Get if node ports are enabled.

instance.setPortsOrdering(nodes, ordering, portDistance) Sets the ordering of the given nodes. Ordering options are 'L-to-R', 'R-to-L', 'T-to-B', 'B-to-T', 'none'. If a node does not have any port before the operation and it is supposed to have some after operation the portDistance parameter is used to set the distance between the node center and the ports. The default port distance is 70. Considers undoable option.

instance.startSpinner(classname) Starts a spinner at the middle of network container element. You can specify a css class that the spinner will have. The default classname is 'default-class'. Requires 'fontawesome.css'.

instance.endSpinner(classname) Ends any spinner having a css class with the given name. Requires 'fontawesome.css'.

instance.elementUtilities General and sbgn specific utilities for cytoscape elements. These are exposed for the users who builds an extension library of sbgnviz. Most users will not need to use this. It includes the followings.

instance.undoRedoActionFunctions Functions to be utilized in defining new actions for cytoscape.js-undo-redo extension. These are exposed for the users who builds an extension library of sbgnviz.

Classes

The following describes objects used by sbgnviz.js and accessible through sbgnviz.classes.

AuxiliaryUnit
eorinfobox.id;
eorinfobox.parent; // points to the cytoscape parent node
eorinfobox.clazz; // 'unit of information' or 'state variable'
eorinfobox.bbox; // includes bbox.x, bbox.y, bbox.w, bbox.h
StateVariable
eVariable.state; // includes state.value and state.variable
UnitOfInformation
OfInformation.label; // includes label.text
AuxUnitLayout
nstance variables
nitLayout.units // list of StateVariable or UnitOfInformation
nitLayout.location // top, bottom, left, right
nitLayout.parentNode // link to cytoscape parent node

nstance methods
dd an auxiliary unit to this layout, optionnally inserting it at a given position
nitLayout.addAuxUnit(unit [,position]);
emove an auxiliary unit from this layout
nitLayout.removeAuxUnit(unit);

lass variables
hose options can be defined for each instance individually. If no value is found for an
nstance, then the class' value is used.
nitLayout.outerMargin = 10;
nitLayout.unitGap = 5;
nitLayout.alwaysShowAuxUnits = false;
nitLayout.maxUnitDisplayed = 4;
EntityType StateVariableDefinition
Events

$(document).on('sbgnvizLoadSampleStart', function(event, filename, cy) { ... }); Triggered when a sample is being loaded. Aliases sbgnvizLoadSample.

$(document).on('sbgnvizLoadFileStart', function(event, filename, cy) { ... }); Triggered when an external sbgnml file is being loaded. Aliases sbgnvizLoadFile.

$(document).on('sbgnvizLoadSampleEnd', function(event, filename, cy) { ... }); Triggered when a sample is loaded

$(document).on('sbgnvizLoadFileEnd', function(event, filename, cy) { ... }); Triggered when an external sbgnml file is loaded

$(document).on('updateGraphStart', function(event, cy) { ... }); Triggered when the graph update is just started

$(document).on('updateGraphEnd', function(event, cy) { ... }); Triggered when the graph update is ended

Dependencies
Optional Dependencies

The following extensions are used by this library if they are registered.

Usage instructions

Download the library:

require() the library as appropriate for your project:

CommonJS:

sbgnviz = require('sbgnviz');
cytoscape = require('cytoscape-for-sbgnviz');
jQuery = require('jQuery');
filesaverjs = require('filesaverjs');

options = {


libs = {
cytoscape: cytoscape,
jQuery: jQuery,
filesaverjs: filesaverjs


viz( options, libs );

In plain JS you do not need to require the libraries you just need to register sbgnviz with the options.

Publishing instructions

This project is set up to automatically be published to npm. To publish:

  1. Set the version number environment variable: export VERSION=1.2.3
  2. Publish: gulp publish
Credits

Thanks to JetBrains for an Open Source License

Team
Alumni

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.