I just installed the cytoscapeRPC plug in so that i can write a python
code for automating the process of loading files into Cytoscape and
saving the generated output.I found the following code in one of the
earlier discussions:
https://trac.nbic.nl/brs2011p07/browser/trunk/brs2011p07/src/piqc/dat...
I would like to know the path as to where the code should be saved for
compiling.I am using cytoscape2.8.3 version(installed on ubuntu12.04)
which is stored in my desktop.I tried by saving the code in cytoscape
dir as well as in documents dir.(pasted the code given in above link
in gedit and tried compiling using terminal)But none worked.
You can store the python code anywhere you want, preferably outside the Cytoscape install folder. It's not tied to Cytoscape in anyway: It merely talks to the XMLRPC server that you can enable from the CytoscapeRPC plugin. To run the code just type `python data2network.py` in your favorite terminal.
On Tuesday, June 19, 2012 8:21:57 AM UTC+2, sanjan wrote:
> Hi,
> I just installed the cytoscapeRPC plug in so that i can write a python > code for automating the process of loading files into Cytoscape and > saving the generated output.I found the following code in one of the > earlier discussions:
> I would like to know the path as to where the code should be saved for > compiling.I am using cytoscape2.8.3 version(installed on ubuntu12.04) > which is stored in my desktop.I tried by saving the code in cytoscape > dir as well as in documents dir.(pasted the code given in above link > in gedit and tried compiling using terminal)But none worked.
Actually i tried compiling the code and got the following error message:
Traceback (most recent call last):
File "data2net.py", line 8, in <module>
from __init__ import connect2cytoscape
ImportError: cannot import name connect2cytoscape
Actually I could not figure out as to where to mention the input file
name(its gedit text file having two columns separated by tab-former being
source and the latter being target).
In fact i have a directory of such files.So instead of filename can dir be
mentioned and made to iterate over all the files?
Could it be that you're getting this error because you've only compied the data2networkpy file, and not the accompanying __init__.py file? That would explain the error that you're getting.
Also, I'm somewhat confused as to what you are trying to achieve: Do you want to write your own code that connects to cytoscape using my code as an example, or do you merely want to use the python scripts I've created?
I could make my code run by executing the following statements in this order: $ svn co https://trac.nbic.nl/svn/brs2011p07//tags/python-cytoscape-rpc/src/piqc A piqc/test A piqc/test/__init__.py A piqc/test/test_data2network.py A piqc/count_graphs.py A piqc/__init__.py A piqc/data2network.py Checked out revision 436.
Convert a spreadsheet of data to a Cytoscape network.
Options: --version show program's version number and exit -h, --help show this help message and exit -f FILE, --file=FILE Peptide identification and quantification data as .tsv or .csv -s SOURCE, --source=SOURCE Source node attribute -t TARGET, --target=TARGET Target node attribute
This script is however a very complicated way to import data: For single files it's probably better to use the Table Import Plugin already provided with Cytoscape. For the directory of files that you mention you would have to write the loop in bash, or alter the Python code yourself. This is currently not supported, and probably wont be in the future, as I've moved development to Java instead of Python.
It contains a connect2cytoscape method that returns a handle that allows you to execute all the commands listed in the CytoscapeRPC documentation: http://homepage.tudelft.nl/f1f6a/CytoscapeRPC_v1.7/tudelft/CytoscapeR... It's best to explore this from an interactive Python session, preferably an iPython session because you'll get tab-completion on the available methods.
Please let me know what it is you're trying to achieve, so I can target my suggestions accordingly.
I converted one of the text files to csv file(in libre calc) and tried
compiling _init_.py first but still getting the same error as follows:
sanjan@ubuntu:~/Documents/programs/cytoRPC$ python _init_.py
sanjan@ubuntu:~/Documents/programs/cytoRPC$ python data2net.py -f test.csv
-s source -t target
Traceback (most recent call last):
File "data2net.py", line 8, in <module>
from __init__ import connect2cytoscape
ImportError: cannot import name connect2cytoscape
Let me clearly state what i am trying to do:
I have a large number of text files having two columns separated by
tab(source and target).All of them are stored in one directory.Instead of
manually importing the files into cytoscape,generate graph ,use network
anlyser plug-in and finally save the statistics generated(deg
distribution,clustering coeff. etc), I thought of automating it through RPC
plug in.But since I am fairly new to python couldn't code it and thought of
using ur code as it too serves similar purpose.
I would be glad if there's a custom made code or if u can give some
pointers as to how to code in python or bash.
I am familiar with basics of python but dont know how to load files to
cytoscape , generate graphs...
Not sure why that would be failing.. Could you instead copy the contents of
__init__.py to the start of data2net.py, and remove the following line:
from __init__ import connect2cytoscape
You should then be able to remove the __init__.py as a separate file, and
running data2net.py should work, provided you have Cytoscape open, and the
CytoscapeRPC plugin server is running.
> Traceback (most recent call last):
> File "data2net.py", line 8, in <module>
> from __init__ import connect2cytoscape
> ImportError: cannot import name connect2cytoscape
> Let me clearly state what i am trying to do:
> I have a large number of text files having two columns separated by
> tab(source and target).All of them are stored in one directory.Instead of
> manually importing the files into cytoscape,generate graph ,use network
> anlyser plug-in and finally save the statistics generated(deg
> distribution,clustering coeff. etc), I thought of automating it through RPC
> plug in.But since I am fairly new to python couldn't code it and thought of
> using ur code as it too serves similar purpose.
> I would be glad if there's a custom made code or if u can give some
> pointers as to how to code in python or bash.
> I am familiar with basics of python but dont know how to load files to
> cytoscape , generate graphs...
> thanks,
> Sanjan
> --
> You received this message because you are subscribed to the Google Groups
> "cytoscape-discuss" group.
> To post to this group, send email to cytoscape-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> cytoscape-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cytoscape-discuss?hl=en.
I modified the code a little bit as i dont have any edge and node attribute
files(attached code).The code ran and created only one node and terminated
giving the following error:
sanjan@ubuntu:~/Documents/programs/cytoRPC$ python myload.py 9000 ip
test_216
Working on sif-file: eco_links156_long.sif
Traceback (most recent call last):
File "myload.py", line 139, in <module>
run()
File "myload.py", line 109, in run
edge_ids = server.Cytoscape.createEdges(netid, nodes_from,
nodes_to,[True]*len(nodes_to), True)
File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
return u.close()
File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 0: 'No method matching arguments: java.lang.String,
[Ljava.lang.Object;, [Ljava.lang.Object;, [Ljava.lang.Object;,
java.lang.Boolean'>
Also can the network analyser(the preinstalled one on cytoscape2.8.3)
plug-in be used through RPC?
Sorry to say I can't help you with that: I have no experience with that
script, or calling plugins through CytoscapeRPC, but maybe Jan Bot can help
you (it's his script).
> I modified the code a little bit as i dont have any edge and node
> attribute files(attached code).The code ran and created only one node and
> terminated giving the following error:
> sanjan@ubuntu:~/Documents/programs/cytoRPC$ python myload.py 9000 ip
> test_216
> Working on sif-file: eco_links156_long.sif
> Traceback (most recent call last):
> File "myload.py", line 139, in <module>
> run()
> File "myload.py", line 109, in run
> edge_ids = server.Cytoscape.createEdges(netid, nodes_from,
> nodes_to,[True]*len(nodes_to), True)
> File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
> return self.__send(self.__name, args)
> File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request
> verbose=self.__verbose
> File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
> return self.single_request(host, handler, request_body, verbose)
> File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request
> return self.parse_response(response)
> File "/usr/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
> return u.close()
> File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close
> raise Fault(**self._stack[0])
> xmlrpclib.Fault: <Fault 0: 'No method matching arguments:
> java.lang.String, [Ljava.lang.Object;, [Ljava.lang.Object;,
> [Ljava.lang.Object;, java.lang.Boolean'>
> Also can the network analyser(the preinstalled one on cytoscape2.8.3)
> plug-in be used through RPC?
> -
> Sanjan
> --
> You received this message because you are subscribed to the Google Groups
> "cytoscape-discuss" group.
> To post to this group, send email to cytoscape-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
> cytoscape-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cytoscape-discuss?hl=en.