nf-core / quantms

Quantitative mass spectrometry workflow. Currently supports proteomics experiments with complex experimental designs for DDA-LFQ, DDA-Isobaric and DIA-LFQ quantification.
https://nf-co.re/quantms
MIT License
31 stars 0 forks source link

Tests for the Python scripts in `./bin` #130

Closed fabianegli closed 7 months ago

fabianegli commented 1 year ago

Description of feature

It would be great to have tests for all the quantms pipeline's Python code.

The automated tests would make the development much more enjoyable and have the benefit to speed up development.

There are a couple of considerations:

Some example of tests for ./bin/diann_convert.py

"""Tests for test_diann_convert.py
"""

from diann_convert import calculate_coverage

def test_calculate_coverage_multiple_incomplete():
    assert calculate_coverage("WATEROVERTHEDUCKSBACK", {"WATER", "DUCK"}) == 0.42857142857142855
def test_calculate_coverage_repeated_complete():
    assert calculate_coverage("DUCKDUCKDUCK", {"DUCK"}) == 1.0
def test_calculate_coverage_incomplete():
    assert calculate_coverage("WATEROVERTHEDUCK", {"DUCK"}) == 0.25
def test_calculate_coverage_overlap_partial_complete():
    assert calculate_coverage("WATER", {"WAT", "TER"}) == 1.0
def test_calculate_coverage_overlap_partial_incomplete():
    assert calculate_coverage("WATERGLASS", {"WAT", "TER"}) == 0.5

NB: the tests require all dependencies of the scripts and hence can not be run on all infrastructure. e.g. there is no openms version for MacOS. So tests might have to be run in containers or some other solution would have to be found.

jpfeuffer commented 1 year ago

Note: (py)OpenMS actually works on macOS. It's just biocondas CI that works in suboptimal ways.

ypriverol commented 7 months ago

I will close this issue for now because we don't have time to this issue now.