Created
November 16, 2021 14:19
-
-
Save leelasd/0949f00f37adbe873b3d7411377c5c7f to your computer and use it in GitHub Desktop.
Extract approved Drugs from Chembl 29 local 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 DISTINCT m.chembl_id AS compound_chembl_id,s.canonical_smiles, | |
m.molregno, | |
m.structure_type, | |
m.first_in_class, | |
m.indication_class, | |
m.first_approval | |
FROM compound_structures s | |
RIGHT JOIN molecule_dictionary m ON s.molregno = m.molregno | |
JOIN compound_records r ON m.molregno = r.molregno | |
AND m.max_phase IN (3,4) | |
""" | |
dat = sqlio.read_sql_query(sql, con) | |
dat.to_csv('new_approved.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