Skip to content

Commit

Permalink
improve vcf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dramanica committed May 13, 2024
1 parent a7e28ec commit 9eb84cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
7 changes: 6 additions & 1 deletion tests/testthat/test_gen_tibble.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

})

0 comments on commit 9eb84cd

Please sign in to comment.