Mercurial > repos > workflow4metabolomics > mzxmlshaper
annotate mzXMLShaper.R @ 0:7c20fbf53fbf draft default tip
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
author | workflow4metabolomics |
---|---|
date | Mon, 07 Oct 2024 11:40:19 +0000 |
parents | |
children |
rev | line source |
---|---|
0
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
2 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
3 # R version 4.3.3 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
4 # Conversion tool mzXMLShaper.R (former cdf2mzml) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
5 # Author: Quentin RUIN |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
6 # Creation date: 25/04/2023 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
7 # Last updated: 09/09/2024 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
8 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
9 cat("\nJob starting time:\n", format(Sys.time(), "%a %d %b %Y %X"), "\n\n") |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
10 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
11 library(mzR) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
12 library(msdata) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
13 library("W4MRUtils") |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
14 library("tools") |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
15 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
16 args <- W4MRUtils::parse_args(args = commandArgs()) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
17 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
18 cat("\n\n--------------------------------------------------------------------", |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
19 "\nParameters used by the 'mz(X)MLShaper' tool:\n\n") |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
20 cat("--------------------------------------------------------------------\n\n") |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
21 print(args) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
22 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
23 inputfilename <- args[[1]] |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
24 outputfileformat <- args[[2]] |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
25 outputfilename <- args[[3]] |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
26 spectrum <- mzR::openMSfile(inputfilename) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
27 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
28 ## Get the spectra |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
29 pks <- mzR::spectra(spectrum) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
30 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
31 ## Get the header |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
32 hdr <- mzR::header(spectrum) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
33 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
34 if (outputfileformat == "mzml") { |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
35 writeMSData(pks, file = outputfilename, outformat = "mzml", header = hdr) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
36 } |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
37 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
38 if (outputfileformat == "mzXml") { |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
39 writeMSData(pks, file = outputfilename, outformat = "mzxml", header = hdr) |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
40 } |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
41 |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
42 cat("\n--------------------------------------------------------------------", |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
43 "\nInformation about R (version, Operating System, attached or loaded packages):\n\n") |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
44 sessionInfo() |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
45 cat("--------------------------------------------------------------------\n", |
7c20fbf53fbf
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit f85839922690f81d3ec5876d1b7981e76e36d363
workflow4metabolomics
parents:
diff
changeset
|
46 "\nJob ending time:\n", format(Sys.time(), "%a %d %b %Y %X")) |