diff --git a/manifest.json b/manifest.json index 14f7414..655cd3d 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "url" : "https://github.com/rjawesome" }, "dumper" : { - "data_url" : ["https://www.bindingdb.org/bind/downloads/BindingDB_All_2022m5.tsv.zip"], + "data_url" : ["https://www.bindingdb.org/bind/downloads/BindingDB_All_202405_tsv.zip"], "uncompress" : true }, "uploader" : { diff --git a/parser.py b/parser.py index 384e3ee..3d23c47 100644 --- a/parser.py +++ b/parser.py @@ -1,13 +1,21 @@ import csv -import json import os from typing import Dict + +""" +Dumped file name +""" +DATA_FILE_NAME = 'BindingDB_All_202405.tsv' + + """ Fields of the Imported CSV: - The array BASE_COLS defines the first columns in each row with data mainly pertaining to the compound. - A sequence of columns is repeated which creates the data for each protein in the row, which is stored in REPEAT_SUBJECT_COLS. + +- Reference: https://www.bindingdb.org/bind/chemsearch/marvin/BindingDB-TSV-Format.pdf """ REPEAT_SUBJECT_COLS = [ 'BindingDB Target Chain Sequence', @@ -30,7 +38,7 @@ 'Ligand InChI Key', 'BindingDB MonomerID', 'BindingDB Ligand Name', - 'Target Name Assigned by Curator or DataSource', + 'Target Name', 'Target Source Organism According to Curator or DataSource', 'Ki (nM)', 'IC50 (nM)', @@ -42,6 +50,7 @@ 'Temp (C)', 'Curation/DataSource', 'Article DOI', + 'BindingDB Entry DOI', 'PMID', 'PubChem AID', 'Patent Number', @@ -109,7 +118,7 @@ "uniprot_type": "all", "relation": False }, - "Target Name Assigned by Curator or DataSource": { + "Target Name": { "location": "subject.name", "type": "split_colon", "uniprot_type": "all", @@ -181,6 +190,12 @@ "uniprot_type": "all", "relation": True }, + "BindingDB Entry DOI": { + "location": "relation.bindingdb_entry_doi", + "type": "string", + "uniprot_type": "all", + "relation": True + }, "PMID": { "location": "relation.pmid", "type": "string", @@ -327,13 +342,13 @@ }, "UniProt (SwissProt) Secondary ID(s) of Target Chain": { "location": "subject.uniprot.secondary_accession", - "type": "split_comma", + "type": "split_space", "uniprot_type": "swissprot", "relation": False }, "UniProt (SwissProt) Alternative ID(s) of Target Chain": { "location": "subject.uniprot.alternative_accession", - "type": "split_comma", + "type": "split_space", "uniprot_type": "swissprot", "relation": False }, @@ -357,13 +372,13 @@ }, "UniProt (TrEMBL) Secondary ID(s) of Target Chain": { "location": "subject.uniprot.secondary_accession", - "type": "split_comma", + "type": "split_space", "uniprot_type": "trembl", "relation": False }, "UniProt (TrEMBL) Alternative ID(s) of Target Chain": { "location": "subject.uniprot.alternative_accession", - "type": "split_comma", + "type": "split_space", "uniprot_type": "trembl", "relation": False } @@ -423,6 +438,8 @@ def process_field(field_name: str, value: str): field_type = COLUMN_DATA[field_name]['type'] if field_type == "int": return int(value) + if field_type == "split_space": + return value.split(' ') if field_type == "split_comma": return value.split(',') if field_type == "split_semicolon": @@ -446,13 +463,13 @@ def read_csv(file: str, delim: str): continue else: base = {'object': {}, 'subject': {}, 'relation': {}} - for j in range(37): + for j in range(38): if row[j] is not None and row[j] != '' and row[j] != 'NULL': val = process_field(BASE_COLS[j], row[j]) set_field(base, BASE_COLS[j], val) - repeats = int(row[36]) # Number of Protein Chains in Target - pos = 37 + repeats = int(row[37]) # Number of Protein Chains in Target + pos = 38 for j in range(repeats): info_1 = special_copy(base) info_2 = special_copy(base) @@ -499,8 +516,7 @@ def merge(main: Dict[str, any], other: Dict[str, any]): def load_data(data_folder): docs = {} row_num = 0 - for row in read_csv(os.path.join(data_folder, './BindingDB_All.tsv'), '\t'): - # print(row['subject']['uniprot']) + for row in read_csv(os.path.join(data_folder, './' + DATA_FILE_NAME), '\t'): try: entry_name = row['subject']['uniprot']['id'] primary_id = row['subject']['uniprot']['accession'] @@ -531,7 +547,7 @@ def load_data(data_folder): yield docs[doc_id] -# def main(): +# type: ignore # def main(): # from time import time # cnt = 0