diff --git a/R/greedyMix.R b/R/greedyMix.R index 9c12cbf..ad55286 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -1,15 +1,16 @@ #' @title Clustering of individuals #' @param data data file #' @param format Format of the data c("FASTA", "VCF" ,"SAM", or "GenePop") +#' @param verbose if \code{TRUE}, prints extra output information #' @importFrom utils read.delim #' @export -greedyMix <- function(data, format) { +greedyMix <- function(data, format, verbose = TRUE) { format <- tolower(format) if (format == "fasta") { out <- load_fasta(data) } else if (format == "vcf") { - stop("VCF files not yet supported." ) # TODO #17: implement load_vcf() + out <- vcfR::read.vcfR(data, verbose = verbose) } else if (format == "sam") { stop("SAM files not yet supported." ) # TODO #18: implement load_sam() diff --git a/inst/ext/vcf_example.vcf b/inst/ext/vcf_example.vcf new file mode 100644 index 0000000..a2f470c --- /dev/null +++ b/inst/ext/vcf_example.vcf @@ -0,0 +1,8 @@ +##fileformat=VCFv4.2 +##FORMAT= +##FORMAT= +##FORMAT= +#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT SAMP001 SAMP002 +20 1291018 rs11449 G A . PASS . GT 0/0 0/1 +20 2300608 rs84825 C T . PASS . GT:GP 0/1:. 0/1:0.03,0.97,0 +20 2301308 rs84823 T G . PASS . GT:PL ./.:. 1/1:10,5,0 \ No newline at end of file diff --git a/tests/testthat/test-greedyMix.R b/tests/testthat/test-greedyMix.R index 71f1ccd..9104176 100644 --- a/tests/testthat/test-greedyMix.R +++ b/tests/testthat/test-greedyMix.R @@ -39,13 +39,19 @@ context("Opening files on greedyMix") df_fasta <- greedyMix( data = paste(path_inst, "FASTA_clustering_haploid.fasta", sep="/"), - format ="fasta" + format = "FASTA" +) +df_vcf <- greedyMix( + data = paste(path_inst, "vcf_example.vcf", sep="/"), + format = "VCF", + verbose = FALSE ) # TODO #17: add example reading VCF # TODO #18: add example reading SAM # TODO #19: add example reading Genpop test_that("Files are imported correctly", { expect_equal(dim(df_fasta), c(5, 99)) + expect_equal(dim(df_vcf), c(variants = 2, fix_cols = 8, gt_cols = 3)) }) context("Linkage")