Previous changeset 0:91a3242fd67f (2022-04-25) Next changeset 2:a35fde23940e (2022-06-08) |
Commit message:
planemo upload commit 42359ca78388ce5221bc88905a78c996c758aa43 |
modified:
MS2snoop.R MS2snoop.xml README.md |
b |
diff -r 91a3242fd67f -r df2672c37732 MS2snoop.R --- a/MS2snoop.R Mon Apr 25 08:23:54 2022 +0000 +++ b/MS2snoop.R Tue May 24 18:14:49 2022 +0000 |
[ |
b'@@ -13,8 +13,22 @@\n #\'\r\n #\' @import optparse\r\n #\'\r\n-NULL\r\n+\r\n+\r\n+assign("MS2SNOOP_VERSION", "1.0.1")\r\n+lockBinding("MS2SNOOP_VERSION", globalenv())\r\n+\r\n+assign("MISSING_PARAMETER_ERROR", 1)\r\n+lockBinding("MISSING_PARAMETER_ERROR", globalenv())\r\n \r\n+assign("BAD_PARAMETER_VALUE_ERROR", 2)\r\n+lockBinding("BAD_PARAMETER_VALUE_ERROR", globalenv())\r\n+\r\n+assign("MISSING_INPUT_FILE_ERROR", 3)\r\n+lockBinding("MISSING_INPUT_FILE_ERROR", globalenv())\r\n+\r\n+assign("NO_ANY_RESULT_ERROR", 255)\r\n+lockBinding("NO_ANY_RESULT_ERROR", globalenv())\r\n \r\n assign("DEFAULT_PRECURSOR_PATH", "peaklist_precursors.tsv")\r\n assign("DEFAULT_FRAGMENTS_PATH", "peaklist_fragments.tsv")\r\n@@ -47,9 +61,6 @@\n lockBinding("DEFAULT_EXTRACT_FRAGMENTS_TOLRT", globalenv())\r\n \r\n \r\n-debug <- FALSE\r\n-\r\n-\r\n ########################################################################\r\n \r\n #\' @title plot_pseudo_spectra\r\n@@ -213,7 +224,7 @@\n ## files (collision energy)\r\n ## this lead to a processing for each fileid\r\n mf <- levels(as.factor(sprecini$fileid))\r\n- if (length(mf) > 1) {\r\n+ if (length(mf) > 1 && global_verbose) {\r\n cat(" several files detected for this compounds :\\n")\r\n }\r\n \r\n@@ -239,7 +250,9 @@\n ## creation of cross table row=scan col=mz X=ra\r\n vmz <- levels(as.factor(sfrgtfil$mznominal))\r\n \r\n- cat(" fragments :", vmz)\r\n+ if (global_verbose) {\r\n+ cat(" fragments :", vmz)\r\n+ }\r\n \r\n ## mz of precursor in data precursor to check correlation with\r\n mz_prec <- paste0("mz", round(mean(sprec$mz), mzdecimal))\r\n@@ -271,7 +284,8 @@\n )\r\n }\r\n }\r\n- if (debug) {\r\n+ if (global_debug) {\r\n+ print(ds_abs_int)\r\n write.table(\r\n x = ds_abs_int,\r\n file = paste0(c_name, "ds_abs_int.txt"),\r\n@@ -358,7 +372,9 @@\n if (!is.null(res_comp_by_file)) {\r\n res_comp <- rbind(res_comp, res_comp_by_file)\r\n }\r\n- cat("\\n")\r\n+ if (global_verbose) {\r\n+ cat("\\n")\r\n+ }\r\n dev.off()\r\n }\r\n } else {\r\n@@ -368,6 +384,25 @@\n return(res_comp)\r\n }\r\n \r\n+set_global <- function(var, value) {\r\n+ assign(var, value, envir = globalenv())\r\n+}\r\n+\r\n+set_debug <- function() {\r\n+ set_global("global_debug", TRUE)\r\n+}\r\n+\r\n+unset_debug <- function() {\r\n+ set_global("global_debug", FALSE)\r\n+}\r\n+\r\n+set_verbose <- function() {\r\n+ set_global("global_verbose", TRUE)\r\n+}\r\n+\r\n+unset_verbose <- function() {\r\n+ set_global("global_verbose", FALSE)\r\n+}\r\n \r\n create_parser <- function() {\r\n parser <- optparse::OptionParser()\r\n@@ -376,7 +411,27 @@\n c("-v", "--verbose"),\r\n action = "store_true",\r\n default = FALSE,\r\n- help = "Print extra output [default %default]"\r\n+ help = paste(\r\n+ "[default %default]",\r\n+ "Print extra output"\r\n+ )\r\n+ )\r\n+ parser <- optparse::add_option(\r\n+ parser,\r\n+ c("-V", "--version"),\r\n+ action = "store_true",\r\n+ default = FALSE,\r\n+ help = "Prints version and exits"\r\n+ )\r\n+ parser <- optparse::add_option(\r\n+ parser,\r\n+ c("-d", "--debug"),\r\n+ action = "store_true",\r\n+ default = FALSE,\r\n+ help = paste(\r\n+ "[default %default]",\r\n+ "Print debug outputs"\r\n+ )\r\n )\r\n parser <- optparse::add_option(\r\n parser,\r\n@@ -416,7 +471,11 @@\n type = "numeric",\r\n action = "store",\r\n default = DEFAULT_TOLMZ,\r\n- metavar = "number"\r\n+ metavar = "number",\r\n+ help = paste(\r\n+ "[default %default]",\r\n+ "Tolerance for MZ (in Dalton) to match the standard in the compounds"\r\n+ )\r\n )\r\n parser <- optparse::add_option(\r\n parser,\r\n@@ -424,16 +483,23 @@\n type = "integer",\r\n action = "store",\r\n default = DEFAULT_TOLRT,\r\n- metavar = "number"\r\n+ metavar = "number",\r\n+ help = paste(\r\n+ "[default %default]",\r\n+ "RT (in seconds) to match the standard in the compounds"\r\n+ )\r\n )\r\n parser <- optparse::add_option(\r\n parser,\r\n c("--seuil_ra"),\r\n type = "numeric",\r\n action = "store",\r\n- hel'..b'th_status(\r\n+ "Missing fragments parameters. Please set it with --fragments.",\r\n+ MISSING_PARAMETER_ERROR\r\n+ )\r\n+ }\r\n+ if (length(args$compounds) == 0 || nchar(args$compounds[1]) == 0) {\r\n+ stop_with_status(\r\n+ "Missing compounds parameters. Please set it with --compounds.",\r\n+ MISSING_PARAMETER_ERROR\r\n+ )\r\n+ }\r\n+ if (!file.exists(args$precursors)) {\r\n+ stop_with_status(\r\n+ sprintf(\r\n+ "Precursors file %s does not exist or cannot be accessed.",\r\n+ args$precursors\r\n+ ),\r\n+ MISSING_INPUT_FILE_ERROR\r\n+ )\r\n+ }\r\n+ if (!file.exists(args$fragments)) {\r\n+ stop_with_status(\r\n+ sprintf(\r\n+ "Fragments file %s does not exist or cannot be accessed.",\r\n+ args$fragments\r\n+ ),\r\n+ MISSING_INPUT_FILE_ERROR\r\n+ )\r\n+ }\r\n+ if (!file.exists(args$compounds)) {\r\n+ stop_with_status(\r\n+ sprintf(\r\n+ "Compounds file %s does not exist or cannot be accessed.",\r\n+ args$compounds\r\n+ ),\r\n+ MISSING_INPUT_FILE_ERROR\r\n+ )\r\n+ }\r\n+ if (\r\n+ "_GALAXY_JOB_HOME_DIR" %in% sysvarnames\r\n+ || "_GALAXY_JOB_TMP_DIR" %in% sysvarnames\r\n+ || "GALAXY_MEMORY_MB" %in% sysvarnames\r\n+ || "GALAXY_MEMORY_MB_PER_SLOT" %in% sysvarnames\r\n+ || "GALAXY_SLOTS" %in% sysvarnames\r\n+ ) {\r\n+ check_galaxy_args_validity(args)\r\n+ }\r\n+}\r\n+\r\n+check_galaxy_args_validity <- function(args) {\r\n+ if (!file.exists(args$output)) {\r\n+ stop_with_status(\r\n+ sprintf(\r\n+ "Output file %s does not exist or cannot be accessed.",\r\n+ args$output\r\n+ ),\r\n+ MISSING_INPUT_FILE_ERROR\r\n+ )\r\n+ }\r\n+}\r\n+\r\n main <- function(args) {\r\n- ## FOLDER AND FILES\r\n+ if (args$version) {\r\n+ cat(sprintf("%s\\n", MS2SNOOP_VERSION))\r\n+ base::quit(status = 0)\r\n+ }\r\n+ sessionInfo()\r\n+ check_args_validity(args)\r\n+ if (args$debug) {\r\n+ set_debug()\r\n+ }\r\n+ if (args$verbose) {\r\n+ set_verbose()\r\n+ }\r\n ## MSpurity precursors file\r\n precursors <- read.table(\r\n file = args$precursors,\r\n@@ -494,22 +659,8 @@\n quote = "\\"",\r\n header = TRUE\r\n )\r\n- ## PARAMETERS\r\n- ## tolerance for mz(dalton) rt(seconds) to match the standard in the compounds\r\n- ## list with the precursor MSpurity file\r\n- tolmz <- args$tolmz\r\n- tolrt <- args$tolrt\r\n \r\n- ## relative intensity threshold\r\n- seuil_ra <- args$seuil_ra\r\n- ## nb decimal for mz\r\n- mzdecimal <- args$mzdecimal\r\n- ## r pearson correlation threshold between precursor and\r\n- # #fragment absolute intensity\r\n- r_threshold <- args$r_threshold\r\n- ## fragments are kept if there are found in a minimum number of scans\r\n- min_number_scan <- args$min_number_scan\r\n-\r\n+ res_all <- NULL\r\n for (i in seq_len(nrow(compounds))) {\r\n ## loop execution for all compounds in the compounds file\r\n res_cor <- NULL\r\n@@ -519,22 +670,24 @@\n mzref = compounds[[2]][i],\r\n rtref = compounds[[3]][i],\r\n c_name = compounds[[1]][i],\r\n- min_number_scan = min_number_scan,\r\n- mzdecimal = mzdecimal,\r\n- r_threshold = r_threshold,\r\n- seuil_ra = seuil_ra,\r\n- tolmz = tolmz,\r\n- tolrt = tolrt\r\n+ min_number_scan = args$min_number_scan,\r\n+ mzdecimal = args$mzdecimal,\r\n+ r_threshold = args$r_threshold,\r\n+ seuil_ra = args$seuil_ra,\r\n+ tolmz = args$tolmz,\r\n+ tolrt = args$tolrt\r\n )\r\n- if (i == 1 & !is.null(res_cor)) {\r\n- res_all <- res_cor\r\n- } else if (!is.null(res_cor)) {\r\n- res_all <- rbind(res_all, res_cor)\r\n+ if (!is.null(res_cor)) {\r\n+ if (is.null(res_all)) {\r\n+ res_all <- res_cor\r\n+ } else {\r\n+ res_all <- rbind(res_all, res_cor)\r\n+ }\r\n }\r\n }\r\n \r\n if (is.null(res_all)) {\r\n- stop("No result at all!")\r\n+ stop_with_status("No result at all!", NO_ANY_RESULT_ERROR)\r\n }\r\n write.table(\r\n x = res_all,\r\n@@ -544,8 +697,9 @@\n )\r\n }\r\n \r\n+unset_debug()\r\n+unset_verbose()\r\n args <- optparse::parse_args(create_parser())\r\n-sessionInfo()\r\n main(args)\r\n \r\n warnings()\r\n' |
b |
diff -r 91a3242fd67f -r df2672c37732 MS2snoop.xml --- a/MS2snoop.xml Mon Apr 25 08:23:54 2022 +0000 +++ b/MS2snoop.xml Tue May 24 18:14:49 2022 +0000 |
[ |
b'@@ -1,93 +1,140 @@\n-<tool id="ms2snoop" name="MS2 Snoop" version="1.0.0" profile="21.05">\n+<tool id="ms2snoop" name="MS2 Snoop" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.01">\n+ <macros>\n+ <token name="@TOOL_VERSION@">1.0.1</token>\n+ <token name="@VERSION_SUFFIX@">0</token>\n+ </macros>\n <description>\n MS1/MS2 spectra and associated adducts extraction and cleaning\n </description>\n-\n+ <edam_topics>\n+ <edam_topic>topic_0091</edam_topic>\n+ <edam_topic>topic_3370</edam_topic>\n+ </edam_topics>\n+ <edam_operations>\n+ <edam_operation>operation_3803</edam_operation>\n+ <edam_operation>operation_3860</edam_operation>\n+ </edam_operations>\n <requirements>\n- <requirement type="package">r-optparse</requirement>\n+ <requirement type="package" version="4.1.3">r-base</requirement>\n+ <requirement type="package" version="1.7.1">r-optparse</requirement>\n </requirements>\n-\n- <command><![CDATA[\n+ <stdio>\n+ <exit_code range="1" level="fatal" description="Missing parameter error" />\n+ <exit_code range="2" level="fatal" description="Bad parameter\'s value" />\n+ <exit_code range="3" level="fatal" description="Missing input file" />\n+ <exit_code range="4:254" level="fatal" description="Unknown error" />\n+ <exit_code range="255" level="fatal" description="No any result to output" />\n+ <regex match="Error in\\s+.*:\\s+.*" />\n+ </stdio>\n+ <version_command>\n+ Rscript \'$__tool_directory__/MS2snoop.R\' --version | head -n 1\n+ </version_command>\n+ <command>\n+ <![CDATA[\n Rscript \'$__tool_directory__/MS2snoop.R\'\n- -o \'$frag_result_txt\'\n- -c \'$compound_txt\'\n- -f \'$peaklist_frag_tsv\'\n- -p \'$peaklist_preco_tsv\'\n+ --output \'$frag_result_txt\'\n+ --compounds \'$compound_txt\'\n+ --fragments \'$peaklist_frag_tsv\'\n+ --precursors \'$peaklist_preco_tsv\'\n --tolmz \'$tolmz\'\n --tolrt \'$tolrt\'\n --seuil_ra \'$seuil_ra\'\n --mzdecimal \'$mzdecimal\'\n --r_threshold \'$r_threshold\'\n --min_number_scan \'$min_number_scan\'\n-;\n- ]]></command>\n-\n+ $advenced.debug\n+ $advenced.verbose\n+ ]]>\n+ </command>\n <inputs>\n <param\n type="data"\n- format="tabular"\n- name="compound_txt"\n- label="compounds_pos.txt"\n+ format="tabular,csv"\n+ argument="--compound_txt"\n+ label="list of compounds : col1=Name of molecule, col2=m/z, col3=retention time"\n />\n <param\n type="data"\n- format="tabular"\n- name="peaklist_frag_tsv"\n- label="peaklist_fragments.tsv"\n+ format="tabular,csv"\n+ argument="--peaklist_frag_tsv"\n+ label="MSpurity fragments file"\n />\n <param\n type="data"\n- format="tabular"\n- name="peaklist_preco_tsv"\n- label="peaklist_precursors.tsv"\n+ format="tabular,csv"\n+ argument="--peaklist_preco_tsv"\n+ label="MSpurity precursors file"\n />\n <param\n- name="tolmz"\n type="float"\n min="0.0001"\n max="10"\n value="0.01"\n label="MZ Tolerence"\n+ argument="--tolmz"\n />\n <param\n- name="tolrt"\n type="integer"\n min="0"\n max="30"\n value="20"\n label="RT Tolerence"\n+ argument="--tolrt"\n />\n <param\n- name="seuil_ra"\n type="float"\n min="0"\n max="1"\n value="0.05"\n label="r pearson correlation threshold between precursor and fragment absolute intensity"\n+ argument="--seuil_ra"\n />\n <param\n- name="mzdecimal"\n type="integer"\n min="0"\n max="5"\n value="0"\n'..b'================ ================= ======= =========\n-**Downstream tools**\n-========================= ================= ======= =========\n-Name output file format parameter\n-========================= ================= ======= =========\n-NA NA NA NA\n-========================= ================= ======= =========\n+--------------\n+Upstream tools\n+--------------\n+\n++-------------------------+-----------------+--------+------------+\n+| Name | output file | format | parameter |\n++=========================+=================+========+============+\n+| msPurity.purityA | NA | TSV | NA |\n++-------------------------+-----------------+--------+------------+\n+| msPurity.frag4feature | NA | TSV | NA |\n++-------------------------+-----------------+--------+------------+\n+\n+----------------\n+Downstream tools\n+----------------\n+\n++-------------------------+-----------------+--------+------------+\n+| Name | output file | format | parameter |\n++=========================+=================+========+============+\n+| NA | NA | NA | NA |\n++-------------------------+-----------------+--------+------------+\n+\n \n -----------\n Input files\n@@ -149,8 +207,10 @@\n | Parameter : num + label | Format |\n +===========================+==================+============+\n | Input from msPurity Precursor | TSV |\n++----------------------------------------------+------------+\n | Input from msPurity fragment | TSV |\n | Input compounds file to search in precursor | |\n++----------------------------------------------+------------+\n | and fragment (Name + m/z + ret Time) | TSV |\n +----------------------------------------------+------------+\n \n@@ -159,35 +219,43 @@\n Parameters\n ----------\n \n-msPurity.purityA output TSV file\n-msPurity.frag4feature output TSV file\n+msPurity.purityA\n+ | output TSV file\n+\n+msPurity.frag4feature\n+ | output TSV file\n+\n Compounds file\n-| A TSV TXT file with a list of compounds with at least 3 columns : \n-| col1=Name of molecule, col2=m/z, col3=retention time\n+ | A TSV TXT file with a list of compounds with at least 3 columns : \n+ | col1=Name of molecule, col2=m/z, col3=retention time\n+\n tolerance for mz(dalton) rt(seconds) to match the standard in the compounds file with the precursor MSpurity files\n-| tolmz <- 0.01\n-| tolrt <- 20\n+ | tolmz <- 0.01\n+ | tolrt <- 20\n+\n relative intensity threshold\n-| seuil_ra = 0.05\n+ | seuil_ra = 0.05\n+\n nb decimal for mz\n-| mzdecimal <- 0\n+ | mzdecimal <- 0\n+\n r pearson correlation threshold between precursor and fragment absolute intensity\n-| r_threshold <- 0.85\n+ | r_threshold <- 0.85\n+\n fragments are kept if there are found in a minimum number of scans\n-| minNumberScan <- 8\n+ | minNumberScan <- 8\n \n ------------\n Output files\n ------------\n \n compound_fragments_result.tsv\n-| tabular output\n-| Array with p rows (corresponding to the fragments for the different compounds of the compounds file)\n-| Last column "corvalid" is a boolean for validated fragments \n+ | tabular output\n+ | Array with p rows (corresponding to the fragments for the different compounds of the compounds file)\n+ | Last column "corvalid" is a boolean for validated fragments \n+\n processing_file.pdf\n-| pdf output \n-| For each compound of the compounds file, Graph of the all fragments with parents (or most intense peak if parent is not detected in the fragments. At the end the pdf file a graph of the spectra with validated fragments.\n-\n+ | pdf output \n+ | For each compound of the compounds file, Graph of the all fragments with parents (or most intense peak if parent is not detected in the fragments. At the end the pdf file a graph of the spectra with validated fragments.\n ]]></help>\n-\n </tool>\n' |
b |
diff -r 91a3242fd67f -r df2672c37732 README.md --- a/README.md Mon Apr 25 08:23:54 2022 +0000 +++ b/README.md Tue May 24 18:14:49 2022 +0000 |
b |
@@ -5,7 +5,7 @@ ----------- * **@name**: MS2 Snoop - * **@version**: 1.0.0 + * **@version**: 1.0.1 * **@authors**: Jean François Martin (INRAE) * **@maintainers**: Lain Pavot (PFEM - INRAE - MetaboHUB) * **@init date**: 2022, April |