Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a MALDI editor export menu #2039

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading