{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","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":11553390,"sourceType":"competition"}],"dockerImageVersionId":31012,"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\n\ncsv_path = \"/kaggle/input/stanford-rna-3d-folding/train_labels.csv\" \ndf = pd.read_csv(csv_path)\n\ndf['target_id'] = df['ID'].apply(lambda x: x.split('_')[0])\ntarget_ids = df['target_id'].unique()\n\ndef plot_rna_interactive(target_id, structure_idx=1):\n    subset = df[df['target_id'] == target_id]\n\n    x_col = f'x_{structure_idx}'\n    y_col = f'y_{structure_idx}'\n    z_col = f'z_{structure_idx}'\n\n    fig = go.Figure()\n\n    fig.add_trace(go.Scatter3d(\n        x=subset[x_col], y=subset[y_col], z=subset[z_col],\n        mode='lines+markers+text',\n        marker=dict(size=4, color='cyan'),\n        line=dict(color='lightblue', width=2),\n        text=subset['resname'],\n        textposition='top center',\n        hoverinfo='text'\n    ))\n\n    fig.update_layout(\n        title=f\"RNA 3D Structure: {target_id} (Structure {structure_idx})\",\n        scene=dict(\n            xaxis_title='X (Å)',\n            yaxis_title='Y (Å)',\n            zaxis_title='Z (Å)',\n            bgcolor='rgb(10,10,10)'\n        ),\n        paper_bgcolor='rgb(20,20,20)',\n        font=dict(color='white'),\n        height=600,\n        margin=dict(l=0, r=0, b=0, t=40)\n    )\n\n    fig.show()\n\nplot_rna_interactive(target_ids[2])","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-04-11T14:40:43.922477Z","iopub.execute_input":"2025-04-11T14:40:43.922788Z","iopub.status.idle":"2025-04-11T14:40:46.751215Z","shell.execute_reply.started":"2025-04-11T14:40:43.922764Z","shell.execute_reply":"2025-04-11T14:40:46.750409Z"}},"outputs":[],"execution_count":null}]}