Skip to content

Instantly share code, notes, and snippets.

@mnowotka
Last active August 29, 2015 14:15
Show Gist options
  • Save mnowotka/72b801c0265ca9000461 to your computer and use it in GitHub Desktop.
Save mnowotka/72b801c0265ca9000461 to your computer and use it in GitHub Desktop.
from chembl_webresource_client.new_client import new_client
# Get Molecules with ATC 'A10' classification
molecules = new_client.molecule.filter(atc_classifications__level5__startswith='A10')
molecule_ids = [mol['molecule_chembl_id'] for mol in molecules]
# Get Targets for Molecules
activities = new_client.activity.filter(molecule_chembl_id__in=molecule_ids).filter(pchembl_value__gte=6)
target_ids = set([act['target_chembl_id'] for act in activities])
# Get Target Details
targets = new_client.target.filter(target_chembl_id__in=target_ids)
for target in targets:
accessions = ", ".join([comp['accession'] for comp in target['target_components']])
print [target['pref_name'], target['organism'], target['target_type'], accessions]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment