Skip to content

Commit

Permalink
Merge pull request #59 from Mesnage-Org/test-ftrs
Browse files Browse the repository at this point in the history
Add test for ftrs files
  • Loading branch information
Ankur-AVP-Patel committed Jan 26, 2022
2 parents 733292a + ef34fe1 commit eaeb672
Show file tree
Hide file tree
Showing 6 changed files with 4,045 additions and 15 deletions.
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)

0 comments on commit eaeb672

Please sign in to comment.