I participated in Google Summer of Code this year under National Resource for Network Biology. This is a complete report of the work done by me during this period. My Project was on GraphSpace and Cytoscape.
CyGraphSpace: Cytoscape app to sync graphs between GraphSpace and Cytoscape
The main goal of the project was to create a Cytoscape app called CyGraphSpace for syncing networks from Cytoscape to GraphSpace and vice-versa.
Before CyGraphSpace, Cytoscape and GraphSpace users needed to sync the graphs manually. The aim behind the app was to remove this inefficiency and make sharing of graphs among researchers effortless.
To enable the connection between the CyGraphSpace app and GraphSpace, I was also required to create a restful client written in Java to interface with GraphSpace REST APIs. This library is named GraphSpaceJavaClient.
Initially, I created the javaclient following the structure of graphspace-python. This structure was a little ugly for the Java library but it helped me to have something quickly as my main focus initially was CyGraphSpace app.
I finished a rudimentary version of the java client in the first 3-4 days and started working on the UI for the app. The java client was filled with bugs and I fixed them along the way as I used them in the CyGraphSpace app. Later, I started writing unit tests to test the methods.
After that I worked mostly on CyGraphSpace app until the last two weeks with the same poorly designed Java Client library. Then my mentor(Aditya) and I discussed about possible structure to use for the library.
We decided to go with the structure followed by Jira Client on Aditya’s suggestion. The current version of GraphSpace client follows this structure.
This structure is much cleaner as it encapsulates each GraphSpace entity into a class which further extends a common base class. This is possible since GraphSpace has common attributes for each supported entities and all the responses are again encapsulated using a common class. This makes the overall code much more DRY.
CyGraphSpace app has also been updated to use this version of GraphSpaceClient
I had a broad idea of the functioanlity and structure of the app as we had planned to have an app similar to CyNDEX. So, I created a UI along the lines of CyNDEx using Swing Components in the first week.
Then in the next I worked on implementing getting graph meta data from GraphSpace to show the list of available graphs to the user.
After that, my progress was stalled for almost 2 weeks as I could not figure out how to create a network inside Cytoscape from the imported graph from GraphSpace. As it turns out, the solution was a 1 line code. Cytoscape already provided the API to create the network from a graph with a cyjs format as we suspected but I overlooked it in the documentation and wasted a lot of time trying random solutions.
This taught me a huge lesson that I should have asked for help sooner as it is easy to make silly mistakes and overlook trivial things and had I done that, I would have saved a lot of time.
Anyways, the problem was solved just in time for the first evaluation. Then we had a discussion about making changes to the UI as the current UI made the app look foreign to Cytoscape and we wanted to provide a more native feel to the user. I spent the next week experimenting with different placements of the menus(as suggested by the mentors) inside Cytoscape.
Finally we decided to go with a structure similar to the app WikiPathways. This had a much more native feel and the app feels like a part of Cytoscape instead of a third party extension.
In the next week, I completed most of the basic functionlities of CyGraphSpace app. This includes importing, exporting and updating graphs; implementing search functioanlity based on names and tags; exporting style.json; adding pagination for results; adding functioanlity to share graphs and add tags to graphs before exporting, etc.
The next week was spent majorly on fixing bugs.
Cytoscape supports exporting style.json but does not importing the style json format. It however, supports importing XML and props formats. Hence, I needed to write it from scratch.
Now, there were two approaches possible. First approach is to convert the style json imported from GraphSpace into the XML format supported by Cytoscape. However, there are a lot of issues with this approach as there seems to be a lot of discrepencies in how these formats save the layout attributes and there is no reliable way to do the conversion since not just the name but also the meaning of the style attributes change for the two formats and there is no documentation for mapping between these formats.
The next approach is to parse the style json file and add visual properties to each graph’s node and edge iteratively. The problem with this approach is that there are a lot of discrepencies between visual properties supported by Cytoscape desktop app and cytoscape.js. Even for the values supported by both, there are numerous cases of differences in types of values accepted for the attributes.
Still, we have decided to use the second approach despite the problems. However, this will require writing extensive boilerplate code for sanity checks and format conversions. Also, before releasing this functioanlity, rigorous testing needs to be done to handle all the edge cases. Hence, the mentors decided to leave it out of GSOC evaluation.
This issue will be more extensively documented on the website and a sub-optimal solution is currently in works in a separate branch.
The project website was created to establish a single source for all CyGraphSpace and GraphSpaceJavaClient related information. The website currently contains the documentation and tutorials to help users get started.
To use the CyGraphSpace app, you first need to install the app. Follow the instructions here.
After you’ve installed the app, you’ll see the CyGraphSpace icon on the Cytoscape Toolbar.
You’ll find the option to import the network under
Before you can use CyGraphSpace, you’ll need to create a GraphSpace account. If you already have an account on GraphSpace, you can skip this step.
Go to www.graphspace.org and click on Create Account.
Then, login to the account.
Now, go to Cytoscape and create a new network. Then click on CyGraphSpace icon to export the network. You’ll first need to login to GraphSpace.
Then, you’ll be asked for confirmation before uploading. Check if the username and graph’s name are correct.
Now, you’ll be able to view the uploaded graph on GraphSpace.
Now, you can try to import this graph to Cytoscape. Go to the Import Graph menu and login to GraphSpace.
Then, click on Import to Cytoscape to import the network.
To view the graph in the browser instead click on Open in GraphSpace.
You can also search the available graphs on GraphSpace.
Below is the video of the tutorial explaning all the features available to you with CyGraphSpace.
1. Style Import
As pointed out above, because of the various problems in implementing a reliable solution for this feature, this functionality is not yet released with the stable version of the app.
This is in works in a separate branch and might be available in future releases.
2. Sharing Graph and adding tags
Sharing graph and adding tags was previously implemented but later removed because the mentor didn’t like the UI and a better UI needs to be thought of for this functionality.
3. User authentication persistent across sessions
There is a trivial method to store user’s data persistently across sessions as listed here. However, this doesn’t seem to work as the values reset in the next session.
A probable reason is that there is a bug in the current version of Cytoscape since the sample app provided by Cytoscape to showcase this functionality also faces similar problem.
They have guided me along the way and helped me with various problems whenever I got stuck. Special thanks to Aditya for spending so many hours working with me trying to resolve several issues I was facing and keeping me on track throughout the coding period.
Apart from the mentors, I’d also like to acknowledge several projects which helped in implementing CyGraphSpace app and GraphSpaceJavaClient.
CyNDEx: A lot of ideas have been taken from CyNDEx’s cytoscape app. I also used CyNDEx code to learn about most of the Cytoscape’s APIs initially.
WikiPathways: WikiPathways app gave the inspiration for the UI used by CyGraphSpace currently.
graphspace-python: GraphSpaceJavaClient was written using graphspace-python as a template.
Jira Client: The inspiration for GraphSpaceJavaClient’s structure was taken from Jira Client library.