Download src/05_sanitize_data.py from Desp-ML/Bioactivity_Final_Project_QM9: direct link, hf CLI and curl.
- Browser
- Download file 688 Bytes
-
https://huggingface.co/datasets/Desp-ML/Bioactivity_Final_Project_QM9/resolve/main/src/05_sanitize_data.py
- Command line
-
hf download hf://datasets/Desp-ML/Bioactivity_Final_Project_QM9/src/05_sanitize_data.py
-
curl -L -o 05_sanitize_data.py https://huggingface.co/datasets/Desp-ML/Bioactivity_Final_Project_QM9/resolve/main/src/05_sanitize_data.py
688 Bytes
| from molvs import standardize_smiles | |
| import pandas as pd | |
| file_path = "./checkpoints_merged/all_data_merged.parquet" | |
| df = pd.read_parquet(file_path) | |
| smiles_column_key = df.columns[2] | |
| sanatized_rows = [] | |
| std_smile_list=[] | |
| failed_to_sanatize_row = [] | |
| for index, row in df.iterrows(): | |
| smile = row[smiles_column_key] | |
| std_smile = standardize_smiles(smile) | |
| std_smile_list.append(std_smile) | |
| df["Smiles_molvs"]=std_smile_list | |
| col = df.columns[-1] # name of the last column | |
| df.insert(3, col, df.pop(col)) # remove it then re‑insert at index 2 | |
| df.drop('SMILES_GDB17', axis=1, inplace=True) | |
| df.to_parquet("./clean_checkpoints/all_data_merged-cleaned.parquet", index=False) |