{
  "id": 433329,
  "title": "Selection submission candidates",
  "url": "/competitions/cafa-5-protein-function-prediction/discussion/433329",
  "author_name": "",
  "post_date": "2023-08-21T09:25:48.139252700Z",
  "votes": 5,
  "comment_count": 4,
  "views": 0,
  "content": "<p>IIt’s time to select the best submission.<br>\nTo do this, you need:</p>\n<p>Take from testsuperset protein that:<br>\nHas not anotation in one of 3 subantologies<br>\nFill this protein during the private timeline.<br>\nI use the history period from 2023-01-01 to 2023-02-01<br>\nAnd 2023-02-01 to 2023-03-01<br>\nAnd calculate the local CAFA metric for all your submission files.</p>\n<p>To calculate local cafa metrics, you can use a code like this:<br>\n<a href=\"https://www.kaggle.com/code/alexandervc/pytorch-keras-etc-3-blend-cafa-metric-etc\" target=\"_blank\">https://www.kaggle.com/code/alexandervc/pytorch-keras-etc-3-blend-cafa-metric-etc</a></p>\n<p>To find data for this, you can use the dataset:<br>\n<a href=\"https://www.kaggle.com/datasets/liudacheldieva/my-dataset\" target=\"_blank\">https://www.kaggle.com/datasets/liudacheldieva/my-dataset</a></p>\n<p>Notebook:<br>\n<a href=\"https://www.kaggle.com/liudacheldieva/test-superset\" target=\"_blank\">https://www.kaggle.com/liudacheldieva/test-superset</a></p>\n<p>How to extract a dataset from testsuperset<br>\nwith no notation n 1 sub ontology at 2023-01-01 and with <br>\nannotation at 2023-02-01:<br>\nYou can get the date by subtracting set from the date 2023-02-01 <br>\nand set on the date 2023-01-01:</p>\n<p>date you can see in line 4:</p>\n<pre><code>column  GO    AC\n</code></pre>\n<p>0    \u0003}q    NaN NaN NaN<br>\n1    AC A2A6H3; B2RY07;  NaN NaN A2A6H3<br>\n2    DT 23-OCT-2007, integrated into UniProtKB/Sw… NaN NaN NaN<br>\n3    DT 11-SEP-2007, sequence version 2. NaN NaN NaN<br>\n4    <strong>DT 28-JUN-2023</strong>, entry version 97.   NaN NaN NaN<br>\n…    … … … …<br>\n13038322    SQ SEQUENCE 73 AA; 8481 MW; 2B13935E3AEF… NaN NaN NaN<br>\n13038323    MPALHIEDLP EKEKLKMEVE QLRKEVKLQR QQVSKCSE…    NaN NaN NaN<br>\n13038324    KNPFKEKGSC VIS  NaN NaN NaN<br>\n13038325    //  NaN NaN NaN<br>\n13038326    ræ\u0003 NaN NaN NaN</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2F9e25c1a4d0c58ef29f3c27bf12afb46c%2F2023-08-21%20%2012.30.51.png?generation=1692614485431109&amp;alt=media\" alt=\"\"></p>\n<p>The object has columns: column, AC, GO</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2Fb122fa78f22cadc59d7482391c00cd97%2F2023-08-21%20%2013.39.19.png?generation=1692615405041785&amp;alt=media\" alt=\"\"></p>\n<p>Task:</p>\n<ul>\n<li>Create a new datetime column that is equal to the date from the column column.</li>\n<li>Set the filter datetime column from 2023-01-01 to 2023-02-01</li>\n<li>Create a new branch column that is equal to 'CCO' MFO' 'BPO' .</li>\n<li>Set a filter on the number of GOs on the date 2023-01-01 in one of the 'CCO' MFO' 'BPO' ==0</li>\n<li>Set a filter on the number of GOs on the date 2023-02-01 in one of the 'CCO' MFO' 'BPO' &gt;0</li>\n<li>Save to private2023-01-01_2023-02-01.tsv</li>\n<li>Calculate competition metric for proteins and one of 'CCO' MFO' 'BPO' From submission.tsv AND one of 'CCO' MFO' 'BPO'</li>\n<li>Compare competition metrics for all your submission.tsv and pick three for Private</li>\n</ul>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2F005f3b6baf246c90e792e27d3bfe3128%2F2023-08-21%20%2012.30.51.png?generation=1692610603508016&amp;alt=media\" alt=\"\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2Fe17968b7914aa9d85dada22e35ff710d%2F2023-08-21%20%2012.33.58.png?generation=1692610623457422&amp;alt=media\" alt=\"\"></p>\n<p>file preprocess:<br>\nVersion 276 </p>\n<p>f = pd.read_csv('/kaggle/input/cafa-submission/tmp5500.txt' , sep = '\\t', names = [\"column\"], encoding= 'unicode_escape')<br>\nf = f[f[\"column\"].notnull()]<br>\nGO = f.copy()</p>\n<p>GO['GO']=f[f[\"column\"].str.contains(\"DR   GO; GO:\")][\"column\"].str.split(';').str[1].str.strip()<br>\nGO['datetime']=pd.to_datetime(GO[[\"GO\",\"entry version\",\"AC\",\"DT\"]][\"DT\"])<br>\nGO['DT']=f[f[\"column\"].str.contains(\"entry version\")][\"column\"].str.split(',').str[1].str.split('\"DT   ').str[1]<br>\nGO['AC']=f[f[\"column\"].str.contains(\"AC \")][\"column\"].str.split(';').str[0].str.split('AC ').str[1].str.strip() </p>\n<p>Up to today version of uniprot in  dataset Version 276 and tier</p>\n<p>code that download uniprot is hear:<br>\nimport numpy as np # linear algebra<br>\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)<br>\nimport os<br>\nfrom tqdm import tqdm<br>\nimport joblib<br>\nimport requests, sys, json<br>\nimport json<br>\nimport shutil<br>\nfrom kaggle_secrets import UserSecretsClient<br>\nimport pathlib</p>\n<h1>protein from test superset:</h1>\n<p>а = pd.read_csv('/kaggle/input/cafa-submission/df_test_seq.tsv', sep=\"\\t\"  ) #141865<br>\nа = а[[\"Id\"]]<br>\nfiles_to_delete = './*.txt'  </p>\n<h1>Change below</h1>\n<p>#<br>\nsecrets = UserSecretsClient()<br>\nos.environ['KAGGLE_USERNAME'] = secrets.get_secret(\"KAGGLE_USERNAME\")<br>\nos.environ['KAGGLE_KEY'] = secrets.get_secret(\"KAGGLE_KEY\")<br>\nos.makedirs('/kaggle/dataset/', exist_ok=True)</p>\n<h1>Change below</h1>\n<p>meta = dict(<br>\n    id=\"liudacheldieva/my-dataset\",<br>\n    title=\"My brand new dataset\",#dataset name<br>\n    isPrivate=True,<br>\n    licenses=[dict(name=\"other\")]<br>\n)<br>\nwith open('/kaggle/dataset/dataset-metadata.json', 'w') as f:<br>\n    json.dump(meta, f)</p>\n<p>os.makedirs('/kaggle/dataset/my-directory', exist_ok=True)</p>\n<h1>start index to load protein to dataset</h1>\n<p>i=5000 #20000 280000</p>\n<p>def get_url(url, **kwargs):<br>\n    response = requests.get(url, **kwargs)<br>\n    if not response.ok:<br>\n        response.raise_for_status()<br>\n        sys.exit()<br>\n    return response</p>\n<p>print(1)<br>\nfor lo in range(0,100):<br>\n  try:<br>\n    uniprot_data_proteins = {}<br>\n    i=i+1<br>\n    start = i<br>\n    for id in list(а[\"Id\"])[start:]:<br>\n        r = get_url(f'https://rest.uniprot.org/unisave/{id}?format=txt')    <br>\n        if i%100 ==0 and i&gt;0:   <br>\n           print(i)   <br>\n        if i%500 ==0 and i&gt;0: #500<br>\n           print(i)<br>\n           joblib.dump(uniprot_data_proteins, f'tmp{i}.txt')<br>\n           uniprot_data_proteins = {}<br>\n        uniprot_data_proteins[str(id)] = r.text   <br>\n        i+=1</p>\n<pre><code>     i% ==  i&gt;: #\n       dirname, _, filenames  .walk():\n         filename  filenames:\n          (..join(dirname, filename))\n          src = ..join(dirname, filename)\n          dst = f\n          shutil.copy2(src, dst)\n      !kaggle datasets version -p  -m  \n\n      files_list = pathlib.Path(.getcwd()).glob(files_to_delete)\n       file_path  files_list:\n        .(file_path)\n\njoblib.(uniprot_data_proteins, f)\n</code></pre>\n<p>except:<br>\n    pass</p>",
  "messages": [
    {
      "id": "2400871",
      "postDate": "08/21/2023 09:25:48",
      "content": "<p>IIt’s time to select the best submission.<br>\nTo do this, you need:</p>\n<p>Take from testsuperset protein that:<br>\nHas not anotation in one of 3 subantologies<br>\nFill this protein during the private timeline.<br>\nI use the history period from 2023-01-01 to 2023-02-01<br>\nAnd 2023-02-01 to 2023-03-01<br>\nAnd calculate the local CAFA metric for all your submission files.</p>\n<p>To calculate local cafa metrics, you can use a code like this:<br>\n<a href=\"https://www.kaggle.com/code/alexandervc/pytorch-keras-etc-3-blend-cafa-metric-etc\" target=\"_blank\">https://www.kaggle.com/code/alexandervc/pytorch-keras-etc-3-blend-cafa-metric-etc</a></p>\n<p>To find data for this, you can use the dataset:<br>\n<a href=\"https://www.kaggle.com/datasets/liudacheldieva/my-dataset\" target=\"_blank\">https://www.kaggle.com/datasets/liudacheldieva/my-dataset</a></p>\n<p>Notebook:<br>\n<a href=\"https://www.kaggle.com/liudacheldieva/test-superset\" target=\"_blank\">https://www.kaggle.com/liudacheldieva/test-superset</a></p>\n<p>How to extract a dataset from testsuperset<br>\nwith no notation n 1 sub ontology at 2023-01-01 and with <br>\nannotation at 2023-02-01:<br>\nYou can get the date by subtracting set from the date 2023-02-01 <br>\nand set on the date 2023-01-01:</p>\n<p>date you can see in line 4:</p>\n<pre><code>column  GO    AC\n</code></pre>\n<p>0    \u0003}q    NaN NaN NaN<br>\n1    AC A2A6H3; B2RY07;  NaN NaN A2A6H3<br>\n2    DT 23-OCT-2007, integrated into UniProtKB/Sw… NaN NaN NaN<br>\n3    DT 11-SEP-2007, sequence version 2. NaN NaN NaN<br>\n4    <strong>DT 28-JUN-2023</strong>, entry version 97.   NaN NaN NaN<br>\n…    … … … …<br>\n13038322    SQ SEQUENCE 73 AA; 8481 MW; 2B13935E3AEF… NaN NaN NaN<br>\n13038323    MPALHIEDLP EKEKLKMEVE QLRKEVKLQR QQVSKCSE…    NaN NaN NaN<br>\n13038324    KNPFKEKGSC VIS  NaN NaN NaN<br>\n13038325    //  NaN NaN NaN<br>\n13038326    ræ\u0003 NaN NaN NaN</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2F9e25c1a4d0c58ef29f3c27bf12afb46c%2F2023-08-21%20%2012.30.51.png?generation=1692614485431109&amp;alt=media\" alt=\"\"></p>\n<p>The object has columns: column, AC, GO</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2Fb122fa78f22cadc59d7482391c00cd97%2F2023-08-21%20%2013.39.19.png?generation=1692615405041785&amp;alt=media\" alt=\"\"></p>\n<p>Task:</p>\n<ul>\n<li>Create a new datetime column that is equal to the date from the column column.</li>\n<li>Set the filter datetime column from 2023-01-01 to 2023-02-01</li>\n<li>Create a new branch column that is equal to 'CCO' MFO' 'BPO' .</li>\n<li>Set a filter on the number of GOs on the date 2023-01-01 in one of the 'CCO' MFO' 'BPO' ==0</li>\n<li>Set a filter on the number of GOs on the date 2023-02-01 in one of the 'CCO' MFO' 'BPO' &gt;0</li>\n<li>Save to private2023-01-01_2023-02-01.tsv</li>\n<li>Calculate competition metric for proteins and one of 'CCO' MFO' 'BPO' From submission.tsv AND one of 'CCO' MFO' 'BPO'</li>\n<li>Compare competition metrics for all your submission.tsv and pick three for Private</li>\n</ul>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2F005f3b6baf246c90e792e27d3bfe3128%2F2023-08-21%20%2012.30.51.png?generation=1692610603508016&amp;alt=media\" alt=\"\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2Fe17968b7914aa9d85dada22e35ff710d%2F2023-08-21%20%2012.33.58.png?generation=1692610623457422&amp;alt=media\" alt=\"\"></p>\n<p>file preprocess:<br>\nVersion 276 </p>\n<p>f = pd.read_csv('/kaggle/input/cafa-submission/tmp5500.txt' , sep = '\\t', names = [\"column\"], encoding= 'unicode_escape')<br>\nf = f[f[\"column\"].notnull()]<br>\nGO = f.copy()</p>\n<p>GO['GO']=f[f[\"column\"].str.contains(\"DR   GO; GO:\")][\"column\"].str.split(';').str[1].str.strip()<br>\nGO['datetime']=pd.to_datetime(GO[[\"GO\",\"entry version\",\"AC\",\"DT\"]][\"DT\"])<br>\nGO['DT']=f[f[\"column\"].str.contains(\"entry version\")][\"column\"].str.split(',').str[1].str.split('\"DT   ').str[1]<br>\nGO['AC']=f[f[\"column\"].str.contains(\"AC \")][\"column\"].str.split(';').str[0].str.split('AC ').str[1].str.strip() </p>\n<p>Up to today version of uniprot in  dataset Version 276 and tier</p>\n<p>code that download uniprot is hear:<br>\nimport numpy as np # linear algebra<br>\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)<br>\nimport os<br>\nfrom tqdm import tqdm<br>\nimport joblib<br>\nimport requests, sys, json<br>\nimport json<br>\nimport shutil<br>\nfrom kaggle_secrets import UserSecretsClient<br>\nimport pathlib</p>\n<h1>protein from test superset:</h1>\n<p>а = pd.read_csv('/kaggle/input/cafa-submission/df_test_seq.tsv', sep=\"\\t\"  ) #141865<br>\nа = а[[\"Id\"]]<br>\nfiles_to_delete = './*.txt'  </p>\n<h1>Change below</h1>\n<p>#<br>\nsecrets = UserSecretsClient()<br>\nos.environ['KAGGLE_USERNAME'] = secrets.get_secret(\"KAGGLE_USERNAME\")<br>\nos.environ['KAGGLE_KEY'] = secrets.get_secret(\"KAGGLE_KEY\")<br>\nos.makedirs('/kaggle/dataset/', exist_ok=True)</p>\n<h1>Change below</h1>\n<p>meta = dict(<br>\n    id=\"liudacheldieva/my-dataset\",<br>\n    title=\"My brand new dataset\",#dataset name<br>\n    isPrivate=True,<br>\n    licenses=[dict(name=\"other\")]<br>\n)<br>\nwith open('/kaggle/dataset/dataset-metadata.json', 'w') as f:<br>\n    json.dump(meta, f)</p>\n<p>os.makedirs('/kaggle/dataset/my-directory', exist_ok=True)</p>\n<h1>start index to load protein to dataset</h1>\n<p>i=5000 #20000 280000</p>\n<p>def get_url(url, **kwargs):<br>\n    response = requests.get(url, **kwargs)<br>\n    if not response.ok:<br>\n        response.raise_for_status()<br>\n        sys.exit()<br>\n    return response</p>\n<p>print(1)<br>\nfor lo in range(0,100):<br>\n  try:<br>\n    uniprot_data_proteins = {}<br>\n    i=i+1<br>\n    start = i<br>\n    for id in list(а[\"Id\"])[start:]:<br>\n        r = get_url(f'https://rest.uniprot.org/unisave/{id}?format=txt')    <br>\n        if i%100 ==0 and i&gt;0:   <br>\n           print(i)   <br>\n        if i%500 ==0 and i&gt;0: #500<br>\n           print(i)<br>\n           joblib.dump(uniprot_data_proteins, f'tmp{i}.txt')<br>\n           uniprot_data_proteins = {}<br>\n        uniprot_data_proteins[str(id)] = r.text   <br>\n        i+=1</p>\n<pre><code>     i% ==  i&gt;: #\n       dirname, _, filenames  .walk():\n         filename  filenames:\n          (..join(dirname, filename))\n          src = ..join(dirname, filename)\n          dst = f\n          shutil.copy2(src, dst)\n      !kaggle datasets version -p  -m  \n\n      files_list = pathlib.Path(.getcwd()).glob(files_to_delete)\n       file_path  files_list:\n        .(file_path)\n\njoblib.(uniprot_data_proteins, f)\n</code></pre>\n<p>except:<br>\n    pass</p>",
      "rawMarkdown": "IIt’s time to select the best submission.\nTo do this, you need:\n\nTake from testsuperset protein that:\nHas not anotation in one of 3 subantologies\nFill this protein during the private timeline.\nI use the history period from 2023-01-01 to 2023-02-01\nAnd 2023-02-01 to 2023-03-01\nAnd calculate the local CAFA metric for all your submission files.\n\nTo calculate local cafa metrics, you can use a code like this:\nhttps://www.kaggle.com/code/alexandervc/pytorch-keras-etc-3-blend-cafa-metric-etc\n\nTo find data for this, you can use the dataset:\nhttps://www.kaggle.com/datasets/liudacheldieva/my-dataset\n\nNotebook:\nhttps://www.kaggle.com/liudacheldieva/test-superset\n\nHow to extract a dataset from testsuperset\nwith no notation n 1 sub ontology at 2023-01-01 and with \nannotation at 2023-02-01:\nYou can get the date by subtracting set from the date 2023-02-01 \nand set on the date 2023-01-01:\n\ndate you can see in line 4:\n\n\n\tcolumn\tGO\tDT\tAC\n0\t\u0003}q\tNaN\tNaN\tNaN\n1\tAC A2A6H3; B2RY07;\tNaN\tNaN\tA2A6H3\n2\tDT 23-OCT-2007, integrated into UniProtKB/Sw...\tNaN\tNaN\tNaN\n3\tDT 11-SEP-2007, sequence version 2.\tNaN\tNaN\tNaN\n4\t**DT 28-JUN-2023**, entry version 97.\tNaN\tNaN\tNaN\n...\t...\t...\t...\t...\n13038322\tSQ SEQUENCE 73 AA; 8481 MW; 2B13935E3AEF...\tNaN\tNaN\tNaN\n13038323\tMPALHIEDLP EKEKLKMEVE QLRKEVKLQR QQVSKCSE...\tNaN\tNaN\tNaN\n13038324\tKNPFKEKGSC VIS\tNaN\tNaN\tNaN\n13038325\t//\tNaN\tNaN\tNaN\n13038326\træ\u0003\tNaN\tNaN\tNaN\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2F9e25c1a4d0c58ef29f3c27bf12afb46c%2F2023-08-21%20%2012.30.51.png?generation=1692614485431109&alt=media)\n\nThe object has columns: column, AC, GO\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2Fb122fa78f22cadc59d7482391c00cd97%2F2023-08-21%20%2013.39.19.png?generation=1692615405041785&alt=media)\n\nTask:\n* Create a new datetime column that is equal to the date from the column column.\n* Set the filter datetime column from 2023-01-01 to 2023-02-01\n* Create a new branch column that is equal to 'CCO' MFO' 'BPO' .\n* Set a filter on the number of GOs on the date 2023-01-01 in one of the 'CCO' MFO' 'BPO' ==0\n* Set a filter on the number of GOs on the date 2023-02-01 in one of the 'CCO' MFO' 'BPO' >0\n* Save to private2023-01-01_2023-02-01.tsv\n* Calculate competition metric for proteins and one of 'CCO' MFO' 'BPO' From submission.tsv AND one of 'CCO' MFO' 'BPO'\n* Compare competition metrics for all your submission.tsv and pick three for Private\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2F005f3b6baf246c90e792e27d3bfe3128%2F2023-08-21%20%2012.30.51.png?generation=1692610603508016&alt=media)\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2Fe17968b7914aa9d85dada22e35ff710d%2F2023-08-21%20%2012.33.58.png?generation=1692610623457422&alt=media)\n\nfile preprocess:\nVersion 276 \n\nf = pd.read_csv('/kaggle/input/cafa-submission/tmp5500.txt' , sep = '\\t', names = [\"column\"], encoding= 'unicode_escape')\nf = f[f[\"column\"].notnull()]\nGO = f.copy()\n\nGO['GO']=f[f[\"column\"].str.contains(\"DR   GO; GO:\")][\"column\"].str.split(';').str[1].str.strip()\nGO['datetime']=pd.to_datetime(GO[[\"GO\",\"entry version\",\"AC\",\"DT\"]][\"DT\"])\nGO['DT']=f[f[\"column\"].str.contains(\"entry version\")][\"column\"].str.split(',').str[1].str.split('\"DT   ').str[1]\nGO['AC']=f[f[\"column\"].str.contains(\"AC \")][\"column\"].str.split(';').str[0].str.split('AC ').str[1].str.strip() \n\nUp to today version of uniprot in  dataset Version 276 and tier\n\ncode that download uniprot is hear:\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nfrom tqdm import tqdm\nimport joblib\nimport requests, sys, json\nimport json\nimport shutil\nfrom kaggle_secrets import UserSecretsClient\nimport pathlib\n#protein from test superset:\nа = pd.read_csv('/kaggle/input/cafa-submission/df_test_seq.tsv', sep=\"\\t\"  ) #141865\nа = а[[\"Id\"]]\nfiles_to_delete = './*.txt'  \n# Change below\n#\nsecrets = UserSecretsClient()\nos.environ['KAGGLE_USERNAME'] = secrets.get_secret(\"KAGGLE_USERNAME\")\nos.environ['KAGGLE_KEY'] = secrets.get_secret(\"KAGGLE_KEY\")\nos.makedirs('/kaggle/dataset/', exist_ok=True)\n# Change below\nmeta = dict(\n    id=\"liudacheldieva/my-dataset\",\n    title=\"My brand new dataset\",#dataset name\n    isPrivate=True,\n    licenses=[dict(name=\"other\")]\n)\nwith open('/kaggle/dataset/dataset-metadata.json', 'w') as f:\n    json.dump(meta, f)\n\nos.makedirs('/kaggle/dataset/my-directory', exist_ok=True)\n\n#start index to load protein to dataset\ni=5000 #20000 280000\n\ndef get_url(url, **kwargs):\n    response = requests.get(url, **kwargs)\n    if not response.ok:\n        response.raise_for_status()\n        sys.exit()\n    return response\n\nprint(1)\nfor lo in range(0,100):\n  try:\n    uniprot_data_proteins = {}\n    i=i+1\n    start = i\n    for id in list(а[\"Id\"])[start:]:\n        r = get_url(f'https://rest.uniprot.org/unisave/{id}?format=txt')    \n        if i%100 ==0 and i>0:   \n           print(i)   \n        if i%500 ==0 and i>0: #500\n           print(i)\n           joblib.dump(uniprot_data_proteins, f'tmp{i}.txt')\n           uniprot_data_proteins = {}\n        uniprot_data_proteins[str(id)] = r.text   \n        i+=1\n    \n        if i%1000 ==0 and i>0: #5000\n          for dirname, _, filenames in os.walk('/kaggle/working'):\n            for filename in filenames:\n              print(os.path.join(dirname, filename))\n              src = os.path.join(dirname, filename)\n              dst = f'/kaggle/dataset/{filename}'\n              shutil.copy2(src, dst)\n          !kaggle datasets version -p \"/kaggle/dataset\" -m \"Updated via notebook\" --dir-mode zip\n      \n          files_list = pathlib.Path(os.getcwd()).glob(files_to_delete)\n          for file_path in files_list:\n            os.remove(file_path)\n    \n    joblib.dump(uniprot_data_proteins, f'tmp{i}.txt')\n  except:\n    pass",
      "votes": null
    },
    {
      "id": "2400903",
      "postDate": "08/21/2023 09:59:13",
      "content": "<p>It may be a good idea to make a notebook out of this post.</p>",
      "rawMarkdown": "It may be a good idea to make a notebook out of this post.",
      "votes": null
    },
    {
      "id": "2400914",
      "postDate": "08/21/2023 10:05:39",
      "content": "<p>You comment on every discussion, but it brings nothing.</p>",
      "rawMarkdown": "You comment on every discussion, but it brings nothing.",
      "votes": null
    },
    {
      "id": "2400974",
      "postDate": "08/21/2023 10:58:38",
      "content": "<p>I think it's good idea to make a notebook out of this post :)</p>\n<p>I create a notebook:<br>\n <a href=\"https://www.kaggle.com/liudacheldieva/test-superset\" target=\"_blank\">https://www.kaggle.com/liudacheldieva/test-superset</a></p>",
      "rawMarkdown": "I think it's good idea to make a notebook out of this post :)\n\nI create a notebook:\n https://www.kaggle.com/liudacheldieva/test-superset",
      "votes": null
    },
    {
      "id": "2401001",
      "postDate": "08/21/2023 11:22:56",
      "content": "<p>Comments by Tilii are very valuable and interesting ! <br>\nMay be even the most valuable in all bioinformatics related competitions. <br>\nAt least for me. </p>",
      "rawMarkdown": "Comments by Tilii are very valuable and interesting ! \nMay be even the most valuable in all bioinformatics related competitions. \nAt least for me.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2400903,
      "author_name": "tilii7",
      "author_url": "",
      "post_date": "08/21/2023 09:59:13",
      "content": "<p>It may be a good idea to make a notebook out of this post.</p>",
      "votes": null,
      "replies": [
        {
          "id": 2400914,
          "author_name": "bejeweled",
          "author_url": "",
          "post_date": "08/21/2023 10:05:39",
          "content": "<p>You comment on every discussion, but it brings nothing.</p>",
          "votes": null,
          "replies": [
            {
              "id": 2400974,
              "author_name": "",
              "author_url": "",
              "post_date": "08/21/2023 10:58:38",
              "content": "<p>I think it's good idea to make a notebook out of this post :)</p>\n<p>I create a notebook:<br>\n <a href=\"https://www.kaggle.com/liudacheldieva/test-superset\" target=\"_blank\">https://www.kaggle.com/liudacheldieva/test-superset</a></p>",
              "votes": null,
              "replies": []
            },
            {
              "id": 2401001,
              "author_name": "alexandervc",
              "author_url": "",
              "post_date": "08/21/2023 11:22:56",
              "content": "<p>Comments by Tilii are very valuable and interesting ! <br>\nMay be even the most valuable in all bioinformatics related competitions. <br>\nAt least for me. </p>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2400871": "IIt’s time to select the best submission.\nTo do this, you need:\n\nTake from testsuperset protein that:\nHas not anotation in one of 3 subantologies\nFill this protein during the private timeline.\nI use the history period from 2023-01-01 to 2023-02-01\nAnd 2023-02-01 to 2023-03-01\nAnd calculate the local CAFA metric for all your submission files.\n\nTo calculate local cafa metrics, you can use a code like this:\nhttps://www.kaggle.com/code/alexandervc/pytorch-keras-etc-3-blend-cafa-metric-etc\n\nTo find data for this, you can use the dataset:\nhttps://www.kaggle.com/datasets/liudacheldieva/my-dataset\n\nNotebook:\nhttps://www.kaggle.com/liudacheldieva/test-superset\n\nHow to extract a dataset from testsuperset\nwith no notation n 1 sub ontology at 2023-01-01 and with \nannotation at 2023-02-01:\nYou can get the date by subtracting set from the date 2023-02-01 \nand set on the date 2023-01-01:\n\ndate you can see in line 4:\n\n\n\tcolumn\tGO\tDT\tAC\n0\t\u0003}q\tNaN\tNaN\tNaN\n1\tAC A2A6H3; B2RY07;\tNaN\tNaN\tA2A6H3\n2\tDT 23-OCT-2007, integrated into UniProtKB/Sw...\tNaN\tNaN\tNaN\n3\tDT 11-SEP-2007, sequence version 2.\tNaN\tNaN\tNaN\n4\t**DT 28-JUN-2023**, entry version 97.\tNaN\tNaN\tNaN\n...\t...\t...\t...\t...\n13038322\tSQ SEQUENCE 73 AA; 8481 MW; 2B13935E3AEF...\tNaN\tNaN\tNaN\n13038323\tMPALHIEDLP EKEKLKMEVE QLRKEVKLQR QQVSKCSE...\tNaN\tNaN\tNaN\n13038324\tKNPFKEKGSC VIS\tNaN\tNaN\tNaN\n13038325\t//\tNaN\tNaN\tNaN\n13038326\træ\u0003\tNaN\tNaN\tNaN\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2F9e25c1a4d0c58ef29f3c27bf12afb46c%2F2023-08-21%20%2012.30.51.png?generation=1692614485431109&alt=media)\n\nThe object has columns: column, AC, GO\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2Fb122fa78f22cadc59d7482391c00cd97%2F2023-08-21%20%2013.39.19.png?generation=1692615405041785&alt=media)\n\nTask:\n* Create a new datetime column that is equal to the date from the column column.\n* Set the filter datetime column from 2023-01-01 to 2023-02-01\n* Create a new branch column that is equal to 'CCO' MFO' 'BPO' .\n* Set a filter on the number of GOs on the date 2023-01-01 in one of the 'CCO' MFO' 'BPO' ==0\n* Set a filter on the number of GOs on the date 2023-02-01 in one of the 'CCO' MFO' 'BPO' >0\n* Save to private2023-01-01_2023-02-01.tsv\n* Calculate competition metric for proteins and one of 'CCO' MFO' 'BPO' From submission.tsv AND one of 'CCO' MFO' 'BPO'\n* Compare competition metrics for all your submission.tsv and pick three for Private\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2F005f3b6baf246c90e792e27d3bfe3128%2F2023-08-21%20%2012.30.51.png?generation=1692610603508016&alt=media)\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4172517%2Fe17968b7914aa9d85dada22e35ff710d%2F2023-08-21%20%2012.33.58.png?generation=1692610623457422&alt=media)\n\nfile preprocess:\nVersion 276 \n\nf = pd.read_csv('/kaggle/input/cafa-submission/tmp5500.txt' , sep = '\\t', names = [\"column\"], encoding= 'unicode_escape')\nf = f[f[\"column\"].notnull()]\nGO = f.copy()\n\nGO['GO']=f[f[\"column\"].str.contains(\"DR   GO; GO:\")][\"column\"].str.split(';').str[1].str.strip()\nGO['datetime']=pd.to_datetime(GO[[\"GO\",\"entry version\",\"AC\",\"DT\"]][\"DT\"])\nGO['DT']=f[f[\"column\"].str.contains(\"entry version\")][\"column\"].str.split(',').str[1].str.split('\"DT   ').str[1]\nGO['AC']=f[f[\"column\"].str.contains(\"AC \")][\"column\"].str.split(';').str[0].str.split('AC ').str[1].str.strip() \n\nUp to today version of uniprot in  dataset Version 276 and tier\n\ncode that download uniprot is hear:\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nfrom tqdm import tqdm\nimport joblib\nimport requests, sys, json\nimport json\nimport shutil\nfrom kaggle_secrets import UserSecretsClient\nimport pathlib\n#protein from test superset:\nа = pd.read_csv('/kaggle/input/cafa-submission/df_test_seq.tsv', sep=\"\\t\"  ) #141865\nа = а[[\"Id\"]]\nfiles_to_delete = './*.txt'  \n# Change below\n#\nsecrets = UserSecretsClient()\nos.environ['KAGGLE_USERNAME'] = secrets.get_secret(\"KAGGLE_USERNAME\")\nos.environ['KAGGLE_KEY'] = secrets.get_secret(\"KAGGLE_KEY\")\nos.makedirs('/kaggle/dataset/', exist_ok=True)\n# Change below\nmeta = dict(\n    id=\"liudacheldieva/my-dataset\",\n    title=\"My brand new dataset\",#dataset name\n    isPrivate=True,\n    licenses=[dict(name=\"other\")]\n)\nwith open('/kaggle/dataset/dataset-metadata.json', 'w') as f:\n    json.dump(meta, f)\n\nos.makedirs('/kaggle/dataset/my-directory', exist_ok=True)\n\n#start index to load protein to dataset\ni=5000 #20000 280000\n\ndef get_url(url, **kwargs):\n    response = requests.get(url, **kwargs)\n    if not response.ok:\n        response.raise_for_status()\n        sys.exit()\n    return response\n\nprint(1)\nfor lo in range(0,100):\n  try:\n    uniprot_data_proteins = {}\n    i=i+1\n    start = i\n    for id in list(а[\"Id\"])[start:]:\n        r = get_url(f'https://rest.uniprot.org/unisave/{id}?format=txt')    \n        if i%100 ==0 and i>0:   \n           print(i)   \n        if i%500 ==0 and i>0: #500\n           print(i)\n           joblib.dump(uniprot_data_proteins, f'tmp{i}.txt')\n           uniprot_data_proteins = {}\n        uniprot_data_proteins[str(id)] = r.text   \n        i+=1\n    \n        if i%1000 ==0 and i>0: #5000\n          for dirname, _, filenames in os.walk('/kaggle/working'):\n            for filename in filenames:\n              print(os.path.join(dirname, filename))\n              src = os.path.join(dirname, filename)\n              dst = f'/kaggle/dataset/{filename}'\n              shutil.copy2(src, dst)\n          !kaggle datasets version -p \"/kaggle/dataset\" -m \"Updated via notebook\" --dir-mode zip\n      \n          files_list = pathlib.Path(os.getcwd()).glob(files_to_delete)\n          for file_path in files_list:\n            os.remove(file_path)\n    \n    joblib.dump(uniprot_data_proteins, f'tmp{i}.txt')\n  except:\n    pass",
    "2400903": "It may be a good idea to make a notebook out of this post.",
    "2400914": "You comment on every discussion, but it brings nothing.",
    "2400974": "I think it's good idea to make a notebook out of this post :)\n\nI create a notebook:\n https://www.kaggle.com/liudacheldieva/test-superset",
    "2401001": "Comments by Tilii are very valuable and interesting ! \nMay be even the most valuable in all bioinformatics related competitions. \nAt least for me."
  },
  "source": "meta"
}