Skip to content

Commit

Permalink
Add get_ms2deepscore_embeddings (from sqlite) to the test create sqli…
Browse files Browse the repository at this point in the history
…te file with embeddings
  • Loading branch information
niekdejonge committed Nov 23, 2023
1 parent 9329b22 commit a1367da
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/test_library_files_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ms2query.clean_and_filter_spectra import normalize_and_filter_peaks
from ms2query.create_new_library.library_files_creator import \
LibraryFilesCreator

from ms2query.query_from_sqlite_database import SqliteLibrary

def test_give_already_used_file_name(tmp_path, path_to_general_test_files, hundred_test_spectra):
already_existing_file = os.path.join(tmp_path, "ms2query_library.sqlite")
Expand Down Expand Up @@ -44,14 +44,26 @@ def test_create_s2v_embeddings(tmp_path, path_to_general_test_files, hundred_tes
atol=1e-5)


def test_create_sqlite_file_with_embeddings(hundred_test_spectra, path_to_general_test_files):
def test_create_sqlite_file_with_embeddings(tmp_path, hundred_test_spectra, path_to_general_test_files, expected_ms2ds_embeddings):
library_spectra = [normalize_and_filter_peaks(s) for s in hundred_test_spectra[:20] if s is not None]
test_create_files = LibraryFilesCreator(
hundred_test_spectra[:20],
output_directory=os.path.join(path_to_general_test_files),
library_spectra,
output_directory=os.path.join(tmp_path),
add_compound_classes=False,
ms2ds_model_file_name=os.path.join(path_to_general_test_files,
'ms2ds_siamese_210301_5000_500_400.hdf5'),
s2v_model_file_name=os.path.join(path_to_general_test_files,
"100_test_spectra_s2v_model.model")
)
test_create_files.create_sqlite_file()
sqlite_library = SqliteLibrary(os.path.join(tmp_path, "ms2query_library.sqlite"))
ms2deepscore_embeddings = sqlite_library.get_ms2deepscore_embeddings()
ms2deepscore_embeddings.columns = pd.RangeIndex(start=0,
stop=len(ms2deepscore_embeddings.columns),
step=1)

pd.testing.assert_frame_equal(ms2deepscore_embeddings,
expected_ms2ds_embeddings.loc[:19],
check_exact=False,
atol=1e-5,
check_names=False)

0 comments on commit a1367da

Please sign in to comment.