Skip to content

Commit

Permalink
Merge pull request #187 from iomega/classes_in_sqlite
Browse files Browse the repository at this point in the history
Classes in sqlite
  • Loading branch information
niekdejonge committed May 18, 2023
2 parents 32ca7d5 + 662e3d2 commit cc16f33
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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).

## [1.0.1]
Small bug fixes
- Allow URLLiberror when loading in compound classes
- Update readme with zenodo files


## [1.0.0]
### Added
- Added compound classes to sqlite file
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ ms2query --library .\folder_to_store_the_library --download --ionmode positive
```

Alternatively all model files can be manually downloaded from
https://zenodo.org/record/7753249#.ZBmO_sLMJPY for positive mode and
https://zenodo.org/record/7753267#.ZBmPYsLMJPY for negative mode.
https://zenodo.org/record/6124552 for positive mode and
https://zenodo.org/record/7104184 for negative mode.

#### Preprocessing mass spectra
MS2Query is run on all MS2 spectra in a spectrum file.
Expand Down Expand Up @@ -126,7 +126,6 @@ Before running the script, replace the variables `ms2query_library_files_directo

This script will first download files for a default MS2Query library.
This default library is trained on the [GNPS library](https://gnps.ucsd.edu/) from 2021-15-12.
Automatic downloading can take long, alternatively all model files can be manually downloaded from https://zenodo.org/record/7753249 for positive mode and https://zenodo.org/record/7753267 for negative mode. When manually downloading, store all these files in one directory and set ms2query_library_files_directory to this directory.

After downloading, a **library search** and an **analog search** is performed on the query spectra in your directory (`ms2_spectra_directory`).
The results generated by MS2Query, are stored as csv files in a results directory within the same directory as your query spectra.
Expand Down
2 changes: 1 addition & 1 deletion ms2query/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.0'
__version__ = '1.0.1'
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import urllib
from http.client import InvalidURL
from typing import List, Optional

import pandas as pd
Expand Down Expand Up @@ -33,7 +34,7 @@ def do_url_request(url: str) -> [bytes, None]:
try:
with urllib.request.urlopen(url) as inf:
result = inf.read()
except (urllib.error.HTTPError, urllib.error.URLError):
except (urllib.error.HTTPError, urllib.error.URLError, InvalidURL):
# apparently the request failed
result = None
except ConnectionAbortedError:
Expand Down
29 changes: 15 additions & 14 deletions tests/test_train_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
from ms2query.create_new_library.train_models import clean_and_train_models
from ms2query.ms2library import create_library_object_from_one_dir, MS2Library

# @pytest.mark.integration
# def test_train_all_models(path_to_general_test_files, tmp_path):
# path_to_test_spectra = os.path.join(path_to_general_test_files, "1000_test_spectra.pickle")
# models_folder = os.path.join(tmp_path, "models")
# clean_and_train_models(path_to_test_spectra,
# "positive",
# models_folder,
# {"ms2ds_fraction_validation_spectra": 2,
# "ms2ds_epochs": 2,
# "spec2vec_iterations": 2,
# "ms2query_fraction_for_making_pairs": 400}
# )
# ms2library = create_library_object_from_one_dir(models_folder)
# assert isinstance(ms2library, MS2Library)

@pytest.mark.integration
def test_train_all_models(path_to_general_test_files, tmp_path):
path_to_test_spectra = os.path.join(path_to_general_test_files, "1000_test_spectra.pickle")
models_folder = os.path.join(tmp_path, "models")
clean_and_train_models(path_to_test_spectra,
"positive",
models_folder,
{"ms2ds_fraction_validation_spectra": 2,
"ms2ds_epochs": 2,
"spec2vec_iterations": 2,
"ms2query_fraction_for_making_pairs": 400}
)
ms2library = create_library_object_from_one_dir(models_folder)
assert isinstance(ms2library, MS2Library)

0 comments on commit cc16f33

Please sign in to comment.