{"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":"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)\nfrom Bio import SeqIO, SearchIO\n!pip install pyhmmer","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-07-12T11:36:41.475828Z","iopub.execute_input":"2023-07-12T11:36:41.476158Z","iopub.status.idle":"2023-07-12T11:36:52.278142Z","shell.execute_reply.started":"2023-07-12T11:36:41.476122Z","shell.execute_reply":"2023-07-12T11:36:52.276691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Домены для train_seq, полученные после применения hmmsearch.","metadata":{}},{"cell_type":"code","source":"fn = '/kaggle/input/domains-seq2/myhits_train.fa'\nsequences_domains = SeqIO.parse(fn, \"fasta\")","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:39:07.948606Z","iopub.execute_input":"2023-07-12T11:39:07.949604Z","iopub.status.idle":"2023-07-12T11:39:07.954887Z","shell.execute_reply.started":"2023-07-12T11:39:07.949568Z","shell.execute_reply":"2023-07-12T11:39:07.953812Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Названия доменов.","metadata":{}},{"cell_type":"code","source":"names_d= '/kaggle/input/domains-names/domains_names'\ncol_name = ['Name']\nnames_dom = pd.read_csv(names_d, sep='\\t', names= col_name)","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:35:32.016908Z","iopub.execute_input":"2023-07-12T11:35:32.017252Z","iopub.status.idle":"2023-07-12T11:35:32.258898Z","shell.execute_reply.started":"2023-07-12T11:35:32.017222Z","shell.execute_reply":"2023-07-12T11:35:32.257766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Создание датафрейма с последовательностями доменов, их названиями и названиями белков, в которых они содержатся.","metadata":{}},{"cell_type":"code","source":"ids=[]\nseqs=[]\ncoord=[]\npfs= []\nnames = []\nfor seq_record in SeqIO.parse('/kaggle/input/domains-seq2/myhits_train.fa', \"fasta\"):\n    ids.append(seq_record.id.split('/')[0])\n    coord.append(seq_record.id.split('/')[3])\n    pfs.append(seq_record.id.split('/')[2])\n    names.append(seq_record.id.split('/')[1])\n    seqs.append(\"\".join(seq_record.seq))","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:39:38.014392Z","iopub.execute_input":"2023-07-12T11:39:38.014809Z","iopub.status.idle":"2023-07-12T11:39:53.944023Z","shell.execute_reply.started":"2023-07-12T11:39:38.014773Z","shell.execute_reply":"2023-07-12T11:39:53.942819Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"seq_record.id","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:35:47.49316Z","iopub.execute_input":"2023-07-12T11:35:47.493643Z","iopub.status.idle":"2023-07-12T11:35:47.50144Z","shell.execute_reply.started":"2023-07-12T11:35:47.493602Z","shell.execute_reply":"2023-07-12T11:35:47.500153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_domains=pd.DataFrame({'id_prot':ids, 'domain_name':names, 'Pf_id': pfs,'coord':coord, 'domain_seq':seqs})","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:39:53.946138Z","iopub.execute_input":"2023-07-12T11:39:53.947611Z","iopub.status.idle":"2023-07-12T11:39:55.02799Z","shell.execute_reply.started":"2023-07-12T11:39:53.947568Z","shell.execute_reply":"2023-07-12T11:39:55.027204Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_domains","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:39:55.029228Z","iopub.execute_input":"2023-07-12T11:39:55.029725Z","iopub.status.idle":"2023-07-12T11:39:55.04537Z","shell.execute_reply.started":"2023-07-12T11:39:55.029698Z","shell.execute_reply":"2023-07-12T11:39:55.044261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_domains[train_domains['id_prot'].isin(['Q9Y7F0'])]","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:39:59.235623Z","iopub.execute_input":"2023-07-12T11:39:59.236009Z","iopub.status.idle":"2023-07-12T11:39:59.329651Z","shell.execute_reply.started":"2023-07-12T11:39:59.235979Z","shell.execute_reply":"2023-07-12T11:39:59.328318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"starts=[]\nends= []\ncoords = train_domains['coord'].tolist()\n\nfor i in range(len(coords)):\n    starts.append(int(coords[i].split('-')[0]))\n    ends.append(int(coords[i].split('-')[1]))","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:01.835578Z","iopub.execute_input":"2023-07-12T11:40:01.836002Z","iopub.status.idle":"2023-07-12T11:40:03.377122Z","shell.execute_reply.started":"2023-07-12T11:40:01.835968Z","shell.execute_reply":"2023-07-12T11:40:03.375971Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_domains['start'] = (starts)\ntrain_domains['ends'] =ends","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:03.379145Z","iopub.execute_input":"2023-07-12T11:40:03.379866Z","iopub.status.idle":"2023-07-12T11:40:04.0403Z","shell.execute_reply.started":"2023-07-12T11:40:03.37983Z","shell.execute_reply":"2023-07-12T11:40:04.039366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_domains = train_domains.sort_values(by='start')","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:04.332357Z","iopub.execute_input":"2023-07-12T11:40:04.333141Z","iopub.status.idle":"2023-07-12T11:40:05.122104Z","shell.execute_reply.started":"2023-07-12T11:40:04.333102Z","shell.execute_reply":"2023-07-12T11:40:05.120995Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_domains","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:05.712593Z","iopub.execute_input":"2023-07-12T11:40:05.712991Z","iopub.status.idle":"2023-07-12T11:40:05.727648Z","shell.execute_reply.started":"2023-07-12T11:40:05.712961Z","shell.execute_reply":"2023-07-12T11:40:05.726859Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_domains=train_domains.drop_duplicates()","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:08.962019Z","iopub.execute_input":"2023-07-12T11:40:08.962895Z","iopub.status.idle":"2023-07-12T11:40:12.102228Z","shell.execute_reply.started":"2023-07-12T11:40:08.96286Z","shell.execute_reply":"2023-07-12T11:40:12.10104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Создание датафрейма с id белков трейна и последовательностями","metadata":{}},{"cell_type":"code","source":"fn2 = '/kaggle/input/cafa-5-protein-function-prediction/Train/train_sequences.fasta'","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:13.172613Z","iopub.execute_input":"2023-07-12T11:40:13.173008Z","iopub.status.idle":"2023-07-12T11:40:13.17796Z","shell.execute_reply.started":"2023-07-12T11:40:13.172976Z","shell.execute_reply":"2023-07-12T11:40:13.17682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"seqs_prot=[]\nids_prot=[]\nfor seq_record in SeqIO.parse(fn2, \"fasta\"):\n    \n    ids_prot.append(seq_record.id)\n    \n    seqs_prot.append(\"\".join(seq_record.seq))\n    \nseq_prot=pd.DataFrame({'id_prot':ids_prot, 'seq_prot':seqs_prot})","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:14.398516Z","iopub.execute_input":"2023-07-12T11:40:14.399669Z","iopub.status.idle":"2023-07-12T11:40:18.293008Z","shell.execute_reply.started":"2023-07-12T11:40:14.39962Z","shell.execute_reply":"2023-07-12T11:40:18.291856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"seq_prot","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:18.29635Z","iopub.execute_input":"2023-07-12T11:40:18.29689Z","iopub.status.idle":"2023-07-12T11:40:18.309351Z","shell.execute_reply.started":"2023-07-12T11:40:18.296849Z","shell.execute_reply":"2023-07-12T11:40:18.308226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data = train_domains.merge(seq_prot, on=[\"id_prot\"])\nnew_data.pop('start')\nnew_data.pop('ends')","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:18.310971Z","iopub.execute_input":"2023-07-12T11:40:18.311364Z","iopub.status.idle":"2023-07-12T11:40:20.140866Z","shell.execute_reply.started":"2023-07-12T11:40:18.311327Z","shell.execute_reply":"2023-07-12T11:40:20.139833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:20.312306Z","iopub.execute_input":"2023-07-12T11:40:20.313289Z","iopub.status.idle":"2023-07-12T11:40:20.327221Z","shell.execute_reply.started":"2023-07-12T11:40:20.313255Z","shell.execute_reply":"2023-07-12T11:40:20.326344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data_2 = new_data.groupby(['id_prot']).count()\nnew_data_2 = new_data_2.reset_index()","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:23.583731Z","iopub.execute_input":"2023-07-12T11:40:23.584106Z","iopub.status.idle":"2023-07-12T11:40:25.701226Z","shell.execute_reply.started":"2023-07-12T11:40:23.58408Z","shell.execute_reply":"2023-07-12T11:40:25.700184Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ids_prot= new_data['id_prot'].tolist()","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:25.702891Z","iopub.execute_input":"2023-07-12T11:40:25.703189Z","iopub.status.idle":"2023-07-12T11:40:25.754582Z","shell.execute_reply.started":"2023-07-12T11:40:25.703164Z","shell.execute_reply":"2023-07-12T11:40:25.753531Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data_3 = new_data.merge(new_data_2, on=[\"id_prot\"])\nnew_data_3 = new_data_3.drop_duplicates(subset=('id_prot', 'domain_name_y'))\nnew_data_3","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:27.543775Z","iopub.execute_input":"2023-07-12T11:40:27.544176Z","iopub.status.idle":"2023-07-12T11:40:30.065228Z","shell.execute_reply.started":"2023-07-12T11:40:27.544143Z","shell.execute_reply":"2023-07-12T11:40:30.064133Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nums= new_data_3['domain_name_y'].tolist()","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:30.067579Z","iopub.execute_input":"2023-07-12T11:40:30.067991Z","iopub.status.idle":"2023-07-12T11:40:30.074314Z","shell.execute_reply.started":"2023-07-12T11:40:30.067954Z","shell.execute_reply":"2023-07-12T11:40:30.073544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_nums = []\nfor l in range(len(nums)):\n\n        for i in range(1, nums[l]+1):\n        \n            new_nums.append(i)\n   ","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:30.075421Z","iopub.execute_input":"2023-07-12T11:40:30.076113Z","iopub.status.idle":"2023-07-12T11:40:30.282646Z","shell.execute_reply.started":"2023-07-12T11:40:30.076083Z","shell.execute_reply":"2023-07-12T11:40:30.281723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data['domain_num']=new_nums","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:30.284533Z","iopub.execute_input":"2023-07-12T11:40:30.284948Z","iopub.status.idle":"2023-07-12T11:40:30.586347Z","shell.execute_reply.started":"2023-07-12T11:40:30.284914Z","shell.execute_reply":"2023-07-12T11:40:30.585443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:34.027966Z","iopub.execute_input":"2023-07-12T11:40:34.028319Z","iopub.status.idle":"2023-07-12T11:40:34.043385Z","shell.execute_reply.started":"2023-07-12T11:40:34.028291Z","shell.execute_reply":"2023-07-12T11:40:34.042533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data = new_data[['id_prot', 'seq_prot','Pf_id','domain_name', 'coord','domain_seq', 'domain_num']]","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:51.235231Z","iopub.execute_input":"2023-07-12T11:40:51.235617Z","iopub.status.idle":"2023-07-12T11:40:52.114874Z","shell.execute_reply.started":"2023-07-12T11:40:51.235587Z","shell.execute_reply":"2023-07-12T11:40:52.113727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data.to_csv('/kaggle/working/train_domains', sep=' ')","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:40:52.189679Z","iopub.execute_input":"2023-07-12T11:40:52.190052Z","iopub.status.idle":"2023-07-12T11:41:51.785993Z","shell.execute_reply.started":"2023-07-12T11:40:52.190023Z","shell.execute_reply":"2023-07-12T11:41:51.783391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Домены для test_seq после hmmseacrh","metadata":{}},{"cell_type":"code","source":"fn_1 = '/kaggle/input/domains-seq2/testhits_new.fa'\ntest_sequences_domains = SeqIO.parse(fn_1, \"fasta\")","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:42:27.380107Z","iopub.execute_input":"2023-07-12T11:42:27.380631Z","iopub.status.idle":"2023-07-12T11:42:27.394265Z","shell.execute_reply.started":"2023-07-12T11:42:27.380582Z","shell.execute_reply":"2023-07-12T11:42:27.393242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Имена доменов","metadata":{}},{"cell_type":"code","source":"names_d= '/kaggle/input/domains-names/test_domains_names'\ncol_name = ['Name']\nnames_dom = pd.read_csv(names_d, sep='\\t', names= col_name)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Создание датафрейма с последовательностями доменов, их названиями и названиями белков, в которых они содержатся.","metadata":{}},{"cell_type":"code","source":"ids=[]\nseqs=[]\ncoord=[]\npfs=[]\nnames=[]\nfor seq_record in SeqIO.parse('/kaggle/input/domains-seq2/testhits_new.fa', \"fasta\"):\n    ids.append(seq_record.id.split('/')[0])\n    coord.append(seq_record.id.split('/')[3])\n    pfs.append(seq_record.id.split('/')[2])\n    names.append(seq_record.id.split('/')[1])\n    seqs.append(\"\".join(seq_record.seq))","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:42:33.706738Z","iopub.execute_input":"2023-07-12T11:42:33.707198Z","iopub.status.idle":"2023-07-12T11:42:48.554972Z","shell.execute_reply.started":"2023-07-12T11:42:33.707166Z","shell.execute_reply":"2023-07-12T11:42:48.554107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"seq_record.id","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:42:48.556542Z","iopub.execute_input":"2023-07-12T11:42:48.557519Z","iopub.status.idle":"2023-07-12T11:42:48.564327Z","shell.execute_reply.started":"2023-07-12T11:42:48.557485Z","shell.execute_reply":"2023-07-12T11:42:48.563385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(names_dom['Name'].tolist())","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:42:48.565861Z","iopub.execute_input":"2023-07-12T11:42:48.566436Z","iopub.status.idle":"2023-07-12T11:42:48.593125Z","shell.execute_reply.started":"2023-07-12T11:42:48.566406Z","shell.execute_reply":"2023-07-12T11:42:48.592158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_domains=pd.DataFrame({'id_prot':ids, 'domain_name':names,'Pf_id': pfs,'coord':coord, 'domain_seq':seqs})","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:42:48.595382Z","iopub.execute_input":"2023-07-12T11:42:48.595744Z","iopub.status.idle":"2023-07-12T11:42:49.447861Z","shell.execute_reply.started":"2023-07-12T11:42:48.595714Z","shell.execute_reply":"2023-07-12T11:42:49.446348Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_domains","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:42:49.449299Z","iopub.execute_input":"2023-07-12T11:42:49.449681Z","iopub.status.idle":"2023-07-12T11:42:49.46693Z","shell.execute_reply.started":"2023-07-12T11:42:49.449647Z","shell.execute_reply":"2023-07-12T11:42:49.46584Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"starts=[]\nends= []\ncoords = test_domains['coord'].tolist()\n\nfor i in range(len(coords)):\n    starts.append(int(coords[i].split('-')[0]))\n    ends.append(int(coords[i].split('-')[1]))","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:31.895516Z","iopub.execute_input":"2023-07-12T11:46:31.896464Z","iopub.status.idle":"2023-07-12T11:46:33.329133Z","shell.execute_reply.started":"2023-07-12T11:46:31.896428Z","shell.execute_reply":"2023-07-12T11:46:33.327779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_domains['start'] = (starts)\ntest_domains['ends'] =ends","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:33.623796Z","iopub.execute_input":"2023-07-12T11:46:33.624198Z","iopub.status.idle":"2023-07-12T11:46:34.234109Z","shell.execute_reply.started":"2023-07-12T11:46:33.62416Z","shell.execute_reply":"2023-07-12T11:46:34.232928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_domains = test_domains.sort_values(by='start')","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:34.235897Z","iopub.execute_input":"2023-07-12T11:46:34.236205Z","iopub.status.idle":"2023-07-12T11:46:34.898746Z","shell.execute_reply.started":"2023-07-12T11:46:34.23618Z","shell.execute_reply":"2023-07-12T11:46:34.897733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_domains","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:34.90025Z","iopub.execute_input":"2023-07-12T11:46:34.900581Z","iopub.status.idle":"2023-07-12T11:46:34.914333Z","shell.execute_reply.started":"2023-07-12T11:46:34.900534Z","shell.execute_reply":"2023-07-12T11:46:34.913516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Создание датафрейма с id белков теста и последовательностями","metadata":{}},{"cell_type":"code","source":"fn_2 = '/kaggle/input/cafa-5-protein-function-prediction/Test (Targets)/testsuperset.fasta'","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:35.874028Z","iopub.execute_input":"2023-07-12T11:46:35.874461Z","iopub.status.idle":"2023-07-12T11:46:35.880176Z","shell.execute_reply.started":"2023-07-12T11:46:35.874431Z","shell.execute_reply":"2023-07-12T11:46:35.878843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"seqs_prot=[]\nids_prot=[]\nfor seq_record in SeqIO.parse(fn_2, \"fasta\"):\n    \n    ids_prot.append(seq_record.id)\n    \n    seqs_prot.append(\"\".join(seq_record.seq))\n    \nseq_prot=pd.DataFrame({'id_prot':ids_prot, 'seq_prot':seqs_prot})","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:36.959881Z","iopub.execute_input":"2023-07-12T11:46:36.960279Z","iopub.status.idle":"2023-07-12T11:46:40.393989Z","shell.execute_reply.started":"2023-07-12T11:46:36.960247Z","shell.execute_reply":"2023-07-12T11:46:40.392963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data = train_domains.merge(seq_prot, on=[\"id_prot\"])\nnew_data.pop('start')\nnew_data.pop('ends')","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:40.396191Z","iopub.execute_input":"2023-07-12T11:46:40.396529Z","iopub.status.idle":"2023-07-12T11:46:41.829324Z","shell.execute_reply.started":"2023-07-12T11:46:40.396501Z","shell.execute_reply":"2023-07-12T11:46:41.828255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data_2 = new_data.groupby(['id_prot']).count()\nnew_data_2 = new_data_2.reset_index()","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:41.830729Z","iopub.execute_input":"2023-07-12T11:46:41.831236Z","iopub.status.idle":"2023-07-12T11:46:42.944527Z","shell.execute_reply.started":"2023-07-12T11:46:41.831207Z","shell.execute_reply":"2023-07-12T11:46:42.943441Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ids_prot= new_data['id_prot'].tolist()","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:42.947251Z","iopub.execute_input":"2023-07-12T11:46:42.948192Z","iopub.status.idle":"2023-07-12T11:46:42.977314Z","shell.execute_reply.started":"2023-07-12T11:46:42.948147Z","shell.execute_reply":"2023-07-12T11:46:42.97635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data_3 = new_data.merge(new_data_2, on=[\"id_prot\"])\nnew_data_3 = new_data_3.drop_duplicates(subset=('id_prot', 'domain_name_y'))\nnew_data_3","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:42.978864Z","iopub.execute_input":"2023-07-12T11:46:42.980088Z","iopub.status.idle":"2023-07-12T11:46:44.160742Z","shell.execute_reply.started":"2023-07-12T11:46:42.980045Z","shell.execute_reply":"2023-07-12T11:46:44.159534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nums= new_data_3['domain_name_y'].tolist()","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:44.162121Z","iopub.execute_input":"2023-07-12T11:46:44.16253Z","iopub.status.idle":"2023-07-12T11:46:44.169292Z","shell.execute_reply.started":"2023-07-12T11:46:44.162495Z","shell.execute_reply":"2023-07-12T11:46:44.168006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_nums = []\nfor l in range(len(nums)):\n\n        for i in range(1, nums[l]+1):\n        \n            new_nums.append(i)\n   ","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:44.170789Z","iopub.execute_input":"2023-07-12T11:46:44.171244Z","iopub.status.idle":"2023-07-12T11:46:44.290776Z","shell.execute_reply.started":"2023-07-12T11:46:44.171205Z","shell.execute_reply":"2023-07-12T11:46:44.289607Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data['domain_num']=new_nums","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:46:44.292547Z","iopub.execute_input":"2023-07-12T11:46:44.293031Z","iopub.status.idle":"2023-07-12T11:46:44.4544Z","shell.execute_reply.started":"2023-07-12T11:46:44.292987Z","shell.execute_reply":"2023-07-12T11:46:44.453448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:47:03.281872Z","iopub.execute_input":"2023-07-12T11:47:03.283093Z","iopub.status.idle":"2023-07-12T11:47:03.299642Z","shell.execute_reply.started":"2023-07-12T11:47:03.28305Z","shell.execute_reply":"2023-07-12T11:47:03.298512Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data = new_data[['id_prot', 'seq_prot','Pf_id', 'domain_name', 'coord','domain_seq', 'domain_num']]","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:47:09.78561Z","iopub.execute_input":"2023-07-12T11:47:09.786397Z","iopub.status.idle":"2023-07-12T11:47:10.255765Z","shell.execute_reply.started":"2023-07-12T11:47:09.786356Z","shell.execute_reply":"2023-07-12T11:47:10.25467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data.to_csv('/kaggle/working/test_domains', sep=' ')","metadata":{"execution":{"iopub.status.busy":"2023-07-12T11:47:11.206408Z","iopub.execute_input":"2023-07-12T11:47:11.207208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"new_data","metadata":{"execution":{"iopub.status.busy":"2023-06-19T12:48:47.113292Z","iopub.execute_input":"2023-06-19T12:48:47.113841Z","iopub.status.idle":"2023-06-19T12:48:47.132173Z","shell.execute_reply.started":"2023-06-19T12:48:47.113799Z","shell.execute_reply":"2023-06-19T12:48:47.131045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}