{"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":"markdown","source":"<font size=6><b>1.Import related libraries</b></font>","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"code","source":"import pandas as pd#导入csv文件的库\nimport numpy as np#进行矩阵运算的库\nimport torch#一个深度学习的库Pytorch\nimport torch.nn as nn#neural network,神经网络\nfrom torch.autograd import Variable#从自动求导中引入变量\nimport torch.optim as optim#一个实现了各种优化算法的库\nimport torch.nn.functional as F#神经网络函数库\nfrom Bio import SeqIO#用bio来解析序列","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:22:28.297753Z","iopub.execute_input":"2023-04-23T10:22:28.298132Z","iopub.status.idle":"2023-04-23T10:22:31.626559Z","shell.execute_reply.started":"2023-04-23T10:22:28.298099Z","shell.execute_reply":"2023-04-23T10:22:31.624835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<font size=6><b>2.deal with training set data.</b></font>\n\n<font size=3><b>Thanks to this article:https://www.kaggle.com/code/leonidkulyk/eda-cafa5-pfp-interactive-dags-plotly</b></font>","metadata":{}},{"cell_type":"markdown","source":"<font size=5><b>2.1 Gene Ontology</b></font>","metadata":{}},{"cell_type":"code","source":"!pip install obonet -q\n!pip install pyvis -q","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:22:57.065868Z","iopub.execute_input":"2023-04-23T10:22:57.06649Z","iopub.status.idle":"2023-04-23T10:23:23.278776Z","shell.execute_reply.started":"2023-04-23T10:22:57.066429Z","shell.execute_reply":"2023-04-23T10:23:23.276953Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import obonet#将obo序列化的本体加载到网络中","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:23:29.852798Z","iopub.execute_input":"2023-04-23T10:23:29.853213Z","iopub.status.idle":"2023-04-23T10:23:30.132944Z","shell.execute_reply.started":"2023-04-23T10:23:29.853174Z","shell.execute_reply":"2023-04-23T10:23:30.131361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"graph = obonet.read_obo('/kaggle/input/cafa-5-protein-function-prediction/Train/go-basic.obo')#接受.obo文件并返回本体的^{}表示","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:23:31.54557Z","iopub.execute_input":"2023-04-23T10:23:31.546126Z","iopub.status.idle":"2023-04-23T10:23:40.4861Z","shell.execute_reply.started":"2023-04-23T10:23:31.546075Z","shell.execute_reply":"2023-04-23T10:23:40.484424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"about this graph:{graph}\")","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:23:40.48855Z","iopub.execute_input":"2023-04-23T10:23:40.488973Z","iopub.status.idle":"2023-04-23T10:23:40.623129Z","shell.execute_reply.started":"2023-04-23T10:23:40.488917Z","shell.execute_reply":"2023-04-23T10:23:40.621847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<font size=5><b>2.2 Training sequences</b></font>","metadata":{}},{"cell_type":"code","source":"sequences = SeqIO.parse('/kaggle/input/cafa-5-protein-function-prediction/Train/train_sequences.fasta', \"fasta\")\nprint(\"Number of sequences:\", sum(1 for seq in sequences))#Amino Acid Composition氨基酸组成","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:24:02.887766Z","iopub.execute_input":"2023-04-23T10:24:02.888191Z","iopub.status.idle":"2023-04-23T10:24:05.124361Z","shell.execute_reply.started":"2023-04-23T10:24:02.888153Z","shell.execute_reply":"2023-04-23T10:24:05.122923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sequences = SeqIO.parse('/kaggle/input/cafa-5-protein-function-prediction/Train/train_sequences.fasta', \"fasta\")\n# get the name of each sequences\ntrainseqs = [str(seq).split('\\n')[-1][4:-2] for seq in sequences]\n# get the length of each sequence\ntrainlengths = [len(seq) for seq in trainseqs]","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:24:11.739813Z","iopub.execute_input":"2023-04-23T10:24:11.741087Z","iopub.status.idle":"2023-04-23T10:24:14.492302Z","shell.execute_reply.started":"2023-04-23T10:24:11.741025Z","shell.execute_reply":"2023-04-23T10:24:14.491153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<font size=5><b>2.3 Training taxonomy</b></font>","metadata":{}},{"cell_type":"code","source":"taxonomy=pd.read_csv('/kaggle/input/cafa-5-protein-function-prediction/Train/train_taxonomy.tsv',sep=\"\\t\")#taxonomy分类","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:24:49.342449Z","iopub.execute_input":"2023-04-23T10:24:49.343014Z","iopub.status.idle":"2023-04-23T10:24:49.489341Z","shell.execute_reply.started":"2023-04-23T10:24:49.34296Z","shell.execute_reply":"2023-04-23T10:24:49.487879Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"the length of taxonomy is\",len(taxonomy))\ntaxonomy=taxonomy.sort_values(by=\"EntryID\")\ntaxonomy","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:24:57.93048Z","iopub.execute_input":"2023-04-23T10:24:57.931797Z","iopub.status.idle":"2023-04-23T10:24:58.206208Z","shell.execute_reply.started":"2023-04-23T10:24:57.931737Z","shell.execute_reply":"2023-04-23T10:24:58.204869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<font size=5><b>2.4 Training terms</b></font>","metadata":{}},{"cell_type":"code","source":"terms=pd.read_csv('/kaggle/input/cafa-5-protein-function-prediction/Train/train_terms.tsv',sep='\\t')\nterms.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:25:47.302416Z","iopub.execute_input":"2023-04-23T10:25:47.303173Z","iopub.status.idle":"2023-04-23T10:25:51.162908Z","shell.execute_reply.started":"2023-04-23T10:25:47.303125Z","shell.execute_reply":"2023-04-23T10:25:51.161682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"terms.describe()","metadata":{"execution":{"iopub.status.busy":"2023-04-23T10:25:51.164795Z","iopub.execute_input":"2023-04-23T10:25:51.165162Z","iopub.status.idle":"2023-04-23T10:25:53.235241Z","shell.execute_reply.started":"2023-04-23T10:25:51.165127Z","shell.execute_reply":"2023-04-23T10:25:53.233942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<font size=3><b>142246 is an important number in this competition,but I don't know how to organize the files in these four training sets.\n\nWishing you the best of luck.</b></font>","metadata":{}}]}