vcf_is_empty: Does the VCF file contain any variants?

View source: R/utils.R

vcf_is_emptyR Documentation

Does the VCF file contain any variants?

Description

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))

tmp1 <- tempfile(pattern = "fakeFile", fileext = "vcf")
writeLines(c("col1\tcol2\tcol3", "1\t2\t3"), con = tmp1)
## Not run: 
vcf_is_empty(tmp1)

## End(Not run)

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))

tmp3 <- tempfile(pattern = "fakeFile", fileext = "FOO")
writeLines(paste(vcf_cols, collapse = "\t"), con = tmp3)
## Not run: 
vcf_is_empty(tmp3)

## End(Not run)


umccr/gpgr documentation built on Nov. 28, 2024, 10:16 a.m.