Skip to content

wrong output file path is checked for existence #358

@alexg9010

Description

@alexg9010

The output file is currently assumed in the same folder as the input tabix file. This is violated if dbdir argument is given.
The file is created at the correct path though.

# catch additional args
args <- list(...)
dir <- dirname(object@dbpath)
if( "dbdir" %in% names(args) ){
if( !(is.null(args$dbdir)) ){
dir <- .check.dbdir(args$dbdir)
}
}
if(!( "suffix" %in% names(args) ) ){
suffix <- "_tiled"
} else {
suffix <- paste0("_",args$suffix)
}
# filename <- paste0(paste([email protected],collapse = "_"),
# suffix,".txt")
filename <- paste0(gsub(".txt.bgz","",object@dbpath),suffix,".txt")
filename <- .checkTabixFileExists(filename)

Simple test:

library(methylKit)
data("methylKit")

dbdir <- "my_storage_path"
dbdir_unite <- file.path(dbdir,"unite")
dbdir_tile <- file.path(dbdir,"tile")
dbdir_diffmeth <- file.path(dbdir,"diffmeth")


## init methylrawlistdb in old dbdir
mlist_db <- methylRawList.obj |> makeMethylDB(dbdir = dbdir)
mlist_db |> getDBPath() |> basename() %in% dir(dbdir) |> all()


get_checked_file <- function(log) {
  matches <- log |> grep(pattern = "checking wether tabix file already exists:" ) + 1 
  return(log[matches])
}

## create new methylbase in new dbdir
unite_log <- {mlist_db_unite <- mlist_db |> unite(dbdir = dbdir_unite)} |> capture.output(type = "message")
identical(
  unite_log |> get_checked_file() |> normalizePath(),
  mlist_db_unite |> getDBPath()
  )

## prints the wrong for diffmeth
diffmeth_log <- {mlist_db_diffmeth <- mlist_db_unite |> calculateDiffMeth(dbdir = dbdir_diffmeth)} |> capture.output(type = "message")
identical(
  diffmeth_log |> get_checked_file() |> normalizePath(),
  mlist_db_diffmeth |> getDBPath()
)


## prints the wrong for tiling
tile_log <- {mlist_db_tiled <- mlist_db |> tileMethylCounts(dbdir = dbdir_tile)} |> capture.output(type = "message") 
identical(
  tile_log |> get_checked_file() |> normalizePath(),
  mlist_db_tiled |> getDBPath()
)


unlink(x = c(dbdir), recursive = TRUE)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions