Skip to content

Commit 832c506

Browse files
committed
more tests
1 parent 0116c6f commit 832c506

4 files changed

Lines changed: 58 additions & 16 deletions

File tree

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ def zoom_raw_file(zoom_raw_path):
1616
raw = RawFile(zoom_raw_path)
1717
yield raw
1818
raw.close()
19+
20+
@pytest.fixture(scope="session")
21+
def angiotensin_raw_file():
22+
path = os.path.join("test_data", "Angiotensin_AllScans.raw")
23+
if not os.path.exists(path):
24+
pytest.skip(f"Test file {path} not found")
25+
raw = RawFile(path)
26+
yield raw
27+
raw.close()

tests/test_centroid.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
import pytest
23

34

45
def test_centroid_stream_retrieval(zoom_raw_file):
@@ -39,3 +40,22 @@ def test_is_centroid_scan(zoom_raw_file):
3940
for i in range(1, 5):
4041
is_c = zoom_raw_file.is_centroid_scan_from_scan_number(i)
4142
assert isinstance(is_c, bool)
43+
44+
def test_centroid_stream_angiotensin(angiotensin_raw_file):
45+
# Scan 1: 526 peaks
46+
cs_1 = angiotensin_raw_file.get_centroid_stream(1, False)
47+
assert cs_1 is not None
48+
assert cs_1.length == 526
49+
assert cs_1.base_peak_mass == pytest.approx(432.9000244140625)
50+
assert cs_1.base_peak_intensity == pytest.approx(447502208.0)
51+
52+
# Scan 2: 39 peaks
53+
cs_2 = angiotensin_raw_file.get_centroid_stream(2, False)
54+
assert cs_2 is not None
55+
assert cs_2.length == 39
56+
57+
# Scan 3: 313 peaks
58+
cs_3 = angiotensin_raw_file.get_centroid_stream(3, False)
59+
assert cs_3 is not None
60+
assert cs_3.length == 313
61+
assert cs_3.base_peak_mass == pytest.approx(110.07129669189453)

tests/test_collision_energy.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,26 @@ def test_isolation_width(raw_file):
6565
assert reaction.isolation_width_offset == pytest.approx(0.0), f"Scan {scan_num} Reaction isolation width offset mismatch"
6666

6767

68-
@pytest.fixture(scope="session")
69-
def angiotensin_raw_file():
70-
path = os.path.join("test_data", "Angiotensin_AllScans.raw")
71-
if not os.path.exists(path):
72-
pytest.skip(f"Test file {path} not found")
73-
raw = RawFile(path)
74-
yield raw
75-
raw.close()
76-
7768
def test_isolation_width_angiotensin(angiotensin_raw_file):
78-
scan_event = angiotensin_raw_file.get_scan_event_for_scan_number(3)
79-
actual_width = scan_event.get_isolation_width(0)
80-
assert actual_width == pytest.approx(2.0), "Scan 3 ScanEvent isolation width mismatch"
81-
82-
reaction = scan_event.get_reaction(0)
83-
assert reaction.isolation_width == pytest.approx(2.0), "Scan 3 Reaction isolation width mismatch"
84-
assert reaction.isolation_width_offset == pytest.approx(0.0), "Scan 3 Reaction isolation width offset mismatch"
69+
# Check values on scan 3 (IW 2.0, CE 30.0)
70+
scan_event_3 = angiotensin_raw_file.get_scan_event_for_scan_number(3)
71+
assert scan_event_3.get_isolation_width(0) == pytest.approx(2.0), "Scan 3 ScanEvent isolation width mismatch"
72+
reaction_3 = scan_event_3.get_reaction(0)
73+
assert reaction_3.isolation_width == pytest.approx(2.0), "Scan 3 Reaction isolation width mismatch"
74+
assert reaction_3.isolation_width_offset == pytest.approx(0.0), "Scan 3 Reaction isolation width offset mismatch"
75+
assert reaction_3.collision_energy == pytest.approx(30.0), "Scan 3 CE mismatch"
76+
assert reaction_3.precursor_mass == pytest.approx(432.9000244140625)
77+
78+
# Check values on scan 10 (Different CE)
79+
scan_event_10 = angiotensin_raw_file.get_scan_event_for_scan_number(10)
80+
reaction_10 = scan_event_10.get_reaction(0)
81+
assert reaction_10.isolation_width == pytest.approx(2.0)
82+
assert reaction_10.collision_energy == pytest.approx(53.98562240600586)
83+
assert reaction_10.precursor_mass == pytest.approx(433.90216064453125)
84+
85+
# Check values on scan 1000 (IW 1.6, Different CE)
86+
scan_event_1000 = angiotensin_raw_file.get_scan_event_for_scan_number(1000)
87+
reaction_1000 = scan_event_1000.get_reaction(0)
88+
assert reaction_1000.isolation_width == pytest.approx(1.600000023841858)
89+
assert reaction_1000.collision_energy == pytest.approx(121.46764373779297)
90+
assert reaction_1000.precursor_mass == pytest.approx(649.8494262695312)

tests/test_metadata.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ def test_metadata_from_zoom_file(zoom_raw_file):
1313
assert ai.tray_index == -1
1414
assert ai.tray_shape == TrayShape.Circular
1515
assert ai.vial_index == -1
16+
17+
def test_metadata_from_angiotensin_file(angiotensin_raw_file):
18+
method_count = angiotensin_raw_file.get_instrument_methods_count()
19+
assert method_count == 1
20+
21+
method = angiotensin_raw_file.get_instrument_method(0)
22+
assert len(method) == 4374

0 commit comments

Comments
 (0)