From ff5d11fdc86abc4819a4b43d60b5b80b41286d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 19 Feb 2022 21:03:04 +0100 Subject: [PATCH 1/2] Code cleanup. --- .../feature.xml | 5 +++-- .../META-INF/MANIFEST.MF | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../supplier/mzml/converter/io/MassSpectrumWriter.java | 10 ++++++---- .../META-INF/MANIFEST.MF | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mzml.feature/feature.xml b/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mzml.feature/feature.xml index 20aa44334d..ccdbef37ae 100644 --- a/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mzml.feature/feature.xml +++ b/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mzml.feature/feature.xml @@ -1,9 +1,10 @@ + provider-name="ChemClipse" + plugin="org.eclipse.chemclipse.feature.branding"> This is the mzML chromatogram converter. diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml.ui/META-INF/MANIFEST.MF b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml.ui/META-INF/MANIFEST.MF index 03122f3a6e..62a3d1535f 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml.ui/META-INF/MANIFEST.MF +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml.ui/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Automatic-Module-Name: org.eclipse.chemclipse.msd.converter.supplier.mzml.ui Bundle-ManifestVersion: 2 -Bundle-Name: Ui +Bundle-Name: mzML UI Bundle-SymbolicName: org.eclipse.chemclipse.msd.converter.supplier.mzml.ui;singleton:=true Bundle-Version: 0.9.0.qualifier Bundle-Activator: org.eclipse.chemclipse.msd.converter.supplier.mzml.ui.Activator diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml/META-INF/MANIFEST.MF b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml/META-INF/MANIFEST.MF index d9153bd634..7a252bb6ea 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml/META-INF/MANIFEST.MF +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Automatic-Module-Name: org.eclipse.chemclipse.msd.converter.supplier.mzml Eclipse-RegisterBuddy: org.eclipse.chemclipse.model, org.eclipse.chemclipse.msd.model Bundle-ManifestVersion: 2 -Bundle-Name: Mzml +Bundle-Name: mzML Bundle-SymbolicName: org.eclipse.chemclipse.msd.converter.supplier.mzml;singleton:=true Bundle-Version: 0.9.0.qualifier Bundle-Activator: org.eclipse.chemclipse.msd.converter.supplier.mzml.Activator diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml/src/org/eclipse/chemclipse/msd/converter/supplier/mzml/converter/io/MassSpectrumWriter.java b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml/src/org/eclipse/chemclipse/msd/converter/supplier/mzml/converter/io/MassSpectrumWriter.java index dbf0ac3d26..e20fbb4e56 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml/src/org/eclipse/chemclipse/msd/converter/supplier/mzml/converter/io/MassSpectrumWriter.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzml/src/org/eclipse/chemclipse/msd/converter/supplier/mzml/converter/io/MassSpectrumWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2021 Lablicate GmbH. + * Copyright (c) 2013, 2022 Lablicate GmbH. * * All rights reserved. * This program and the accompanying materials are made available under the @@ -12,7 +12,6 @@ package org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.io; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; @@ -25,17 +24,20 @@ public class MassSpectrumWriter implements IMassSpectraWriter { @Override - public void write(File file, IScanMSD massSpectrum, boolean append, IProgressMonitor monitor) throws FileNotFoundException, FileIsNotWriteableException, IOException { + public void write(File file, IScanMSD massSpectrum, boolean append, IProgressMonitor monitor) throws FileIsNotWriteableException, IOException { + throw new UnsupportedOperationException(); } @Override - public void write(File file, IMassSpectra massSpectra, boolean append, IProgressMonitor monitor) throws FileNotFoundException, FileIsNotWriteableException, IOException { + public void write(File file, IMassSpectra massSpectra, boolean append, IProgressMonitor monitor) throws FileIsNotWriteableException, IOException { + throw new UnsupportedOperationException(); } @Override public void writeMassSpectrum(FileWriter fileWriter, IScanMSD massSpectrum, IProgressMonitor monitor) throws IOException { + throw new UnsupportedOperationException(); } } diff --git a/chemclipse/tests/org.eclipse.chemclipse.msd.converter.supplier.mzml.fragment.test/META-INF/MANIFEST.MF b/chemclipse/tests/org.eclipse.chemclipse.msd.converter.supplier.mzml.fragment.test/META-INF/MANIFEST.MF index c27e330c63..50680c1025 100644 --- a/chemclipse/tests/org.eclipse.chemclipse.msd.converter.supplier.mzml.fragment.test/META-INF/MANIFEST.MF +++ b/chemclipse/tests/org.eclipse.chemclipse.msd.converter.supplier.mzml.fragment.test/META-INF/MANIFEST.MF @@ -7,4 +7,5 @@ Bundle-Version: 0.9.0.qualifier Bundle-Vendor: ChemClipse Fragment-Host: org.eclipse.chemclipse.msd.converter.supplier.mzml;bundle-version="0.8.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Require-Bundle: org.junit;bundle-version="4.11.0" +Require-Bundle: org.junit;bundle-version="4.11.0", + org.eclipse.chemclipse.rcp.app.test;bundle-version="0.9.0" From cb195338bf4103231aea53b3f22459d5fe37a035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 19 Feb 2022 21:09:09 +0100 Subject: [PATCH 2/2] Add an import converter for mMass .msd files. --- .../.project | 17 ++ .../build.properties | 1 + .../feature.xml | 34 ++++ .../feature.xml | 13 +- .../.classpath | 7 + .../.gitignore | 1 + .../.project | 28 +++ .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 22 ++ .../OSGI-INF/l10n/bundle_en.properties | 1 + .../build.properties | 6 + .../plugin.xml | 18 ++ .../converter/supplier/mmass/Activator.java | 43 ++++ .../MassSpectrumExportConverter.java | 45 +++++ .../MassSpectrumImportConverter.java | 62 ++++++ .../MassSpectrumMagicNumberMatcher.java | 45 +++++ .../converter/io/MassSpectrumReader.java | 49 +++++ .../converter/io/MassSpectrumWriter.java | 43 ++++ .../mmass/converter/model/IVendorIon.java | 17 ++ .../converter/model/IVendorMassSpectra.java | 17 ++ .../mmass/converter/model/VendorIon.java | 67 +++++++ .../converter/model/VendorMassSpectra.java | 30 +++ .../io/MassSpectrumReaderVersion22.java | 189 ++++++++++++++++++ 23 files changed, 758 insertions(+), 4 deletions(-) create mode 100644 chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/.project create mode 100644 chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/build.properties create mode 100644 chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/feature.xml create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.classpath create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.gitignore create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.project create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.settings/org.eclipse.jdt.core.prefs create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/META-INF/MANIFEST.MF create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/OSGI-INF/l10n/bundle_en.properties create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/build.properties create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/plugin.xml create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/Activator.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumExportConverter.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumImportConverter.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumMagicNumberMatcher.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/io/MassSpectrumReader.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/io/MassSpectrumWriter.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/model/IVendorIon.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/model/IVendorMassSpectra.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/model/VendorIon.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/model/VendorMassSpectra.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/internal/io/MassSpectrumReaderVersion22.java diff --git a/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/.project b/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/.project new file mode 100644 index 0000000000..b23a5c09f4 --- /dev/null +++ b/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/.project @@ -0,0 +1,17 @@ + + + org.eclipse.chemclipse.msd.converter.supplier.mmass.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/build.properties b/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/feature.xml b/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/feature.xml new file mode 100644 index 0000000000..4672b65802 --- /dev/null +++ b/chemclipse/features/org.eclipse.chemclipse.msd.converter.supplier.mmass.feature/feature.xml @@ -0,0 +1,34 @@ + + + + + This is the mMass .msd file converter. + + + + Copyright (c) 2022 Lablicate GmbH. + + + + Copyright (c) 2022 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/chemclipse/features/org.eclipse.chemclipse.rcp.app.compilation.core.feature/feature.xml b/chemclipse/features/org.eclipse.chemclipse.rcp.app.compilation.core.feature/feature.xml index d594fb0189..2aa0628326 100644 --- a/chemclipse/features/org.eclipse.chemclipse.rcp.app.compilation.core.feature/feature.xml +++ b/chemclipse/features/org.eclipse.chemclipse.rcp.app.compilation.core.feature/feature.xml @@ -3,7 +3,8 @@ id="org.eclipse.chemclipse.rcp.app.compilation.core.feature" label="ChemClipse Core" version="0.9.0.qualifier" - provider-name="ChemClipse" plugin="org.eclipse.chemclipse.feature.branding"> + provider-name="ChemClipse" + plugin="org.eclipse.chemclipse.feature.branding"> This is the ChemClipse core feature. @@ -232,7 +233,7 @@ http://www.eclipse.org/legal/epl-v10.html - + @@ -240,10 +241,10 @@ http://www.eclipse.org/legal/epl-v10.html - + + version="0.0.0"/> + + diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.classpath b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.classpath new file mode 100644 index 0000000000..eca7bdba8f --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.gitignore b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.gitignore new file mode 100644 index 0000000000..5e56e040ec --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.project b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.project new file mode 100644 index 0000000000..40f683aa0c --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.project @@ -0,0 +1,28 @@ + + + org.eclipse.chemclipse.msd.converter.supplier.mmass + + + + + + 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/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.settings/org.eclipse.jdt.core.prefs b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..0c68a61dca --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/.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/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/META-INF/MANIFEST.MF b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..fc3df99cf5 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: org.eclipse.chemclipse.msd.converter.supplier.mzml +Eclipse-RegisterBuddy: org.eclipse.chemclipse.model, org.eclipse.chemclipse.msd.model +Bundle-ManifestVersion: 2 +Bundle-Name: mMass Converter +Bundle-SymbolicName: org.eclipse.chemclipse.msd.converter.supplier.mmass;singleton:=true +Bundle-Version: 0.9.0.qualifier +Bundle-Activator: org.eclipse.chemclipse.msd.converter.supplier.mmass.Activator +Bundle-Vendor: ChemClipse +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", + org.apache.commons.codec;bundle-version="1.9.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Import-Package: org.apache.commons.lang3.tuple;version="3.1.0", + org.eclipse.chemclipse.xxd.converter.supplier.io.exception diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/OSGI-INF/l10n/bundle_en.properties b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/OSGI-INF/l10n/bundle_en.properties new file mode 100644 index 0000000000..597fd0bfba --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/OSGI-INF/l10n/bundle_en.properties @@ -0,0 +1 @@ +#Properties file diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/build.properties b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/build.properties new file mode 100644 index 0000000000..3e5f9ad7d0 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + OSGI-INF/ diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/plugin.xml b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/plugin.xml new file mode 100644 index 0000000000..3a47075bca --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/plugin.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/Activator.java b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/Activator.java new file mode 100644 index 0000000000..0cd9c2ec5f --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/Activator.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2013, 2022 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 org.eclipse.chemclipse.msd.converter.supplier.mmass; + +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/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumExportConverter.java b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumExportConverter.java new file mode 100644 index 0000000000..2083205138 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumExportConverter.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2022 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 org.eclipse.chemclipse.msd.converter.supplier.mmass.converter; + +import java.io.File; + +import org.eclipse.chemclipse.msd.converter.massspectrum.AbstractMassSpectrumExportConverter; +import org.eclipse.chemclipse.msd.model.core.IMassSpectra; +import org.eclipse.chemclipse.msd.model.core.IScanMSD; +import org.eclipse.chemclipse.processing.core.IProcessingInfo; +import org.eclipse.chemclipse.processing.core.ProcessingInfo; +import org.eclipse.core.runtime.IProgressMonitor; + +public class MassSpectrumExportConverter extends AbstractMassSpectrumExportConverter { + + private static final String DESCRIPTION = "mMass .msd Mass Spectra Export Converter"; + + @Override + public IProcessingInfo convert(File file, IScanMSD massSpectrum, boolean append, IProgressMonitor monitor) { + + return getProcessingInfo(); + } + + @Override + public IProcessingInfo convert(File file, IMassSpectra massSpectra, boolean append, IProgressMonitor monitor) { + + return getProcessingInfo(); + } + + private IProcessingInfo getProcessingInfo() { + + IProcessingInfo processingInfo = new ProcessingInfo<>(); + processingInfo.addErrorMessage(DESCRIPTION, "It's not possible to export mass spectra as mMass .msd yet."); + return processingInfo; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumImportConverter.java b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumImportConverter.java new file mode 100644 index 0000000000..e554f3c9a8 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumImportConverter.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2022 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 org.eclipse.chemclipse.msd.converter.supplier.mmass.converter; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.eclipse.chemclipse.converter.exceptions.FileIsEmptyException; +import org.eclipse.chemclipse.converter.exceptions.FileIsNotReadableException; +import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.msd.converter.io.IMassSpectraReader; +import org.eclipse.chemclipse.msd.converter.massspectrum.AbstractMassSpectrumImportConverter; +import org.eclipse.chemclipse.msd.converter.supplier.mmass.converter.io.MassSpectrumReader; +import org.eclipse.chemclipse.msd.model.core.IMassSpectra; +import org.eclipse.chemclipse.processing.core.IProcessingInfo; +import org.eclipse.core.runtime.IProgressMonitor; + +public class MassSpectrumImportConverter extends AbstractMassSpectrumImportConverter { + + private static final Logger logger = Logger.getLogger(MassSpectrumImportConverter.class); + private static final String DESCRIPTION = "mMass .msd annotated Mass Spectrum Import"; + + @Override + public IProcessingInfo convert(File file, IProgressMonitor monitor) { + + IProcessingInfo processingInfo = super.validate(file); + if(!processingInfo.hasErrorMessages()) { + try { + IMassSpectraReader massSpectraReader = new MassSpectrumReader(); + IMassSpectra massSpectra = massSpectraReader.read(file, monitor); + if(massSpectra != null && massSpectra.size() > 0) { + processingInfo.setProcessingResult(massSpectra); + } else { + processingInfo.addErrorMessage(DESCRIPTION, "No mass spectra are stored." + file.getAbsolutePath()); + } + } catch(FileNotFoundException e) { + logger.warn(e); + processingInfo.addErrorMessage(DESCRIPTION, "The file couldn't be found: " + file.getAbsolutePath()); + } catch(FileIsNotReadableException e) { + logger.warn(e); + processingInfo.addErrorMessage(DESCRIPTION, "The file is not readable: " + file.getAbsolutePath()); + } catch(FileIsEmptyException e) { + logger.warn(e); + processingInfo.addErrorMessage(DESCRIPTION, "The file is empty: " + file.getAbsolutePath()); + } catch(IOException e) { + logger.warn(e); + processingInfo.addErrorMessage(DESCRIPTION, "Something has gone completely wrong: " + file.getAbsolutePath()); + } + } + return processingInfo; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumMagicNumberMatcher.java b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumMagicNumberMatcher.java new file mode 100644 index 0000000000..e8a0d7b5c4 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mmass/src/org/eclipse/chemclipse/msd/converter/supplier/mmass/converter/MassSpectrumMagicNumberMatcher.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2022 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 org.eclipse.chemclipse.msd.converter.supplier.mmass.converter; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher; +import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher; + +public class MassSpectrumMagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher { + + @Override + public boolean checkFileFormat(File file) { + + boolean isValidFormat = false; + if(!file.exists()) { + return isValidFormat; + } + if(!checkFileExtension(file, ".msd")) { + return isValidFormat; + } + try (FileReader fileReader = new FileReader(file)) { + final char[] charBuffer = new char[60]; + fileReader.read(charBuffer); + final String header = new String(charBuffer); + if(header.contains("= VendorIon.MIN_ABUNDANCE && intensity <= VendorIon.MAX_ABUNDANCE) { + double mz = AbstractIon.getIon(mzs[i]); + IVendorIon ion = new VendorIon(mz, intensity); + massSpectrum.addIon(ion); + } + } catch(AbundanceLimitExceededException e) { + logger.warn(e); + } catch(IonLimitExceededException e) { + logger.warn(e); + } + } + } + + private void checkArray(NamedNodeMap attributes) { + + if(!attributes.getNamedItem("compression").getTextContent().equals("zlib")) { + throw new UnsupportedOperationException("Only zlib compression is supported."); + } + if(!attributes.getNamedItem("endian").getTextContent().equals("little")) { + throw new UnsupportedOperationException("Only Little Endian is supported."); + } + if(!attributes.getNamedItem("precision").getTextContent().equals("32")) { + throw new UnsupportedOperationException("Only 32-bit precision is supported."); + } + } + + private ByteBuffer decompress(byte[] binary) throws DataFormatException { + + ByteBuffer byteBuffer = ByteBuffer.wrap(binary); + Inflater inflater = new Inflater(); + inflater.setInput(byteBuffer.array()); + byte[] byteArray = new byte[byteBuffer.capacity() * 10]; + int decodedLength = inflater.inflate(byteArray); + byteBuffer = ByteBuffer.wrap(byteArray, 0, decodedLength); + byteBuffer.order(ByteOrder.LITTLE_ENDIAN); + return byteBuffer; + } + + private float[] decodeFloatArray(ByteBuffer byteBuffer) { + + FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); + float[] values = new float[floatBuffer.capacity()]; + for(int index = 0; index < floatBuffer.capacity(); index++) { + values[index] = floatBuffer.get(index); + } + return values; + } +}