From 97adad66850fcaf7eb250ebeda30c11867a72c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Tue, 23 Feb 2021 18:13:16 +0100 Subject: [PATCH] Add basic support for PCA with MALDI-TOF spectra. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matthias Mailänder --- .../META-INF/MANIFEST.MF | 3 +- ...ca.ui.quickstart.SpectraTileDefinition.xml | 7 + .../wizards/SpectraFilesWizardPage.java | 53 ++++ .../internal/wizards/SpectraInputWizard.java | 89 ++++++ .../wizards/SpectraSettingsWizardPage.java | 294 ++++++++++++++++++ .../pca/ui/quickstart/QuickStartPart.java | 5 +- .../ui/quickstart/SpectraTileDefinition.java | 33 ++ .../pca/core/PcaExtractionSpectra.java | 70 +++++ .../extraction/SpectraExtractionSupport.java | 236 ++++++++++++++ .../model/statistics/IMassToChargeRatio.java | 21 ++ .../model/statistics/MassToChargeRatio.java | 77 +++++ .../chemclipse/model/types/DataType.java | 8 +- .../chemclipse/processing/DataCategory.java | 4 +- .../processing/DataCategoryGroup.java | 6 +- .../support/events/IChemClipseEvents.java | 2 + .../xxd/ui/part/support/OverviewSupport.java | 12 + .../part/support/SupplierEditorSupport.java | 14 + 17 files changed, 927 insertions(+), 7 deletions(-) create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.SpectraTileDefinition.xml create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraFilesWizardPage.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraInputWizard.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraSettingsWizardPage.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/quickstart/SpectraTileDefinition.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/core/PcaExtractionSpectra.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/extraction/SpectraExtractionSupport.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/statistics/IMassToChargeRatio.java create mode 100644 chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/statistics/MassToChargeRatio.java diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/META-INF/MANIFEST.MF b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/META-INF/MANIFEST.MF index 49fafdb2ae..878bb96b8a 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/META-INF/MANIFEST.MF +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/META-INF/MANIFEST.MF @@ -64,4 +64,5 @@ Import-Package: javax.annotation;version="1.0.0";resolution:=optional, Bundle-ActivationPolicy: lazy Service-Component: OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.PeakTileDefinition.xml, OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.ScanTileDefinition.xml, - OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.FileTileDefinition.xml + OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.FileTileDefinition.xml, + OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.SpectraTileDefinition.xml diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.SpectraTileDefinition.xml b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.SpectraTileDefinition.xml new file mode 100644 index 0000000000..877f8f4fc8 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/OSGI-INF/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart.SpectraTileDefinition.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraFilesWizardPage.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraFilesWizardPage.java new file mode 100644 index 0000000000..31d2eb2615 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraFilesWizardPage.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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: + * Jan Holy - initial API and implementation + * Christoph Läubrich - change to new Wizard API + * Philip Wenig - get rid of JavaFX + * Matthias Mailänder - adapted for MALDI + *******************************************************************************/ +package org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.internal.wizards; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.DataInputEntry; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.IDataInputEntry; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.preferences.PreferenceSupplier; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.Activator; +import org.eclipse.chemclipse.model.types.DataType; +import org.eclipse.chemclipse.ux.extension.xxd.ui.wizards.InputEntriesWizard; +import org.eclipse.chemclipse.ux.extension.xxd.ui.wizards.InputWizardSettings; + +public class SpectraFilesWizardPage extends DataInputPageWizard { + + public SpectraFilesWizardPage() { + + super("DataInputFiles"); + setTitle("MALDI-TOF MS Input Files"); + setDescription("This wizard lets you select MALDI-TOF MS input files and set bulk group name."); + } + + @Override + protected void addFiles() { + + InputWizardSettings inputWizardSettings = InputWizardSettings.create(Activator.getDefault().getPreferenceStore(), PreferenceSupplier.N_INPUT_FILE, DataType.MALDI); + inputWizardSettings.setTitle("MALDI-TOF MS Input Files"); + inputWizardSettings.setDescription("This wizard lets you select several mass spectra input files."); + // + List dataInputEntries = new ArrayList<>(); + for(File file : InputEntriesWizard.openWizard(getShell(), inputWizardSettings).keySet()) { + dataInputEntries.add(new DataInputEntry(file.getAbsolutePath())); + } + // + addInputFiles(dataInputEntries); + update(); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraInputWizard.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraInputWizard.java new file mode 100644 index 0000000000..585007a901 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraInputWizard.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * 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: + * Jan Holy - initial API and implementation + * Matthias Mailänder - adapted for MALDI + *******************************************************************************/ +package org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.internal.wizards; + +import java.util.List; + +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.core.IExtractionData; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.core.IFilterSettings; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.core.IPreprocessingSettings; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.core.PcaExtractionSpectra; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.extraction.SpectraExtractionSupport.ExtractionType; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.IAnalysisSettings; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.IDataInputEntry; +import org.eclipse.jface.wizard.Wizard; + +public class SpectraInputWizard extends Wizard implements IInputWizard { + + private SpectraSettingsWizardPage spectraSettingsWizardPage = new SpectraSettingsWizardPage(); + private SpectraFilesWizardPage spectraFilesWizardPage = new SpectraFilesWizardPage(); + private GroupNamesWizardPage groupNamesWizardPage = new GroupNamesWizardPage(); + private PreprocessingWizardPage preprocessingWizardPage = new PreprocessingWizardPage(); + private FilterWizardPage filterWizardPage = new FilterWizardPage(); + /* + * Will be created when finishing the report. + */ + private PcaExtractionSpectra pcaExtractionData; + + @Override + public void addPages() { + + addPage(spectraSettingsWizardPage); + addPage(spectraFilesWizardPage); + addPage(groupNamesWizardPage); + addPage(preprocessingWizardPage); + addPage(filterWizardPage); + } + + @Override + public IExtractionData getExtractionData() { + + return pcaExtractionData; + } + + @Override + public List getDataInputEntries() { + + return spectraFilesWizardPage.getUniqueDataInputEnties(); + } + + @Override + public IAnalysisSettings getAnalysisSettings() { + + return spectraSettingsWizardPage.getAnalysisSettings(); + } + + @Override + public IPreprocessingSettings getPreprocessingSettings() { + + return preprocessingWizardPage.getPreprocessingSettings(); + } + + @Override + public IFilterSettings getFilterSettings() { + + return filterWizardPage.getFilterSettings(); + } + + @Override + public boolean performFinish() { + + List dataInputs = getDataInputEntries(); + int massWindow = spectraSettingsWizardPage.getMassWindow(); + boolean useDefaultProperties = spectraSettingsWizardPage.isUseDefaultProperties(); + ExtractionType extractionType = spectraSettingsWizardPage.getExtractionType(); + int maximalNumberScans = spectraSettingsWizardPage.getMaximalNumberPeaks(); + pcaExtractionData = new PcaExtractionSpectra(massWindow, maximalNumberScans, dataInputs, extractionType, useDefaultProperties); + return true; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraSettingsWizardPage.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraSettingsWizardPage.java new file mode 100644 index 0000000000..81cf61b536 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/internal/wizards/SpectraSettingsWizardPage.java @@ -0,0 +1,294 @@ +/******************************************************************************* + * 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: + * Jan Holy - initial API and implementation + * Philip Wenig - Optimization UI + * Matthias Mailänder - adapted for MALDI-TOF MS + *******************************************************************************/ +package org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.internal.wizards; + +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.extraction.SpectraExtractionSupport.ExtractionType; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.Algorithm; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.AnalysisSettings; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.IAnalysisSettings; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.preferences.PreferenceSupplier; +import org.eclipse.chemclipse.support.ui.provider.AbstractLabelProvider; +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.UpdateValueStrategy; +import org.eclipse.core.databinding.conversion.IConverter; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.core.databinding.observable.value.WritableValue; +import org.eclipse.core.databinding.validation.ValidationStatus; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.jface.databinding.wizard.WizardPageSupport; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Spinner; +import org.eclipse.swt.widgets.Text; + +public class SpectraSettingsWizardPage extends WizardPage { + + private IAnalysisSettings analysisSettings = new AnalysisSettings(); + // + private DataBindingContext dataBindingContext = new DataBindingContext(); + private ExtractionType extractionType; + private IObservableValue maximalNumberPeaks = new WritableValue<>(); + private IObservableValue massWindow = new WritableValue<>(); + private boolean useDefaultProperties; + // + private Algorithm[] algorithms = new Algorithm[]{Algorithm.SVD, Algorithm.NIPALS, Algorithm.OPLS}; + + public SpectraSettingsWizardPage() { + + super("Main Parameters"); + setTitle("Set Main Parameters"); + massWindow.setValue(1); + maximalNumberPeaks.setValue(5000); + extractionType = ExtractionType.CLOSEST_MASS; + useDefaultProperties = true; + } + + public int getMassWindow() { + + return massWindow.getValue(); + } + + public IAnalysisSettings getAnalysisSettings() { + + return analysisSettings; + } + + public int getMaximalNumberPeaks() { + + return maximalNumberPeaks.getValue(); + } + + public ExtractionType getExtractionType() { + + return extractionType; + } + + public boolean isUseDefaultProperties() { + + return useDefaultProperties; + } + + @Override + public void createControl(Composite parent) { + + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout(1, false)); + // + WizardPageSupport.create(this, dataBindingContext); + // + createLabel(composite, "Mass Window [Da]:"); + createVariableSection(composite); + createLabel(composite, "Maximum Number of Peaks:"); + createSpinnerNumberOfPeaks(composite); + createCheckBoxDefaultProperties(composite); + createRadioButtonClosestMass(composite, true); + createRadioButtonInterpolate(composite, false); + // + createLabel(composite, "Number of PCs:"); + createSpinnerPrincipleComponents(composite); + createLabel(composite, "Algorithm:"); + createComboViewerAlgorithm(composite); + // + setControl(composite); + } + + private Label createLabel(Composite parent, String text) { + + Label label = new Label(parent, SWT.NONE); + label.setText(text); + return label; + } + + private void createVariableSection(Composite parent) { + + Text text = new Text(parent, SWT.BORDER); + text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // + UpdateValueStrategy widgetToModel = UpdateValueStrategy.create(IConverter.create(String.class, Integer.class, o1 -> { + try { + return Integer.parseInt((String)o1); + } catch(NumberFormatException e) { + // No message + } + return null; + })); + // + widgetToModel.setBeforeSetValidator(o1 -> { + if(o1 instanceof Integer) { + Integer i = (Integer)o1; + if(i > 0) { + return ValidationStatus.ok(); + } + } + return ValidationStatus.error("Warning: The value must be positive."); + }); + // + UpdateValueStrategy modelToWidget = UpdateValueStrategy.create(IConverter.create(Integer.class, String.class, o1 -> Integer.toString(((Integer)o1)))); + dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(text), massWindow, widgetToModel, modelToWidget); + } + + private Button createCheckBoxDefaultProperties(Composite parent) { + + Button button = new Button(parent, SWT.CHECK); + button.setText("Use default properties if it is possible (spectra have same start m/z and interval)"); + button.setToolTipText("Default Properties"); + button.setSelection(true); + button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // + button.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + + useDefaultProperties = button.getSelection(); + } + }); + // + return button; + } + + private Spinner createSpinnerNumberOfPeaks(Composite parent) { + + Spinner spinner = new Spinner(parent, SWT.BORDER); + spinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + spinner.setMinimum(1); + spinner.setIncrement(1000); + spinner.setMaximum(Integer.MAX_VALUE); + dataBindingContext.bindValue(WidgetProperties.selection().observe(spinner), maximalNumberPeaks); + // + return spinner; + } + + private Button createRadioButtonClosestMass(Composite parent, boolean selected) { + + Button button = new Button(parent, SWT.RADIO); + button.setText("Select the closest m/z value"); + button.setToolTipText("Closest Mass"); + button.setSelection(selected); + button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // + button.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + + extractionType = ExtractionType.CLOSEST_MASS; + } + }); + // + return button; + } + + private Button createRadioButtonInterpolate(Composite parent, boolean selected) { + + Button button = new Button(parent, SWT.RADIO); + button.setText("Interpolate m/z"); + button.setToolTipText("Interpolation"); + button.setSelection(selected); + button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + // + button.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + + extractionType = ExtractionType.LINEAR_INTERPOLATION_MASS; + } + }); + // + return button; + } + + private Spinner createSpinnerPrincipleComponents(Composite parent) { + + Spinner spinner = new Spinner(parent, SWT.BORDER); + spinner.setToolTipText("Number of Principal Components"); + spinner.setMinimum(PreferenceSupplier.MIN_NUMBER_OF_COMPONENTS); + spinner.setIncrement(1); + spinner.setSelection(analysisSettings.getNumberOfPrincipalComponents()); + spinner.setMaximum(PreferenceSupplier.MAX_NUMBER_OF_COMPONENTS); + spinner.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + + if(analysisSettings != null) { + analysisSettings.setNumberOfPrincipalComponents(spinner.getSelection()); + } + } + }); + // + return spinner; + } + + private ComboViewer createComboViewerAlgorithm(Composite parent) { + + ComboViewer comboViewer = new ComboViewer(parent, SWT.READ_ONLY); + comboViewer.setContentProvider(ArrayContentProvider.getInstance()); + comboViewer.setInput(algorithms); + comboViewer.setLabelProvider(new AbstractLabelProvider() { + + @Override + public String getText(Object element) { + + if(element instanceof Algorithm) { + return ((Algorithm)element).getName(); + } + return null; + } + }); + // + Combo combo = comboViewer.getCombo(); + combo.setToolTipText("PCA Algorithm"); + combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + combo.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + + Object object = comboViewer.getStructuredSelection().getFirstElement(); + if(object instanceof Algorithm) { + if(analysisSettings != null) { + analysisSettings.setAlgorithm((Algorithm)object); + } + } + } + }); + // + combo.select(getSelectedAlgorithmIndex(comboViewer)); + // + return comboViewer; + } + + private int getSelectedAlgorithmIndex(ComboViewer comboViewer) { + + for(int i = 0; i < algorithms.length; i++) { + Algorithm algorithm = algorithms[i]; + if(algorithm.equals(analysisSettings.getAlgorithm())) { + return i; + } + } + return -1; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/quickstart/QuickStartPart.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/quickstart/QuickStartPart.java index eeb95e4ed0..7d58d73a9f 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/quickstart/QuickStartPart.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/quickstart/QuickStartPart.java @@ -37,12 +37,13 @@ public void create(Composite parent) { tileContainer.addTaskTile(new PeakTileDefinition()); tileContainer.addTaskTile(new ScanTileDefinition()); tileContainer.addTaskTile(new FileTileDefinition()); + tileContainer.addTaskTile(new SpectraTileDefinition()); /* * Additional */ IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - store.setDefault(WelcomeViewExtensionHandler.PREFERENCE_MAX_TILES, 9); - store.setDefault(WelcomeViewExtensionHandler.PREFERENCE_MIN_TILES, 3); + store.setDefault(WelcomeViewExtensionHandler.PREFERENCE_MAX_TILES, 3); + store.setDefault(WelcomeViewExtensionHandler.PREFERENCE_MIN_TILES, 2); // new WelcomeViewExtensionHandler(tileContainer, store, CreatePcaEvaluation.PCA_PERSPECTIVE); } diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/quickstart/SpectraTileDefinition.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/quickstart/SpectraTileDefinition.java new file mode 100644 index 0000000000..f43957196c --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/ui/quickstart/SpectraTileDefinition.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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 org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.quickstart; + +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.internal.wizards.IInputWizard; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.ui.internal.wizards.SpectraInputWizard; +import org.eclipse.chemclipse.ux.extension.ui.definitions.TileDefinition; +import org.osgi.service.component.annotations.Component; + +@Component(service = TileDefinition.class) +public class SpectraTileDefinition extends WizardTile { + + @Override + public String getTitle() { + + return "Spectra"; + } + + @Override + protected IInputWizard createWizard() { + + return new SpectraInputWizard(); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/core/PcaExtractionSpectra.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/core/PcaExtractionSpectra.java new file mode 100644 index 0000000000..976e0fa8b8 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/core/PcaExtractionSpectra.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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: + * Jan Holy - initial API and implementation + * Alexander Kerner - Generics + * Philip Wenig - improvements + * Matthias Mailänder - adapted for MALDI-TOF MS + *******************************************************************************/ +package org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.core; + +import java.io.File; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.extraction.SpectraExtractionSupport; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.extraction.SpectraExtractionSupport.ExtractionType; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.IDataInputEntry; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.Samples; +import org.eclipse.chemclipse.msd.converter.massspectrum.MassSpectrumConverter; +import org.eclipse.chemclipse.msd.model.core.IIon; +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.core.runtime.IProgressMonitor; + +public class PcaExtractionSpectra implements IExtractionData { + + private List dataInputEntries; + private int maximalNumberPeaks; + private int massWindow; + private boolean useDefaultProperties; + private ExtractionType extractionType; + + public PcaExtractionSpectra(int massWindow, int maximalNumberPeaks, List dataInputEntries, ExtractionType extractionType, boolean useDefaultProperties) { + + this.massWindow = massWindow; + this.dataInputEntries = dataInputEntries; + this.extractionType = extractionType; + this.useDefaultProperties = useDefaultProperties; + this.maximalNumberPeaks = maximalNumberPeaks; + } + + @Override + public Samples process(IProgressMonitor monitor) { + + SpectraExtractionSupport spectraExtractionSupport = new SpectraExtractionSupport(massWindow, maximalNumberPeaks, extractionType, useDefaultProperties); + Map> inputData = new HashMap<>(); + for(IDataInputEntry input : dataInputEntries) { + IProcessingInfo processingInfo = MassSpectrumConverter.convert(new File(input.getInputFile()), monitor); + IMassSpectra massSpectra = processingInfo.getProcessingResult(); + if(massSpectra == null) + continue; + IScanMSD massSpectrum = massSpectra.getMassSpectrum(1); + if(massSpectrum == null) + continue; + List ions = massSpectrum.getIons(); + if(ions.size() > 0) + inputData.put(input, ions); + } + return spectraExtractionSupport.process(inputData, monitor); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/extraction/SpectraExtractionSupport.java b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/extraction/SpectraExtractionSupport.java new file mode 100644 index 0000000000..4cc10a9e26 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca/src/org/eclipse/chemclipse/chromatogram/xxd/process/supplier/pca/extraction/SpectraExtractionSupport.java @@ -0,0 +1,236 @@ +/******************************************************************************* + * 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: + * Jan Holy - initial API and implementation + * Philip Wenig - improvements + * Matthias Mailänder - adapted for MALDI-TOF MS + *******************************************************************************/ +package org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.extraction; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.NavigableMap; +import java.util.Set; +import java.util.TreeMap; + +import org.apache.commons.math3.analysis.UnivariateFunction; +import org.apache.commons.math3.analysis.interpolation.LinearInterpolator; +import org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.IDataInputEntry; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.PeakSampleData; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.Sample; +import org.eclipse.chemclipse.chromatogram.xxd.process.supplier.pca.model.Samples; +import org.eclipse.chemclipse.model.statistics.MassToChargeRatio; +import org.eclipse.chemclipse.msd.model.core.IIon; +import org.eclipse.core.runtime.IProgressMonitor; + +public class SpectraExtractionSupport { + + public enum ExtractionType { + CLOSEST_MASS, LINEAR_INTERPOLATION_MASS; + } + + private double beginMassMax; + private double endMassMin; + private ExtractionType extractionType; + private int maximalNumberPeaks; + private double massWindow; + private boolean useDefaultProperties; + + public SpectraExtractionSupport(int massWindow, int maximalNumberPeaks, ExtractionType extractionType, boolean useDefaultProperties) { + + this.massWindow = massWindow; + this.extractionType = extractionType; + this.useDefaultProperties = useDefaultProperties; + this.maximalNumberPeaks = maximalNumberPeaks; + this.extractionType = extractionType; + } + + public Samples process(Map> dataInput, IProgressMonitor monitor) { + + /* + * Initialize PCA Results + */ + List samplesList = new ArrayList<>(); + dataInput.keySet().forEach(d -> samplesList.add(new Sample(d.getName(), d.getGroupName()))); + Samples samples = new Samples(samplesList); + /* + * Extract data + */ + Map> extractIons = extractIons(dataInput, monitor); + // + boolean similarMassSpectrum = true; + if(useDefaultProperties) { + Collection> dataSet = extractIons.values(); + boolean isFirst = true; + Set massRange = new HashSet<>(); + int massRangeSize = massRange.size(); + for(NavigableMap data : dataSet) { + if(isFirst) { + massRange.addAll(data.keySet()); + } else { + if(data.size() != massRange.size()) { + similarMassSpectrum = false; + break; + } + long dataSize = data.keySet().stream().filter(mz -> massRange.contains(mz)).count(); + if(dataSize != massRangeSize) { + similarMassSpectrum = false; + break; + } + } + } + } + double size = ((endMassMin - beginMassMax) / massWindow); + if(size > maximalNumberPeaks) { + massWindow = (endMassMin - beginMassMax) / maximalNumberPeaks; + similarMassSpectrum = false; + } + if(similarMassSpectrum && useDefaultProperties) { + useDefaultProperties(samples, extractIons); + } else { + switch(extractionType) { + case CLOSEST_MASS: + setClosestMass(samples, extractIons); + break; + case LINEAR_INTERPOLATION_MASS: + interpolation(samples, extractIons, new LinearInterpolator()); + break; + } + } + return samples; + } + + private Map> extractIons(Map> inputs, IProgressMonitor monitor) { + + beginMassMax = 0; + endMassMin = Integer.MAX_VALUE; + Map> scanMap = new HashMap<>(); + for(Entry> input : inputs.entrySet()) { + TreeMap extractPeaks = new TreeMap<>(); + Collection ions = input.getValue(); + /* + * extract ions + */ + for(IIon ion : ions) { + float abundance = ion.getAbundance(); + double mass = ion.getIon(); + extractPeaks.put(mass, abundance); + } + double firstMass = extractPeaks.firstKey(); + double lastMass = extractPeaks.lastKey(); + if(firstMass > beginMassMax) { + beginMassMax = firstMass; + } + if(lastMass < endMassMin) { + endMassMin = lastMass; + } + scanMap.put(input.getKey().getName(), extractPeaks); + } + return scanMap; + } + + private Float getClosestMass(NavigableMap ions, double i) { + + Entry massAbundanceCeil = ions.ceilingEntry(i); + Entry massAbundanceFloor = ions.floorEntry(i); + if(massAbundanceCeil != null && massAbundanceFloor != null) { + if((massAbundanceCeil.getKey() - i) < (i - massAbundanceFloor.getKey())) { + return massAbundanceCeil.getValue(); + } else { + return massAbundanceFloor.getValue(); + } + } else if(massAbundanceCeil != null) { + return massAbundanceCeil.getValue(); + } else if(massAbundanceFloor != null) { + return massAbundanceFloor.getValue(); + } + return null; + } + + private void interpolation(Samples samples, Map> extractIons, UnivariateInterpolator interpolator) { + + for(Sample sample : samples.getSampleList()) { + List data = sample.getSampleData(); + NavigableMap ions = extractIons.get(sample.getName()); + double[] mz = new double[ions.size()]; + double[] abundance = new double[ions.size()]; + int j = 0; + Iterator> it = ions.entrySet().iterator(); + while(it.hasNext()) { + Entry entry = it.next(); + mz[j] = entry.getKey(); + abundance[j] = entry.getValue(); + j++; + } + UnivariateFunction fun = interpolator.interpolate(mz, abundance); + for(double i = beginMassMax; i <= endMassMin; i += massWindow) { + double value = fun.value(i); + PeakSampleData d = new PeakSampleData(value, null); + data.add(d); + } + } + setMassToChargeRatio(samples); + } + + private void setClosestMass(Samples samples, Map> extractIons) { + + for(Sample sample : samples.getSampleList()) { + List data = sample.getSampleData(); + NavigableMap scans = extractIons.get(sample.getName()); + for(double i = beginMassMax; i <= endMassMin; i += massWindow) { + Float value = getClosestMass(scans, i); + PeakSampleData d = new PeakSampleData(value, null); + data.add(d); + } + } + setMassToChargeRatio(samples); + } + + private void setMassToChargeRatio(Samples samples) { + + List mz = new ArrayList<>(); + for(double i = beginMassMax; i <= endMassMin; i += massWindow) { + mz.add(i); + } + samples.getVariables().addAll(MassToChargeRatio.create(mz)); + } + + private void useDefaultProperties(Samples samples, Map> extractIons) { + + Set massToChargeRatioSet = extractIons.entrySet().iterator().next().getValue().keySet(); + List massToChargeRatio = new ArrayList<>(massToChargeRatioSet); + Collections.sort(massToChargeRatio); + for(Sample sample : samples.getSampleList()) { + Iterator it = massToChargeRatio.iterator(); + List data = sample.getSampleData(); + NavigableMap scans = extractIons.get(sample.getName()); + while(it.hasNext()) { + Double mz = it.next(); + Float abundance = scans.get(mz); + PeakSampleData d; + if(abundance != null) { + d = new PeakSampleData(abundance, null); + } else { + abundance = getClosestMass(scans, mz); + d = new PeakSampleData(abundance, null); + } + data.add(d); + } + } + samples.getVariables().addAll(MassToChargeRatio.create(massToChargeRatio)); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/statistics/IMassToChargeRatio.java b/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/statistics/IMassToChargeRatio.java new file mode 100644 index 0000000000..33c2768b7e --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/statistics/IMassToChargeRatio.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * 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 org.eclipse.chemclipse.model.statistics; + +public interface IMassToChargeRatio extends IVariable { + + String TYPE = "[m/z]"; + + double getMassToChargeRatio(); + + void setMassToChargeRatio(double mz); +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/statistics/MassToChargeRatio.java b/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/statistics/MassToChargeRatio.java new file mode 100644 index 0000000000..91b3dfffb6 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/statistics/MassToChargeRatio.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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 org.eclipse.chemclipse.model.statistics; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.chemclipse.support.text.ValueFormat; + +public class MassToChargeRatio extends AbstractVariable implements IMassToChargeRatio { + + private DecimalFormat decimalFormat = ValueFormat.getDecimalFormatEnglish("0"); + private double mz = 0; + + public static List create(List massToChargeRotatios) { + + List massToChargeList = new ArrayList<>(); + for(int i = 0; i < massToChargeRotatios.size(); i++) { + massToChargeList.add(new MassToChargeRatio(massToChargeRotatios.get(i))); + } + return massToChargeList; + } + + public MassToChargeRatio(Double mz) { + + super(); + this.mz = mz; + setValue(convertValue()); + setType(IMassToChargeRatio.TYPE); + setSelected(true); + } + + public MassToChargeRatio(Double mz, String description) { + + this(mz); + setDescription(description); + } + + @Override + public int compareTo(IVariable o) { + + if(o instanceof IMassToChargeRatio) { + IMassToChargeRatio mz = (IMassToChargeRatio)o; + // round internally if not already done by pre-processing + return Integer.compare((int)Math.round(getMassToChargeRatio()), (int)Math.round(mz.getMassToChargeRatio())); + } + return 0; + } + + private String convertValue() { + + return decimalFormat.format(getMassToChargeRatio()); + } + + @Override + public double getMassToChargeRatio() { + + return mz; + } + + @Override + public void setMassToChargeRatio(double mz) { + + this.mz = mz; + setValue(convertValue()); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/types/DataType.java b/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/types/DataType.java index 5011abd781..875c1a655e 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/types/DataType.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.model/src/org/eclipse/chemclipse/model/types/DataType.java @@ -14,6 +14,7 @@ import org.eclipse.chemclipse.processing.DataCategory; public enum DataType { + NONE, // Used e.g. as an initial value for the Scan Table AUTO_DETECT, // Auto-Detect MSD_NOMINAL, // Quadrupole, Ion Trap @@ -28,7 +29,8 @@ public enum DataType { PCR, // Polymerase Chain Reaction SEQ, // Sequences MTH, // Methods - QDB; // Quantitation Databases + QDB, // Quantitation Databases + MALDI; // MALDI-TOF MS public static DataType fromDataCategory(DataCategory category) { @@ -42,6 +44,8 @@ public static DataType fromDataCategory(DataCategory category) { case FID: case NMR: return DataType.NMR; + case MALDI: + return DataType.MALDI; default: return DataType.AUTO_DETECT; } @@ -58,6 +62,8 @@ public DataCategory toDataCategory() { return DataCategory.CSD; case NMR: return DataCategory.NMR; + case MALDI: + return DataCategory.MALDI; default: return DataCategory.AUTO_DETECT; } diff --git a/chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/DataCategory.java b/chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/DataCategory.java index 752f87dfbf..89a8413075 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/DataCategory.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/DataCategory.java @@ -18,13 +18,15 @@ * */ public enum DataCategory { + MSD(Messages.getString("DataCategory.MSD")), // CSD(Messages.getString("DataCategory.CSD")), // WSD(Messages.getString("DataCategory.WSD")), // FID(Messages.getString("DataCategory.FID")), // NMR(Messages.getString("DataCategory.NMR")), // XIR(Messages.getString("DataCategory.XIR")), // - PCR(Messages.getString("DataCategory.PCR")), + PCR(Messages.getString("DataCategory.PCR")), // + MALDI(Messages.getString("DataCategory.MALDI")), // /** * Suggests that this Filter can support a wide range of datatypes and content-sensing is the only option to check if the filter, processor or converter can really handle the data or not */ diff --git a/chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/DataCategoryGroup.java b/chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/DataCategoryGroup.java index d23258e44f..4c89b51f27 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/DataCategoryGroup.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.processing/src/org/eclipse/chemclipse/processing/DataCategoryGroup.java @@ -23,14 +23,16 @@ public final class DataCategoryGroup { private final Set dataCategories; private static final DataCategoryGroup[] DEFAULT_GROUPS = new DataCategoryGroup[]{ // new DataCategoryGroup("Chromatography", DataCategory.CSD, DataCategory.MSD, DataCategory.WSD), // - new DataCategoryGroup("Spectroscopy", DataCategory.FID, DataCategory.NMR)// - }; + new DataCategoryGroup("Spectroscopy", DataCategory.FID, DataCategory.NMR), // + new DataCategoryGroup("Spectrometry", DataCategory.MALDI)}; public DataCategoryGroup(String name, DataCategory... dataCategories) { + this(name, Arrays.asList(dataCategories)); } public DataCategoryGroup(String name, Collection dataCategories) { + this.name = name; this.dataCategories = Collections.unmodifiableSet(new LinkedHashSet<>(dataCategories)); } diff --git a/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/events/IChemClipseEvents.java b/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/events/IChemClipseEvents.java index d85a79188d..85753c4235 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/events/IChemClipseEvents.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.support/src/org/eclipse/chemclipse/support/events/IChemClipseEvents.java @@ -24,6 +24,7 @@ public interface IChemClipseEvents { String TOPIC_SCAN_NMR_UPDATE_RAWFILE = "scan/nmr/update/rawfile"; String TOPIC_PLATE_PCR_UPDATE_RAWFILE = "plate/pcr/update/rawfile"; String TOPIC_SEQUENCE_UPDATE_RAWFILE = "sequence/update/rawfile"; + String TOPIC_MASS_SPECTRUM_UPDATE_RAWFILE = "spectrum/ms/update/rawfile"; String TOPIC_METHOD_UPDATE_RAWFILE = "method/update/rawfile"; String TOPIC_QUANTIATION_DATABASE_UPDATE_RAWFILE = "quantitation/database/update/rawfile"; String TOPIC_CHROMATOGRAM_XXD_UPDATE_NONE = "chromatogram/xxd/update/none"; @@ -34,6 +35,7 @@ public interface IChemClipseEvents { String TOPIC_SCAN_NMR_UPDATE_OVERVIEW = "scan/nmr/update/overview"; String TOPIC_SCAN_XIR_UPDATE_OVERVIEW = "scan/xir/update/overview"; String TOPIC_SEQUENCE_UPDATE_OVERVIEW = "sequence/update/overview"; + String TOPIC_MASS_SPECTRUM_UPDATE_OVERVIEW = "spectrum/ms/update/overview"; String TOPIC_METHOD_UPDATE_OVERVIEW = "method/update/overview"; String TOPIC_QUANTIATION_DATABASE_UPDATE_OVERVIEW = "quantitation/database/update/overview"; // diff --git a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/OverviewSupport.java b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/OverviewSupport.java index 915f2308f2..471bafa810 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/OverviewSupport.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/OverviewSupport.java @@ -22,6 +22,7 @@ import org.eclipse.chemclipse.model.core.IMeasurementInfo; import org.eclipse.chemclipse.model.selection.IChromatogramSelection; import org.eclipse.chemclipse.msd.converter.chromatogram.ChromatogramConverterMSD; +import org.eclipse.chemclipse.msd.converter.massspectrum.MassSpectrumConverter; import org.eclipse.chemclipse.nmr.converter.core.ScanConverterNMR; import org.eclipse.chemclipse.processing.core.IProcessingInfo; import org.eclipse.chemclipse.support.events.IChemClipseEvents; @@ -119,6 +120,15 @@ private boolean updateFile(File file, String topic) { if(data instanceof IMeasurementInfo) { return fireUpdate(data); } + } else if(topic.equals(IChemClipseEvents.TOPIC_MASS_SPECTRUM_UPDATE_RAWFILE)) { + /* + * MALDI + */ + IProcessingInfo processingInfo = MassSpectrumConverter.convert(file, new NullProgressMonitor()); + Object data = processingInfo.getProcessingResult(); + if(data instanceof IMeasurementInfo) { + return fireUpdate(data); + } } else { /* * MSD, CSD, WSD @@ -174,11 +184,13 @@ private void initializeTopics() { topics.add(IChemClipseEvents.TOPIC_CHROMATOGRAM_WSD_UPDATE_RAWFILE); topics.add(IChemClipseEvents.TOPIC_SCAN_NMR_UPDATE_RAWFILE); topics.add(IChemClipseEvents.TOPIC_SCAN_XIR_UPDATE_RAWFILE); + topics.add(IChemClipseEvents.TOPIC_MASS_SPECTRUM_UPDATE_RAWFILE); topics.add(IChemClipseEvents.TOPIC_CHROMATOGRAM_MSD_UPDATE_OVERVIEW); topics.add(IChemClipseEvents.TOPIC_CHROMATOGRAM_CSD_UPDATE_OVERVIEW); topics.add(IChemClipseEvents.TOPIC_CHROMATOGRAM_WSD_UPDATE_OVERVIEW); topics.add(IChemClipseEvents.TOPIC_SCAN_NMR_UPDATE_OVERVIEW); topics.add(IChemClipseEvents.TOPIC_SCAN_XIR_UPDATE_OVERVIEW); + topics.add(IChemClipseEvents.TOPIC_MASS_SPECTRUM_UPDATE_OVERVIEW); topics.add(IChemClipseEvents.TOPIC_CHROMATOGRAM_XXD_UPDATE_NONE); } } diff --git a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/SupplierEditorSupport.java b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/SupplierEditorSupport.java index cf91907d6d..26d77166d3 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/SupplierEditorSupport.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/part/support/SupplierEditorSupport.java @@ -25,10 +25,12 @@ import org.eclipse.chemclipse.model.core.IMeasurementInfo; import org.eclipse.chemclipse.model.types.DataType; import org.eclipse.chemclipse.msd.converter.chromatogram.ChromatogramConverterMSD; +import org.eclipse.chemclipse.msd.converter.massspectrum.MassSpectrumConverter; import org.eclipse.chemclipse.nmr.converter.core.ScanConverterNMR; import org.eclipse.chemclipse.pcr.converter.core.PlateConverterPCR; import org.eclipse.chemclipse.processing.converter.ISupplier; import org.eclipse.chemclipse.support.events.IChemClipseEvents; +import org.eclipse.chemclipse.ux.extension.msd.ui.editors.MassSpectrumEditor; import org.eclipse.chemclipse.ux.extension.ui.editors.EditorDescriptor; import org.eclipse.chemclipse.ux.extension.ui.provider.AbstractSupplierFileEditorSupport; import org.eclipse.chemclipse.ux.extension.ui.provider.ISupplierEditorSupport; @@ -105,6 +107,9 @@ private static List getSupplier(DataType dataType) { case QDB: supplier = QuantDBConverter.getQuantDBConverterSupport().getSupplier(); break; + case MALDI: + supplier = MassSpectrumConverter.getMassSpectrumConverterSupport().getSupplier(); + break; default: // No action } @@ -207,6 +212,15 @@ private void initialize(DataType dataType) { topicUpdateRawfile = IChemClipseEvents.TOPIC_QUANTIATION_DATABASE_UPDATE_RAWFILE; topicUpdateOverview = IChemClipseEvents.TOPIC_QUANTIATION_DATABASE_UPDATE_OVERVIEW; break; + case MALDI: + type = TYPE_SCAN_MSD; + elementId = MassSpectrumEditor.ID; + contributionURI = MassSpectrumEditor.CONTRIBUTION_URI; + iconURI = MassSpectrumEditor.ICON_URI; + tooltip = MassSpectrumEditor.TOOLTIP; + topicUpdateRawfile = IChemClipseEvents.TOPIC_MASS_SPECTRUM_UPDATE_RAWFILE; + topicUpdateOverview = IChemClipseEvents.TOPIC_MASS_SPECTRUM_UPDATE_OVERVIEW; + break; default: break; }