comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:7c20fbf53fbf
1 #!/usr/bin/env Rscript
2
3 # R version 4.3.3
4 # Conversion tool mzXMLShaper.R (former cdf2mzml)
5 # Author: Quentin RUIN
6 # Creation date: 25/04/2023
7 # Last updated: 09/09/2024
8
9 cat("\nJob starting time:\n", format(Sys.time(), "%a %d %b %Y %X"), "\n\n")
10
11 library(mzR)
12 library(msdata)
13 library("W4MRUtils")
14 library("tools")
15
16 args <- W4MRUtils::parse_args(args = commandArgs())
17
18 cat("\n\n--------------------------------------------------------------------",
19 "\nParameters used by the 'mz(X)MLShaper' tool:\n\n")
20 cat("--------------------------------------------------------------------\n\n")
21 print(args)
22
23 inputfilename <- args[[1]]
24 outputfileformat <- args[[2]]
25 outputfilename <- args[[3]]
26 spectrum <- mzR::openMSfile(inputfilename)
27
28 ## Get the spectra
29 pks <- mzR::spectra(spectrum)
30
31 ## Get the header
32 hdr <- mzR::header(spectrum)
33
34 if (outputfileformat == "mzml") {
35 writeMSData(pks, file = outputfilename, outformat = "mzml", header = hdr)
36 }
37
38 if (outputfileformat == "mzXml") {
39 writeMSData(pks, file = outputfilename, outformat = "mzxml", header = hdr)
40 }
41
42 cat("\n--------------------------------------------------------------------",
43 "\nInformation about R (version, Operating System, attached or loaded packages):\n\n")
44 sessionInfo()
45 cat("--------------------------------------------------------------------\n",
46 "\nJob ending time:\n", format(Sys.time(), "%a %d %b %Y %X"))