latendre / PythonCyc

MIT License
22 stars 6 forks source link

PToolsError when calling meta.pathway_components(pwy) #1

Open dkaplan65 opened 6 years ago

dkaplan65 commented 6 years ago

I am sometimes getting a PToolsError when I am retrieving the components of a pathway. For example:

import pythoncyc meta = pythoncyc.select_organism('meta') pathway = meta['| PWY-6883|'] components = meta.pathway_components(pathway)

Throws this error:

Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pythoncyc/PGDB.py", line 1441, in pathway_components return self.sendPgdbFnCall('pathway-components', may_be_frameid(pwy), **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pythoncyc/PGDB.py", line 370, in sendPgdbFnCall return self.sendPgdbQuery(fnCall) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pythoncyc/PGDB.py", line 341, in sendPgdbQuery return PTools.sendQueryToPTools('(with-organism (:org-id \''+self._orgid+') '+query+')') File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pythoncyc/PTools.py", line 182, in sendQueryToPTools raise PToolsError('An internal error occurred in the running Pathway Tools application: %s' % r) pythoncyc.PTools.PToolsError: An internal error occurred in the running Pathway Tools application: :error, During the evaluation of '(WITH-ORGANISM (:ORG-ID 'META) (PATHWAY-COMPONENTS 'PWY-6883))', the following error occurred: #<TYPE-ERROR @

x1042840b32>

This happens every time I call meta.pathways_components for this pathway. This also occurs when I pass in the pathway frameid instead of the PFrame.

This error does not only happen to just this pathway, it happens to 390 other pathways. I got this number by running this code:

import pythoncyc meta = pythoncyc.select_organism('meta') pathways = meta.pathways cnt = 0

for pathway in pathways.instances: frameid = pathway.frameid try: components = meta.pathway_components(frameid) except: cnt = cnt + 1

print(cnt)

Why is this happening? Am I doing something wrong?

(Sorry about the indentation)

latendre commented 6 years ago

Hello Pablo,

The Lisp (Pathway Tools) function pathway-components unfortunately breaks on pathways that are super-pathways, that is, pathways that have sub-pathways. You can directly see the issue by calling the pathway-components function, on a Lisp prompt, with the pwy-6883 as an argument. Therefore, before calling pathway-components you have to make sure that the pathway is not a super-pathway. One way to do that is to use the PythonCyc method all_pathways with the parameter “base" set to True. You will only have the base pathways returned. See the PythonCyc API for more details.

Best,

— Mario Latendresse SRI International

On Oct 16, 2018, at 9:25 AM, Pablo Peña notifications@github.com wrote:

I am sometimes getting a PToolsError when I am retrieving the components of a pathway. For example:

import pythoncyc meta = pythoncyc.select_organism('meta') pathway = meta['| PWY-6883|'] components = meta.pathway_components(pathway)

Throws this error:

Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pythoncyc/PGDB.py", line 1441, in pathway_components return self.sendPgdbFnCall('pathway-components', may_be_frameid(pwy), **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pythoncyc/PGDB.py", line 370, in sendPgdbFnCall return self.sendPgdbQuery(fnCall) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pythoncyc/PGDB.py", line 341, in sendPgdbQuery return PTools.sendQueryToPTools('(with-organism (:org-id ''+self._orgid+') '+query+')') File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pythoncyc/PTools.py", line 182, in sendQueryToPTools raise PToolsError('An internal error occurred in the running Pathway Tools application: %s' % r) pythoncyc.PTools.PToolsError: An internal error occurred in the running Pathway Tools application: :error, During the evaluation of '(WITH-ORGANISM (:ORG-ID 'META) (PATHWAY-COMPONENTS 'PWY-6883))', the following error occurred: #<TYPE-ERROR @

x1042840b32>

This happens every time I call meta.pathways_components for this pathway. This also occurs when I pass in the pathway frameid instead of the PFrame.

This error does not only happen to just this pathway, it happens to 390 other pathways. I got this number by running this code:

import pythoncyc meta = pythoncyc.select_organism('meta') pathways = meta.pathways cnt = 0

for pathway in pathways.instances: frameid = pathway.frameid try: components = meta.pathway_components(frameid) except: cnt = cnt + 1

print(cnt)

Why is this happening? Am I doing something wrong?

(Sorry about the indentation)

Hi dkaplan65 :) I hope that this is not too late, perhaps this might help you

import pythoncyc pathway_connection = pythoncyc.select_organism('meta')

retrieving all the available meta ids for the class "Pathways"

pathways_meta_ids = pathway_connection.get_class_all_instances("|Pathways|")

retrieving and appending to the list all the subclasses meta ids for the

class "Pathways"

pathways_meta_ids.extend(pathway_connection.get_class_all_subs("|Pathways|"))

Removing all the repeated pathway ids, if any

pathways_meta_ids = list(set(pathways_meta_ids))

looping through the pathways ids and trying to retrieve the components

for each pathway id

for pathway_id in pathways_meta_ids: print pathway_id, try: print pathway_connection.pathway_components(pathway_id) except: print "could not retrieve pathway components" If you have any issue or concern about how to use pythoncyc I might be able to help you, since I got a little experience with this library.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/latendre/PythonCyc/issues/1#issuecomment-430304029, or mute the thread https://github.com/notifications/unsubscribe-auth/AAecBFdPtF3Lmu37S-hz5naG7utgGpN7ks5ulgiCgaJpZM4Wt_io.