Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Mar 23, 2024
1 parent ac9fe62 commit 77ab79d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
8 changes: 3 additions & 5 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,14 @@ tableFormat <- function(vcffile, region, samples, format, ids, qualval, pass, IN
#' \itemize{ \item Parameter: line - A string for a line in the variant of VCF. Not ended with "newline" }
#' @field close Close and save the vcf file
#' @examples
#' outvcf <- file.path(tempdir(), "test_vcfwriter.vcf.gz")
#' file.create(outvcf)
#' outvcf <- file.path(paste0(tempfile(), ".vcf.gz"))
#' bw <- vcfwriter$new(outvcf, "VCF4.3")
#' bw$addContig("chr20")
#' bw$addINFO("AF", "A", "Float", "Estimated allele frequency in the range (0,1)");
#' bw$addFORMAT("GT", "1", "String", "Genotype");
#' bw$addSample("NA12878")
#' bw$addSample("NA12879")
#' s1 <- "chr20\t2006060\trs146931526\tG\tC\t100\tPASS\tAF=0.04\tGT\t1|0\t1|1"
#' s1 <- "chr20\t2006060\trs146931526\tG\tC\t100\tPASS\t.\tGT\t1|0\t1|1"
#' tryCatch((bw$writeline(s1)), error=function(e) e)
#' bw$close()
#' file.remove(outvcf)
NULL

7 changes: 2 additions & 5 deletions man/vcfwriter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/vcf-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,15 @@ using namespace std;
//' \itemize{ \item Parameter: line - A string for a line in the variant of VCF. Not ended with "newline" }
//' @field close Close and save the vcf file
//' @examples
//' outvcf <- file.path(tempdir(), "test_vcfwriter.vcf.gz")
//' file.create(outvcf)
//' outvcf <- file.path(paste0(tempfile(), ".vcf.gz"))
//' bw <- vcfwriter$new(outvcf, "VCF4.3")
//' bw$addContig("chr20")
//' bw$addINFO("AF", "A", "Float", "Estimated allele frequency in the range (0,1)");
//' bw$addFORMAT("GT", "1", "String", "Genotype");
//' bw$addSample("NA12878")
//' bw$addSample("NA12879")
//' s1 <- "chr20\t2006060\trs146931526\tG\tC\t100\tPASS\tAF=0.04\tGT\t1|0\t1|1"
//' s1 <- "chr20\t2006060\trs146931526\tG\tC\t100\tPASS\t.\tGT\t1|0\t1|1"
//' tryCatch((bw$writeline(s1)), error=function(e) e)
//' bw$close()
//' file.remove(outvcf)
class vcfwriter {
public:
vcfwriter(std::string vcffile, std::string version) : bw(vcffile, version) {}
Expand Down
9 changes: 3 additions & 6 deletions tests/testthat/test-vcf-writer.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
library(testthat)

test_that("vcfwriter: writing variant works", {
skip_on_os(c("windows"), arch = NULL)
outvcf <- file.path(tempdir(), "test_vcfwriter.vcf.gz")
file.create(outvcf)
## skip_on_os(c("windows"), arch = NULL)
outvcf <- file.path(paste0(tempfile(), ".vcf.gz"))
bw <- vcfwriter$new(outvcf, "VCF4.3")
bw$addLine('##ALT=<ID=NON_REF,Description="Represents any possible alternative allele at this location">')
bw$addContig("chr20")
bw$addFILTER("PASS", "All filters passed")
bw$addINFO("AF", "A", "Float", "Estimated allele frequency in the range (0,1)");
bw$addFORMAT("GT", "1", "String", "Genotype");
bw$addSample("NA12878")
s1 <- "chr20\t2006060\trs146931526\tG\tC\t100\tPASS\tAF=0.000998403\tGT\t1|0"
s1 <- "chr20\t2006060\trs146931526\tG\tC\t100\tPASS\t."
bw$writeline(s1)
bw$close()
## tests
Expand Down

0 comments on commit 77ab79d

Please sign in to comment.