Nothing
setClass(Class = "SamToBam",
contains = "ATACProc"
)
setMethod(
f = "init",
signature = "SamToBam",
definition = function(.Object,prevSteps = list(), ..., samInput = NULL, bamOutput = NULL, editable = FALSE){
atacProc <- NULL
if(length(prevSteps)>0){
atacProc <- prevSteps[[1]]
}
allparam <- list(...)
input_file <- allparam[["input_file"]]
output_file <- allparam[["output_file"]]
# necessary parameters
if((!is.null(atacProc)) ){
input(.Object)[["samInput"]] <- getParam(atacProc, "samOutput")
}else if(is.null(atacProc)){ # input
input(.Object)[["samInput"]] <- samInput
}
# unnecessary parameters
if(is.null(bamOutput)){
param(.Object)[["name_tmp"]] <- getAutoPath(.Object, input(.Object)[["samInput"]],"sam|SAM","" )
output(.Object)[["bamOutput"]] <- getAutoPath(.Object, input(.Object)[["samInput"]],"sam|SAM","bam")
output(.Object)[["baiOutput"]] <- getAutoPath(.Object, input(.Object)[["samInput"]],"sam|SAM","bam.bai")
}else{
bamOutput <- addFileSuffix(bamOutput,".bam")
param(.Object)[["name_tmp"]] <- substring(bamOutput,first = 1,last = nchar(bamOutput) - 4)
output(.Object)[["bamOutput"]] <- bamOutput
output(.Object)[["baiOutput"]] <- addFileSuffix(bamOutput,".bai")
}
.Object
}
)
setMethod(
f = "processing",
signature = "SamToBam",
definition = function(.Object,...){
Rsamtools::asBam(file = input(.Object)[["samInput"]], destination = param(.Object)[["name_tmp"]],overwrite = TRUE)
.Object
}
)
setMethod(
f = "genReport",
signature = "SamToBam",
definition = function(.Object, ...){
.Object
}
)
#' @name SamToBam
#' @title Convert sam format to bam format.
#' @description
#' This function convert a sam file into a bam file.
#' @param atacProc \code{\link{ATACProc-class}} object scalar.
#' It has to be the return value of upstream process:
#' \code{\link{atacBowtie2Mapping}}.
#' @param samInput \code{Character} scalar.
#' Sam file input path.
#' @param bamOutput \code{Character} scalar.
#' Bam file output path. If ignored, bed file will be put in the same path as
#' the sam file.
#' @param ... Additional arguments, currently unused.
#' @details The sam file wiil be automatically obtained from
#' object(\code{atacProc}) or input by hand. bamOutput can be ignored.
#' @return An invisible \code{\link{ATACProc-class}} object scalar for
#' downstream analysis.
#' @author Wei Zhang
#' @examples
#'
#' library(R.utils)
#' sam_bz <- system.file("extdata", "Example.sam.bz2", package="esATAC")
#' sam_path <- as.vector(bunzip2(filename = sam_bz,
#' destname = file.path(getwd(), "Example.sam"),
#' ext="bz2", FUN=bzfile, remove = FALSE))
#' sam2bam(samInput = sam_path)
#'
#' @seealso
#' \code{\link{atacBowtie2Mapping}}
#' \code{\link{atacBam2Bed}}
#' \code{\link{atacBamSort}}
setGeneric("atacSam2Bam",function(atacProc,
samInput = NULL, bamOutput = NULL, ...) standardGeneric("atacSam2Bam"))
#' @rdname SamToBam
#' @aliases atacSam2Bam
#' @export
setMethod(
f = "atacSam2Bam",
signature = "ATACProc",
definition = function(atacProc,
samInput = NULL, bamOutput = NULL, ...){
allpara <- c(list(Class = "SamToBam", prevSteps = list(atacProc)),as.list(environment()),list(...))
step <- do.call(new,allpara)
invisible(step)
}
)
#' @rdname SamToBam
#' @aliases sam2bam
#' @export
sam2bam <- function(samInput, bamOutput = NULL, ...){
allpara <- c(list(Class = "SamToBam", prevSteps = list()),as.list(environment()),list(...))
step <- do.call(new,allpara)
invisible(step)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.