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

Things break.

parent acef780a
No related branches found
No related tags found
No related merge requests found
Pipeline #67644 failed
......@@ -213,7 +213,7 @@ metfrag_run_many <- function(fn_jar,file_tab, mem = NA_character_, java_bin = "j
}
summarise_metfrag_results <- function(param,path,subpaths,file_tab) {
summarise_metfrag_results <- function(param,path,subpaths,cand_parameters,scores,collect_candidates,file_tab) {
## which(max(as.numeric(mf_res$Score))==as.numeric(mf_res$Score))
index_maxScore = 1L
......@@ -232,15 +232,7 @@ summarise_metfrag_results <- function(param,path,subpaths,file_tab) {
}
.adapt_col_types <- function(x) {
x[,c("Score",
"NoExplPeaks",
"NumberPeaksUsed",
"FragmenterScore",
"OfflineIndividualMoNAScore"):=lapply(.SD, as.numeric),.SDcol=c("Score",
"NoExplPeaks",
"NumberPeaksUsed",
"FragmenterScore",
"OfflineIndividualMoNAScore")]
x[,(names(scores)):=lapply(.SD, as.numeric),.SDcol=names(scores)]
}
.calc_basic_scores <- function(x) {
......@@ -249,15 +241,51 @@ summarise_metfrag_results <- function(param,path,subpaths,file_tab) {
n_Score_GE4=length(which(Score>=4)),
n_Score_GE3=length(which(Score>=3)),
n_Score_GE2=length(which(Score>=2))),
keyby="stag"]
by=keyz]
}
.get_candidate_param <- function(x) {
res = x[,.SD[..index_maxScore],
.SDcol=cand_parameters,
keyby=keyz]
## data.table::setnames(res,old = names(res), new = paste0("top_",names(res)))
res
}
.make_max_cols <- function(x) {
res = x[,lapply(.SD,function(s) max(s,na.rm=T)),.SDcol=names(scores),keyby=keyz]
data.table::setnames(res,old = names(res),new = paste0("max_",names(res)))
res
}
.collect_candidates <- function(x) {
x[,lapply(.SD, function(col) paste(col,collapse=";")),
.SDcol=collect_candidates,
keyby=keyz]
}
thetab = .read_results()
thetab = .adapt_col_types(thetab)
monatab = thetab[,.(max_MoNAIndiv=max(OfflineIndividualMoNAScore))]
basictab = .calc_basic_scores(thetab)
.adapt_col_types(thetab)
btab = .calc_basic_scores(thetab)
cctab = .collect_candidates(thetab)
candtab = .get_candidate_param(thetab)
mxtab = .make_max_cols(thetab)
res = file_tab
res = res[btab]
res = res[cctab]
res = res[candtab]
res = res[mxtab]
res
}
......@@ -351,6 +351,7 @@ METFRAG_DEFAULT_SCORES = list(FragmenterScore=1.0,OfflineIndividualMoNAScore=1.0
# not
# work
# well.
## METFRAG_DEFAULT_WEIGHTS = "1,1"
METFRAG_DEFAULT_MAX_TREE_DEPTH = 2
METFRAG_SAMPLE_NAME = "sample"
......
......@@ -25,7 +25,13 @@ make_dummy_mf_project <- function() {
x$conf$metfrag$param$MetFragDatabaseType = "LocalCSV"
x$conf$metfrag$db_file = basename(getOption("fn_db"))
x$conf$metfrag$scores = list(FragmenterScore=1.0,
OfflineIndividualMoNAScore=1.0)
OfflineIndividualMoNAScore=1.0,
PubMedCount=1.0,
PatentCount=1.0,
AnnoTypeCount=1.0)
x$conf$metfrag$cand_parameters = c("Identifier","CompoundName")
x$conf$metfrag$collect_candidates = c("Identifier")
yaml::write_yaml(x=x$conf,file=file.path(p_dir,"conf-state.yaml"))
m = new_project(project = p_dir,
......
......@@ -74,6 +74,9 @@ ok_return_val("metfrag_run",{
x = summarise_metfrag_results(param = m$conf$metfrag$param,
path = m$run$metfrag$path,
subpaths = m$run$metfrag$subpaths,
cand_parameters = m$conf$metfrag$cand_parameters,
scores = m$conf$metfrag$scores,
collect_candidates= m$conf$metfrag$collect_candidates,
file_tab = ftab)
......
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