How to duplicate a network with CyRest API

537 views
Skip to first unread message

mbro...@gmail.com

unread,
Oct 7, 2016, 3:22:01 PM10/7/16
to cytoscape-helpdesk
I would like to create a duplicate network (including its node layout) within a session (so that nodes are at the same location, but colored with different styles later).
I wonder if there is a way to do that? If yes, ignore the question in the next paragraph.

Right now, my plan is to create a network twice (end up with two identical networks), then apply a layout to the first network, retrieve the first view from the first network (which contains position.x and position.y data) and try to create a new view on the second (so the second has the same coordinates).  So this leads to a test that I need to modify node coordinates.  I run POST to create a new view, position.x and position.y data are not used by the server in my test, all nodes in the view still have zero for their x and y.  Could you let me know if the current CyREST API ignores position.x and position.y during view creation, or this is a bug on my side?

Thanks!

Keiichiro Ono

unread,
Oct 7, 2016, 4:21:10 PM10/7/16
to cytoscape...@googlegroups.com
Hi.

If you just want to create duplicate networks from desktop, CTR+A and
then CTR+N. This creates duplicated network in the same collection.

If you want to do it programmatically via CyREST, you can use POST
method for a particular network. For example,

GET /v1/networks/1234

returns network JSON with SUID 1234 from Cytoscape, but if you use

POST /v1/networks/1234

This creates a new networks from selected nodes and edges in the
network 1234. So, in your case, you just need to select all and then
use this POST method.

Kei
> --
> You received this message because you are subscribed to the Google Groups
> "cytoscape-helpdesk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cytoscape-helpd...@googlegroups.com.
> To post to this group, send email to cytoscape...@googlegroups.com.
> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
> For more options, visit https://groups.google.com/d/optout.



--
===================================

Keiichiro Ono
http://keiono.github.io/

===================================

mbro...@gmail.com

unread,
Oct 7, 2016, 4:40:14 PM10/7/16
to cytoscape-helpdesk
Thank for the quick reply.  First, I need to do this programmatically.  Second, I had tried what you suggested, yes, I can duplicate the network (nodes and edges), but the issue is all nodes are located in the center of the view, having x=y=0 in the new network view, but I need to clone the node coordinates as well.

Thanks! 

    cc=CyRestClient(ip="localhost", port="1234")
    first_net_id=cc.network.get_all()[0]
    first_net=cc.network.create(suid=first_net_id)
    print cc.network.create(suid=None,data= first_net.to_json())
    exit()
 
Reply all
Reply to author
Forward
0 new messages