Skip to contents

Checks if the VCF file contains any variants.

Usage

vcf_is_empty(x)

Arguments

x

Path to VCF file.

Value

TRUE if there is at least one variant in the VCF, FALSE otherwise.

Examples

x <- system.file("extdata/umccrise/snv/somatic-ensemble-PASS.vcf.gz", package = "gpgr")
(y <- vcf_is_empty(x))
#> [1] FALSE

tmp1 <- tempfile(pattern = "fakeFile", fileext = "vcf")
writeLines(c("col1\tcol2\tcol3", "1\t2\t3"), con = tmp1)
if (FALSE) {
vcf_is_empty(tmp1)
}

vcf_cols <- c(
  "#CHROM", "POS", "ID", "REF", "ALT", "QUAL",
  "FILTER", "INFO", "FORMAT"
)
tmp2 <- tempfile(pattern = "fakeFile", fileext = "vcf")
writeLines(paste(vcf_cols, collapse = "\t"), con = tmp2)
(z <- vcf_is_empty(tmp2))
#> /tmp/Rtmp9SHz04/fakeFile1762368830cevcf does not contain any non-header rows.
#> [1] TRUE

tmp3 <- tempfile(pattern = "fakeFile", fileext = "FOO")
writeLines(paste(vcf_cols, collapse = "\t"), con = tmp3)
if (FALSE) {
vcf_is_empty(tmp3)
}