{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":67356,"databundleVersionId":8006601,"sourceType":"competition"}],"dockerImageVersionId":30702,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-04-23T05:27:54.951981Z","iopub.execute_input":"2024-04-23T05:27:54.952993Z","iopub.status.idle":"2024-04-23T05:27:54.964951Z","shell.execute_reply.started":"2024-04-23T05:27:54.952952Z","shell.execute_reply":"2024-04-23T05:27:54.963772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import sys","metadata":{"execution":{"iopub.status.busy":"2024-04-23T05:22:25.407262Z","iopub.execute_input":"2024-04-23T05:22:25.407670Z","iopub.status.idle":"2024-04-23T05:22:25.412230Z","shell.execute_reply.started":"2024-04-23T05:22:25.407638Z","shell.execute_reply":"2024-04-23T05:22:25.411023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pwd","metadata":{"execution":{"iopub.status.busy":"2024-04-23T05:27:13.417873Z","iopub.execute_input":"2024-04-23T05:27:13.418278Z","iopub.status.idle":"2024-04-23T05:27:14.445162Z","shell.execute_reply.started":"2024-04-23T05:27:13.418247Z","shell.execute_reply":"2024-04-23T05:27:14.443881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls","metadata":{"execution":{"iopub.status.busy":"2024-04-23T05:27:18.593903Z","iopub.execute_input":"2024-04-23T05:27:18.594944Z","iopub.status.idle":"2024-04-23T05:27:19.634625Z","shell.execute_reply.started":"2024-04-23T05:27:18.594901Z","shell.execute_reply":"2024-04-23T05:27:19.633123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\n\nfilename = \"/kaggle/input/leash-BELKA/train.csv\"\n\n# load a limited train set from BELKA comp\ndf = pd.read_csv(filename, nrows=100000)","metadata":{"execution":{"iopub.status.busy":"2024-04-23T05:51:37.228931Z","iopub.execute_input":"2024-04-23T05:51:37.229326Z","iopub.status.idle":"2024-04-23T05:51:37.474442Z","shell.execute_reply.started":"2024-04-23T05:51:37.229288Z","shell.execute_reply":"2024-04-23T05:51:37.473421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(20)","metadata":{"execution":{"iopub.status.busy":"2024-04-23T05:29:33.827744Z","iopub.execute_input":"2024-04-23T05:29:33.828107Z","iopub.status.idle":"2024-04-23T05:29:33.851731Z","shell.execute_reply.started":"2024-04-23T05:29:33.828079Z","shell.execute_reply":"2024-04-23T05:29:33.850733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install rdkit","metadata":{"execution":{"iopub.status.busy":"2024-04-23T05:30:45.406582Z","iopub.execute_input":"2024-04-23T05:30:45.406969Z","iopub.status.idle":"2024-04-23T05:31:00.912019Z","shell.execute_reply.started":"2024-04-23T05:30:45.406939Z","shell.execute_reply":"2024-04-23T05:31:00.910791Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from rdkit import Chem\nfrom rdkit.Chem import Draw\nfrom IPython.display import display\n\ndef display_mols(dataframe: pd.DataFrame, \n                 num_to_output: int = 10,\n                 smiles_column: str = \"molecule_smiles\") -> None:\n    \"\"\" \n    This function uses rdkit to convert smiles to mols and output \n    the 2D structure to the notebook.\n    \"\"\"\n    for index, row in df.iterrows():\n        smiles = row[smiles_column]\n        print(f\"SMILES:\\t{smiles}\")\n        mol = Chem.MolFromSmiles(smiles)\n        img = Draw.MolToImage(mol)\n        display(img)\n        if index == num_to_output:\n            break\n\ndisplay_mols(df)","metadata":{"execution":{"iopub.status.busy":"2024-04-23T06:33:30.147448Z","iopub.execute_input":"2024-04-23T06:33:30.147840Z","iopub.status.idle":"2024-04-23T06:33:30.409182Z","shell.execute_reply.started":"2024-04-23T06:33:30.147810Z","shell.execute_reply":"2024-04-23T06:33:30.408198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# shuffle data to get more variety\nshuffled_df = df.sample(frac=1).reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2024-04-23T06:33:39.657849Z","iopub.execute_input":"2024-04-23T06:33:39.658243Z","iopub.status.idle":"2024-04-23T06:33:39.692950Z","shell.execute_reply.started":"2024-04-23T06:33:39.658206Z","shell.execute_reply":"2024-04-23T06:33:39.691928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_mols(shuffled_df)","metadata":{"execution":{"iopub.status.busy":"2024-04-23T06:33:40.088562Z","iopub.execute_input":"2024-04-23T06:33:40.088940Z","iopub.status.idle":"2024-04-23T06:33:40.397898Z","shell.execute_reply.started":"2024-04-23T06:33:40.088907Z","shell.execute_reply":"2024-04-23T06:33:40.396547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_mols(shuffled_df, smiles_column = \"buildingblock1_smiles\")","metadata":{"execution":{"iopub.status.busy":"2024-04-23T06:33:46.725588Z","iopub.execute_input":"2024-04-23T06:33:46.725992Z","iopub.status.idle":"2024-04-23T06:33:46.977009Z","shell.execute_reply.started":"2024-04-23T06:33:46.725960Z","shell.execute_reply":"2024-04-23T06:33:46.975829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_mols(shuffled_df, smiles_column = \"buildingblock2_smiles\")","metadata":{"execution":{"iopub.status.busy":"2024-04-23T06:33:56.338527Z","iopub.execute_input":"2024-04-23T06:33:56.338891Z","iopub.status.idle":"2024-04-23T06:33:56.552439Z","shell.execute_reply.started":"2024-04-23T06:33:56.338861Z","shell.execute_reply":"2024-04-23T06:33:56.551386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_mols(shuffled_df, smiles_column = \"buildingblock3_smiles\")","metadata":{"execution":{"iopub.status.busy":"2024-04-23T06:34:00.888810Z","iopub.execute_input":"2024-04-23T06:34:00.889176Z","iopub.status.idle":"2024-04-23T06:34:01.113043Z","shell.execute_reply.started":"2024-04-23T06:34:00.889148Z","shell.execute_reply":"2024-04-23T06:34:01.112044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}