{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!conda install openbabel -c openbabel -y","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-10-17T16:13:24.023496Z","iopub.execute_input":"2022-10-17T16:13:24.024179Z","iopub.status.idle":"2022-10-17T16:15:29.890031Z","shell.execute_reply.started":"2022-10-17T16:13:24.024119Z","shell.execute_reply":"2022-10-17T16:15:29.889146Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pybel\n\n# def xyz_to_smiles(fname: str) -> str:\ndef xyz_to_smiles(fname):\n    \n    mol = next(pybel.readfile(\"xyz\", fname))\n    smi = mol.write(format=\"smi\")\n\n    return smi, smi.split()[0].strip()","metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","execution":{"iopub.status.busy":"2022-10-17T16:15:29.891781Z","iopub.execute_input":"2022-10-17T16:15:29.892186Z","iopub.status.idle":"2022-10-17T16:15:29.986427Z","shell.execute_reply.started":"2022-10-17T16:15:29.892144Z","shell.execute_reply":"2022-10-17T16:15:29.985238Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"inp_file_name = \"../input/tmqmsample/tmQM_X1_first_mol.xyz\"\nsmi_obj, smi_str = xyz_to_smiles(inp_file_name)\nprint(smi_obj, smi_str)","metadata":{"execution":{"iopub.status.busy":"2022-10-17T16:15:29.988078Z","iopub.execute_input":"2022-10-17T16:15:29.988506Z","iopub.status.idle":"2022-10-17T16:15:30.009614Z","shell.execute_reply.started":"2022-10-17T16:15:29.988412Z","shell.execute_reply":"2022-10-17T16:15:30.008617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# smi = xyz_to_smiles(\"../input/structures/dsgdb9nsd_028960.xyz\")\nxyz_mol = next(pybel.readfile(\"xyz\", inp_file_name))\nprint(xyz_mol)","metadata":{"execution":{"iopub.status.busy":"2022-10-17T16:15:30.011674Z","iopub.execute_input":"2022-10-17T16:15:30.012093Z","iopub.status.idle":"2022-10-17T16:15:30.023672Z","shell.execute_reply.started":"2022-10-17T16:15:30.012022Z","shell.execute_reply":"2022-10-17T16:15:30.022623Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(type(smi_obj), type(smi_str))","metadata":{"execution":{"iopub.status.busy":"2022-10-17T16:15:30.025962Z","iopub.execute_input":"2022-10-17T16:15:30.026369Z","iopub.status.idle":"2022-10-17T16:15:30.032303Z","shell.execute_reply.started":"2022-10-17T16:15:30.026198Z","shell.execute_reply":"2022-10-17T16:15:30.030941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mymol_smi = pybel.readstring(\"smi\", smi_str)\nxyz_out = mymol_smi.write(format=\"xyz\")\nprint(xyz_out)","metadata":{"execution":{"iopub.status.busy":"2022-10-17T16:15:30.033914Z","iopub.execute_input":"2022-10-17T16:15:30.034225Z","iopub.status.idle":"2022-10-17T16:15:30.046617Z","shell.execute_reply.started":"2022-10-17T16:15:30.034172Z","shell.execute_reply":"2022-10-17T16:15:30.045462Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pybel.outformats","metadata":{"execution":{"iopub.status.busy":"2022-10-17T16:38:49.370754Z","iopub.execute_input":"2022-10-17T16:38:49.371321Z","iopub.status.idle":"2022-10-17T16:38:49.379130Z","shell.execute_reply.started":"2022-10-17T16:38:49.371252Z","shell.execute_reply":"2022-10-17T16:38:49.378076Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}