PathwayCommons / app-ui

Web UI for accessing Pathway Commons data
http://apps.pathwaycommons.org
MIT License
2 stars 15 forks source link

Creating Dummy Cytoscape Object #921

Closed MichaelWrana closed 6 years ago

MichaelWrana commented 6 years ago

Refs #861

Background Info

The general idea is to calculate the centrality values for all the nodes on the server rather than the client. In order to do that I need to create a dummy cytoscape network object and utilize eles.betweennessCentrality() : http://js.cytoscape.org/#eles.betweennessCentrality. This cytoscape object will only exist in the scope of some function and calculate centrality values for each node. The calculated values will then be passed to the client through the network JSON.

Actual Issue

I have no idea how to create a non-displayed network using the new CytoscapeService.

What I have tried: In server/graph-generation/interaction/index.js in the parse function, inserted the following (line 67-68) :

const cySrv = new CytoscapeService({headless:true,container:undefined,elements:network});
cySrv.mount();
const cy = cySrv.get();

Where network is an object that looks like: { edges: [ ... ] , nodes: [ ... ] }

This gives console error:

error:    TypeError: cy.expandCollapse is not a function
    at Object.bindEvents [as onMount] (/Users/michaelwrana/Documents/app-ui/src/client/common/cy/events/index.js:6:6)
    at CytoscapeService.mount (/Users/michaelwrana/Documents/app-ui/src/client/common/cy/index.js:78:13)
    at parse (/Users/michaelwrana/Documents/app-ui/src/server/graph-generation/interaction/index.js:76:11)
    at pc.query.then.res (/Users/michaelwrana/Documents/app-ui/src/server/graph-generation/interaction/index.js:38:17)
    at process._tickCallback (internal/process/next_tick.js:178:7)
maxkfranz commented 6 years ago

I have no idea how to create a non-displayed network using the new CytoscapeService.

The CytoscapeService is only needed for react components. On the server, just create a new Cytoscape() in the block where it's needed.

MichaelWrana commented 6 years ago

That seems to have worked. Thanks!