Python package: Bioservices, error using UniChem() command

134 Views Asked by At

I was following the tutorial on the webpage: http://pythonhosted.org/bioservices/compound_tutorial.html

Everything worked well until I reached the following command:

uni = UniChem()

and then I received the error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "P:\Anaconda\lib\site-packages\bioservices\unichem.py", line 84, in __init__
    maxid_service = int(self.get_all_src_ids()[-1]['src_id'])
TypeError: list indices must be integers, not str

As a minimum working example:

from bioservices import *
uni = UniChem()

and then I receive the error. I understand the error (for the most part) but I don't know how to fix it. So my question is how do I fix the function or work around it?

The overall aim it to map a list of 1000 drug names (and hopefully more in the near future) to Chembl IDs.

1

There are 1 best solutions below

0
On

The error you saw is probably related to the fact that when you tried to connect to UniChem service, it was off for maintenance or it took too much time to initialize. The consequence is that the service was not started hence the error message you got.

I've just tried (bioservices 1.2.6)

from bioservices import *
uni = UniChem()

and it worked. The following request also worked:

>>> mapping = uni.get_mapping("kegg_ligand", "chembl")
'CHEMBL278315'