Skip to content

Commit

Permalink
integration test 1
Browse files Browse the repository at this point in the history
Integration test added for main function
  • Loading branch information
agmcfarland committed Aug 2, 2024
1 parent 1ed8284 commit 2accac1
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ sftp-config.json
tests/testthat/Rplots.pdf
*.pptx

/tests/quantify_edits/
/tests/quantify_edits/

/tests/testthat/integration_test_1/
1 change: 1 addition & 0 deletions R/quantify_edits.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ quantify_edits <- function(
spec_info_combo_overview_table = df_annotations,
abundance_cutoff = run_params$abundance_cutoff)


bam_files <- list_bam_files(base_directory = run_params$base_directory)

logr::log_print(bam_files)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ devtools::install_github('agmcfarland/BEiGUIDE')

# Usage


5 changes: 3 additions & 2 deletions tests/testthat/test-bam_file_to_table.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
test_that("bam_file_to_table works", {

subsetted_test_data_path <- testthat::test_path('testdata', 'integration_1')

bam_file_path <- testthat::test_path('testdata', 'process_data', 'align', 'GTSP5614-neg-3.bin2.bam')
bam_file_path <- file.path(subsetted_test_data_path, 'process_data', 'align', 'GTSP5610-neg-1.bin1.bam')

file.exists(bam_file_path)

df_bam <- bam_file_to_table(bam_file_path)

testthat::expect_equal(nrow(df_bam), 172)
testthat::expect_equal(nrow(df_bam), 398787)

testthat::expect_equal(ncol(df_bam), 9)

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-list_bam_files.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
testthat::test_that("list_bam_files works", {

bam_list <- list_bam_files(base_directory = testthat::test_path('testdata'))
subsetted_test_data_path <- testthat::test_path('testdata', 'integration_1')

testthat::expect_equal(length(bam_list), 1)
bam_list <- list_bam_files(base_directory = subsetted_test_data_path)

testthat::expect_equal(bam_list[1], testthat::test_path('testdata', 'process_data', 'align', 'GTSP5614-neg-3.bin2.bam'))
testthat::expect_equal(length(bam_list), 6)

})
8 changes: 5 additions & 3 deletions tests/testthat/test-make_edit_site_table.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
test_that("make_edit_site_table works", {

df_ft_data <- pull_ft_data_tables(base_directory = testthat::test_path('testdata'))
subsetted_test_data_path <- testthat::test_path('testdata', 'integration_1')

df_annotations <- pull_combo_overview_table(base_directory = testthat::test_path('testdata'))
df_ft_data <- pull_ft_data_tables(base_directory = subsetted_test_data_path)

df_annotations <- pull_combo_overview_table(base_directory = subsetted_test_data_path)

df_edit_sites <- make_edit_site_table(
ft_data_table = df_ft_data,
spec_info_combo_overview_table = df_annotations,
abundance_cutoff = 3)

testthat::expect_equal(53, nrow(df_edit_sites))
testthat::expect_equal(11, nrow(df_edit_sites))

testthat::expect_equal(13, ncol(df_edit_sites))

Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-parallel_bam_file_to_table.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
test_that("parallel_bam_file_list_to_table works", {

subsetted_test_data_path <- testthat::test_path('testdata', 'integration_1')

bam_file_path <- testthat::test_path('testdata', 'process_data', 'align', 'GTSP5614-neg-3.bin2.bam')
bam_file_path <- file.path(subsetted_test_data_path, 'process_data', 'align', 'GTSP5610-neg-1.bin1.bam')

file.exists(bam_file_path)

df_bam <- parallel_bam_file_list_to_table(bam_file_path)

testthat::expect_equal(nrow(df_bam), 172)
testthat::expect_equal(nrow(df_bam), 398787)

testthat::expect_equal(ncol(df_bam), 10)

Expand Down
7 changes: 5 additions & 2 deletions tests/testthat/test-pull_combo_overview_table.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
testthat::test_that("pull_combo_overview_table works", {
df_combo_overview <- pull_combo_overview_table(base_directory = testthat::test_path('testdata'))

testthat::expect_equal(15, nrow(df_combo_overview))
subsetted_test_data_path <- testthat::test_path('testdata', 'integration_1')

df_combo_overview <- pull_combo_overview_table(base_directory = subsetted_test_data_path)

testthat::expect_equal(2, nrow(df_combo_overview))

testthat::expect_equal(7, ncol(df_combo_overview))

Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-pull_ft_data_tables.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
testthat::test_that("pull_ft_data_tables works", {

df_ft_data <- pull_ft_data_tables(base_directory = testthat::test_path('testdata'))
subsetted_test_data_path <- testthat::test_path('testdata', 'integration_1')

testthat::expect_equal(14362, nrow(df_ft_data))
df_ft_data <- pull_ft_data_tables(base_directory = subsetted_test_data_path)

testthat::expect_equal(5815, nrow(df_ft_data))

testthat::expect_equal(9, ncol(df_ft_data))

Expand Down
27 changes: 27 additions & 0 deletions tests/testthat/test-quantify_edits.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
test_that("quantify_edits works", {

test_data <- testthat::test_path('testdata', 'integration_1')

test_output <- file.path(testthat::test_path('integration_test_1'))

dir.create(test_output, showWarnings = FALSE)

quantify_edits(
base_directory = test_data,
output_directory = test_output,
n_processors = 8
)

df_edit_sites <- readRDS(file.path(test_output, 'quantify_edits', 'edit_sites.rds'))

df_base_percentages <- readRDS(file.path(test_output, 'quantify_edits', 'base_percentages.rds'))

testthat::expect_equal(nrow(df_edit_sites), 11)

testthat::expect_equal(ncol(df_edit_sites), 13)

testthat::expect_equal(nrow(df_base_percentages), 147)

testthat::expect_equal(ncol(df_base_percentages), 16)

})
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 2accac1

Please sign in to comment.