Skip to content

Commit

Permalink
Fix URIs matching error in sdrfToNfConf.R (#46)
Browse files Browse the repository at this point in the history
* Update sdrfToNfConf.R

* fix value of 'missing_uri_files', when 'uri_select' is not a data.frame or matrix

* rm blank space
  • Loading branch information
pmb59 authored May 20, 2024
1 parent c5b46fc commit ac7bf36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions bin/sdrfToNfConf.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ for ( n in names(opt) ) {
}

################################################################################
# First round SDRF field checks: before we know about field content
# First round SDRF field checks: before we know about field content
################################################################################

# Load the SDRF
Expand Down Expand Up @@ -1124,14 +1124,14 @@ configs <- lapply(species_list, function(species){
}else{

# For each library we check if there is a fastq URI that can supply the file
uri_select <- apply(species.protocol.sdrf[,uri_cols], 2, function(x) basename(x) == files)
uri_select <- apply(species.protocol.sdrf[,uri_cols], 2, function(x) basename(x) == files)

if (is.data.frame(uri_select) || is.matrix(uri_select)) {
# the following line gives an error: dim(X) must have a positive length
# if not a matrix or a data.frame
missing_uri_files <- files[which(! apply(apply(species.protocol.sdrf[,uri_cols], 2, function(x) basename(x) == files), 1, any))]
} else {
missing_uri_files <- files[which(! apply(as.data.frame( apply(species.protocol.sdrf[,uri_cols], 2, function(x) basename(x) == files) ), 1, any))]
missing_uri_files <- files[which(! any(apply(species.protocol.sdrf[, uri_cols], 2, function(x) basename(x) == files)) )]
}

if (length(missing_uri_files) > 0){
Expand Down
8 changes: 4 additions & 4 deletions bin/utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pinfo <- function(...) {
cat(paste0("[INFO ",format(Sys.time(), format="%d/%m-%H:%M"),"] ",...,"\n"))
cat(paste0("[INFO ", format(Sys.time(), format="%d/%m-%H:%M"),"] ",...,"\n"))
}

perror <- function(...) {
Expand All @@ -10,14 +10,14 @@ pwarning <- function(...) {
cat(paste0("[WARNING] ",...,"\n"),file=stderr())
}

read.tsv <- function(f,header=TRUE, comment.char="", nrows=-1L,fill=FALSE, quote="\"", colClasses=NULL, drop=NULL) {
read.tsv <- function(f, header=TRUE, comment.char="", nrows=-1L,fill=FALSE, quote="\"", colClasses=NULL, drop=NULL) {
tsv.data <- NULL

suppressPackageStartupMessages(require(data.table))

fread(input=f,sep = "\t", nrows=nrows, header=header,check.names=FALSE,data.table=FALSE,fill=fill,drop=drop, quote=quote,colClasses=colClasses)
fread(input=f, sep = "\t", nrows=nrows, header=header, check.names=FALSE,data.table=FALSE, fill=fill, drop=drop, quote=quote, colClasses=colClasses)
}

write.tsv <- function(x, file, header=TRUE){
fwrite(x,file=file,sep="\t",row.names=FALSE,col.names=header,quote=FALSE,verbose=FALSE)
}
}

0 comments on commit ac7bf36

Please sign in to comment.