{"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"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Intalling Libraries ","metadata":{}},{"cell_type":"code","source":"!pip install arnie forgi #dask\n!conda install -y -c bioconda viennarna","metadata":{"execution":{"iopub.status.idle":"2023-09-08T15:46:12.305602Z","shell.execute_reply.started":"2023-09-08T15:42:26.968024Z","shell.execute_reply":"2023-09-08T15:46:12.304194Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Environment","metadata":{}},{"cell_type":"code","source":"# Install Eternafold; not available via conda-forge quite yet, so we install from the pipeline build artifacts directly\n# !conda install eternafold\n!wget https://artprodeus21.artifacts.visualstudio.com/A910fa339-c7c2-46e8-a579-7ea247548706/84710dde-1620-425b-80d0-4cf5baca359d/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2NvbmRhLWZvcmdlL3Byb2plY3RJZC84NDcxMGRkZS0xNjIwLTQyNWItODBkMC00Y2Y1YmFjYTM1OWQvYnVpbGRJZC83NzI5MTAvYXJ0aWZhY3ROYW1lL2NvbmRhX3BrZ3NfbGludXg1/content?format=zip\n!unzip content\\?format\\=zip\n!conda install conda_pkgs_linux/eternafold-1.3.1-h00ab1b0_0.conda","metadata":{"execution":{"iopub.status.busy":"2023-09-08T15:46:12.308312Z","iopub.execute_input":"2023-09-08T15:46:12.308681Z","iopub.status.idle":"2023-09-08T15:46:29.686891Z","shell.execute_reply.started":"2023-09-08T15:46:12.308646Z","shell.execute_reply":"2023-09-08T15:46:29.685494Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Ordinarily, the `EternaFold` conda package will automatically set necessary environment variables, but Kaggle's conda install works a little differently. Let's set them manually here using `%env`.","metadata":{}},{"cell_type":"code","source":"%env ETERNAFOLD_PATH=/opt/conda/bin/eternafold-bin\n%env ETERNAFOLD_PARAMETERS=/opt/conda/lib/eternafold-lib/parameters/EternaFoldParams.v1","metadata":{"execution":{"iopub.status.busy":"2023-09-08T15:46:29.688916Z","iopub.execute_input":"2023-09-08T15:46:29.689335Z","iopub.status.idle":"2023-09-08T15:46:29.697838Z","shell.execute_reply.started":"2023-09-08T15:46:29.689272Z","shell.execute_reply":"2023-09-08T15:46:29.696713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Loading Libraries","metadata":{}},{"cell_type":"code","source":"### General ###\nimport warnings \n\n### Data Handling ###\nimport pandas as pd\n\n### Bioinformatics ###\nfrom arnie.mfe import mfe\nfrom arnie.bpps import bpps\nimport forgi.visual.mplotlib as fvm\nimport forgi.graph.bulge_graph as fgb\n\n### Viz ###\nimport matplotlib.pyplot as plt\n\nwarnings.filterwarnings(\"ignore\", category = RuntimeWarning)","metadata":{"execution":{"iopub.status.busy":"2023-09-08T15:46:29.700626Z","iopub.execute_input":"2023-09-08T15:46:29.701007Z","iopub.status.idle":"2023-09-08T15:46:30.759789Z","shell.execute_reply.started":"2023-09-08T15:46:29.700960Z","shell.execute_reply":"2023-09-08T15:46:30.758628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/stanford-ribonanza-rna-folding/train_data.csv')\nsequence = train[train[\"sequence_id\"] == \"8cdfeef009ea\"][\"sequence\"][0]#.compute()\nsequence","metadata":{"execution":{"iopub.status.busy":"2023-09-08T15:46:30.761503Z","iopub.execute_input":"2023-09-08T15:46:30.762205Z","iopub.status.idle":"2023-09-08T15:48:35.444789Z","shell.execute_reply.started":"2023-09-08T15:46:30.762160Z","shell.execute_reply":"2023-09-08T15:48:35.442485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"structure = mfe(sequence, package = \"eternafold\")\nstructure","metadata":{"execution":{"iopub.status.busy":"2023-09-08T15:48:35.447092Z","iopub.execute_input":"2023-09-08T15:48:35.447679Z","iopub.status.idle":"2023-09-08T15:48:35.663631Z","shell.execute_reply.started":"2023-09-08T15:48:35.447643Z","shell.execute_reply":"2023-09-08T15:48:35.662801Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Plot 2D RNA Structure","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(10, 10))\nbg = fgb.BulgeGraph.from_fasta_text(f'>rna1\\n{structure}\\n{sequence}')[0]\nfvm.plot_rna(bg, lighten=0.5, text_kwargs = {\"fontweight\":None})\nplt.show();","metadata":{"execution":{"iopub.status.busy":"2023-09-08T15:48:35.665114Z","iopub.execute_input":"2023-09-08T15:48:35.665469Z","iopub.status.idle":"2023-09-08T15:48:37.477337Z","shell.execute_reply.started":"2023-09-08T15:48:35.665438Z","shell.execute_reply":"2023-09-08T15:48:37.475969Z"},"trusted":true},"execution_count":null,"outputs":[]}],"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"}}