Skip to content

Commit

Permalink
Merge pull request #216 from RECETOX/wverastegui/issue185
Browse files Browse the repository at this point in the history
Implemented unit test for the function load.lcms.R
  • Loading branch information
hechth authored Apr 24, 2024
2 parents 70be153 + ae8b451 commit c1937cd
Show file tree
Hide file tree
Showing 9 changed files with 12,333 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/r-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Create conda environment
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: recetox-aplcms-dev
auto-update-conda: true
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [dev] - unreleased
### Added
- added tests for mzdata and mzxml formats [#216](https://github.com/RECETOX/recetox-aplcms/pull/216)
### Changed
### Removed

Expand Down
2 changes: 1 addition & 1 deletion conda/environment-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ dependencies:
- anaconda-client
- conda-build
- conda-verify
- r-base =4.2
- r-base
4 changes: 2 additions & 2 deletions conda/environment-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ channels:
- bioconda
- defaults
dependencies:
- r-base =4.2
- r-base
- icu <=70.1
- r-mass
- r-rgl
- bioconductor-mzR
- bioconductor-mzR ==2.28.0
- r-splines2
- r-doparallel
- r-foreach
Expand Down
4 changes: 2 additions & 2 deletions conda/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ channels:
- bioconda
- defaults
dependencies:
- r-base =4.2
- r-base
- r-mass
- r-rgl
- bioconductor-mzR
- bioconductor-mzR ==2.28.0
- r-splines2
- r-doparallel
- r-foreach
Expand Down
8 changes: 4 additions & 4 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ build:

requirements:
host:
- r-base =4.2
- r-base
- r-mass
- r-rgl
- bioconductor-mzR
- bioconductor-mzR ==2.28.0
- r-splines2
- r-doparallel
- r-foreach
Expand All @@ -37,10 +37,10 @@ requirements:
- r-tibble

run:
- r-base =4.2
- r-base
- r-mass
- r-rgl
- bioconductor-mzR
- bioconductor-mzR ==2.28.0
- r-splines2
- r-doparallel
- r-foreach
Expand Down
4 changes: 3 additions & 1 deletion tests/remote-files/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ https://gitlab.ics.muni.cz/umsa/umsa-files/-/raw/master/testdata/recetox-aplcms/
https://gitlab.ics.muni.cz/umsa/umsa-files/-/raw/master/testdata/recetox-aplcms/input/RCX_06_shortened.mzML
https://gitlab.ics.muni.cz/umsa/umsa-files/-/raw/master/testdata/recetox-aplcms/input/RCX_07_shortened.mzML
https://gitlab.ics.muni.cz/umsa/umsa-files/-/raw/master/testdata/recetox-aplcms/input/RCX_08_shortened.mzML
https://gitlab.ics.muni.cz/umsa/umsa-files/-/raw/master/testdata/recetox-aplcms/input/single_eic.mzml
https://gitlab.ics.muni.cz/umsa/umsa-files/-/raw/master/testdata/recetox-aplcms/input/single_eic.mzml
https://gitlab.ics.muni.cz/umsa/umsa-files/-/raw/master/testdata/recetox-aplcms/input/alg3.mzdata
https://gitlab.ics.muni.cz/umsa/umsa-files/-/raw/master/testdata/recetox-aplcms/input/test_file.mzXML
12,279 changes: 12,279 additions & 0 deletions tests/testdata/test0_copy.mzxml

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions tests/testthat/test-load.lcms.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
create_test_case <- function(filename, mz_length, rt_length, intensities_length) {
list(
filename = filename,
expected_type = "list",
expected_lengths = c(mz = mz_length, rt = rt_length, intensities = intensities_length),
expected_num_na = c(mz = 0, rt = 0, intensities = 0)
)
}

patrick::with_parameters_test_that(
"test load.lcms reads different file types",
{
# Arrange: Set up test inputs
testdata <- file.path("..", "testdata")
input_path <- file.path(testdata, "input", filename)

# Act: Execute the function with the test inputs
data <- load.lcms(input_path)

# Assert: Verify the function output matches expected results
# Check that the function returns an object of the expected type
actual_type <- data
testthat::expect_type(actual_type, expected_type)

# Check the lengths of the vectors in the list
actual_lengths <- lengths(data)
testthat::expect_equal(actual_lengths, expected_lengths)

# Check the number of NA values in each vector
actual_num_na <- sapply(data, function(x) sum(is.na(x)))
testthat::expect_equal(actual_num_na, expected_num_na)
},

patrick::cases(
test_case_1 = create_test_case("RCX_06_shortened.mzML", 879476, 879476, 879476),
test_case_2 = create_test_case("test_file.mzXML", 9647575, 9647575, 9647575),
test_case_3 = create_test_case("alg3.mzdata", 543894, 543894, 543894)
)
)

0 comments on commit c1937cd

Please sign in to comment.