cytoscape

Cytoscape - Set nodeCustomGraphicsSizeSync and nodeSizeLocked from CyREST


Is there a way to programatically set nodeCustomGraphicsSizeSync and nodeSizeLocked in Cytoscape with the CyRest api ?

They are usually set in the UI by the two checkboxes "Fit Custom Graphics to node" and "Lock node width and height" (see image).

options in cytoscape

I tried this, which does not work:

from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient()
my_style = cy.style.create('custom_theme', original_style=cy.style.get('default'))
net = cy.network.create(name='My Network', collection='My network collection')
my_style.update_defaults({
                          'NODE_SIZE':200, #works
                          'NODE_CUSTOMGRAPHICS_SIZE_1':80, #works,
                          'NODE_CUSTOMGRAPHICS_POSITION_1':'N,S,c,0.00,0.00', #works
                          'nodeCustomGraphicsSizeSync' : 'false', # does not work
                          'nodeSizeLocked' : 'false' # does not work
                           })
cy.style.apply(my_style, net)

I think it is because these are not VisualProperties but Visual Property Dependencies

I found this mention of a related issue, but no other references (the redmine seems down):

3245 Creating a copy of a VisualStyle--VisualPropertyDependencies not copied

from https://cytoscape.org/cy3_welcome_letter_v14.pdf

I'm using Cytoscape 3.7.2 and py2cytoscape.


Solution

  • There is a way in CyREST, but I'm not sure it's been made available through py2cytoscape. Basically, you need to update the dependencies, which is a different REST endpoint (/{name}/dependencies) and you want to use "enabled" rather than "true". You may want to see if there is an update_dependencies in py2cytoscape (I don't see one after a quick look at the docs). If not, add an issue in github: https://github.com/cytoscape/py2cytoscape