Is there a way to load a style through Cyrest

34 views
Skip to first unread message

Ruth Isserlin

unread,
Nov 7, 2016, 1:47:14 PM11/7/16
to cytoscape...@googlegroups.com
Hi, 
I have a defined style that I have exported from Cytoscape in xml format.  Is there a way to load this into a new cytoscae session through cyrest?  (I can see how to create a new style through cyrest but not how to create a style from a file. 
Thanks, 
Ruth 

Kei

unread,
Nov 10, 2016, 12:11:33 PM11/10/16
to cytoscape-helpdesk
Hi Ruth.

File import via CyREST is supported only for networks, but not for styles.
But it's a good point.  I'll add it to the new API TODO list.

Thanks,
Kei



2016年11月7日月曜日 10時47分14秒 UTC-8 risserlin:

katja...@gmail.com

unread,
Nov 7, 2017, 12:06:15 PM11/7/17
to cytoscape-helpdesk
Hi,

I, too, would like to be able to load a style file that I generated with cytoscape into my CyRest script as this would be much faster than generating the style from scratch within python. I saw that cytoscape allows to save the style in json format now. So, my hope is that you might have implemented now an option to load a style from a file?

Thanks.
Katja

David Otasek

unread,
Nov 7, 2017, 1:49:18 PM11/7/17
to cytoscape...@googlegroups.com
Hi Katja, you can define a style via CyREST via issuing a POST request to http://localhost:1234/v1/styles using a JSON message body.

I've attached a sample JSON file that can be applied to the galFiltered network included in Cytoscape's sample files. 

You can explore all the available styles via a GET request to /v1/styles, which returns a list of style names, and then GET /v1/styles/{name} which returns JSON like the attached for each style.

You can also check https://github.com/cytoscape/cytoscape-automation/tree/master/for-scripters to see if there is an R or Python library function that offers an in-language shortcut to achieve this.
 


--
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-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/49afaa9a-948c-4ba2-954c-681c35068c86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

style_example.json

Katja Luck

unread,
Nov 7, 2017, 3:03:22 PM11/7/17
to cytoscape...@googlegroups.com
Thanks, David. Unless I am not mistaken, I don't think you have answered my question which probably is because I haven't stated it well enough. Because it is quite painful to build that style dictionary manually in python to be posted then via CyREST, I thought, I can maybe upload a toy network to Cytoscape manually, and within Cytoscape, manually define the style as I need it, then save it in json format and then open it in my python script and post it via CyREST so that it is used for the many networks that I want to visualize.

Inspecting the json style file that I exported from cytoscape for the style that I have created myself, I realized that even though it is a dictionary, it contains other keywords and specifications, which is maybe why it is not applied to my networks as I am trying to make this working.

So, my question is, is there a way to define my custom style in cytoscape, manually, save it and then to reuse it from within CyREST? If so, how can I do this?

Sorry for not understanding.

Thanks!
Katja

You received this message because you are subscribed to a topic in the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-helpdesk/xObExcZ6uhY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpd...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
<style_example.json>

David Otasek

unread,
Nov 7, 2017, 3:23:13 PM11/7/17
to cytoscape...@googlegroups.com
Yes; within Cytoscape you can build your style under a new style name (for our example 'katja style')

Once you are happy, you can get the CyREST compatible JSON for that style using the following GET request:

http://localhost:1234/v1/styles/katya style

That JSON can be saved and applied programmatically through the methods I mentioned earlier.

Is this more what you had in mind?

To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsubscri...@googlegroups.com.


-- 
You received this message because you are subscribed to a topic in the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-helpdesk/xObExcZ6uhY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.

To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
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-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

Katja Luck

unread,
Nov 7, 2017, 3:41:58 PM11/7/17
to cytoscape...@googlegroups.com
yes, great! many thanks.

To unsubscribe from this group and all its topics, send an email to cytoscape-helpd...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages