Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for ftrs files #59

Merged
merged 6 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3,987 changes: 3,987 additions & 0 deletions data/baseline_output_ftrs.csv

Large diffs are not rendered by default.

File renamed without changes.
Binary file modified data/ftrs_test_data.ftrs
Binary file not shown.
17 changes: 12 additions & 5 deletions make_baseline.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import pgfinder.matching as matching

# Set mass database and modifications
csv_filepath = "data/masses/e_coli_monomer_masses.csv"
mq_file_name = "data/maxquant_test_data.txt"

raw_data = matching.maxquant_file_reader(mq_file_name)
theo_masses = matching.theo_masses_reader(csv_filepath)
mod_test = ['Sodium','Potassium','Anhydro','DeAc','Deacetyl_Anhydro','Nude','Decay','Amidation','Amidase','Double_Anh','multimers_Glyco']
results = matching.data_analysis(raw_data, theo_masses, 0.5, mod_test, 10)

results.to_csv("data/baseline_output.csv")
# Generate maxquant baseline
mq_file_name = "data/maxquant_test_data.txt"
raw_data_mq = matching.maxquant_file_reader(mq_file_name)
results = matching.data_analysis(raw_data_mq, theo_masses, 0.5, mod_test, 10)
results.to_csv("data/baseline_output_mq.csv")

# Generate ftrs baseline
ftrs_file_name = "data/ftrs_test_data.ftrs"
raw_data_ftrs = matching.ftrs_reader(ftrs_file_name)
results = matching.data_analysis(raw_data_ftrs, theo_masses, 0.5, mod_test, 10)
results.to_csv("data/baseline_output_ftrs.csv")
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ To run tests:
pytest
```

The tests check output against an [expected baseline](data/baseline_output.csv). To recreate this (e.g. in response to improvements to the scientific "correctness" of the code ouput), use:
The tests check output against an expected baseline for [Maxquant](data/baseline_output.csv) or [FTRS](data/baseline_output_ftrs.csv). To recreate this (e.g. in response to improvements to the scientific "correctness" of the code ouput), use:

```
python make_baseline.py
```

and replace the exisiting file.
and replace the existing file.

**This software is licensed as specified by the [GPL License](COPYING) and [LGPL License](COPYING.LESSER).**
52 changes: 44 additions & 8 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,59 @@
import pandas as pd
import pytest
import pgfinder.matching as matching
import pgfinder.validation as validation

def test_matching_baseline():
'''Test that output of the major function in the module is unchanged.'''
masses_file_name = "data/masses/e_coli_monomer_masses.csv"
mq_file_name = "data/maxquant_test_data.txt"
@pytest.fixture
def masses_file_name():
return "data/masses/e_coli_monomer_masses.csv"

@pytest.fixture
def mod_test():
"""Modifications used in regression testing."""
return ['Sodium','Potassium','Anhydro','DeAc','Deacetyl_Anhydro','Nude','Decay','Amidation','Amidase','Double_Anh','multimers_Glyco']

@pytest.fixture
def mq_file_name():
return "data/maxquant_test_data.txt"

@pytest.fixture
def mq_baseline_df():
return pd.read_csv("data/baseline_output_mq.csv", index_col=0)

@pytest.fixture
def ftrs_file_name():
return "data/ftrs_test_data.ftrs"

@pytest.fixture
def ftrs_baseline_df():
return pd.read_csv("data/baseline_output_ftrs.csv", index_col=0)

def test_matching_mq_baseline(masses_file_name, mq_file_name, mod_test, mq_baseline_df):
'''Test that output of the major function in the module is unchanged.'''

raw_data = matching.maxquant_file_reader(mq_file_name)
validation.validate_raw_data_df(raw_data)

theo_masses = matching.theo_masses_reader(masses_file_name)
validation.validate_theo_masses_df(theo_masses)

mod_test = ['Sodium','Potassium','Anhydro','DeAc','Deacetyl_Anhydro','Nude','Decay','Amidation','Amidase','Double_Anh','multimers_Glyco']

validation.validate_enabled_mod_list(mod_test)

output_df = matching.data_analysis(raw_data, theo_masses, 0.5, mod_test, 10)

baseline_df = pd.read_csv("data/baseline_output.csv", index_col=0)
pd.testing.assert_frame_equal(output_df, mq_baseline_df)

pd.testing.assert_frame_equal(output_df, baseline_df)
def test_matching_ftrs_baseline(masses_file_name, ftrs_file_name, mod_test, ftrs_baseline_df):
"""Test that output of the major function in the module is unchanged."""

raw_data = matching.ftrs_reader(ftrs_file_name)
validation.validate_raw_data_df(raw_data)

theo_masses = matching.theo_masses_reader(masses_file_name)
validation.validate_theo_masses_df(theo_masses)

validation.validate_enabled_mod_list(mod_test)

output_df = matching.data_analysis(raw_data, theo_masses, 0.5, mod_test, 10)

pd.testing.assert_frame_equal(output_df, ftrs_baseline_df)