Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Mar 24, 2024
1 parent 5e85c2f commit bcdea19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 3 additions & 4 deletions tests/testthat/test-vcf-comp.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ rawvcf <- system.file("extdata", "raw.gt.vcf.gz", package="vcfppR")
imputedvcf <- system.file("extdata", "imputed.gt.vcf.gz", package="vcfppR")

test_that("can work for F1 score", {
samples <- "HG00133,HG00143,HG00262"
res <- vcfcomp(imputedvcf, imputedvcf, stats = "f1", format=c("GT", 'GT'), samples = samples)
samples <- "HG00133,HG00262"
res <- vcfcomp(rawvcf, imputedvcf, stats = "f1", format=c("GT", 'GT'), samples = samples)
expect_identical(paste0(res$samples, collapse = ","), samples)
expect_identical(res$f1, rep(1,3))
expect_identical(res$f1, rep(1,2))
})

test_that("can work for correlation r2 between DS and GT", {
res <- vcfcomp(imputedvcf, imputedvcf)
r2 <- res$r2
expect_identical(as.numeric(res$r2[5,]), c(16, 16, 1, 1))
})
4 changes: 1 addition & 3 deletions tests/testthat/test-vcf-writer.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
library(testthat)

test_that("vcfwriter: writing variant works", {
## skip_on_os(c("windows"), arch = NULL)
outvcf <- file.path(paste0(tempfile(), ".vcf.gz"))
bw <- vcfwriter$new(outvcf, "VCF4.3")
bw$addLine('##ALT=<ID=NON_REF,Description="Represents any possible alternative allele at this location">')
Expand All @@ -12,12 +11,11 @@ test_that("vcfwriter: writing variant works", {
bw$writeline(s1)
bw$close()
## tests
skip_on_os(c("windows"), arch = NULL)
br <- vcfreader$new(outvcf)
print(br$header())
br$variant()
s2 <- gsub("\n", "", br$string())
expect_identical(br$chr(), "chr20")
expect_identical(s1, s2)
s2 <- br$line()
expect_identical(s1, s2)
})
Expand Down

0 comments on commit bcdea19

Please sign in to comment.