diff --git a/NAMESPACE b/NAMESPACE index 8913399..d72f6da 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(arg0) export(bcftools) export(bedtools) export(bowtie2) +export(bwa) export(cellranger) export(cmd_background) export(cmd_conda) diff --git a/R/cmd-bwa.R b/R/cmd-bwa.R new file mode 100644 index 0000000..d83b343 --- /dev/null +++ b/R/cmd-bwa.R @@ -0,0 +1,48 @@ +#' Run BWA +#' +#' BWA is a software package that aligns low-divergence sequences to a +#' large reference genome, such as the human genome +#' @param subcmd Sub-Command of BWA (e.g., "index", "mem"). +#' @param ... `r rd_dots("bwa")`. +#' @param bwa `r rd_cmd("bwa")`. +#' @inherit exec return +#' @seealso +#' - +#' +#' `r rd_seealso()` +#' @examples +#' \dontrun{ +#' # Index reference genome +#' bwa("index", "-a", "bwtsw", "reference.fa") |> +#' cmd_run() +#' +#' # Paired-end sequence alignment +#' bwa("mem", "-t", "4", "reference.fa", "read1.fq", "read2.fq") |> +#' cmd_run(stdout = "output.sam") +#' +#' # Single-end alignment (generate sai file) +#' bwa("aln", "-t", "4", "reference.fa", "read.fq") |> +#' cmd_run(stdout = "read.sai") +#' } +#' @family command +#' @export +bwa <- make_command( + "bwa", + function(subcmd = NULL, ..., bwa = NULL) { + assert_string(subcmd, allow_empty = FALSE, allow_null = TRUE) + assert_string(bwa, allow_empty = FALSE, allow_null = TRUE) + BWA$new(cmd = bwa, ..., subcmd = subcmd) + } +) + +BWA <- R6Class( + "BWA", + inherit = Command, + private = list( + alias = function() "bwa", + setup_help_params = function() "--help", + combine_params = function(subcmd) { + c(subcmd, super$combine_params()) + } + ) +) diff --git a/blit.Rproj b/blit.Rproj index aaa62a5..69fafd4 100644 --- a/blit.Rproj +++ b/blit.Rproj @@ -5,8 +5,13 @@ SaveWorkspace: No AlwaysSaveHistory: Default EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 Encoding: UTF-8 +RnwWeave: Sweave +LaTeX: pdfLaTeX + AutoAppendNewline: Yes StripTrailingWhitespace: Yes LineEndingConversion: Posix diff --git a/man/allele_counter.Rd b/man/allele_counter.Rd index cfa696b..1d2fa45 100644 --- a/man/allele_counter.Rd +++ b/man/allele_counter.Rd @@ -46,6 +46,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/bcftools.Rd b/man/bcftools.Rd index f884a5e..fd249fb 100644 --- a/man/bcftools.Rd +++ b/man/bcftools.Rd @@ -36,6 +36,7 @@ Other \code{commands}: \code{\link{allele_counter}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/bedtools.Rd b/man/bedtools.Rd index 869b61c..e85eb08 100644 --- a/man/bedtools.Rd +++ b/man/bedtools.Rd @@ -33,6 +33,7 @@ Other \code{commands}: \code{\link{allele_counter}()}, \code{\link{bcftools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/bowtie2.Rd b/man/bowtie2.Rd index 361c175..a103f2d 100644 --- a/man/bowtie2.Rd +++ b/man/bowtie2.Rd @@ -42,6 +42,7 @@ Other \code{commands}: \code{\link{allele_counter}()}, \code{\link{bcftools}()}, \code{\link{bedtools}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/bwa.Rd b/man/bwa.Rd new file mode 100644 index 0000000..908161b --- /dev/null +++ b/man/bwa.Rd @@ -0,0 +1,68 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cmd-bwa.R +\name{bwa} +\alias{bwa} +\title{Run BWA} +\usage{ +bwa(subcmd = NULL, ..., bwa = NULL) +} +\arguments{ +\item{subcmd}{Sub-Command of BWA (e.g., "index", "mem").} + +\item{...}{<\link[rlang:dyn-dots]{dynamic dots}> Additional arguments passed to \code{bwa} command. Empty arguments are automatically trimmed. If a single argument, such as a file path, contains spaces, it must be quoted, for example using \code{\link[=shQuote]{shQuote()}}. Details see: \code{cmd_help(bwa())}.} + +\item{bwa}{A string of path to \code{bwa} command.} +} +\value{ +A \code{command} object. +} +\description{ +BWA is a software package that aligns low-divergence sequences to a +large reference genome, such as the human genome +} +\examples{ +\dontrun{ +# Index reference genome +bwa("index", "-a", "bwtsw", "reference.fa") |> + cmd_run() + +# Paired-end sequence alignment +bwa("mem", "-t", "4", "reference.fa", "read1.fq", "read2.fq") |> + cmd_run(stdout = "output.sam") + +# Single-end alignment (generate sai file) +bwa("aln", "-t", "4", "reference.fa", "read.fq") |> + cmd_run(stdout = "read.sai") +} +} +\seealso{ +\itemize{ +\item \url{http://bio-bwa.sourceforge.net/} +\item \code{\link[=cmd_wd]{cmd_wd()}}/\code{\link[=cmd_envvar]{cmd_envvar()}}/\code{\link[=cmd_envpath]{cmd_envpath()}}/\code{\link[=cmd_condaenv]{cmd_condaenv()}} +\item \code{\link[=cmd_on_start]{cmd_on_start()}}/\code{\link[=cmd_on_exit]{cmd_on_exit()}} +\item \code{\link[=cmd_on_succeed]{cmd_on_succeed()}}/\code{\link[=cmd_on_fail]{cmd_on_fail()}} +\item \code{\link[=cmd_parallel]{cmd_parallel()}} +} + +Other \code{commands}: +\code{\link{allele_counter}()}, +\code{\link{bcftools}()}, +\code{\link{bedtools}()}, +\code{\link{bowtie2}()}, +\code{\link{cellranger}()}, +\code{\link{conda}()}, +\code{\link{fastp}()}, +\code{\link{fastq_pair}()}, +\code{\link{gistic2}()}, +\code{\link{kraken2}()}, +\code{\link{kraken_tools}()}, +\code{\link{perl}()}, +\code{\link{pyscenic}()}, +\code{\link{python}()}, +\code{\link{samtools}()}, +\code{\link{seqkit}()}, +\code{\link{snpEff}()}, +\code{\link{trust4}()}, +\code{\link{varscan}()} +} +\concept{command} diff --git a/man/cellranger.Rd b/man/cellranger.Rd index f52c025..8b51c7e 100644 --- a/man/cellranger.Rd +++ b/man/cellranger.Rd @@ -51,6 +51,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{conda}()}, \code{\link{fastp}()}, \code{\link{fastq_pair}()}, diff --git a/man/conda.Rd b/man/conda.Rd index 9fe0555..6ca35db 100644 --- a/man/conda.Rd +++ b/man/conda.Rd @@ -32,6 +32,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{fastp}()}, \code{\link{fastq_pair}()}, diff --git a/man/exec.Rd b/man/exec.Rd index 31fb607..32bc558 100644 --- a/man/exec.Rd +++ b/man/exec.Rd @@ -24,6 +24,7 @@ Invoke a System Command \item \code{\link[=bcftools]{bcftools()}} \item \code{\link[=bedtools]{bedtools()}} \item \code{\link[=bowtie2]{bowtie2()}} +\item \code{\link[=bwa]{bwa()}} \item \code{\link[=cellranger]{cellranger()}} \item \code{\link[=conda]{conda()}} \item \code{\link[=fastp]{fastp()}} diff --git a/man/fastp.Rd b/man/fastp.Rd index ec3e879..4546142 100644 --- a/man/fastp.Rd +++ b/man/fastp.Rd @@ -36,6 +36,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastq_pair}()}, diff --git a/man/fastq_pair.Rd b/man/fastq_pair.Rd index 3764bc6..ebd9fbf 100644 --- a/man/fastq_pair.Rd +++ b/man/fastq_pair.Rd @@ -57,6 +57,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/gistic2.Rd b/man/gistic2.Rd index 42e9a6a..a1f8c0f 100644 --- a/man/gistic2.Rd +++ b/man/gistic2.Rd @@ -54,6 +54,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/kraken2.Rd b/man/kraken2.Rd index 0a1adc0..c67271a 100644 --- a/man/kraken2.Rd +++ b/man/kraken2.Rd @@ -60,6 +60,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/kraken_tools.Rd b/man/kraken_tools.Rd index fece02b..813ad80 100644 --- a/man/kraken_tools.Rd +++ b/man/kraken_tools.Rd @@ -36,6 +36,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/perl.Rd b/man/perl.Rd index c2b8c8e..0b5d27a 100644 --- a/man/perl.Rd +++ b/man/perl.Rd @@ -33,6 +33,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/pyscenic.Rd b/man/pyscenic.Rd index 63f20fc..5fa2b6a 100644 --- a/man/pyscenic.Rd +++ b/man/pyscenic.Rd @@ -33,6 +33,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/python.Rd b/man/python.Rd index d4e32a3..b733052 100644 --- a/man/python.Rd +++ b/man/python.Rd @@ -33,6 +33,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/samtools.Rd b/man/samtools.Rd index 5b1c133..7a3d4a5 100644 --- a/man/samtools.Rd +++ b/man/samtools.Rd @@ -35,6 +35,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/seqkit.Rd b/man/seqkit.Rd index fcfe722..5dff545 100644 --- a/man/seqkit.Rd +++ b/man/seqkit.Rd @@ -33,6 +33,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/snpEff.Rd b/man/snpEff.Rd index 79b611a..c6fa9a1 100644 --- a/man/snpEff.Rd +++ b/man/snpEff.Rd @@ -35,6 +35,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/trust4.Rd b/man/trust4.Rd index cdcc7bd..3956a32 100644 --- a/man/trust4.Rd +++ b/man/trust4.Rd @@ -88,6 +88,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/man/varscan.Rd b/man/varscan.Rd index 03ae011..6c949eb 100644 --- a/man/varscan.Rd +++ b/man/varscan.Rd @@ -35,6 +35,7 @@ Other \code{commands}: \code{\link{bcftools}()}, \code{\link{bedtools}()}, \code{\link{bowtie2}()}, +\code{\link{bwa}()}, \code{\link{cellranger}()}, \code{\link{conda}()}, \code{\link{fastp}()}, diff --git a/tests/testthat/test-exec.R b/tests/testthat/test-exec.R index 2e848cc..e325bef 100644 --- a/tests/testthat/test-exec.R +++ b/tests/testthat/test-exec.R @@ -8,6 +8,13 @@ testthat::test_that("`bedtools()` works as expected", { bedtools() |> cmd_help() }) +testthat::test_that("`bwa()` works as expected", { + testthat::skip_if_not(nzchar(Sys.which("bwa"))) + bwa() |> cmd_help() + bwa("index") |> cmd_help() + bwa("mem") |> cmd_help() +}) + testthat::test_that("`cellranger()` works as expected", { testthat::skip_if_not(nzchar(Sys.which("cellranger"))) cellranger() |> cmd_help() @@ -96,4 +103,30 @@ testthat::test_that("`bcftools()` works as expected", { testthat::test_that("`bowtie2()` works as expected", { testthat::skip_if_not(nzchar(Sys.which("bowtie2"))) bowtie2() |> cmd_help() -}) \ No newline at end of file +}) + +testthat::test_that("`varscan()` works as expected", { + testthat::skip_if_not(nzchar(Sys.which("varscan"))) + varscan() |> cmd_help() +}) + +testthat::test_that("`fastp()` works as expected", { + testthat::skip_if_not(nzchar(Sys.which("fastp"))) + fastp() |> cmd_help() +}) + + +testthat::test_that("`snpeff()` works as expected", { + testthat::skip_if_not(nzchar(Sys.which("snpeff"))) + snpeff() |> cmd_help() +}) + +testthat::test_that("`bcftools()` works as expected", { + testthat::skip_if_not(nzchar(Sys.which("bcftools"))) + bcftools() |> cmd_help() +}) + +testthat::test_that("`bowtie2()` works as expected", { + testthat::skip_if_not(nzchar(Sys.which("bowtie2"))) + bowtie2() |> cmd_help() +})