Created
November 16, 2021 03:36
-
-
Save leelasd/e609e5ad87050a5638ec790041ac164d to your computer and use it in GitHub Desktop.
Extract Permeability Data from Chembl SQL database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
import pandas as pd | |
import pandas.io.sql as sqlio | |
con = psycopg2.connect(database="chembl_29", user="leelasd", password="", host="127.0.0.1", port="5432") | |
print("Database opened successfully") | |
sql="""SELECT m.chembl_id AS compound_chembl_id, | |
s.canonical_smiles, | |
r.compound_key, | |
a.description AS assay_description, act.standard_type, | |
d.pubmed_id AS pubmed_id_or_doi, | |
act.standard_relation, | |
act.standard_value, | |
act.standard_units, | |
act.activity_comment | |
FROM compound_structures s, | |
molecule_dictionary m, | |
compound_records r, | |
docs d, | |
activities act, | |
assays a, | |
target_dictionary t | |
WHERE s.molregno = m.molregno | |
AND m.molregno = r.molregno | |
AND r.record_id = act.record_id | |
AND r.doc_id = d.doc_id | |
AND act.assay_id = a.assay_id | |
AND a.tid = t.tid | |
AND a.assay_type = 'A' | |
AND ((a.description LIKE '%Permeability%') OR (a.description LIKE '%permeability%')) | |
""" | |
dat = sqlio.read_sql_query(sql, con) | |
dat.to_csv('perm.csv',index=False) | |
print("Operation done successfully") | |
con.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment