Skip to content

Instantly share code, notes, and snippets.

@iwatobipen
Created November 20, 2022 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwatobipen/d340fe06a6f45754954332ff7f5d164d to your computer and use it in GitHub Desktop.
Save iwatobipen/d340fe06a6f45754954332ff7f5d164d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
Copy link

cthoyt commented Nov 20, 2022

Are you aware of chembl-downloader? I made it so we could more easily write code that does these SQL statements (like in cell 5) and requires no prior setup since it uses SQLite.

import chembl_downloader

# this gets put directly in a pandas dataframe
df = chembl_downloader.query(
    """\
    select canonical_smiles, molregno, activity_id, standard_value, standard_units 
    from activities
        join assays using (assay_id)
        join compound_structures using (molregno)
    where tid = 165 
        and standard_type = 'Ki' 
        and standard_value is not null 
        and standard_relation = '='
        and canonical_smiles not like '%.%';
    """
)

This also has the benefit of automatically getting the latest version of ChEMBL for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment