From 3f6045f1aa50c5b9fcc8dcdfdabaacf1998ca9f4 Mon Sep 17 00:00:00 2001 From: niekdejonge Date: Tue, 21 Mar 2023 11:58:56 +0100 Subject: [PATCH 1/5] Define most up to date zenodo dois in function --- README.md | 5 +---- ms2query/__init__.py | 4 +--- ms2query/run_ms2query.py | 13 +++++++++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 02d0f138..d2293e54 100644 --- a/README.md +++ b/README.md @@ -136,11 +136,8 @@ ms2query_library_files_directory = "./ms2query_library_files" ms2_spectra_directory = ion_mode = # Fill in "positive" or "negative" to indicate for which ion mode you would like to download the library -zenodo_DOIs = {"positive": 7753249, - "negative": 7753267} - # Downloads pretrained models and files for MS2Query (>2GB download) -download_zenodo_files(zenodo_DOIs[ion_mode], +download_zenodo_files(ion_mode, ms2query_library_files_directory) # Create a MS2Library object diff --git a/ms2query/__init__.py b/ms2query/__init__.py index 6de7d15d..b68def1f 100644 --- a/ms2query/__init__.py +++ b/ms2query/__init__.py @@ -70,9 +70,7 @@ def command_line(): additional_metadata_columns=additional_columns) if args.download: assert ion_mode is not None, "Ion mode should be specified by adding --ion_mode" - zenodo_DOIs = {"positive": 7753249, - "negative": 7753267} - download_zenodo_files(zenodo_DOIs[ion_mode], + download_zenodo_files(ion_mode, ms2query_library_files_directory) if ms2_spectra_location is not None: diff --git a/ms2query/run_ms2query.py b/ms2query/run_ms2query.py index 5795c11f..c31438dd 100644 --- a/ms2query/run_ms2query.py +++ b/ms2query/run_ms2query.py @@ -6,8 +6,16 @@ from ms2query.utils import load_matchms_spectrum_objects_from_file, SettingsRunMS2Query, return_non_existing_file_name -def download_zenodo_files(zenodo_doi: int, - dir_to_store_files:str): +def zenodo_dois(ionisation_mode): + "Returns the most up to date DOI for Zenodo" + zenodo_DOIs = {"positive": 7753249, + "negative": 7753267} + assert ionisation_mode in zenodo_DOIs, "Expected 'positive' or 'negative' as input" + return zenodo_DOIs[ionisation_mode] + + +def download_zenodo_files(ionisation_mode: int, + dir_to_store_files: str): """Downloads files from Zenodo Args: @@ -20,6 +28,7 @@ def download_zenodo_files(zenodo_doi: int, """ if not os.path.exists(dir_to_store_files): os.mkdir(dir_to_store_files) + zenodo_doi = zenodo_dois(ionisation_mode) file_names_metadata_url = "https://zenodo.org/api/records/" + str(zenodo_doi) with urlopen(file_names_metadata_url) as zenodo_metadata_file: file_names_metadata_json: dict = json.loads(zenodo_metadata_file.read()) From 97d465e2f7c164f41bcdd757161bb7232220a904 Mon Sep 17 00:00:00 2001 From: niekdejonge Date: Tue, 21 Mar 2023 12:01:40 +0100 Subject: [PATCH 2/5] Define most up to date zenodo dois in function --- CHANGELOG.md | 3 +++ ms2query/__version__.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08eff6e2..19def431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.7.1] +- Define the newest zenodo DOI in one location. + ## [0.7.0] - Store random forest model in Onnx format diff --git a/ms2query/__version__.py b/ms2query/__version__.py index a71c5c7f..f0788a87 100644 --- a/ms2query/__version__.py +++ b/ms2query/__version__.py @@ -1 +1 @@ -__version__ = '0.7.0' +__version__ = '0.7.1' From da16f498380c896699df6136e132956613688cbd Mon Sep 17 00:00:00 2001 From: niekdejonge Date: Tue, 21 Mar 2023 12:05:53 +0100 Subject: [PATCH 3/5] Update manual zenodo link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d2293e54..d4d2f94a 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ ms2query --library .\folder_to_store_the_library --download --ionmode positive ``` Alternatively all model files can be manually downloaded from -https://zenodo.org/record/6997924#.YvuonS5BxPY for positive mode and -https://zenodo.org/record/7107654#.Yy3BeKRBxPY for negative mode. +https://zenodo.org/record/7753249#.ZBmO_sLMJPY for positive mode and +https://zenodo.org/record/7753267#.ZBmPYsLMJPY for negative mode. #### Preprocessing mass spectra MS2Query is run on all MS2 spectra in a spectrum file. From 29e76ba9ff10614a990ccd753ea33017291279c9 Mon Sep 17 00:00:00 2001 From: niekdejonge Date: Tue, 21 Mar 2023 12:18:04 +0100 Subject: [PATCH 4/5] Disable test for downloading --- tests/test_run_ms2query.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tests/test_run_ms2query.py b/tests/test_run_ms2query.py index 29162d8f..69c9ea54 100644 --- a/tests/test_run_ms2query.py +++ b/tests/test_run_ms2query.py @@ -17,25 +17,13 @@ def test_download_default_models(tmp_path): """Tests downloading small files from zenodo The files are a total of 20 MB from https://zenodo.org/record/7108049#.Yy2nPKRBxPY""" - dir_to_store_test_files = os.path.join(tmp_path, "positive_model") - download_zenodo_files(7108049, dir_to_store_test_files) - assert os.path.exists(dir_to_store_test_files) - assert os.path.exists(os.path.join(dir_to_store_test_files, - "GNPS_15_12_2021_neg_test_250_inchikeys.pickle")) - assert os.path.exists(os.path.join(dir_to_store_test_files, - "GNPS_15_12_2021_neg_test_3000_spectra.pickle")) - assert os.path.exists(os.path.join(dir_to_store_test_files, - "GNPS_15_12_2021_pos_test_250_inchikeys.pickle")) - assert os.path.exists(os.path.join(dir_to_store_test_files, - "GNPS_15_12_2021_pos_test_3000_spectra.pickle")) - run_test = False # Run test is set to false, since downloading takes too long for default testing if run_test: dir_to_store_positive_files = os.path.join(tmp_path, "positive_model") dir_to_store_negative_files = os.path.join(tmp_path, "negative_model") - download_zenodo_files(6997924, dir_to_store_positive_files) - download_zenodo_files(7107654, dir_to_store_negative_files) + download_zenodo_files("positive", dir_to_store_positive_files) + download_zenodo_files("negative", dir_to_store_negative_files) assert os.path.exists(dir_to_store_positive_files) assert os.path.exists(dir_to_store_negative_files) pos_ms2library = create_library_object_from_one_dir(dir_to_store_positive_files) From 58aaf96fcf2caf37d9b39f18640744a28dd9cda9 Mon Sep 17 00:00:00 2001 From: niekdejonge Date: Tue, 21 Mar 2023 12:18:44 +0100 Subject: [PATCH 5/5] Change typehinting --- ms2query/run_ms2query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ms2query/run_ms2query.py b/ms2query/run_ms2query.py index c31438dd..89fb47ab 100644 --- a/ms2query/run_ms2query.py +++ b/ms2query/run_ms2query.py @@ -14,7 +14,7 @@ def zenodo_dois(ionisation_mode): return zenodo_DOIs[ionisation_mode] -def download_zenodo_files(ionisation_mode: int, +def download_zenodo_files(ionisation_mode: str, dir_to_store_files: str): """Downloads files from Zenodo