Skip to content

Commit a45efab

Browse files
Tighten idperformance test setup (#18)
1 parent 6d9e62c commit a45efab

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tests/test_idperformance.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,19 +270,21 @@ def _time_search(engine: SimpleSearchEngine, experiment: Py_MSExperiment) -> tup
270270

271271
def test_simple_search_engine_identifies_targets(tmp_path):
272272
fasta_path = _build_fasta(tmp_path)
273-
protein_stream = ProteinStream.from_fasta(fasta_path)
274-
peptide_stream = protein_stream.digest(min_length=6, max_length=10)
275-
digested = list(peptide_stream)
276-
targets = [entry.peptide for entry in digested]
273+
targets = [
274+
entry.peptide
275+
for entry in ProteinStream.from_fasta(fasta_path).digest(min_length=6, max_length=10)
276+
]
277277
assert len(targets) == 2
278278
decoys = [_reverse_sequence(peptide) for peptide in targets]
279279

280-
spectra_records = list(
281-
protein_stream.digest(min_length=6, max_length=10)
282-
.theoretical_spectra(generator_params=GENERATOR_PARAMS)
283-
)
284-
experiment = _build_experiment(spectra_records, decoys[0])
285-
processed = experiment.filter_top_n_peaks(200).normalize_to_tic()
280+
processed = _build_experiment(
281+
list(
282+
ProteinStream.from_fasta(fasta_path)
283+
.digest(min_length=6, max_length=10)
284+
.theoretical_spectra(generator_params=GENERATOR_PARAMS)
285+
),
286+
decoys[0],
287+
).filter_top_n_peaks(200).normalize_to_tic()
286288

287289
assert all(math.isclose(spec.total_ion_current, 1.0, rel_tol=1e-6) for spec in processed.ms2_spectra())
288290
assert all(spec.precursor_mass is not None for spec in processed.ms2_spectra())
@@ -291,8 +293,7 @@ def test_simple_search_engine_identifies_targets(tmp_path):
291293
psms = engine.search(processed)
292294
assert len(psms) == 3
293295

294-
scored = _compute_q_values(psms)
295-
confident = scored[scored["q_value"] <= 0.01]
296+
confident = _compute_q_values(psms).query("q_value <= 0.01")
296297
assert len(confident) == 2
297298
assert set(confident["Sequence"]) == {seq.toString() for seq in targets}
298299

0 commit comments

Comments
 (0)