{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":87793,"databundleVersionId":11228175,"sourceType":"competition"}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport plotly.graph_objects as go","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-27T23:42:11.871980Z","iopub.execute_input":"2025-02-27T23:42:11.872360Z","iopub.status.idle":"2025-02-27T23:42:12.946330Z","shell.execute_reply.started":"2025-02-27T23:42:11.872323Z","shell.execute_reply":"2025-02-27T23:42:12.945298Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def plot_structure(df: pd.DataFrame, sequence_id: str) -> None:\n    sequence_df = df[df[\"sequence_id\"] == sequence_id]\n    sequence_points = sequence_df[[\"x_1\", \"y_1\", \"z_1\", \"resname\"]]\n    \n    colors = {\"A\": \"red\", \"G\": \"blue\", \"C\": \"green\", \"U\": \"orange\"}\n    fig = go.Figure()\n    \n    for resname, color in colors.items():\n        subset = sequence_df[sequence_df[\"resname\"] == resname]\n        fig.add_trace(go.Scatter3d(\n            x=subset[\"x_1\"], y=subset[\"y_1\"], z=subset[\"z_1\"],\n            mode='markers',\n            marker=dict(size=5, color=color),\n            name=resname,\n        ))\n    \n    fig.add_trace(go.Scatter3d(\n        x=sequence_df[\"x_1\"], y=sequence_df[\"y_1\"], z=sequence_df[\"z_1\"],\n        mode='lines',\n        line=dict(color='gray', width=2),\n        name='RNA Backbone'\n    ))\n    \n    fig.update_layout(\n            scene=dict(xaxis_title='X', yaxis_title='Y', zaxis_title='Z'),\n            title=f'3D RNA Structure of sequence {sequence_id}',\n        )\n            \n    fig.show(renderer=\"iframe\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-27T23:46:23.783205Z","iopub.execute_input":"2025-02-27T23:46:23.783981Z","iopub.status.idle":"2025-02-27T23:46:23.792106Z","shell.execute_reply.started":"2025-02-27T23:46:23.783937Z","shell.execute_reply":"2025-02-27T23:46:23.790691Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/stanford-rna-3d-folding/train_labels.csv\")\ndf[\"sequence_id\"] = df[\"ID\"].apply(lambda x: \"_\".join(x.split(\"_\")[:-1]))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-27T23:46:23.805172Z","iopub.execute_input":"2025-02-27T23:46:23.805662Z","iopub.status.idle":"2025-02-27T23:46:24.091654Z","shell.execute_reply.started":"2025-02-27T23:46:23.805626Z","shell.execute_reply":"2025-02-27T23:46:24.090524Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_structure(df, \"1OSW_A\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-27T23:47:07.088406Z","iopub.execute_input":"2025-02-27T23:47:07.088726Z","iopub.status.idle":"2025-02-27T23:47:07.166555Z","shell.execute_reply.started":"2025-02-27T23:47:07.088701Z","shell.execute_reply":"2025-02-27T23:47:07.165295Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_structure(df, \"1A60_A\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-27T23:46:24.205478Z","iopub.execute_input":"2025-02-27T23:46:24.205802Z","iopub.status.idle":"2025-02-27T23:46:24.285635Z","shell.execute_reply.started":"2025-02-27T23:46:24.205775Z","shell.execute_reply":"2025-02-27T23:46:24.284431Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_structure(df, \"7QDU_Q\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-27T23:46:25.394653Z","iopub.execute_input":"2025-02-27T23:46:25.395025Z","iopub.status.idle":"2025-02-27T23:46:25.463760Z","shell.execute_reply.started":"2025-02-27T23:46:25.394996Z","shell.execute_reply":"2025-02-27T23:46:25.462740Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_structure(df, \"8QO5_A\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-27T23:46:25.530738Z","iopub.execute_input":"2025-02-27T23:46:25.531093Z","iopub.status.idle":"2025-02-27T23:46:25.609241Z","shell.execute_reply.started":"2025-02-27T23:46:25.531036Z","shell.execute_reply":"2025-02-27T23:46:25.608048Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}