Skip to content

Commit

Permalink
Merge pull request #2039 from Mailaender/maldi-chart-menus
Browse files Browse the repository at this point in the history
Added a MALDI editor export menu
  • Loading branch information
eselmeister authored Jan 20, 2025
2 parents eb283b8 + 378f909 commit 1192aff
Show file tree
Hide file tree
Showing 12 changed files with 519 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Lablicate GmbH.
* Copyright (c) 2024, 2025 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -12,27 +12,64 @@
package org.eclipse.chemclipse.msd.converter.supplier.cml.converter;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException;
import org.eclipse.chemclipse.converter.l10n.ConverterMessages;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.msd.converter.io.IMassSpectraWriter;
import org.eclipse.chemclipse.msd.converter.massspectrum.AbstractMassSpectrumExportConverter;
import org.eclipse.chemclipse.msd.converter.supplier.cml.converter.io.MassSpectraWriter;
import org.eclipse.chemclipse.msd.model.core.IMassSpectra;
import org.eclipse.chemclipse.msd.model.core.IScanMSD;
import org.eclipse.chemclipse.msd.model.implementation.MassSpectra;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.ProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;

public class MassSpectrumExportConverter extends AbstractMassSpectrumExportConverter {

private static final Logger logger = Logger.getLogger(MassSpectrumExportConverter.class);
private static final String DESCRIPTION = "CML Mass Spectra Export Converter";

@Override
public IProcessingInfo<File> convert(File file, IScanMSD massSpectrum, boolean append, IProgressMonitor monitor) {

IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
return processingInfo;
IMassSpectra massSpectra = new MassSpectra();
massSpectra.addMassSpectrum(massSpectrum);
return convert(file, massSpectra, append, monitor);
}

@Override
public IProcessingInfo<File> convert(File file, IMassSpectra massSpectra, boolean append, IProgressMonitor monitor) {

IProcessingInfo<File> processingInfo = validate(file, massSpectra);
if(!processingInfo.hasErrorMessages()) {
try {
IMassSpectraWriter massSpectraWriter = new MassSpectraWriter();
massSpectraWriter.write(file, massSpectra, append, monitor);
processingInfo.setProcessingResult(file);
} catch(FileNotFoundException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotFound, file.getAbsolutePath()));
} catch(FileIsNotWriteableException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotWritable, file.getAbsolutePath()));
} catch(IOException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.failedToWriteFile, file.getAbsolutePath()));
}
}
return processingInfo;
}

private IProcessingInfo<File> validate(File file, IMassSpectra massSpectra) {

IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
processingInfo.addMessages(super.validate(file));
processingInfo.addMessages(super.validate(massSpectra));
return processingInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
importContentMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzdata.converter.MassSpectrumFileContentMatcher"
importConverter="org.eclipse.chemclipse.msd.converter.supplier.mzdata.converter.MassSpectrumImportConverter"
importMagicNumberMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzdata.converter.MagicNumberMatcher"
isExportable="false"
isExportable="true"
isImportable="true">
</MassSpectrumSupplier>
</extension>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2023 Lablicate GmbH.
* Copyright (c) 2008, 2025 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -13,31 +13,64 @@
package org.eclipse.chemclipse.msd.converter.supplier.mzdata.converter;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException;
import org.eclipse.chemclipse.converter.l10n.ConverterMessages;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.msd.converter.io.IMassSpectraWriter;
import org.eclipse.chemclipse.msd.converter.massspectrum.AbstractMassSpectrumExportConverter;
import org.eclipse.chemclipse.msd.converter.supplier.mzdata.internal.io.MassSpectrumWriterVersion105;
import org.eclipse.chemclipse.msd.model.core.IMassSpectra;
import org.eclipse.chemclipse.msd.model.core.IScanMSD;
import org.eclipse.chemclipse.msd.model.implementation.MassSpectra;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.ProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;

public class MassSpectrumExportConverter extends AbstractMassSpectrumExportConverter {

private static final Logger logger = Logger.getLogger(MassSpectrumExportConverter.class);
private static final String DESCRIPTION = "mzXML Mass Spectra Export Converter";

@Override
public IProcessingInfo<File> convert(File file, IScanMSD massSpectrum, boolean append, IProgressMonitor monitor) {

IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
processingInfo.addErrorMessage(DESCRIPTION, "It's not possible to export mass spectrum data as mzXML yet.");
return processingInfo;
IMassSpectra massSpectra = new MassSpectra();
massSpectra.addMassSpectrum(massSpectrum);
return convert(file, massSpectra, append, monitor);
}

@Override
public IProcessingInfo<File> convert(File file, IMassSpectra massSpectra, boolean append, IProgressMonitor monitor) {

IProcessingInfo<File> processingInfo = validate(file, massSpectra);
if(!processingInfo.hasErrorMessages()) {
try {
IMassSpectraWriter massSpectraWriter = new MassSpectrumWriterVersion105();
massSpectraWriter.write(file, massSpectra, append, monitor);
processingInfo.setProcessingResult(file);
} catch(FileNotFoundException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotFound, file.getAbsolutePath()));
} catch(FileIsNotWriteableException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotWritable, file.getAbsolutePath()));
} catch(IOException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.failedToWriteFile, file.getAbsolutePath()));
}
}
return processingInfo;
}

private IProcessingInfo<File> validate(File file, IMassSpectra massSpectra) {

IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
processingInfo.addErrorMessage(DESCRIPTION, "It's not possible to export mass spectrum data as mzXML yet.");
processingInfo.addMessages(super.validate(file));
processingInfo.addMessages(super.validate(massSpectra));
return processingInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
importContentMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.MassSpectrumFileContentMatcher"
importConverter="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.MassSpectrumImportConverter"
importMagicNumberMatcher="org.eclipse.chemclipse.xxd.converter.supplier.mzml.converter.MagicNumberMatcher"
isExportable="false"
isExportable="true"
isImportable="true">
</MassSpectrumSupplier>
</extension>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2023 Lablicate GmbH.
* Copyright (c) 2021, 2025 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -12,31 +12,64 @@
package org.eclipse.chemclipse.msd.converter.supplier.mzml.converter;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException;
import org.eclipse.chemclipse.converter.l10n.ConverterMessages;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.msd.converter.io.IMassSpectraWriter;
import org.eclipse.chemclipse.msd.converter.massspectrum.AbstractMassSpectrumExportConverter;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.io.MassSpectrumWriterVersion110;
import org.eclipse.chemclipse.msd.model.core.IMassSpectra;
import org.eclipse.chemclipse.msd.model.core.IScanMSD;
import org.eclipse.chemclipse.msd.model.implementation.MassSpectra;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.ProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;

public class MassSpectrumExportConverter extends AbstractMassSpectrumExportConverter {

private static final Logger logger = Logger.getLogger(MassSpectrumExportConverter.class);
private static final String DESCRIPTION = "mzML Mass Spectra Export Converter";

@Override
public IProcessingInfo<File> convert(File file, IScanMSD massSpectrum, boolean append, IProgressMonitor monitor) {

IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
processingInfo.addErrorMessage(DESCRIPTION, "It's not possible to export mass spectrum data as mzML yet.");
return processingInfo;
IMassSpectra massSpectra = new MassSpectra();
massSpectra.addMassSpectrum(massSpectrum);
return convert(file, massSpectra, append, monitor);
}

@Override
public IProcessingInfo<File> convert(File file, IMassSpectra massSpectra, boolean append, IProgressMonitor monitor) {

IProcessingInfo<File> processingInfo = validate(file, massSpectra);
if(!processingInfo.hasErrorMessages()) {
try {
IMassSpectraWriter massSpectraWriter = new MassSpectrumWriterVersion110();
massSpectraWriter.write(file, massSpectra, append, monitor);
processingInfo.setProcessingResult(file);
} catch(FileNotFoundException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotFound, file.getAbsolutePath()));
} catch(FileIsNotWriteableException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotWritable, file.getAbsolutePath()));
} catch(IOException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.failedToWriteFile, file.getAbsolutePath()));
}
}
return processingInfo;
}

private IProcessingInfo<File> validate(File file, IMassSpectra massSpectra) {

IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
processingInfo.addErrorMessage(DESCRIPTION, "It's not possible to export mass spectrum data as mzML yet.");
processingInfo.addMessages(super.validate(file));
processingInfo.addMessages(super.validate(massSpectra));
return processingInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
importContentMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzxml.converter.MassSpectrumFileContentMatcher"
importConverter="org.eclipse.chemclipse.msd.converter.supplier.mzxml.converter.MassSpectrumImportConverter"
importMagicNumberMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzxml.converter.MagicNumberMatcher"
isExportable="false"
isExportable="true"
isImportable="true">
</MassSpectrumSupplier>
</extension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,64 @@
package org.eclipse.chemclipse.msd.converter.supplier.mzxml.converter;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException;
import org.eclipse.chemclipse.converter.l10n.ConverterMessages;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.msd.converter.io.IMassSpectraWriter;
import org.eclipse.chemclipse.msd.converter.massspectrum.AbstractMassSpectrumExportConverter;
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.io.MassSpectrumWriterVersion22;
import org.eclipse.chemclipse.msd.model.core.IMassSpectra;
import org.eclipse.chemclipse.msd.model.core.IScanMSD;
import org.eclipse.chemclipse.msd.model.implementation.MassSpectra;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.ProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;

public class MassSpectrumExportConverter extends AbstractMassSpectrumExportConverter {

private static final Logger logger = Logger.getLogger(MassSpectrumExportConverter.class);
private static final String DESCRIPTION = "mzML Mass Spectra Export Converter";

@Override
public IProcessingInfo<File> convert(File file, IScanMSD massSpectrum, boolean append, IProgressMonitor monitor) {

IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
return processingInfo;
IMassSpectra massSpectra = new MassSpectra();
massSpectra.addMassSpectrum(massSpectrum);
return convert(file, massSpectra, append, monitor);
}

@Override
public IProcessingInfo<File> convert(File file, IMassSpectra massSpectra, boolean append, IProgressMonitor monitor) {

IProcessingInfo<File> processingInfo = validate(file, massSpectra);
if(!processingInfo.hasErrorMessages()) {
try {
IMassSpectraWriter massSpectraWriter = new MassSpectrumWriterVersion22();
massSpectraWriter.write(file, massSpectra, append, monitor);
processingInfo.setProcessingResult(file);
} catch(FileNotFoundException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotFound, file.getAbsolutePath()));
} catch(FileIsNotWriteableException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotWritable, file.getAbsolutePath()));
} catch(IOException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.failedToWriteFile, file.getAbsolutePath()));
}
}
return processingInfo;
}

private IProcessingInfo<File> validate(File file, IMassSpectra massSpectra) {

IProcessingInfo<File> processingInfo = new ProcessingInfo<>();
processingInfo.addMessages(super.validate(file));
processingInfo.addMessages(super.validate(massSpectra));
return processingInfo;
}
}
Loading

0 comments on commit 1192aff

Please sign in to comment.