From 9eb84cdfb1797b64df3ea0d7513d2940f6f86eed Mon Sep 17 00:00:00 2001 From: Andrea Manica Date: Mon, 13 May 2024 21:12:10 +0100 Subject: [PATCH] improve vcf tests --- R/utils.R | 1 + tests/testthat/test_gen_tibble.R | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/R/utils.R b/R/utils.R index d5e957b9..c4f90b14 100644 --- a/R/utils.R +++ b/R/utils.R @@ -21,6 +21,7 @@ tidy_dist_matrix<- function(mat){ xy %>% tibble::as_tibble() %>% dplyr::mutate(value=mat[xy]) } + # stop if not diploid stopifnot_diploid <- function(x){ if (attr(x,"ploidy")!=2){ diff --git a/tests/testthat/test_gen_tibble.R b/tests/testthat/test_gen_tibble.R index 4274fac6..a0d3750a 100644 --- a/tests/testthat/test_gen_tibble.R +++ b/tests/testthat/test_gen_tibble.R @@ -91,6 +91,11 @@ test_that("gen_tibble from files",{ # now read in vcf vcf_path <- system.file("extdata/pop_a.vcf", package = "tidypopgen") pop_a_vcf_gt <- gen_tibble(vcf_path, quiet=TRUE,backingfile = tempfile()) - all.equal(show_genotypes(pop_a_gt),show_genotypes(pop_a_vcf_gt)) + expect_true(all.equal(show_genotypes(pop_a_gt),show_genotypes(pop_a_vcf_gt))) + # reload it in chunks + pop_a_vcf_gt2 <- gen_tibble(vcf_path, quiet=TRUE,backingfile = tempfile(), loci_per_chunk=2) + expect_true(all.equal(show_genotypes(pop_a_vcf_gt2),show_genotypes(pop_a_vcf_gt))) + expect_true(all.equal(show_loci(pop_a_vcf_gt2),show_loci(pop_a_vcf_gt))) + # we should add similar tests for pop b, which has missing data })