GithubHelp home page GithubHelp logo

Comments (8)

mnowotka avatar mnowotka commented on May 25, 2024

Hi,
Yes, of course this is supported. For molecules:

from chembl_webresource_client.new_client import new_client
molecule = new_client.molecule
molecule.set_format('json')
res = molecule.search('viagra')

For targets:

from chembl_webresource_client.new_client import new_client
target = new_client.target
target.set_format('json')
res = target.search('lipoxygenase')

For more advanced examples, please take a look at tests file: https://github.com/chembl/chembl_webresource_client/blob/master/chembl_webresource_client/tests.py

from chembl_webresource_client.

i-shah avatar i-shah commented on May 25, 2024

Thank you ! I've been looking at the REST API and trying to figure out how to filter based on the molecule_synonyms/molecule_synonym

from chembl_webresource_client.

mnowotka avatar mnowotka commented on May 25, 2024

You can do that as well:

target = new_client.target
gene_name = 'GABRB2'
targets_for_gene = target.filter(target_components__target_component_synonyms__component_synonym__icontains=gene_name)

or shorter:

shortcut = target.filter(target_synonym__icontains=gene_name)

The difference is that the 'search' method uses solr index so it's faster. When you are using 'filter' you have to know exactly where you want to search and it can be slower.

from chembl_webresource_client.

i-shah avatar i-shah commented on May 25, 2024

Much rather use the solr index. Out of curiosity though, how would you search for molecule synonyms using a filter ?

from chembl_webresource_client.

mnowotka avatar mnowotka commented on May 25, 2024

Since a single molecule may have multiple synonyms (one to many relation) and there is no separate endpoint for synonyms this is not possible to do directly apply such a filter on the molecule entity. This is (one of the reasons) why we exposed another endpoint called 'drug': https://www.ebi.ac.uk/chembl/api/data/drug.json. But please note it only contains approved drugs (max_phase=4).

Example of searching for synonym using URL:
https://www.ebi.ac.uk/chembl/api/data/drug.json?synonyms__icontains=prazosin

and the client:

drug = new_client.drug
res =  drug.filter(synonyms__icontains="prazosin")

For a general synonym search across all ChEMBL molecules, the solr based 'search' method is the only option though.

from chembl_webresource_client.

mnowotka avatar mnowotka commented on May 25, 2024

Hi,

I'm closing this issue now but feel free to reopen if you have some more questions about this topic. For other questions, please create a new issue.

from chembl_webresource_client.

i-shah avatar i-shah commented on May 25, 2024

from chembl_webresource_client.

BJWiley233 avatar BJWiley233 commented on May 25, 2024

I just downloaded the conda package from here. When I run:
target.filter(target_components__target_component_synonyms__component_synonym__icontains=gene_name)
or
target.filter(target_synonym__icontains=gene_name)
I get

TypeError: 'NoneType' object cannot be interpreted as an integer

I can run in once and then it breaks there after.

from chembl_webresource_client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.