Skip to content

Instantly share code, notes, and snippets.

@mnowotka
Last active August 29, 2015 14:00
Show Gist options
  • Save mnowotka/11210342 to your computer and use it in GitHub Desktop.
Save mnowotka/11210342 to your computer and use it in GitHub Desktop.
# our standard invocation:
from chembl_webresource_client import *
targets = TargetResource()
print targets.status()
True
# status returns True so we can proceed:
#first let's get a single target:
t = targets.get('CHEMBL2477')
print t
{u'targetType': u'SINGLE PROTEIN', u'chemblId': u'CHEMBL2477', u'geneNames': u'Unspecified',
u'description': u'Alpha-amylase 2B ', u'compoundCount': 0, u'bioactivityCount': 0,
u'proteinAccession': u'P19961',
u'synonyms': u'1,4-alpha-D-glucan glucanohydrolase 2B,Alpha-amylase 2B,Carcinoid alpha-amylase,AMY2B,3.2.1.1',
u'organism': u'Homo sapiens', u'preferredName': u'Alpha-amylase 2B '}
# the same but in xml:
t = targets.get('CHEMBL2477', frmt='xml')
print t
'''<?xml version='1.0' encoding='utf-8'?>\n<target>
<targetType>SINGLE PROTEIN</targetType><chemblId>CHEMBL2477</chemblId>
<geneNames>Unspecified</geneNames><description>Alpha-amylase 2B </description>
<compoundCount>0</compoundCount><bioactivityCount>0</bioactivityCount><proteinAccession>P19961</proteinAccession>
<synonyms>1,4-alpha-D-glucan glucanohydrolase 2B,Alpha-amylase 2B,Carcinoid alpha-amylase,AMY2B,3.2.1.1</synonyms>
<organism>Homo sapiens</organism><preferredName>Alpha-amylase 2B </preferredName></target>'''
# we can get a target by it's uniprot id as well:
t = targets.get(uniprot='Q13936')
print t
{u'targetType': u'SINGLE PROTEIN', u'chemblId': u'CHEMBL1940', u'geneNames': u'Unspecified',
u'description': u'Voltage-gated L-type calcium channel alpha-1C subunit', u'compoundCount': 178,
u'bioactivityCount': 246, u'proteinAccession': u'Q13936',
u'synonyms': u'CCHL1A1,CACNL1A1,Calcium channel, L type, alpha-1 polypeptide, isoform 1, cardiac muscle,Voltage-gated calcium channel subunit alpha Cav1.2,CACNA1C,CACN2,CACH2 ,Voltage-dependent L-type calcium channel subunit alpha-1C',
u'organism': u'Homo sapiens', u'preferredName': u'Voltage-gated L-type calcium channel alpha-1C subunit'}
# as with compiunds, we can specify a list of ids to get multiple targets in single call:
ts = targets.get(['CHEMBL240', 'CHEMBL2477'])
print ts
ts
[
{u'targetType': u'SINGLE PROTEIN', u'chemblId': u'CHEMBL240',
u'geneNames': u'Unspecified', u'description': u'HERG', u'compoundCount': 10890,
u'bioactivityCount': 14056, u'proteinAccession': u'Q12809',
u'synonyms': u'HERG,hERG-1,ERG ,Voltage-gated potassium channel subunit Kv11.1,Eag homolog,Ether-a-go-go-related protein 1,Potassium voltage-gated channel subfamily H member 2,ERG-1,ERG1,Ether-a-go-go-related gene potassium channel 1,H-ERG,KCNH2,hERG1,Eag-related protein 1',
u'organism': u'Homo sapiens', u'preferredName': u'HERG'},
{u'targetType': u'SINGLE PROTEIN', u'chemblId': u'CHEMBL2477',
u'geneNames': u'Unspecified', u'description': u'Alpha-amylase 2B ', u'compoundCount': 0, u'bioactivityCount': 0,
u'proteinAccession': u'P19961',
u'synonyms': u'1,4-alpha-D-glucan glucanohydrolase 2B,Alpha-amylase 2B,Carcinoid alpha-amylase,AMY2B,3.2.1.1',
u'organism': u'Homo sapiens', u'preferredName': u'Alpha-amylase 2B '}
]
# retieving all available targets looks like this:
all_targets = targets.get_all()
len(all_targets)
10983
# almost 11k targets in a few seconds, great!
# we can get approved drugs for a given target as well:
drugs = targets.approved_drugs('CHEMBL1824')
print drugs[0]['name']
u'TRASTUZUMAB'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment