diff --git a/NEWS.md b/NEWS.md index b84076a..a279537 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# vcfppR 0.3.7 + +* add vcfreader@samples() + # vcfppR 0.3.6 * add `vcfreader::line` diff --git a/R/RcppExports.R b/R/RcppExports.R index a543017..c1a8155 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -61,6 +61,7 @@ heterozygosity <- function(vcffile, region = "", samples = "-", pass = FALSE, qu #' @field hasOTHER Test if current variant has a OTHER or not #' @field hasOVERLAP Test if current variant has a OVERLAP or not #' @field nsamples Return the number of samples +#' @field samples Return a vector of samples id #' @field header Return the raw string of the vcf header #' @field string Return the raw string of current variant including newline #' @field line Return the raw string of current variant without newline diff --git a/man/vcfreader.Rd b/man/vcfreader.Rd index f927016..aa9dd1c 100644 --- a/man/vcfreader.Rd +++ b/man/vcfreader.Rd @@ -91,6 +91,8 @@ Type the name of the class to see the details and methods \item{\code{nsamples}}{Return the number of samples} +\item{\code{samples}}{Return a vector of samples id} + \item{\code{header}}{Return the raw string of the vcf header} \item{\code{string}}{Return the raw string of current variant including newline} diff --git a/src/vcf-reader.cpp b/src/vcf-reader.cpp index f8af7c5..faabdea 100644 --- a/src/vcf-reader.cpp +++ b/src/vcf-reader.cpp @@ -51,6 +51,7 @@ using namespace std; //' @field hasOTHER Test if current variant has a OTHER or not //' @field hasOVERLAP Test if current variant has a OVERLAP or not //' @field nsamples Return the number of samples +//' @field samples Return a vector of samples id //' @field header Return the raw string of the vcf header //' @field string Return the raw string of current variant including newline //' @field line Return the raw string of current variant without newline @@ -245,6 +246,7 @@ class vcfreader { return v.size() / nsamples(); } inline std::string header() const { return br.header.asString(); } + inline std::vector samples() const { return br.header.getSamples(); } inline std::string string() const { return var.asString(); } inline std::string line() { std::string s = var.asString(); @@ -363,6 +365,7 @@ RCPP_MODULE(vcfreader) { .method("hasOTHER", &vcfreader::hasOTHER) .method("hasOVERLAP", &vcfreader::hasOVERLAP) .method("nsamples", &vcfreader::nsamples) + .method("samples", &vcfreader::samples) .method("header", &vcfreader::header) .method("string", &vcfreader::string) .method("line", &vcfreader::line)