Skip to content

Commit

Permalink
Fixed issues with downloading file and getting latest source version.
Browse files Browse the repository at this point in the history
  • Loading branch information
beaslejt committed Sep 6, 2023
1 parent f979316 commit 08aa891
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions parsers/drugmechdb/src/loadDrugMechDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, test_mode: bool = False, source_data_dir: str = None):
super().__init__(test_mode=test_mode, source_data_dir=source_data_dir)
self.drugmechdb_version = '202307' # TODO temporarily hard coded
#self.drugmechdb_version = self.get_latest_source_version()
self.bindingdb_data_url = [f"https://github.com/SuLab/DrugMechDB/raw/main/"]
self.drugmechdb_data_url = f"https://github.com/SuLab/DrugMechDB/raw/main/"
self.drugmechdb_file_name = f"indication_paths.json"
self.data_files = [self.drugmechdb_file_name]

Expand All @@ -52,12 +52,12 @@ def get_latest_source_version(self) -> str:
gets the latest version of the data
:return:
"""
if self.bindingdb_version:
return self.bindingdb_version
if self.drugmechdb_version:
return self.drugmechdb_version
### The method below gets the database version from the html, but this may be subject to change. ###
binding_db_download_page_response = rq.get('https://www.bindingdb.org/rwd/bind/chemsearch/marvin/Download.jsp')
version_index = binding_db_download_page_response.text.index('BindingDB_All_2D_') + 17
bindingdb_version = binding_db_download_page_response.text[version_index:version_index + 6]
drugmechdb_download_page_response = rq.get('https://www.bindingdb.org/rwd/bind/chemsearch/marvin/Download.jsp')
version_index = drugmechdb_download_page_response.text.index('BindingDB_All_2D_') + 17
bindingdb_version = drugmechdb_download_page_response.text[version_index:version_index + 6]

return f"{bindingdb_version}"

Expand All @@ -68,7 +68,7 @@ def get_data(self) -> int:
data_puller = GetData()
i=0
for source in self.data_files:
source_url = f"{self.bindingdb_data_url[i]}{source}"
source_url = f"{self.drugmechdb_data_url}{source}"
data_puller.pull_via_http(source_url, self.data_path)
i+=1
return True
Expand Down

0 comments on commit 08aa891

Please sign in to comment.