Skip to content

Commit

Permalink
added tests in R, Python and core Java implementations related to Mas…
Browse files Browse the repository at this point in the history
  • Loading branch information
ssmehta committed Nov 14, 2023
1 parent 030b4a5 commit dc775bb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,24 @@ public void testSplashHistogramBinBoundaries() {
}
}

/**
* tests for the SPLASH histogram issue reported in:
* https://github.com/MassBank/MassBank-data/issues/248
*/
@Test
public void testSplashItHistogramSmallIntensities() {

Splash splash = getHashImpl();

Spectrum spectrum = new SpectrumImpl(Arrays.asList(
new Ion(44.998, 0.2),
new Ion(80.0261, 0.1),
new Ion(93.0321, 0.4),
new Ion(108.0227, 0.3)

), SpectraType.MS);

String hash = splash.splashIt(spectrum);
assertEquals(hash, "splash10-052f-9300000000-5cd70311703e2423a1c5");
}
}
16 changes: 16 additions & 0 deletions python/tests/test_splash.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,21 @@ def test_spectrum_3(self):

self.assertEqual(Splash().splash(Spectrum(spectrum_string, SpectrumType.MS)), splash_code)

def test_small_intensities(self):
# tests for the initial SPLASH issue reported in:
# https://github.com/MassBank/MassBank-data/issues/248
spectrum_string = "44.998:0.2 80.0261:0.1 93.0321:0.4 108.0227:0.3"
splash_code = 'splash10-052f-9300000000-5cd70311703e2423a1c5'

self.assertEqual(Splash().splash(Spectrum(spectrum_string, SpectrumType.MS)), splash_code)

# using MassBank scaled intensities
# should yield the same histogram blocks but different hash block
spectrum_string = "44.998:499 80.0261:249 93.0321:999 108.0227:749"
splash_code = 'splash10-052f-9300000000-a485843aed0475c0a1b9'

self.assertEqual(Splash().splash(Spectrum(spectrum_string, SpectrumType.MS)), splash_code)


if __name__ == '__main__':
unittest.main()
16 changes: 16 additions & 0 deletions splashR/tests/testthat/test-small-intensities.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
library(splashR)
context("Test suite")

test_that("small-intensities", {
# tests for the SPLASH histogram issue reported in:
# https://github.com/MassBank/MassBank-data/issues/248
s <- cbind(mz=c(44.998, 80.0261, 93.0321, 108.0227),
intensity=c(0.2, 0.1, 0.4, 0.3))
expect_equal(getSplash(s), "splash10-052f-9300000000-5cd70311703e2423a1c5")

# using MassBank scaled intensities
# should yield the same histogram blocks but different hash block
s <- cbind(mz=c(44.998, 80.0261, 93.0321, 108.0227),
intensity=c(499, 249, 999, 749))
expect_equal(getSplash(s), "splash10-052f-9300000000-a485843aed0475c0a1b9")
})

0 comments on commit dc775bb

Please sign in to comment.