Skip to content

Commit

Permalink
added tests for the mass tolerance calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
picciama committed Aug 3, 2023
1 parent 1eb11af commit 62b78b2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/unit_tests/test_fragments.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,31 @@ def test_compute_peptide_masses_with_invalid_mod(self):
"""Negative testing of computation of peptide mass with unknown modification in mod string."""
seq = "SEQUENC[UNIMOD:0]E"
self.assertRaises(AssertionError, fragments.compute_peptide_mass, seq)


class TestMassTolerances(unittest.TestCase):
"""Testing the mass tolerance calculations in various scenarios."""

def test_mass_tol_with_ppm(self):
"""Test get_min_max_mass with a user defined ppm measure."""
window = fragments.get_min_max_mass(
mass_analyzer="FTMS", mass=10.0, mass_tolerance=15, unit_mass_tolerance="ppm"
)
self.assertEqual(window, (9.99985, 10.00015))

def test_mass_tol_with_da(self):
"""Test get_min_max_mass with a user defined da measure."""
window = fragments.get_min_max_mass(
mass_analyzer="FTMS", mass=10.0, mass_tolerance=0.3, unit_mass_tolerance="da"
)
self.assertEqual(window, (9.7, 10.3))

def test_mass_tol_with_defaults(self):
"""Test get_min_max_mass with mass analyzer defaults."""
window_ftms = fragments.get_min_max_mass(mass_analyzer="FTMS", mass=10.0)
window_itms = fragments.get_min_max_mass(mass_analyzer="ITMS", mass=10.0)
window_tof = fragments.get_min_max_mass(mass_analyzer="TOF", mass=10.0)

self.assertEqual(window_ftms, (9.9998, 10.0002))
self.assertEqual(window_tof, (9.9996, 10.0004))
self.assertEqual(window_itms, (9.65, 10.35))

0 comments on commit 62b78b2

Please sign in to comment.