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

wrapper tests #37

Merged
merged 16 commits into from
Jul 19, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {
stage('Test R code') {
steps {
echo 'Testing R code....'
sh 'docker run -i --rm --network="host" -w="/tmp" -v $(pwd | sed "s|/var/jenkins_home|/data/home/jenkins|g")/R/tests:/tmp zsibio.ii.pw.edu.pl:50009/zsi-bio-toolset Rscript run_tests.R' }
sh 'docker run -i --rm --network="host" -w="/tmp" -v $(pwd | sed "s|/var/jenkins_home|/data/home/jenkins|g")/R:/tmp zsibio.ii.pw.edu.pl:50009/zsi-bio-toolset Rscript tests/run_tests.R' }
post {
always {
junit '**R/tests/*.xml'
Expand Down
6 changes: 3 additions & 3 deletions R/CNVCALLER.RUNNER/inst/run_cnvcaller.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ read_parameters <- function(tabName, id, conn){
chr=chr))
}

save_calls <- function(calls, conn){
save_calls <- function(calls, table_name, parameters_id, conn){
if (nrow(calls) != 0) {
for(i in 1:nrow(calls)) {
call <- calls[i,]
query <- paste("INSERT INTO TEST_CALLS (parameters_id, sample_name, chr, cnv, st_bp, ed_bp, length_kb, st_exon, ed_exon, raw_cov, norm_cov, copy_no, lratio, mBIC) VALUES ('", opt$id, "','", call[1], "','", call[2], "','", call[3], "','", call[4], "','", call[5], "','", call[6], "','", call[7], "','", call[8], "','", call[9], "','", call[10], "','", call[11], "','", call[12], "','", call[13], "');", sep="")
query <- paste("INSERT INTO ", table_name, " (parameters_id, sample_name, chr, cnv, st_bp, ed_bp, length_kb, st_exon, ed_exon, raw_cov, norm_cov, copy_no, lratio, mBIC) VALUES ('", parameters_id, "','", call[1], "','", call[2], "','", call[3], "','", call[4], "','", call[5], "','", call[6], "','", call[7], "','", call[8], "','", call[9], "','", call[10], "','", call[11], "','", call[12], "','", call[13], "');", sep="")
dbSendUpdate(conn, query)
}
}
Expand Down Expand Up @@ -101,7 +101,7 @@ cov_table <- read_coverage_table(parameters$cov_table, conn_psql,parameters$chr)
#print(cov_table)
calls <- run_caller(parameters, cov_table)
#print(calls)
save_calls(calls, conn_psql)
save_calls(calls, "TEST_CALLS", opt$id, conn_psql)

dbDisconnect(conn_hive)
dbUnloadDriver(drv_hive)
Expand Down
2 changes: 1 addition & 1 deletion R/CODEXCOV/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Description: An extended implementation of the CODEX package in R. It extends
parameters.
Depends:
R (>= 3.2.3),
CODEX (== 1.8.0),
CODEX (== 1.9.0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we upgrade Codex version?

testthat (== 1.0.2.9000),
devtools (== 1.13.2),
DBI (== 0.7),
Expand Down
7 changes: 4 additions & 3 deletions R/tests/run_tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ if (length(which(installed.packages()[,1] == "CODEX")) == 0){
biocLite("CODEX")
}

setwd('tests/')
devtools::install('../CNVCALLER.RUNNER')
devtools::install('../CODEXCOV')

library(testthat)
#source("test_functions_CODEX.R")
#source("test_functions_HMZDelFinder.R")
#capture.output(test_dir(".", reporter="junit"),file="results.xml")
out <- capture.output(test_dir(".", reporter="junit"))
writeLines(out[grep("<?xml version=", out):length(out)], "results.xml")
89 changes: 89 additions & 0 deletions R/tests/test_CODEXCOV_wrapper.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
library(testthat)
library(CNVCALLER.RUNNER)

context("Testing run_wrapper_CODEXCOV function")

test_that("basic test for run_wrapper_CODEXCOV function, without calls",{
mapp_thresh <- "0.9"
cov_thresh_from <- "20"
cov_thresh_to <- "4000"
length_thresh_from <- "0"
length_thresh_to <- "200000"
gc_thresh_from <- "5"
gc_thresh_to <- "100"
K_from <- "1"
K_to <- "3"
lmax <- "200"
cov_table <- as.data.frame(matrix(data=c("NA12044",6,"2",17211,173310,151.636363636364,
"NA11829",4,"2",16712,167190,100,
"NA07051",7,"2",30275,304310,155.929936305732,
"NA07051",1,"2",14642,148820,160.3900414937759,
"NA12044",8,"2",69069,700290,581.723204994797,
"NA12044",9,"2",129133,1292530,30.4462809917355,
"NA12044",10,"2",228233,2283540,223.311475409836,
"NA11829",9,"2",129133,1292530,270.4462809917355,
"NA11829",10,"2",228233,2283540,223.311475409836,
"NA11994",9,"2",129133,1292530,180.4462809917355,
"NA11994",3,"2",15751,159900,500.29357798165138,
"NA11829",5,"2",16834,170740,400.19502074688797,
"NA07051",3,"2",15751,159900,900.75313807531381,
"NA18504",5,"2",16834,170740,110.46887966805,
"NA07051",4,"2",16599,167080,100.72815533980583,
"NA12044",4,"2",16599,166400,100.30952380952381,
"NA11994",2,"2",14943,150630,103.900826446281,
"NA18504",6,"2",17211,173310,81.801652892562,
"NA18504",10,"2",228233,2283540,223.311475409836,
"NA12044",2,"2",14943,150630,76.0661157024793,
"NA07051",8,"2",69069,700290,691.77627471384,
"NA07051",2,"2",14943,150630,170.0826446280992,
"NA18504",1,"2",14642,148820,35.8630705394191,
"NA18504",8,"2",69069,700290,240.60561914672,
"NA12044",3,"2",15751,159900,200.88202247191011,
"NA18504",9,"2",129133,1292530,200.4462809917355,
"NA11829",6,"2",17211,173310,148.95041322314,
"NA18504",2,"2",14943,150630,230.7603305785124,
"NA11829",8,"2",69069,700290,1022.60561914672,
"NA07051",5,"2",16834,170740,76.448132780083,
"NA12044",7,"2",30275,304310,126.821656050955,
"NA11994",4,"2",16599,167130,100.13913043478261,
"NA18504",3,"2",15751,159900,26.0833333333333,
"NA12044",5,"2",16834,170740,400.4070796460177,
"NA18504",7,"2",30275,304310,161.554140127389,
"NA11829",2,"2",14943,150630,22.289256198347,
"NA11994",10,"2",228233,2283540,200.17213114754098,
"NA07051",10,"2",228233,2283540,166.918032786885,
"NA11994",7,"2",30275,304310,172.980891719745,
"NA11994",6,"2",17211,173310,163.595041322314,
"NA11994",8,"2",69069,700290,88.76482830385,
"NA07051",9,"2",129133,1292530,320.4132231404959,
"NA11829",1,"2",14642,148820,51.244813278008,
"NA11829",7,"2",30275,304310,132.828025477707,
"NA11994",5,"2",16834,170740,600.70124481327801,
"NA11994",1,"2",14642,148820,146.879668049793,
"NA07051",6,"2",17211,173310,47.4876033057851,
"NA11829",3,"2",15751,159900,130.2958333333333,
"NA12044",1,"2",14642,148820,111.020746887967,
"NA18504",4,"2",16599,167170,300.58823529411765), nrow=50, ncol=6, byrow=TRUE))
colnames(cov_table) <- c("sample_name", "target_id", "chr", "pos_min", "pos_max", "cov_avg")
cov_table[,"sample_name"] <- sapply(cov_table[,"sample_name"], toString)
cov_table[,"target_id"] <- as.integer(cov_table[,"target_id"])
cov_table[,"chr"] <- sapply(cov_table[,"chr"], toString)
cov_table[,"pos_min"] <- as.integer(as.character(cov_table[,"pos_min"]))
cov_table[,"pos_max"] <- as.integer(as.character(cov_table[,"pos_max"]))
cov_table[,"cov_avg"] <- as.numeric(as.character(cov_table[,"cov_avg"]))
calls <- run_wrapper_CODEXCOV(mapp_thresh,
cov_thresh_from,
cov_thresh_to,
length_thresh_from,
length_thresh_to,
gc_thresh_from,
gc_thresh_to,
K_from,
K_to,
lmax,
cov_table)
expect_equal(length(calls), 0)
})



Empty file.
2 changes: 0 additions & 2 deletions R/tests/test_functions_CODEX.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
library(testthat)
if (length(which(installed.packages()[,1] == "devtools")) == 0){install.packages("devtools",repos="https://cloud.r-project.org/")}
if (length(which(installed.packages()[,1] == "CODEXCOV")) == 0){devtools::install("../CODEXCOV")}
library(CODEXCOV)

context("Testing gcmapp1 function")
Expand Down
Loading