-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Labels
Description
In readMeth, the assembly argument cannot be an empty string "".
When saving as DB, this is interpreted as NA and then due to the anyNA checks for header, the header is ignored.
This cause failure of reading the DB due to missing arguments in e.g., new("methylRawDB", ...), which would be otherwise initialized from the header.
Lines 279 to 334 in ecf8584
| readMethylRawDB<-function(dbpath,dbtype=NULL, | |
| sample.id=NULL, assembly=NULL ,context=NULL, | |
| resolution=NULL,skip=0){ | |
| if(!file.exists(paste0(dbpath,".tbi"))) | |
| { | |
| Rsamtools::indexTabix(dbpath,seq=1, start=2, end=3, | |
| skip=skip, comment="#", zeroBased=FALSE) | |
| } | |
| # if the tabix file includes a header generated with obj2tabix, | |
| # it can easily be parsed into the respective object | |
| head <- checkTabixHeader(tbxFile = dbpath, | |
| message = paste("No Tabix Header Found,", | |
| "trying to create methylRawDB from supplied arguments.")) | |
| if(!is.null(head) & !anyNA(head)) { | |
| if(! any(head$class == c("methylRaw", "methylRawDB") ) ) { | |
| stop( | |
| paste("Tabix file does not originate from methylRaw or methylRawDB.\n", | |
| "Please provide the correct class of data.") | |
| ) | |
| } | |
| if(is.null(head$num.records)) { | |
| num.records=Rsamtools::countTabix(dbpath)[[1]] | |
| } else num.records = head$num.records | |
| obj <- new("methylRawDB", dbpath=normalizePath(dbpath), | |
| num.records=num.records, sample.id = head$sample.ids, | |
| assembly = head$assembly,context=head$context, | |
| resolution=head$resolution,dbtype=head$dbtype) | |
| } else { | |
| # else we need to generate it from the supplied arguments | |
| argList <- list(sample.id = sample.id, assembly = assembly,context=context, | |
| resolution=resolution,dbtype=dbtype) | |
| checkMissingArg <- sapply(argList,is.null) | |
| if(any(checkMissingArg)) { | |
| stop("Missing argument: ",paste(names(argList[checkMissingArg]),collapse = ", ")) | |
| } | |
| num.records=Rsamtools::countTabix(dbpath)[[1]] ## | |
| obj <- new("methylRawDB",dbpath=normalizePath(dbpath),num.records=num.records, | |
| sample.id = sample.id, assembly = assembly,context=context, | |
| resolution=resolution,dbtype=dbtype) | |
| } | |
| if(valid.methylRawDB(obj)) {return(obj)} | |
| } |
Setting a check or at least documenting this behaviour would be IMHO helpful.
Reactions are currently unavailable