Skip to content

Commit

Permalink
Remove pickled embeddings from tests and update select_files_for_ms2q…
Browse files Browse the repository at this point in the history
…uery
  • Loading branch information
niekdejonge committed Nov 26, 2023
1 parent 39f9273 commit 9d1fd33
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 42 deletions.
3 changes: 1 addition & 2 deletions ms2query/ms2library.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ def select_files_for_ms2query(file_names: List[str], files_to_select=None):
"""Selects the files needed for MS2Library based on their file extensions. """
dict_with_file_extensions = \
{"sqlite": ".sqlite", "s2v_model": ".model", "ms2ds_model": ".hdf5",
"ms2query_model": ".onnx", "s2v_embeddings": "s2v_embeddings.pickle",
"ms2ds_embeddings": "ms2ds_embeddings.pickle"}
"ms2query_model": ".onnx"}
if files_to_select is not None:
dict_with_file_extensions = {key: value for key, value in dict_with_file_extensions.items()
if key in files_to_select}
Expand Down
16 changes: 0 additions & 16 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,3 @@ def hundred_test_spectra(path_to_general_test_files):
def expected_tanimoto_scores_df(path_to_general_test_files):
return pd.read_csv(os.path.join(path_to_general_test_files,
"tanimoto_scores_100_test_spectra.csv"), index_col=0)


@pytest.fixture(scope="package")
def expected_ms2ds_embeddings(path_to_general_test_files):
expected_embeddings = load_pickled_file(os.path.join(
path_to_general_test_files,
"100_test_spectra_ms2ds_embeddings.pickle"))
return expected_embeddings


@pytest.fixture(scope="package")
def expected_s2v_embeddings(path_to_general_test_files):
expected_embeddings = load_pickled_file(os.path.join(
path_to_general_test_files,
"100_test_spectra_s2v_embeddings.pickle"))
return expected_embeddings
Binary file not shown.
Binary file not shown.
24 changes: 0 additions & 24 deletions tests/test_library_files_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,6 @@ def test_give_already_used_file_name(tmp_path, path_to_general_test_files, hundr
LibraryFilesCreator(hundred_test_spectra, tmp_path)


def test_create_ms2ds_embeddings(tmp_path, path_to_general_test_files,
hundred_test_spectra,
expected_ms2ds_embeddings,
ms2deepscore_model_file_name):
"""Tests store_ms2ds_embeddings"""
library_spectra = [normalize_and_filter_peaks(s) for s in hundred_test_spectra if s is not None]
embeddings = create_ms2ds_embeddings(ms2ds_model=load_ms2ds_model(ms2deepscore_model_file_name),
list_of_spectra=library_spectra)
pd.testing.assert_frame_equal(embeddings, expected_ms2ds_embeddings,
check_exact=False,
atol=1e-5)


def test_create_s2v_embeddings(tmp_path, path_to_general_test_files, hundred_test_spectra,
expected_s2v_embeddings,
spec2vec_model_file_name):
"""Tests store_ms2ds_embeddings"""
library_spectra = [normalize_and_filter_peaks(s) for s in hundred_test_spectra if s is not None]

embeddings = create_s2v_embeddings(Word2Vec.load(spec2vec_model_file_name), library_spectra)
pd.testing.assert_frame_equal(embeddings, expected_s2v_embeddings,
check_exact=False,
atol=1e-5)

def check_sqlite_files_are_equal(new_sqlite_file_name, reference_sqlite_file, check_metadata=True):
"""Raises an error if the two sqlite files are not equal"""
# Test if file is made
Expand Down

0 comments on commit 9d1fd33

Please sign in to comment.