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