From 1257b85a7efd3329dd2b4810b1dbe75bef70a6c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Todor=20Kondi=C4=87?= <kontrapunkt@uclmail.net> Date: Fri, 3 Mar 2023 08:01:58 +0100 Subject: [PATCH] Remove main bits of setid table processing. --- R/api.R | 10 +++------- R/mix.R | 17 ----------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/R/api.R b/R/api.R index 5e90ae1..8b37188 100644 --- a/R/api.R +++ b/R/api.R @@ -151,8 +151,6 @@ load_compound_input <- function(m) { cmpds[,("known"):=.(the_ifelse(!is.na(SMILES),"structure",the_ifelse(!is.na(Formula),"formula","mz")))] m$input$tab$cmpds <- cmpds fn_setid <- file.path(m$run$paths$project,m$conf$compounds$sets) - m$input$tab$setid <- read_setid(fn_setid, - m$input$tab$cmpds) m } @@ -190,18 +188,16 @@ load_inputs <- function(m) { mk_comp_tab <- function(m) { message("Stage: comptab") - setid <- m$input$tab$setid - setkey(setid,set) mzml<- m$input$tab$mzml setkey(mzml,set) cmpds<-m$input$tab$cmpds - setkey(cmpds,ID) + setkey(cmpds,set,ID) assert(nrow(cmpds)>0,msg="No compound lists have been provided.") - assert(all(mzml[,unique(set)] %in% setid[,unique(set)]),msg="Not all set names in the `datatab' data file table match those in the provided set list.") + assert(all(mzml[,unique(set)] %in% cmpds[,unique(set)]),msg="Not all set names in the `datatab' data file table match those in the provided set list.") assert(all(mzml[,!is.na(unique(adduct))]),msg="Some data file entries do not have selected adducts.") message("Begin generation of the comprehensive table.") - comp <- cmpds[setid,on="ID"][mzml,.(tag,adduct,ID,RT,set,Name,file,SMILES,Formula,mz,known),on="set",allow.cartesian=T] + comp <- cmpds[mzml,.(tag,adduct,ID,RT,set,Name,file,SMILES,Formula,mz,known),on="set",allow.cartesian=T] tab2file(tab=comp,file=paste0("setidmerge",".csv")) setkey(comp,known,set,ID) message("Merged all sets.") diff --git a/R/mix.R b/R/mix.R index aa88970..5adef45 100644 --- a/R/mix.R +++ b/R/mix.R @@ -489,23 +489,6 @@ vald_comp_tab<-function(df,ndf,checkSMILES=F,checkMz=F,checkNames=F) { df } -read_setid <- function(fn,cmpds) { - assert(file.exists(fn),msg=paste("Please provide valid compounds set table:", fn)) - assert(nrow(cmpds) > 0,msg="Please provide at least one compounds list.") - setid <- file2tab(fn,colClasses=c(ID="character")) - x<-cmpds[setid,on='ID'][,.SD,.SDcols=c(colnames(setid),'known')] - - sids <- unique(setid$ID) - cids <- unique(cmpds$ID) - diff <- setdiff(sids,cids) - assert(length(diff)==0,msg=paste("The following IDs from set table have not been found in the compound table:","------",print_table(dtable(diff)),"------",sep = "\n")) - x -} - - - - - verify_cmpd_l <- function(dt,fn) { fields <- colnames(EMPTY_CMPD_LIST) dtflds <- colnames(dt) -- GitLab