Skip to content
Snippets Groups Projects
Commit 1257b85a authored by Todor Kondić's avatar Todor Kondić
Browse files

Remove main bits of setid table processing.

parent 1d41c576
No related branches found
No related tags found
No related merge requests found
...@@ -151,8 +151,6 @@ load_compound_input <- function(m) { ...@@ -151,8 +151,6 @@ load_compound_input <- function(m) {
cmpds[,("known"):=.(the_ifelse(!is.na(SMILES),"structure",the_ifelse(!is.na(Formula),"formula","mz")))] cmpds[,("known"):=.(the_ifelse(!is.na(SMILES),"structure",the_ifelse(!is.na(Formula),"formula","mz")))]
m$input$tab$cmpds <- cmpds m$input$tab$cmpds <- cmpds
fn_setid <- file.path(m$run$paths$project,m$conf$compounds$sets) 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 m
} }
...@@ -190,18 +188,16 @@ load_inputs <- function(m) { ...@@ -190,18 +188,16 @@ load_inputs <- function(m) {
mk_comp_tab <- function(m) { mk_comp_tab <- function(m) {
message("Stage: comptab") message("Stage: comptab")
setid <- m$input$tab$setid
setkey(setid,set)
mzml<- m$input$tab$mzml mzml<- m$input$tab$mzml
setkey(mzml,set) setkey(mzml,set)
cmpds<-m$input$tab$cmpds cmpds<-m$input$tab$cmpds
setkey(cmpds,ID) setkey(cmpds,set,ID)
assert(nrow(cmpds)>0,msg="No compound lists have been provided.") 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.") assert(all(mzml[,!is.na(unique(adduct))]),msg="Some data file entries do not have selected adducts.")
message("Begin generation of the comprehensive table.") 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")) tab2file(tab=comp,file=paste0("setidmerge",".csv"))
setkey(comp,known,set,ID) setkey(comp,known,set,ID)
message("Merged all sets.") message("Merged all sets.")
......
...@@ -489,23 +489,6 @@ vald_comp_tab<-function(df,ndf,checkSMILES=F,checkMz=F,checkNames=F) { ...@@ -489,23 +489,6 @@ vald_comp_tab<-function(df,ndf,checkSMILES=F,checkMz=F,checkNames=F) {
df 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) { verify_cmpd_l <- function(dt,fn) {
fields <- colnames(EMPTY_CMPD_LIST) fields <- colnames(EMPTY_CMPD_LIST)
dtflds <- colnames(dt) dtflds <- colnames(dt)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment