From 34ebe7597d9410d08352630a8ef026ef37819a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 17 Oct 2024 21:16:43 +0200 Subject: [PATCH 1/2] Set scan cycles. --- .../supplier/mz5/io/ChromatogramReader.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ChromatogramReader.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ChromatogramReader.java index 557de5e9d..a168132b4 100644 --- a/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ChromatogramReader.java +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ChromatogramReader.java @@ -141,6 +141,7 @@ private void readScanProxies(IHDF5SimpleReader reader, CVReference[] cvReference double[] mzs = reader.readDoubleArray(Mz5.SPECTRUM_MZ); float[] spectrumIntensity = reader.readFloatArray(Mz5.SPECTRUM_INTENSITY); int start = 0; + int cycleNumber = isMultiStageMassSpectrum(cvParams, cvReferences) ? 1 : 0; for(int i = 0; i < spectrumIndex.length; i++) { int offset = spectrumIndex[i]; IScanMarker scanMarker = new ScanMarker(start, offset); @@ -149,6 +150,11 @@ private void readScanProxies(IHDF5SimpleReader reader, CVReference[] cvReference scanProxy.setIdentifier(spectrumTitles[i]); scanProxy.setRetentionTime(retentionTimes[i]); scanProxy.setMassSpectrometer(msLevels[i]); + if(scanProxy.getMassSpectrometer() < 2) { + cycleNumber++; + if(cycleNumber >= 1) { + scanProxy.setCycleNumber(cycleNumber); + } float totalSignal = 0; for(int o = start; o < offset; o++) { totalSignal = totalSignal + spectrumIntensity[o]; @@ -229,4 +235,16 @@ private int getTimeMultiplicator(CVReference unit) { } return multiplicator; } + + private boolean isMultiStageMassSpectrum(CVParam[] cvParams, CVReference[] cvReferences) { + + for(CVParam cvParam : cvParams) { + if(cvParam.cvRefID == getMassSpectrumLevelReference(cvReferences)) { + if(Short.parseShort(cvParam.value) > 1) { + return true; + } + } + } + return false; + } } From 93d6c9aa4fc45cc658a9cdcb252ad97d48b9362a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 17 Oct 2024 21:48:34 +0200 Subject: [PATCH 2/2] Set precursor ion. --- .../supplier/mz5/io/ChromatogramReader.java | 18 +++++++++++++++ .../supplier/mz5/io/ReaderProxy.java | 10 ++++++++- .../supplier/mz5/model/VendorScanProxy.java | 2 +- .../ChromatogramImportConverter_ITest.java | 22 ++++++++++++++----- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ChromatogramReader.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ChromatogramReader.java index a168132b4..4033bbaa5 100644 --- a/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ChromatogramReader.java +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ChromatogramReader.java @@ -123,6 +123,7 @@ private void readScanProxies(IHDF5SimpleReader reader, CVReference[] cvReference int[] retentionTimes = new int[spectrumIndex.length]; String[] spectrumTitles = new String[spectrumIndex.length]; short[] msLevels = new short[spectrumIndex.length]; + double[] selectedIon = new double[spectrumIndex.length]; int p = 0; for(CVParam cvParam : cvParams) { if(cvParam.cvRefID == getScanStartTimeReference(cvReferences)) { @@ -136,6 +137,9 @@ private void readScanProxies(IHDF5SimpleReader reader, CVReference[] cvReference if(cvParam.cvRefID == getMassSpectrumLevelReference(cvReferences)) { msLevels[p] = Short.parseShort(cvParam.value); } + if(cvParam.cvRefID == getSelectedIonReference(cvReferences)) { + selectedIon[p] = Double.parseDouble(cvParam.value); + } } try { double[] mzs = reader.readDoubleArray(Mz5.SPECTRUM_MZ); @@ -152,6 +156,9 @@ private void readScanProxies(IHDF5SimpleReader reader, CVReference[] cvReference scanProxy.setMassSpectrometer(msLevels[i]); if(scanProxy.getMassSpectrometer() < 2) { cycleNumber++; + } else { + scanProxy.setPrecursorIon(selectedIon[i]); + } if(cycleNumber >= 1) { scanProxy.setCycleNumber(cycleNumber); } @@ -247,4 +254,15 @@ private boolean isMultiStageMassSpectrum(CVParam[] cvParams, CVReference[] cvRef } return false; } + + private int getSelectedIonReference(CVReference[] cvReferences) { + + int selectedIonRef = 0; + for(int c = 0; c < cvReferences.length; c++) { + if(cvReferences[c].accession == 1000744 && cvReferences[c].name.equals("selected ion m/z")) { + selectedIonRef = c; + } + } + return selectedIonRef; + } } diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ReaderProxy.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ReaderProxy.java index 5dfcf525e..7025d1103 100644 --- a/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ReaderProxy.java +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/io/ReaderProxy.java @@ -15,6 +15,8 @@ import java.io.IOException; import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.msd.model.core.IIonTransition; +import org.eclipse.chemclipse.msd.model.implementation.IonTransition; import org.eclipse.core.runtime.IProgressMonitor; import net.openchrom.msd.converter.supplier.mz5.io.support.IScanMarker; @@ -36,7 +38,13 @@ public void readMassSpectrum(double[] mzs, float[] spectrumIntensity, IScanMarke for(int o = start; o < offset; o++) { float intensity = spectrumIntensity[o]; mz += mzs[o]; // first m/z value and then deltas - IVendorIon ion = new VendorIon(mz, intensity); + IVendorIon ion = null; + if(massSpectrum.getPrecursorIon() != 0) { + IIonTransition ionTransition = new IonTransition(massSpectrum.getPrecursorIon(), mz, 0, 1, 1, 0); + ion = new VendorIon(mz, intensity, ionTransition); + } else { + ion = new VendorIon(mz, intensity); + } massSpectrum.addIon(ion); } } catch(OutOfMemoryError e) { diff --git a/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/model/VendorScanProxy.java b/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/model/VendorScanProxy.java index 22b862596..139df9ac8 100644 --- a/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/model/VendorScanProxy.java +++ b/openchrom/plugins/net.openchrom.msd.converter.supplier.mz5/src/net/openchrom/msd/converter/supplier/mz5/model/VendorScanProxy.java @@ -70,7 +70,7 @@ public IVendorScan makeDeepCopy() throws CloneNotSupportedException { * Make a deep copy of all ions. */ for(IIon ion : getIons()) { - IVendorIon vendorIon = new VendorIon(ion.getIon(), ion.getAbundance()); + IVendorIon vendorIon = new VendorIon(ion.getIon(), ion.getAbundance(), ion.getIonTransition()); massSpectrum.addIon(vendorIon); } return massSpectrum; diff --git a/openchrom/tests/net.openchrom.msd.converter.supplier.mz5.fragment.test/src/net/openchrom/msd/converter/supplier/mz5/fragment/test/ChromatogramImportConverter_ITest.java b/openchrom/tests/net.openchrom.msd.converter.supplier.mz5.fragment.test/src/net/openchrom/msd/converter/supplier/mz5/fragment/test/ChromatogramImportConverter_ITest.java index 1ca5055fb..6234f4c81 100644 --- a/openchrom/tests/net.openchrom.msd.converter.supplier.mz5.fragment.test/src/net/openchrom/msd/converter/supplier/mz5/fragment/test/ChromatogramImportConverter_ITest.java +++ b/openchrom/tests/net.openchrom.msd.converter.supplier.mz5.fragment.test/src/net/openchrom/msd/converter/supplier/mz5/fragment/test/ChromatogramImportConverter_ITest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 Lablicate GmbH. + * Copyright (c) 2022, 2024 Lablicate GmbH. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -14,13 +14,16 @@ import java.io.File; import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD; +import org.eclipse.chemclipse.msd.model.core.IIon; +import org.eclipse.chemclipse.msd.model.core.IRegularMassSpectrum; import org.eclipse.chemclipse.processing.core.IProcessingInfo; import org.eclipse.core.runtime.NullProgressMonitor; -import junit.framework.TestCase; import net.openchrom.msd.converter.supplier.mz5.PathResolver; import net.openchrom.msd.converter.supplier.mz5.converter.ChromatogramImportConverter; +import junit.framework.TestCase; + public class ChromatogramImportConverter_ITest extends TestCase { private IChromatogramMSD chromatogram; @@ -49,8 +52,17 @@ public void testLoading() { public void testScans() { - assertEquals(chromatogram.getNumberOfScans(), 26); - assertEquals(chromatogram.getScan(10).getTotalSignal(), 105525.87f); - assertEquals(chromatogram.getScan(26).getRetentionTime(), 16639); + assertEquals(26, chromatogram.getNumberOfScans()); + assertEquals(105525.87f, chromatogram.getScan(10).getTotalSignal()); + assertEquals(16639, chromatogram.getScan(26).getRetentionTime()); + } + + public void testIonTransitions() { + + IRegularMassSpectrum massSpectrum = (IRegularMassSpectrum)chromatogram.getScan(3); + assertEquals(367.201873779297, massSpectrum.getPrecursorIon()); + IIon ion = massSpectrum.getIons().get(0); + assertEquals(367, ion.getIonTransition().getQ1Ion()); + assertEquals(112.1d, ion.getIonTransition().getQ3Ion()); } }