Skip to content

Instantly share code, notes, and snippets.

View kirkdotcam's full-sized avatar
🔍
Coding the science!

Camden Kirkland kirkdotcam

🔍
Coding the science!
View GitHub Profile
search_failure = []
inchi_dict = {}
for drug in top200_names:
res = requests.get(f"https://cactus.nci.nih.gov/chemical/structure/{drug}/stdinchi")
if res.status_code == 404:
search_failure.append(res)
else:
inchi_dict[drug] = res.text
products_by_prescrip = df.groupby("Product Name").sum()["Number of Prescriptions"]
top200 = products_by_prescrip.sort_values(0,ascending=False)[0:200]
top200 = pd.DataFrame(top200)
top200 = top200.reset_index()
top200_names = top200["Product Name"].unique()
df['Product Name'] = df['Product Name'].replace({
"AMOXICILLI":"AMOXICILLIN",
"Lisinopril":"LISINOPRIL",
"ATAVORSTAT":"ATAVORSTATIN",
"VENTOLIN H":"ALBUTEROL",
"FLUTICASON":"FLUTICASONE",
"ONDANSETRO":"ONDANSETRON",
"PROAIR HFA":"ALBUTEROL",
"MONTELUKAS":"MONTELUKAST",
"LEVOTHYROX":"LEVOTHYROXINE",
df = pd.read_csv("<PATH>/data/State_Drug_Utilization_Data_2018.csv")
df.head()
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
from libs.rdkit_io import inchi_to_mol_file
import pandas as pd
import requests
from rdkit import Chem
def inchi_to_mol_file(inchi, name):
"""Converts inchi to mol, also returns mol
Args:
inchi (string): inchi to convert
name (string): name of molecule, will be used in filename
"""
Chem.MolToSmiles(toluene)
samedicyclohexane = Chem.MolFromMolFile("../mols/dicyclohexane.mol")
samedicyclohexane
dicyclohexane = Chem.MolFromInchi('InChI=1S/C17H32/c1-2-15(13-16-9-5-3-6-10-16)14-17-11-7-4-8-12-17/h15-17H,2-14H2,1H3')
dicyclohexane
toluene = Chem.MolFromSmiles('CC1=CC=CC=C1')
toluene