This file contains hidden or 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
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 |
This file contains hidden or 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
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() |
This file contains hidden or 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
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", |
This file contains hidden or 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
df = pd.read_csv("<PATH>/data/State_Drug_Utilization_Data_2018.csv") | |
df.head() |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 | |
""" | |
This file contains hidden or 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
Chem.MolToSmiles(toluene) |
This file contains hidden or 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
samedicyclohexane = Chem.MolFromMolFile("../mols/dicyclohexane.mol") | |
samedicyclohexane |
This file contains hidden or 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
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 |
This file contains hidden or 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
toluene = Chem.MolFromSmiles('CC1=CC=CC=C1') | |
toluene |