Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URIs matching error in sdrfToNfConf.R #46

Merged
merged 13 commits into from
May 20, 2024
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 @@ -1077,14 +1077,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)) )]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain briefly what are you trying to do here.. So I know what I understood from code is right..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @anilthanki Did you have a look to the description of the PR?

Basically, in this chunk for each library it is checked if there is a fastq URI that can supply the file. The error was in the fix for the case when uri_select is not a matrix or a data.frame

}

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)
}
}