view 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
line wrap: on
line source

#!/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"))