From f7f6239d27bb887ab7407c5d61478f5ae81c5638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 29 Jul 2021 17:11:52 +0200 Subject: [PATCH] Add support for reading .mzMLb chromatograms. --- .../.project | 17 ++ .../build.properties | 1 + .../feature.xml | 45 +++++ .../feature.xml | 4 + openchrom/features/pom.xml | 1 + .../.classpath | 7 + .../.gitignore | 1 + .../.project | 28 +++ .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 24 +++ .../OSGI-INF/l10n/bundle_en.properties | 12 ++ .../build.properties | 6 + .../plugin.xml | 17 ++ .../converter/supplier/mzmlb/Activator.java | 43 +++++ .../supplier/mzmlb/PathResolver.java | 45 +++++ .../ChromatogramImportConverter.java | 71 ++++++++ .../mzmlb/converter/MagicNumberMatcher.java | 26 +++ .../mzmlb/internal/io/ReaderProxy.java | 84 +++++++++ .../supplier/mzmlb/internal/model/mzML.java | 17 ++ .../mzmlb/internal/support/IConstants.java | 18 ++ .../supplier/mzmlb/io/ChromatogramReader.java | 166 ++++++++++++++++++ .../supplier/mzmlb/io/ChromatogramWriter.java | 30 ++++ .../supplier/mzmlb/io/IReaderProxy.java | 26 +++ .../supplier/mzmlb/io/ProxyReader.java | 31 ++++ .../mzmlb/io/support/IScanMarker.java | 31 ++++ .../supplier/mzmlb/io/support/ScanMarker.java | 76 ++++++++ .../mzmlb/model/IVendorChromatogram.java | 17 ++ .../supplier/mzmlb/model/IVendorIon.java | 17 ++ .../supplier/mzmlb/model/IVendorScan.java | 17 ++ .../mzmlb/model/IVendorScanProxy.java | 17 ++ .../mzmlb/model/VendorChromatogram.java | 25 +++ .../supplier/mzmlb/model/VendorIon.java | 67 +++++++ .../supplier/mzmlb/model/VendorScan.java | 94 ++++++++++ .../supplier/mzmlb/model/VendorScanProxy.java | 117 ++++++++++++ openchrom/plugins/pom.xml | 1 + 35 files changed, 1206 insertions(+) create mode 100644 openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/.project create mode 100644 openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/build.properties create mode 100644 openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/feature.xml create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.classpath create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.gitignore create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.project create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.settings/org.eclipse.jdt.core.prefs create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/META-INF/MANIFEST.MF create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/OSGI-INF/l10n/bundle_en.properties create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/build.properties create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/plugin.xml create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/Activator.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/PathResolver.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/converter/ChromatogramImportConverter.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/converter/MagicNumberMatcher.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/io/ReaderProxy.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/model/mzML.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/support/IConstants.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ChromatogramReader.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ChromatogramWriter.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/IReaderProxy.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ProxyReader.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/support/IScanMarker.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/support/ScanMarker.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorChromatogram.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorIon.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorScan.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorScanProxy.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorChromatogram.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorIon.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorScan.java create mode 100644 openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorScanProxy.java diff --git a/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/.project b/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/.project new file mode 100644 index 000000000..f94fe9b10 --- /dev/null +++ b/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/.project @@ -0,0 +1,17 @@ + + + net.openchrom.msd.converter.supplier.mzmlb.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/build.properties b/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/build.properties new file mode 100644 index 000000000..64f93a9f0 --- /dev/null +++ b/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/feature.xml b/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/feature.xml new file mode 100644 index 000000000..d15445d45 --- /dev/null +++ b/openchrom/features/net.openchrom.msd.converter.supplier.mzmlb.feature/feature.xml @@ -0,0 +1,45 @@ + + + + + This is the mzMLb chromatogram converter. + + + + Copyright (c) 2014, 2021 Lablicate GmbH. + + + + Copyright (c) 2014, 2021 Lablicate GmbH. + +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License +v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html + + + + + + + + + + + diff --git a/openchrom/features/net.openchrom.platform.feature/feature.xml b/openchrom/features/net.openchrom.platform.feature/feature.xml index d6a77d250..a676009d7 100644 --- a/openchrom/features/net.openchrom.platform.feature/feature.xml +++ b/openchrom/features/net.openchrom.platform.feature/feature.xml @@ -141,6 +141,10 @@ id="net.openchrom.nmr.converter.supplier.nmrml.feature" version="0.0.0"/> + + net.openchrom.msd.converter.supplier.mz5.feature net.openchrom.xxd.converter.supplier.gaml.feature net.openchrom.nmr.converter.supplier.nmrml.feature + net.openchrom.msd.converter.supplier.mzmlb.feature diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.classpath b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.classpath new file mode 100644 index 000000000..eca7bdba8 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.gitignore b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.gitignore new file mode 100644 index 000000000..ae3c17260 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.project b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.project new file mode 100644 index 000000000..67ca2990a --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.project @@ -0,0 +1,28 @@ + + + net.openchrom.msd.converter.supplier.mzmlb + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.settings/org.eclipse.jdt.core.prefs b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..0c68a61dc --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/META-INF/MANIFEST.MF b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/META-INF/MANIFEST.MF new file mode 100644 index 000000000..2909d53a7 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/META-INF/MANIFEST.MF @@ -0,0 +1,24 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: net.openchrom.msd.converter.supplier.mz5 +Bundle-ManifestVersion: 2 +Bundle-Name: mzMLb +Bundle-SymbolicName: net.openchrom.msd.converter.supplier.mzmlb;singleton:=true +Bundle-Version: 1.4.0.qualifier +Bundle-Activator: net.openchrom.msd.converter.supplier.mzmlb.Activator +Bundle-Vendor: OpenChrom +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.chemclipse.msd.converter;bundle-version="0.8.0", + org.eclipse.chemclipse.msd.model;bundle-version="0.8.0", + org.eclipse.chemclipse.logging;bundle-version="0.8.0", + org.eclipse.chemclipse.processing;bundle-version="0.8.0", + org.eclipse.chemclipse.converter;bundle-version="0.8.0", + org.eclipse.chemclipse.model;bundle-version="0.8.0", + org.eclipse.chemclipse.support;bundle-version="0.8.0", + net.openchrom.thirdpartylibraries.jhdf5, + org.eclipse.chemclipse.msd.converter.supplier.mzml +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Export-Package: net.openchrom.msd.converter.supplier.mzmlb, + net.openchrom.msd.converter.supplier.mzmlb.converter, + net.openchrom.msd.converter.supplier.mzmlb.io, + net.openchrom.msd.converter.supplier.mzmlb.model diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/OSGI-INF/l10n/bundle_en.properties b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/OSGI-INF/l10n/bundle_en.properties new file mode 100644 index 000000000..70d792b0b --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/OSGI-INF/l10n/bundle_en.properties @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2015, 2017 Lablicate GmbH. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Dr. Philip Wenig - initial API and implementation +############################################################################### +#Properties file diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/build.properties b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/build.properties new file mode 100644 index 000000000..948f0bdf0 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/,\ + plugin.xml diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/plugin.xml b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/plugin.xml new file mode 100644 index 000000000..6f8941b00 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/plugin.xml @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/Activator.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/Activator.java new file mode 100644 index 000000000..3b25c98df --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/Activator.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + public static BundleContext getContext() { + + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + + Activator.context = null; + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/PathResolver.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/PathResolver.java new file mode 100644 index 000000000..6eda0a0bc --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/PathResolver.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb; + +import java.io.IOException; +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.osgi.framework.Bundle; + +public class PathResolver { + + /** + * Returns a absolute path of the specified Folder. For example + * TESTDATA_IMPORT_EMPTY as an absolute Path: + * $PluginPath$/testData/files/data.mzMLb + * + * @param string + * @return String absolutePath + */ + public static String getAbsolutePath(String string) { + + Bundle bundle = Platform.getBundle(Activator.getContext().getBundle().getSymbolicName()); + IPath path = new Path(string); + URL url = FileLocator.find(bundle, path, null); + try { + return FileLocator.resolve(url).getPath().toString(); + } catch(IOException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/converter/ChromatogramImportConverter.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/converter/ChromatogramImportConverter.java new file mode 100644 index 000000000..fb45db24f --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/converter/ChromatogramImportConverter.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2013, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + * Christoph Läubrich - add generics + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.converter; + +import java.io.File; + +import org.eclipse.chemclipse.converter.chromatogram.AbstractChromatogramImportConverter; +import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.model.core.IChromatogramOverview; +import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDReader; +import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD; +import org.eclipse.chemclipse.processing.core.IProcessingInfo; +import org.eclipse.core.runtime.IProgressMonitor; + +import net.openchrom.msd.converter.supplier.mzmlb.internal.support.IConstants; +import net.openchrom.msd.converter.supplier.mzmlb.io.ChromatogramReader; + +public class ChromatogramImportConverter extends AbstractChromatogramImportConverter { + + private static final Logger logger = Logger.getLogger(ChromatogramImportConverter.class); + private static final String DESCRIPTION = "mzMLb Import Converter"; + + @Override + public IProcessingInfo convert(File file, IProgressMonitor monitor) { + + IProcessingInfo processingInfo = super.validate(file); + if(!processingInfo.hasErrorMessages()) { + /* + * Read the chromatogram. + */ + IChromatogramMSDReader reader = new ChromatogramReader(); + monitor.subTask(IConstants.IMPORT_CHROMATOGRAM); + try { + IChromatogramMSD chromatogram = reader.read(file, monitor); + processingInfo.setProcessingResult(chromatogram); + } catch(Exception e) { + logger.warn(e); + processingInfo.addErrorMessage(DESCRIPTION, "Something has definitely gone wrong with the file: " + file.getAbsolutePath()); + } + } + return processingInfo; + } + + @Override + public IProcessingInfo convertOverview(File file, IProgressMonitor monitor) { + + IProcessingInfo processingInfo = super.validate(file); + if(!processingInfo.hasErrorMessages()) { + IChromatogramMSDReader reader = new ChromatogramReader(); + monitor.subTask(IConstants.IMPORT_CHROMATOGRAM_OVERVIEW); + try { + IChromatogramOverview chromatogramOverview = reader.readOverview(file, monitor); + processingInfo.setProcessingResult(chromatogramOverview); + } catch(Exception e) { + logger.warn(e); + processingInfo.addErrorMessage(DESCRIPTION, "Something has definitely gone wrong with the file: " + file.getAbsolutePath()); + } + } + return processingInfo; + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/converter/MagicNumberMatcher.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/converter/MagicNumberMatcher.java new file mode 100644 index 000000000..ad81add62 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/converter/MagicNumberMatcher.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.converter; + +import java.io.File; + +import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher; +import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher; + +public class MagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher { + + @Override + public boolean checkFileFormat(File file) { + + return checkFileExtension(file, ".mzMLb"); + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/io/ReaderProxy.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/io/ReaderProxy.java new file mode 100644 index 000000000..462b7508a --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/io/ReaderProxy.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.internal.io; + +import java.io.IOException; +import java.lang.reflect.Array; + +import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.model.exceptions.AbundanceLimitExceededException; +import org.eclipse.chemclipse.msd.model.exceptions.IonLimitExceededException; +import org.eclipse.core.runtime.IProgressMonitor; + +import net.openchrom.msd.converter.supplier.mzmlb.io.IReaderProxy; +import net.openchrom.msd.converter.supplier.mzmlb.io.support.IScanMarker; +import net.openchrom.msd.converter.supplier.mzmlb.model.IVendorIon; +import net.openchrom.msd.converter.supplier.mzmlb.model.IVendorScanProxy; +import net.openchrom.msd.converter.supplier.mzmlb.model.VendorIon; + +import ch.systemsx.cisd.hdf5.IHDF5SimpleReader; + +public class ReaderProxy implements IReaderProxy { + + private static final Logger logger = Logger.getLogger(ReaderProxy.class); + + @Override + public void readMassSpectrum(IHDF5SimpleReader reader, IScanMarker scanMarker, IVendorScanProxy massSpectrum, IProgressMonitor monitor) throws IOException { + + double[] mzs = null; + String mzDataset = scanMarker.getMassesDataset(); + if(mzDataset.contains("float64")) { + mzs = reader.readDoubleArray(mzDataset); + } else if(mzDataset.contains("float32")) { + mzs = floatsToDoubles(reader.readFloatArray(mzDataset)); + } + float[] intensities = null; + String intensityDataset = scanMarker.getIntensitiesDataset(); + if(intensityDataset.contains("float64")) { + intensities = doublesToFloats(reader.readDoubleArray(intensityDataset)); + } else if(intensityDataset.contains("float32")) { + intensities = reader.readFloatArray(intensityDataset); + } + for(int i = scanMarker.getOffset(); i < scanMarker.getOffset() + scanMarker.getLength(); i++) { + try { + float abundance = Array.getFloat(intensities, i); + double mz = Array.getDouble(mzs, i); + if(abundance >= VendorIon.MIN_ABUNDANCE && abundance <= VendorIon.MAX_ABUNDANCE && mz > VendorIon.MIN_ION && mz < VendorIon.MAX_ION) { + IVendorIon ion = new VendorIon(mz, abundance); + massSpectrum.addIon(ion); + } + } catch(AbundanceLimitExceededException e) { + logger.warn(e); + } catch(IonLimitExceededException e) { + logger.warn(e); + } + } + } + + private static float[] doublesToFloats(final double[] input) { + + float[] output = new float[input.length]; + for(int i = 0; i < input.length; i++) { + output[i] = (float)input[i]; + } + return output; + } + + private static double[] floatsToDoubles(final float[] input) { + + double[] output = new double[input.length]; + for(int i = 0; i < input.length; i++) { + output[i] = (double)input[i]; + } + return output; + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/model/mzML.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/model/mzML.java new file mode 100644 index 000000000..1f9b56849 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/model/mzML.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.internal.model; + +public class mzML { + + public String version; +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/support/IConstants.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/support/IConstants.java new file mode 100644 index 000000000..12af7f0b7 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/internal/support/IConstants.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.internal.support; + +public interface IConstants { + + String IMPORT_CHROMATOGRAM = "Import mzMLb Chromatogram"; + String IMPORT_CHROMATOGRAM_OVERVIEW = "Import mzMLb Chromatogram Overview"; +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ChromatogramReader.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ChromatogramReader.java new file mode 100644 index 000000000..1fddd7196 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ChromatogramReader.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.io; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.chemclipse.converter.exceptions.FileIsEmptyException; +import org.eclipse.chemclipse.converter.exceptions.FileIsNotReadableException; +import org.eclipse.chemclipse.converter.io.AbstractChromatogramReader; +import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.model.core.IChromatogramOverview; +import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDReader; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.io.IFormat; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.IConstants; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.XmlReader; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.BinaryDataArrayType; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.CVParamType; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.MzML; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.RunType; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.ScanType; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.SpectrumListType; +import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model.SpectrumType; +import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD; +import org.eclipse.core.runtime.IProgressMonitor; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import net.openchrom.msd.converter.supplier.mzmlb.io.support.IScanMarker; +import net.openchrom.msd.converter.supplier.mzmlb.io.support.ScanMarker; +import net.openchrom.msd.converter.supplier.mzmlb.model.IVendorChromatogram; +import net.openchrom.msd.converter.supplier.mzmlb.model.IVendorScanProxy; +import net.openchrom.msd.converter.supplier.mzmlb.model.VendorChromatogram; +import net.openchrom.msd.converter.supplier.mzmlb.model.VendorScanProxy; + +import ch.systemsx.cisd.hdf5.HDF5Factory; +import ch.systemsx.cisd.hdf5.IHDF5SimpleReader; + +public class ChromatogramReader extends AbstractChromatogramReader implements IChromatogramMSDReader { + + private static final Logger logger = Logger.getLogger(ChromatogramReader.class); + + public ChromatogramReader() { + + } + + @Override + public IChromatogramOverview readOverview(File file, IProgressMonitor monitor) throws FileNotFoundException, FileIsNotReadableException, FileIsEmptyException, IOException { + + return null; + } + + @Override + public IChromatogramMSD read(File file, IProgressMonitor monitor) throws FileNotFoundException, FileIsNotReadableException, FileIsEmptyException, IOException { + + IVendorChromatogram chromatogram = null; + try { + IHDF5SimpleReader reader = HDF5Factory.openForReading(file); + byte[] xml = reader.readAsByteArray(IConstants.NODE_MZML); + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + InputStream inputStream = new ByteArrayInputStream(xml); + Document document = documentBuilder.parse(inputStream); + NodeList topNode = document.getElementsByTagName(IConstants.NODE_MZML); + JAXBContext jaxbContext = JAXBContext.newInstance(IFormat.CONTEXT_PATH_V_110); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + MzML mzML = (MzML)unmarshaller.unmarshal(topNode.item(0)); + RunType run = mzML.getRun(); + chromatogram = new VendorChromatogram(); + SpectrumListType spectrumList = run.getSpectrumList(); + monitor.beginTask(IConstants.IMPORT_CHROMATOGRAM, spectrumList.getCount().intValue()); + for(SpectrumType spectrum : spectrumList.getSpectrum()) { + monitor.subTask(IConstants.SCAN + " " + spectrum.getIndex().intValue()); + float abundance = 0.0f; + int retentionTime = 0; + short msLevel = 0; + String intensityDataset = null; + String mzDataset = null; + int length = 0; + int offset = 0; + for(CVParamType cvParamSpectrum : spectrum.getCvParam()) { + if(cvParamSpectrum.getAccession().equals("MS:1000285") && cvParamSpectrum.getName().equals("total ion current")) { + abundance = Float.parseFloat(cvParamSpectrum.getValue()); + } + if(cvParamSpectrum.getAccession().equals("MS:1000511") && cvParamSpectrum.getName().equals("ms level")) { + msLevel = Short.parseShort(cvParamSpectrum.getValue()); + } + for(ScanType scan : spectrum.getScanList().getScan()) { + for(CVParamType cvParamScan : scan.getCvParam()) { + if(cvParamScan.getAccession().equals("MS:1000016") && cvParamScan.getName().equals("scan start time")) { + int multiplicator = XmlReader.getTimeMultiplicator(cvParamScan); + retentionTime = Math.round(Float.parseFloat(cvParamScan.getValue()) * multiplicator); + } + } + } + for(BinaryDataArrayType binaryDataArray : spectrum.getBinaryDataArrayList().getBinaryDataArray()) { + String dataSet = ""; + boolean mzs = false; + boolean intensities = false; + for(CVParamType cvParamBinary : binaryDataArray.getCvParam()) { + if(cvParamBinary.getAccession().equals("MS:1002841") && cvParamBinary.getName().equals("external HDF5 dataset")) { + dataSet = cvParamBinary.getValue(); + } + if(cvParamBinary.getAccession().equals("MS:1002842") && cvParamBinary.getName().equals("external offset")) { + offset = Integer.parseInt(cvParamBinary.getValue()); + } + if(cvParamBinary.getAccession().equals("MS:1002843") && cvParamBinary.getName().equals("external array length")) { + length = Integer.parseInt(cvParamBinary.getValue()); + } + if(cvParamBinary.getAccession().equals("MS:1000514") && cvParamBinary.getName().equals("m/z array")) { + mzs = true; + } + if(cvParamBinary.getAccession().equals("MS:1000515") && cvParamBinary.getName().equals("intensity array")) { + intensities = true; + } + } + if(mzs) { + mzDataset = dataSet; + } else if(intensities) { + intensityDataset = dataSet; + } + mzs = false; + intensities = false; + } + } + IScanMarker scanMarker = new ScanMarker(mzDataset, intensityDataset, length, offset); + IVendorScanProxy scanProxy = new VendorScanProxy(reader, scanMarker); + scanProxy.setScanNumber(spectrum.getIndex().intValue()); + scanProxy.setIdentifier(spectrum.getId()); + scanProxy.setRetentionTime(retentionTime); + scanProxy.setMassSpectrometer(msLevel); + scanProxy.setTotalSignal(abundance); + chromatogram.addScan(scanProxy); + chromatogram.setFile(file); + } + } catch(ParserConfigurationException e) { + logger.warn(e); + } catch(SAXException e) { + logger.warn(e); + } catch(JAXBException e) { + logger.warn(e); + } + monitor.done(); + return chromatogram; + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ChromatogramWriter.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ChromatogramWriter.java new file mode 100644 index 000000000..b665273c7 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ChromatogramWriter.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.io; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException; +import org.eclipse.chemclipse.converter.io.AbstractChromatogramWriter; +import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDWriter; +import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD; +import org.eclipse.core.runtime.IProgressMonitor; + +public class ChromatogramWriter extends AbstractChromatogramWriter implements IChromatogramMSDWriter { + + @Override + public void writeChromatogram(File file, IChromatogramMSD chromatogram, IProgressMonitor monitor) throws FileNotFoundException, FileIsNotWriteableException, IOException { + + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/IReaderProxy.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/IReaderProxy.java new file mode 100644 index 000000000..60f5e4734 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/IReaderProxy.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.io; + +import java.io.IOException; + +import org.eclipse.core.runtime.IProgressMonitor; + +import net.openchrom.msd.converter.supplier.mzmlb.io.support.IScanMarker; +import net.openchrom.msd.converter.supplier.mzmlb.model.IVendorScanProxy; + +import ch.systemsx.cisd.hdf5.IHDF5SimpleReader; + +public interface IReaderProxy { + + void readMassSpectrum(IHDF5SimpleReader reader, IScanMarker scanMarker, IVendorScanProxy massSpectrum, IProgressMonitor monitor) throws IOException; +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ProxyReader.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ProxyReader.java new file mode 100644 index 000000000..3f96f9e1d --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/ProxyReader.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.io; + +import java.io.IOException; + +import org.eclipse.core.runtime.IProgressMonitor; + +import net.openchrom.msd.converter.supplier.mzmlb.internal.io.ReaderProxy; +import net.openchrom.msd.converter.supplier.mzmlb.io.support.IScanMarker; +import net.openchrom.msd.converter.supplier.mzmlb.model.IVendorScanProxy; + +import ch.systemsx.cisd.hdf5.IHDF5SimpleReader; + +public class ProxyReader { + + public void readMassSpectrum(IHDF5SimpleReader reader, IScanMarker scanMarker, IVendorScanProxy massSpectrum, IProgressMonitor monitor) throws IOException { + + IReaderProxy scanReaderProxy = new ReaderProxy(); + scanReaderProxy.readMassSpectrum(reader, scanMarker, massSpectrum, monitor); + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/support/IScanMarker.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/support/IScanMarker.java new file mode 100644 index 000000000..6eb124c0a --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/support/IScanMarker.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.io.support; + +public interface IScanMarker { + + String getMassesDataset(); + + void setMassesDataset(String massesDataset); + + String getIntensitiesDataset(); + + void setIntensitiesDataset(String intensityDataset); + + int getLength(); + + void setLength(int length); + + int getOffset(); + + void setOffset(int offset); +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/support/ScanMarker.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/support/ScanMarker.java new file mode 100644 index 000000000..9e8f543fc --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/io/support/ScanMarker.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.io.support; + +public class ScanMarker implements IScanMarker { + + private String massesDataset; + private String intensitiesDataset; + private int length; + private int offset; + + public ScanMarker(String massesDataset, String intensitiesDataset, int length, int offset) { + + this.massesDataset = massesDataset; + this.intensitiesDataset = intensitiesDataset; + this.length = length; + this.offset = offset; + } + + @Override + public String getIntensitiesDataset() { + + return intensitiesDataset; + } + + @Override + public void setIntensitiesDataset(String intensitiesDataset) { + + this.intensitiesDataset = intensitiesDataset; + } + + @Override + public String getMassesDataset() { + + return massesDataset; + } + + @Override + public void setMassesDataset(String massesDataset) { + + this.massesDataset = massesDataset; + } + + @Override + public int getLength() { + + return length; + } + + @Override + public void setLength(int length) { + + this.length = length; + } + + @Override + public int getOffset() { + + return offset; + } + + @Override + public void setOffset(int offset) { + + this.offset = offset; + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorChromatogram.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorChromatogram.java new file mode 100644 index 000000000..39b59ea48 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorChromatogram.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.model; + +import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD; + +public interface IVendorChromatogram extends IChromatogramMSD { +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorIon.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorIon.java new file mode 100644 index 000000000..c0e854fc2 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorIon.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.model; + +import org.eclipse.chemclipse.msd.model.core.IScanIon; + +public interface IVendorIon extends IScanIon { +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorScan.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorScan.java new file mode 100644 index 000000000..894099750 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorScan.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.model; + +import org.eclipse.chemclipse.msd.model.core.IVendorMassSpectrum; + +public interface IVendorScan extends IVendorMassSpectrum { +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorScanProxy.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorScanProxy.java new file mode 100644 index 000000000..e3afc0456 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/IVendorScanProxy.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2017, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.model; + +import org.eclipse.chemclipse.msd.model.core.IVendorMassSpectrumProxy; + +public interface IVendorScanProxy extends IVendorScan, IVendorMassSpectrumProxy { +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorChromatogram.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorChromatogram.java new file mode 100644 index 000000000..9765cacc5 --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorChromatogram.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.model; + +import org.eclipse.chemclipse.msd.model.core.AbstractChromatogramMSD; + +public class VendorChromatogram extends AbstractChromatogramMSD implements IVendorChromatogram { + + private static final long serialVersionUID = 7237916814647121133L; + + @Override + public String getName() { + + return extractNameFromFile("mzMLbChromatogram"); + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorIon.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorIon.java new file mode 100644 index 000000000..f4113520f --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorIon.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.model; + +import org.eclipse.chemclipse.model.exceptions.AbundanceLimitExceededException; +import org.eclipse.chemclipse.msd.model.core.AbstractScanIon; +import org.eclipse.chemclipse.msd.model.core.IIonTransition; +import org.eclipse.chemclipse.msd.model.exceptions.IonLimitExceededException; +import org.eclipse.chemclipse.msd.model.exceptions.IonTransitionIsNullException; + +public class VendorIon extends AbstractScanIon implements IVendorIon { + + /** + * Renew the serialVersionUID any time you have changed some fields or + * methods. + */ + private static final long serialVersionUID = 7237916814647121133L; + // A max value for abundance + public static final float MIN_ABUNDANCE = Float.MIN_VALUE; + public static final float MAX_ABUNDANCE = Float.MAX_VALUE; + // A max value for m/z + public static final double MIN_ION = 1.0d; + public static final double MAX_ION = 65535.0d; + + public VendorIon(double ion, float abundance) throws AbundanceLimitExceededException, IonLimitExceededException { + + super(ion, abundance); + } + + public VendorIon(double ion, float abundance, IIonTransition ionTransition) throws AbundanceLimitExceededException, IonLimitExceededException, IonTransitionIsNullException { + + super(ion, abundance, ionTransition); + } + + @Override + public float getMinPossibleAbundanceValue() { + + return MIN_ABUNDANCE; + } + + @Override + public float getMaxPossibleAbundanceValue() { + + return MAX_ABUNDANCE; + } + + @Override + public double getMinPossibleIonValue() { + + return MIN_ION; + } + + @Override + public double getMaxPossibleIonValue() { + + return MAX_ION; + } +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorScan.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorScan.java new file mode 100644 index 000000000..38ed3ee2c --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorScan.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2014, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.model; + +import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.model.exceptions.AbundanceLimitExceededException; +import org.eclipse.chemclipse.msd.model.core.AbstractVendorMassSpectrum; +import org.eclipse.chemclipse.msd.model.core.IIon; +import org.eclipse.chemclipse.msd.model.exceptions.IonLimitExceededException; + +public class VendorScan extends AbstractVendorMassSpectrum implements IVendorScan { + + /** + * Renew the serialVersionUID any time you have changed some fields or + * methods. + */ + private static final long serialVersionUID = -7237916814647121133L; + private static final Logger logger = Logger.getLogger(VendorScan.class); + /** + * MAX_MASSFRAGMENTS The total amount of ions to be stored in the + * chemclipse chromatogram.
+ * It does not mean, that ion 65535 is the upper bound, but only 65535 mass + * fragments can be stored in a mass spectrum. + */ + public static final int MAX_MASSFRAGMENTS = 65535; + public static final int MIN_RETENTION_TIME = 0; + public static final int MAX_RETENTION_TIME = Integer.MAX_VALUE; + + public VendorScan() { + + super(); + } + + @Override + public int getMaxPossibleIons() { + + return MAX_MASSFRAGMENTS; + } + + @Override + public int getMinPossibleRetentionTime() { + + return MIN_RETENTION_TIME; + } + + @Override + public int getMaxPossibleRetentionTime() { + + return MAX_RETENTION_TIME; + } + + // -------------------------------IMassSpectrumCloneable + @Override + public IVendorScan makeDeepCopy() throws CloneNotSupportedException { + + IVendorScan massSpectrum = (IVendorScan)super.clone(); + IVendorIon mzmlbIon; + /* + * The instance variables have been copied by super.clone();.
The + * ions in the ion list need not to be removed via + * removeAllIons as the method super.clone() has created a new + * list.
It is necessary to fill the list again, as the abstract + * super class does not know each available type of ion.
+ * Make a deep copy of all ions. + */ + for(IIon ion : getIons()) { + try { + mzmlbIon = new VendorIon(ion.getIon(), ion.getAbundance()); + massSpectrum.addIon(mzmlbIon); + } catch(AbundanceLimitExceededException e) { + logger.warn(e); + } catch(IonLimitExceededException e) { + logger.warn(e); + } + } + return massSpectrum; + } + + @Override + protected Object clone() throws CloneNotSupportedException { + + return makeDeepCopy(); + } + // -------------------------------IMassSpectrumCloneable +} diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorScanProxy.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorScanProxy.java new file mode 100644 index 000000000..5424d605f --- /dev/null +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mzmlb/src/net/openchrom/msd/converter/supplier/mzmlb/model/VendorScanProxy.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2017, 2021 Lablicate GmbH. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Dr. Philip Wenig - initial API and implementation + *******************************************************************************/ +package net.openchrom.msd.converter.supplier.mzmlb.model; + +import java.io.IOException; + +import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.model.exceptions.AbundanceLimitExceededException; +import org.eclipse.chemclipse.msd.model.core.AbstractVendorMassSpectrumProxy; +import org.eclipse.chemclipse.msd.model.core.IIon; +import org.eclipse.chemclipse.msd.model.exceptions.IonLimitExceededException; +import org.eclipse.core.runtime.NullProgressMonitor; + +import net.openchrom.msd.converter.supplier.mzmlb.io.ProxyReader; +import net.openchrom.msd.converter.supplier.mzmlb.io.support.IScanMarker; + +import ch.systemsx.cisd.hdf5.IHDF5SimpleReader; + +public class VendorScanProxy extends AbstractVendorMassSpectrumProxy implements IVendorScanProxy { + + /** + * Renew the serialVersionUID any time you have changed some fields or + * methods. + */ + private static final long serialVersionUID = 7237916814647121133L; + private static final Logger logger = Logger.getLogger(VendorScanProxy.class); + // + private IHDF5SimpleReader reader; + private IScanMarker scanMarker; + // + public static final int MAX_IONS = 200000; + public static final int MIN_RETENTION_TIME = 0; + public static final int MAX_RETENTION_TIME = Integer.MAX_VALUE; + + public VendorScanProxy(IHDF5SimpleReader reader, IScanMarker scanMarker) { + + this.reader = reader; + this.scanMarker = scanMarker; + } + + @Override + public int getMaxPossibleIons() { + + return MAX_IONS; + } + + @Override + public int getMinPossibleRetentionTime() { + + return MIN_RETENTION_TIME; + } + + @Override + public int getMaxPossibleRetentionTime() { + + return MAX_RETENTION_TIME; + } + + @Override + public void importIons() { + + try { + ProxyReader scanProxyReader = new ProxyReader(); + scanProxyReader.readMassSpectrum(reader, scanMarker, this, new NullProgressMonitor()); + } catch(IOException e) { + logger.warn(e); + } + } + + // -------------------------------IMassSpectrumCloneable + /** + * Keep in mind, it is a covariant return.
+ * IMassSpectrum is needed. IMassSpectrum is a subtype of + * ISupplierMassSpectrum is a subtype of IMassSpectrum. + */ + @Override + public IVendorScan makeDeepCopy() throws CloneNotSupportedException { + + IVendorScanProxy massSpectrum = (IVendorScanProxy)super.clone(); + IVendorIon vendorIon; + /* + * The instance variables have been copied by super.clone();.
The + * ions in the ion list need not to be removed via + * removeAllIons as the method super.clone() has created a new + * list.
It is necessary to fill the list again, as the abstract + * super class does not know each available type of ion.
+ * Make a deep copy of all ions. + */ + for(IIon ion : getIons()) { + try { + vendorIon = new VendorIon(ion.getIon(), ion.getAbundance()); + massSpectrum.addIon(vendorIon); + } catch(AbundanceLimitExceededException e) { + logger.warn(e); + } catch(IonLimitExceededException e) { + logger.warn(e); + } + } + return massSpectrum; + } + + @Override + protected Object clone() throws CloneNotSupportedException { + + return makeDeepCopy(); + } + // -------------------------------IMassSpectrumCloneable +} diff --git a/openchrom/plugins/pom.xml b/openchrom/plugins/pom.xml index a2aaf77b7..604590f20 100644 --- a/openchrom/plugins/pom.xml +++ b/openchrom/plugins/pom.xml @@ -96,5 +96,6 @@ net.openchrom.xir.converter.supplier.gaml net.openchrom.xxd.converter.supplier.gaml net.openchrom.nmr.converter.supplier.nmrml + net.openchrom.msd.converter.supplier.mzmlb