Skip to content

Commit

Permalink
use vcfpp.h v0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Aug 7, 2024
1 parent 9836448 commit f331d32
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: vcfppR
Title: Rapid Manipulation of the Variant Call Format (VCF)
Version: 0.4.7
Version: 0.4.8
Authors@R: c(
person("Zilong", "Li", , "zilong.dk@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5859-2078")),
Expand Down
2 changes: 0 additions & 2 deletions R/vcf-compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ vcfcomp <- function(test, truth,
choose_random_start = FALSE,
return_pse_sites = FALSE,
...) {
if((!file.exists(test)) | (!file.exists(truth)))
stop("file doesn't exist")
if(is.null(bins)){
bins <- sort(unique(c(
c(0, 0.01 / 1000, 0.02 / 1000, 0.05 / 1000),
Expand Down
2 changes: 0 additions & 2 deletions R/vcf-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ vcfsummary <- function(vcffile,
pass = FALSE,
qual = 0,
svtype = FALSE) {
if(!file.exists(vcffile))
stop("file doesn't exist")
if(svtype) {
ret <- summarySVs(vcffile, region, samples, pass, qual)
} else {
Expand Down
2 changes: 0 additions & 2 deletions R/vcf-tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ vcftable <- function(vcffile,
collapse = TRUE,
setid = FALSE,
mac = 0) {
if(!file.exists(vcffile))
stop("file doesn't exist")
snps <- FALSE
indels <- FALSE
svs <- FALSE
Expand Down
6 changes: 5 additions & 1 deletion src/vcfpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file https://github.com/Zilong-Li/vcfpp/vcfpp.h
* @author Zilong Li
* @email zilong.dk@gmail.com
* @version v0.4.0
* @version v0.4.1
* @breif a single C++ file for manipulating VCF
* Copyright (C) 2022-2023.The use of this code is governed by the LICENSE file.
******************************************************************************/
Expand Down Expand Up @@ -1519,6 +1519,7 @@ class BcfReader
{
fname = file;
fp = std::shared_ptr<htsFile>(hts_open(file.c_str(), "r"), htsFile_close());
if(!fp) throw std::invalid_argument("I/O error: input file is invalid");
header.hdr = bcf_hdr_read(fp.get());
nsamples = bcf_hdr_nsamples(header.hdr);
SamplesName = header.getSamples();
Expand Down Expand Up @@ -1710,6 +1711,7 @@ class BcfWriter
{
auto mode = getMode(fname, "w");
fp = std::shared_ptr<htsFile>(hts_open(fname.c_str(), mode.c_str()), htsFile_close());
if(!fp) throw std::invalid_argument("I/O error: input file is invalid");
}

/**
Expand All @@ -1724,6 +1726,7 @@ class BcfWriter
void open(const std::string & fname, const std::string & mode)
{
fp = std::shared_ptr<htsFile>(hts_open(fname.c_str(), mode.c_str()), htsFile_close());
if(!fp) throw std::invalid_argument("I/O error: input file is invalid");
}

/// close the BcfWriter object.
Expand Down Expand Up @@ -1751,6 +1754,7 @@ class BcfWriter
void copyHeader(const std::string & vcffile)
{
htsFile * fp2 = hts_open(vcffile.c_str(), "r");
if(!fp2) throw std::invalid_argument("I/O error: input file is invalid");
header.hdr = bcf_hdr_read(fp2);
hts_close(fp2);
initalHeader(header);
Expand Down

0 comments on commit f331d32

Please sign in to comment.