{"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":"Published on September 07, 2023. By Marília Prata, mpwolke","metadata":{}},{"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)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn import feature_extraction, linear_model, model_selection, preprocessing\nimport plotly.graph_objs as go\nimport plotly.offline as py\nimport plotly.express as px\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')\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":"2023-09-08T00:09:23.303651Z","iopub.execute_input":"2023-09-08T00:09:23.304062Z"},"_kg_hide-input":true,"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Competition Citation:\n\n@misc{stanford-ribonanza-rna-folding,\n\n    author = {Rhiju Das, Shujun He, Rui Huang, Jill Townley, Rachael Kretsch, Thomas Karagianes, John Nicol, Grace Nye, Christian Choe, Jonathan Romano, Maggie Demkin, Walter Reade, and Eterna players },\n    \n    title = {Stanford Ribonanza RNA Folding},\n    \n    publisher = {Kaggle},\n    \n    year = {2023},\n    \n    url = {https://kaggle.com/competitions/stanford-ribonanza-rna-folding}\n}","metadata":{}},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn import feature_extraction, linear_model, model_selection, preprocessing\nimport plotly.graph_objs as go\nimport plotly.offline as py\nimport plotly.express as px\nimport os\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2023-09-08T00:38:33.051643Z","iopub.execute_input":"2023-09-08T00:38:33.051981Z","iopub.status.idle":"2023-09-08T00:38:34.804955Z","shell.execute_reply.started":"2023-09-08T00:38:33.051954Z","shell.execute_reply":"2023-09-08T00:38:34.803620Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Those train/test/submission csv took so long to be opened.\n\nAnyway, I don't even have a clue about what to make with them. ","metadata":{}},{"cell_type":"code","source":"#train = pd.read_csv('/kaggle/input/stanford-ribonanza-rna-folding/train_data.csv')\n#test = pd.read_csv('/kaggle/input/stanford-ribonanza-rna-folding/test_sequences.csv')\n#submission = pd.read_csv('/kaggle/input/stanford-ribonanza-rna-folding/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:05:33.368073Z","iopub.execute_input":"2023-09-08T01:05:33.368425Z","iopub.status.idle":"2023-09-08T01:05:33.372503Z","shell.execute_reply.started":"2023-09-08T01:05:33.368398Z","shell.execute_reply":"2023-09-08T01:05:33.371576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Supplementary R1 Silico Predictions","metadata":{}},{"cell_type":"code","source":"silico = pd.read_csv('/kaggle/input/stanford-ribonanza-rna-folding/supplementary_silico_predictions/R1_silico_predictions.csv')\nsilico.tail()","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:20:30.257477Z","iopub.execute_input":"2023-09-08T01:20:30.257838Z","iopub.status.idle":"2023-09-08T01:20:35.344327Z","shell.execute_reply.started":"2023-09-08T01:20:30.257809Z","shell.execute_reply":"2023-09-08T01:20:35.343595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#First row, fifth column \n\nsilico.iloc[1,4]","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:16:54.548474Z","iopub.execute_input":"2023-09-08T01:16:54.548813Z","iopub.status.idle":"2023-09-08T01:16:54.555426Z","shell.execute_reply.started":"2023-09-08T01:16:54.548787Z","shell.execute_reply":"2023-09-08T01:16:54.554243Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Fourth row, fifth column \n\nsilico.iloc[4,4]","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:20:08.588925Z","iopub.execute_input":"2023-09-08T01:20:08.589332Z","iopub.status.idle":"2023-09-08T01:20:08.596412Z","shell.execute_reply.started":"2023-09-08T01:20:08.589303Z","shell.execute_reply":"2023-09-08T01:20:08.595200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"silico[\"name\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:37:36.159781Z","iopub.execute_input":"2023-09-08T01:37:36.160169Z","iopub.status.idle":"2023-09-08T01:37:36.176986Z","shell.execute_reply.started":"2023-09-08T01:37:36.160129Z","shell.execute_reply":"2023-09-08T01:37:36.176186Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#EteRNA\n\nEteRNA - Crowdsourcing New RNA Designs\n\n\"Ribonucleic acid — or RNA — is key to life, playing a role in regulating the functions of cells. Scientists have been exploring RNA structures to better understand their biological roles.\"\n\n\"To that end, researchers at Carnegie Mellon University and Stanford University have harnessed the power of crowdsourcing to create new RNA designs through an online game. Funded through seed grants from by the National Institutes of Health, the National Science Foundation, Stanford University and others, EteRNA is a browser-based “game with a purpose” that lets players solve puzzles related to the folding of RNA molecules. The goal is to help find RNA molecules that are biologically active.\"\n\nProject Description\n\nEteRNA is a two-dimensional puzzle-solving exercise using the four bases — adenine, guanine, uracil and cytosine — that make up RNA molecules. Players can design elaborate structures, including knots, lattices and switches.\n\nEteRNA takes advantage of human problem-solving capabilities to solve puzzles that are too difficult for computers, given their lack of human intuition. As one project developer put it, “Computers don’t have flashes of insight.” The researchers are capitalizing on the collective intelligence of EteRNA players to answer fundamental questions about RNA folding mechanics.\n\nEach week, the gaming community chooses the best designs created by players. Scientists at Stanford then synthesize the selected RNA molecules to see how their folding patterns compare with computer predictions, thereby improving computer models.\n\nhttps://www.citizenscience.gov/eterna/#","metadata":{}},{"cell_type":"code","source":"#Code by Taha07  https://www.kaggle.com/taha07/data-scientists-jobs-analysis-visualization/notebook\n\nfrom wordcloud import WordCloud\nfrom wordcloud import STOPWORDS\nstopwords = set(STOPWORDS)\nwordcloud = WordCloud(background_color = 'white',\n                      color_func=lambda *args, **kwargs: \"black\",\n                      height =2000,\n                      width = 2000\n                     ).generate(str(silico[\"name\"]))\nplt.rcParams['figure.figsize'] = (12,12)\nplt.axis(\"off\")\nplt.imshow(wordcloud)\nplt.title(\"EteRNA\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:31:06.231771Z","iopub.execute_input":"2023-09-08T01:31:06.232113Z","iopub.status.idle":"2023-09-08T01:31:07.669779Z","shell.execute_reply.started":"2023-09-08T01:31:06.232086Z","shell.execute_reply":"2023-09-08T01:31:07.668873Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#On Bad Lines to Open the Tsv","metadata":{}},{"cell_type":"code","source":"puzzle = pd.read_csv('../input/stanford-ribonanza-rna-folding/eterna_openknot_metadata/puzzle_11318423_RYOP50_with_description.tsv', sep='\\t', on_bad_lines= 'skip')\n\npuzzle.head()","metadata":{"execution":{"iopub.status.busy":"2023-09-08T00:50:00.629001Z","iopub.execute_input":"2023-09-08T00:50:00.629414Z","iopub.status.idle":"2023-09-08T00:50:00.659719Z","shell.execute_reply.started":"2023-09-08T00:50:00.629384Z","shell.execute_reply":"2023-09-08T00:50:00.658809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Knots\n\nCitation: Rivera, M., Hao, Y., Maillard, R.A. et al. Mechanical unfolding of a knotted protein unveils the kinetic and thermodynamic consequences of threading a polypeptide chain. Sci Rep 10, 9562 (2020). https://doi.org/10.1038/s41598-020-66258-5\n\n\"Knots are remarkable topological features in nature. The presence of knots in crystallographic structures of proteins have stimulated considerable research to determine the kinetic and thermodynamic consequences of threading a polypeptide chain. By mechanically manipulating MJ0366, a small single domain protein harboring a shallow trefoil knot, the authors allowed the protein to refold from either the knotted or the unknotted denatured state to characterize the free energy profile associated to both folding pathways.\"\n\n\"Their results support that a protein knot can be formed during a single cooperative step of folding but occurs at the expenses of a large increment on the free energy barrier.\"\n\nhttps://www.nature.com/articles/s41598-020-66258-5#:~:text=Knotted%20proteins%20have%20emerged%20as,protein%20data%20bank2%2C3.","metadata":{}},{"cell_type":"code","source":"#Code by Taha07  https://www.kaggle.com/taha07/data-scientists-jobs-analysis-visualization/notebook\n\nfrom wordcloud import WordCloud\nfrom wordcloud import STOPWORDS\nstopwords = set(STOPWORDS)\nwordcloud = WordCloud(background_color = 'black',\n                      color_func=lambda *args, **kwargs: \"white\",\n                      height =2000,\n                      width = 2000\n                     ).generate(str(puzzle[\"title\"]))\nplt.rcParams['figure.figsize'] = (12,12)\nplt.axis(\"off\")\nplt.imshow(wordcloud)\nplt.title(\"I'm Knot Givig Up\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-08T00:53:33.915129Z","iopub.execute_input":"2023-09-08T00:53:33.915451Z","iopub.status.idle":"2023-09-08T00:53:36.596573Z","shell.execute_reply.started":"2023-09-08T00:53:33.915428Z","shell.execute_reply":"2023-09-08T00:53:36.595694Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#One Bpp file. Though here are txt extensions\n\nAnother step that I'm clueless about how to proceed.\n\n\"The BPP file extension is associated with Clarion a database application development environment that supports 4GL language, C++, and Modula-2 programming languages.The BPP file stores backup of application created in Clarion.\"\nhttps://www.solvusoft.com/en/file-extensions/file-extension-bpp/#:~:text=The%20BPP%20file%20extension%20is,SoftVelocity","metadata":{}},{"cell_type":"code","source":"bpp = '../input/stanford-ribonanza-rna-folding/Ribonanza_bpp_files/extra_data/7/7/7/b7317e8cd936.txt'\nwith open(bpp) as f: # The with keyword automatically closes the file when you are done\n    print (f.read(500))\n","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:13:11.176035Z","iopub.execute_input":"2023-09-08T01:13:11.176378Z","iopub.status.idle":"2023-09-08T01:13:11.183339Z","shell.execute_reply.started":"2023-09-08T01:13:11.176346Z","shell.execute_reply":"2023-09-08T01:13:11.182082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Andrey Shtrauss ttps://www.kaggle.com/code/shtrausslearning/biopython-bioinformatics-basics\n\nfrom Bio.Seq import Seq\nfrom Bio import SeqIO, SearchIO\nfrom Bio.SeqRecord import SeqRecord\n\nn = 'GGGAACGACUCGAGUAGAGUCGAAAAGGAGAGUUUAGUAAAAUAUAACACAACAUUUGUAAUUGUGUUAUCUGAUAACAAUUAUGGUGAUUGUGUAUUAUUCUCAUAUUGUGUAUUCAAGUAGAGAGUGCAUAUCAGUGUUCGCACUGAUGUGUACAAAAGAAACAACAACAACAAC'  # RNA sequence\naa = 'GGGAACGACUCGAGUAGAGUCGAAAAUCUUGGAGAUUUCAAAACCAUUGAGGAACUUGAAAGACUAAAACCGGGAGAAAAAGCCAACAUCUUACUUUACCAAGGAAAGCCCGUUAAAGUAGUUAAAAUGUGCAGGCUCCUUCGGGAGCCUGCACAUAAAAGAAACAACAACAACAAC' # RNA sequence\n\nseq_n = Seq(n)\nseq_aa = Seq(aa)","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:21:55.129934Z","iopub.execute_input":"2023-09-08T01:21:55.130324Z","iopub.status.idle":"2023-09-08T01:21:55.251011Z","shell.execute_reply.started":"2023-09-08T01:21:55.130290Z","shell.execute_reply":"2023-09-08T01:21:55.250088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#It's hard to say that I don't know what to make with those sequences.","metadata":{}},{"cell_type":"code","source":"#Andrey Shtrauss ttps://www.kaggle.com/code/shtrausslearning/biopython-bioinformatics-basics\n\nprint(seq_n.reverse_complement()) # possible\nprint(seq_aa.reverse_complement()) # not actually possible","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:22:25.913056Z","iopub.execute_input":"2023-09-08T01:22:25.913441Z","iopub.status.idle":"2023-09-08T01:22:25.919579Z","shell.execute_reply.started":"2023-09-08T01:22:25.913412Z","shell.execute_reply":"2023-09-08T01:22:25.918100Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Thanks God! That Fasta file has only 432.1 KB. The last time one fasta stopped my Notebook.","metadata":{}},{"cell_type":"markdown","source":"#Pseudoknots\n\n\"Pseudoknot structures appear to play a pivotal role in small subunit ribosomal RNA and in the noncoding regions of viral RNAs. There are also strong indications that RNA pseudoknots are highly suitable structural motifs for the recognition and binding of proteins.\"\n\n\nCitation: Cornelis W.A. Pleij,\n\nRNA pseudoknots, Current Opinion in Structural Biology\n\nVolume 4, Issue 3,1994, Pages 337-344,ISSN 0959-440X\n\nhttps://doi.org/10.1016/S0959-440X(94)90101-5.\n(https://www.sciencedirect.com/science/article/pii/S0959440X94901015)\n\nAbstract: \"Many new RNA pseudoknot structures have been detected and proposed in the past year. Although we are still waiting for the first detailed structure of a pseudoknot, their role in processes such as translational autoregulation or ribosomal frameshifting has been extensively studied and is now well established. Pseudoknot structures appear to play a pivotal role in small subunit ribosomal RNA and in the noncoding regions of viral RNAs. There are also strong indications that RNA pseudoknots are highly suitable structural motifs for the recognition and binding of proteins.\"\n\nhttps://www.sciencedirect.com/science/article/pii/S0959440X94901015#:~:text=Pseudoknot%20structures%20appear%20to%20play,recognition%20and%20binding%20of%20proteins.","metadata":{}},{"cell_type":"code","source":"#https://www.kaggle.com/code/mpwolke/cafa-5-protein-prediction\n\n#https://stackoverflow.com/questions/29805642/learning-to-parse-a-fasta-file-with-python\n\ndef read_fasta(fp):\n        name, seq = None, []\n        for line in fp:\n            line = line.rstrip()\n            if line.startswith(\">\"):\n                if name: yield (name, ''.join(seq))\n                name, seq = line, []\n            else:\n                seq.append(line)\n        if name: yield (name, ''.join(seq))\n\nwith open('../input/stanford-ribonanza-rna-folding/sequence_libraries/pseudoknot90_puzzle_11387276.tsv.RNA_sequences.fa') as fp:\n    for name, seq in read_fasta(fp):\n        print(name, seq)","metadata":{"execution":{"iopub.status.busy":"2023-09-08T01:46:51.109181Z","iopub.execute_input":"2023-09-08T01:46:51.109485Z","iopub.status.idle":"2023-09-08T01:46:51.149188Z","shell.execute_reply.started":"2023-09-08T01:46:51.109461Z","shell.execute_reply":"2023-09-08T01:46:51.148424Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Taha07  https://www.kaggle.com/taha07/data-scientists-jobs-analysis-visualization/notebook\n\nfrom wordcloud import WordCloud\nfrom wordcloud import STOPWORDS\nstopwords = set(STOPWORDS)\nwordcloud = WordCloud(background_color = 'black',\n                      color_func=lambda *args, **kwargs: \"white\",\n                      height =2000,\n                      width = 2000\n                     ).generate(str(puzzle[\"body\"]))\nplt.rcParams['figure.figsize'] = (12,12)\nplt.axis(\"off\")\nplt.imshow(wordcloud)\nplt.title(\"It's knot over till it's Over\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-08T00:55:30.920687Z","iopub.execute_input":"2023-09-08T00:55:30.921012Z","iopub.status.idle":"2023-09-08T00:55:33.645227Z","shell.execute_reply.started":"2023-09-08T00:55:30.920985Z","shell.execute_reply":"2023-09-08T00:55:33.644187Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#PseudoKnot Pushes : ) Really????","metadata":{}},{"cell_type":"markdown","source":"#Loops and PseudoKnots\n\n\"An RNA secondary structure illustrating the types of features included in nearest neighbor parameter sets. Loops are composed of nucleotides not in canonical pairs. Hairpin loops have one exiting helix. Internal and bulge loops have two exiting helices. Internal loops have nucleotides not in canonical pairs on each of two strands, but bulge loops have nucleotides not in canonical pairs on only one strand. Multibranch loops, also called helical junctions, have three or more exiting helices. Exterior loops contain the ends of sequences and one or more exiting helices.\"\n\n\"Pseudoknots are canonical pairs connecting loop regions closed by other helices. Formally, a pseudoknot occurs when there are at least two pairs, with indices i paired to j and i′ paired to j′, that satisfy the condition i < i′ < j < j′. The pseudoknot helix is often considered to be composed of the fewest pairs that need to be removed to relieve the pseudoknot. In this structure, the tan nucleotides are in pairs that could be removed to relieve the pseudoknot.\"\n\n![](https://www.researchgate.net/publication/38058637/figure/fig3/AS:325002718138375@1454498094387/An-RNA-secondary-structure-illustrating-the-types-of-features-included-in-nearest.png)\nhttps://www.researchgate.net/figure/An-RNA-secondary-structure-illustrating-the-types-of-features-included-in-nearest_fig3_38058637","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"}}