# HG changeset patch # User lain # Date 1617800736 0 # Node ID bdb2878ee1891b69994be97c608238358a7f72b5 # Parent f4fc4a0f41e206f44c22d2911e2825f147d6262c " master branch Updating" diff -r f4fc4a0f41e2 -r bdb2878ee189 XSeekerPreparator.R --- a/XSeekerPreparator.R Thu Mar 18 10:46:01 2021 +0000 +++ b/XSeekerPreparator.R Wed Apr 07 13:05:36 2021 +0000 @@ -484,18 +484,44 @@ singlefile <- rdata$singlefile process_arg_list <- rdata$listOFlistArguments var_meta <- rdata$variableMetadata - ## We needed to get rid of the rdata, which is very big. - ## So we gathered all variable assignment from rdata here, and got rid of it. - rm(rdata) process_params <- list() - for (list_name in names(process_arg_list)) { - param_list <- list() - for (param_name in names(process_arg_list[[list_name]])) { - param_list[[param_name]] <- process_arg_list[[list_name]][[param_name]] + if (is.null(process_arg_list)) { + histories <- list() + for (history in xcms_set@.processHistory) { + if ( + class(history@param) == "CentWaveParam" + && history@type == "Peak detection" + ) { + params <- history@param + process_params <- list(list( + xfunction="annotatediff", + ppm=params@ppm, + peakwidth=sprintf("%s - %s", params@peakwidth[[1]], params@peakwidth[[2]]), + snthresh=params@snthresh, + prefilterStep=params@prefilter[[1]], + prefilterLevel=params@prefilter[[2]], + mzdiff=params@mzdiff, + fitgauss=params@fitgauss, + noise=params@noise, + mzCenterFun=params@mzCenterFun, + integrate=params@integrate, + firstBaselineCheck=params@firstBaselineCheck, + snthreshIsoROIs=!identical(params@roiScales, numeric(0)) + )) + break + } } - process_params[[length(process_params)+1]] <- param_list + } else { + for (list_name in names(process_arg_list)) { + param_list <- list() + for (param_name in names(process_arg_list[[list_name]])) { + param_list[[param_name]] <- process_arg_list[[list_name]][[param_name]] + } + process_params[[length(process_params)+1]] <- param_list + } } + message("Parameters from previous processes extracted.") @@ -532,7 +558,7 @@ env$tic <- ms_file@tic env$mz <- ms_file@env$mz env$scanindex <- ms_file@scanindex - env$scantime <- ms_file@scantime + env$scantime <- ms_file@scantime * 60 env$intensity <- ms_file@env$intensity env$polarity <- as.character(ms_file@polarity[[1]]) @@ -555,6 +581,7 @@ context$show_percent <- show_percent context$cluster_mean_rt_abundance <- list() context$central_feature <- list() + context$adducts <- list() load_variable_metadata(orm, var_meta, context) clusters <- context$clusters rm(context) @@ -695,6 +722,7 @@ } } create_associated_cluster( + orm, context$central_feature[[clusterID]], dummy_feature, clusterID, context, curent_var_meta, next_pc_group, @@ -761,22 +789,31 @@ } create_associated_cluster <- function( + orm, sample_no, feature, clusterID, context, curent_var_meta, next_pc_group, next_align_group ) { - pcgroup <- as.numeric(curent_var_meta[["pcgroup"]]) - adduct <- as.character(curent_var_meta[["adduct"]]) - annotation <- curent_var_meta[["isotopes"]] clusterID <- as.character(clusterID) if (is.null(cluster <- context$clusters[[clusterID]])) { + pcgroup <- as.numeric(curent_var_meta[["pcgroup"]]) + adduct_name <- as.character(curent_var_meta[["adduct"]]) + annotation <- curent_var_meta[["isotopes"]] cluster <- context$clusters[[clusterID]] <- orm$cluster( pc_group=pcgroup + next_pc_group, - adduct=adduct, + # adduct=adduct, align_group=next_align_group, # curent_group=curent_group, clusterID=context$clusterID, annotation=annotation ) + if (is.null(adduct <- context$adducts[[adduct_name]])) { + context$adducts[[adduct_name]] <- orm$adduct()$load_by(name=adduct_name)$first() + if (is.null(adduct <- context$adducts[[adduct_name]])) { + adduct <- context$adducts[[adduct_name]] <- orm$adduct(name=adduct_name, charge=0) + adduct$save() + } + } + cluster$set_adduct(adduct) ## Crappy hack to assign sample id to cluster without loading the sample. ## Samples are too big (their sample$env) and slows the process, and eat all the menory ## so we dont't want to load them. diff -r f4fc4a0f41e2 -r bdb2878ee189 XSeekerPreparator.xml --- a/XSeekerPreparator.xml Thu Mar 18 10:46:01 2021 +0000 +++ b/XSeekerPreparator.xml Wed Apr 07 13:05:36 2021 +0000 @@ -197,13 +197,12 @@ score="FLOAT", deviation="FLOAT", status="TEXT", - adduct="TEXT", curent_group="INTEGER", pc_group="INTEGER", align_group="INTEGER", xcms_group="INTEGER" ), - one=list("sample", "compound") + one=list("sample", "compound", "adduct") ), compound=DBModelR::ModelDefinition( table="compound", diff -r f4fc4a0f41e2 -r bdb2878ee189 galaxy/tools/LC-MSMS/XSeekerPreparator.R --- a/galaxy/tools/LC-MSMS/XSeekerPreparator.R Thu Mar 18 10:46:01 2021 +0000 +++ b/galaxy/tools/LC-MSMS/XSeekerPreparator.R Wed Apr 07 13:05:36 2021 +0000 @@ -484,18 +484,44 @@ singlefile <- rdata$singlefile process_arg_list <- rdata$listOFlistArguments var_meta <- rdata$variableMetadata - ## We needed to get rid of the rdata, which is very big. - ## So we gathered all variable assignment from rdata here, and got rid of it. - rm(rdata) process_params <- list() - for (list_name in names(process_arg_list)) { - param_list <- list() - for (param_name in names(process_arg_list[[list_name]])) { - param_list[[param_name]] <- process_arg_list[[list_name]][[param_name]] + if (is.null(process_arg_list)) { + histories <- list() + for (history in xcms_set@.processHistory) { + if ( + class(history@param) == "CentWaveParam" + && history@type == "Peak detection" + ) { + params <- history@param + process_params <- list(list( + xfunction="annotatediff", + ppm=params@ppm, + peakwidth=sprintf("%s - %s", params@peakwidth[[1]], params@peakwidth[[2]]), + snthresh=params@snthresh, + prefilterStep=params@prefilter[[1]], + prefilterLevel=params@prefilter[[2]], + mzdiff=params@mzdiff, + fitgauss=params@fitgauss, + noise=params@noise, + mzCenterFun=params@mzCenterFun, + integrate=params@integrate, + firstBaselineCheck=params@firstBaselineCheck, + snthreshIsoROIs=!identical(params@roiScales, numeric(0)) + )) + break + } } - process_params[[length(process_params)+1]] <- param_list + } else { + for (list_name in names(process_arg_list)) { + param_list <- list() + for (param_name in names(process_arg_list[[list_name]])) { + param_list[[param_name]] <- process_arg_list[[list_name]][[param_name]] + } + process_params[[length(process_params)+1]] <- param_list + } } + message("Parameters from previous processes extracted.") @@ -532,7 +558,7 @@ env$tic <- ms_file@tic env$mz <- ms_file@env$mz env$scanindex <- ms_file@scanindex - env$scantime <- ms_file@scantime + env$scantime <- ms_file@scantime * 60 env$intensity <- ms_file@env$intensity env$polarity <- as.character(ms_file@polarity[[1]]) @@ -555,6 +581,7 @@ context$show_percent <- show_percent context$cluster_mean_rt_abundance <- list() context$central_feature <- list() + context$adducts <- list() load_variable_metadata(orm, var_meta, context) clusters <- context$clusters rm(context) @@ -695,6 +722,7 @@ } } create_associated_cluster( + orm, context$central_feature[[clusterID]], dummy_feature, clusterID, context, curent_var_meta, next_pc_group, @@ -761,22 +789,31 @@ } create_associated_cluster <- function( + orm, sample_no, feature, clusterID, context, curent_var_meta, next_pc_group, next_align_group ) { - pcgroup <- as.numeric(curent_var_meta[["pcgroup"]]) - adduct <- as.character(curent_var_meta[["adduct"]]) - annotation <- curent_var_meta[["isotopes"]] clusterID <- as.character(clusterID) if (is.null(cluster <- context$clusters[[clusterID]])) { + pcgroup <- as.numeric(curent_var_meta[["pcgroup"]]) + adduct_name <- as.character(curent_var_meta[["adduct"]]) + annotation <- curent_var_meta[["isotopes"]] cluster <- context$clusters[[clusterID]] <- orm$cluster( pc_group=pcgroup + next_pc_group, - adduct=adduct, + # adduct=adduct, align_group=next_align_group, # curent_group=curent_group, clusterID=context$clusterID, annotation=annotation ) + if (is.null(adduct <- context$adducts[[adduct_name]])) { + context$adducts[[adduct_name]] <- orm$adduct()$load_by(name=adduct_name)$first() + if (is.null(adduct <- context$adducts[[adduct_name]])) { + adduct <- context$adducts[[adduct_name]] <- orm$adduct(name=adduct_name, charge=0) + adduct$save() + } + } + cluster$set_adduct(adduct) ## Crappy hack to assign sample id to cluster without loading the sample. ## Samples are too big (their sample$env) and slows the process, and eat all the menory ## so we dont't want to load them. diff -r f4fc4a0f41e2 -r bdb2878ee189 galaxy/tools/LC-MSMS/XSeekerPreparator.xml --- a/galaxy/tools/LC-MSMS/XSeekerPreparator.xml Thu Mar 18 10:46:01 2021 +0000 +++ b/galaxy/tools/LC-MSMS/XSeekerPreparator.xml Wed Apr 07 13:05:36 2021 +0000 @@ -197,13 +197,12 @@ score="FLOAT", deviation="FLOAT", status="TEXT", - adduct="TEXT", curent_group="INTEGER", pc_group="INTEGER", align_group="INTEGER", xcms_group="INTEGER" ), - one=list("sample", "compound") + one=list("sample", "compound", "adduct") ), compound=DBModelR::ModelDefinition( table="compound",