Skip to content

Commit

Permalink
Add mzML HPLC-DAD read/write support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Sep 11, 2024
1 parent 14a3b60 commit 12cde19
Show file tree
Hide file tree
Showing 184 changed files with 3,069 additions and 1,111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@

<plugin
id="org.eclipse.chemclipse.msd.converter.supplier.mzml"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
version="0.0.0"/>

<plugin
id="org.eclipse.chemclipse.msd.converter.supplier.mzml.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
version="0.0.0"/>

<plugin
id="org.eclipse.chemclipse.wsd.converter.supplier.mzml"
version="0.0.0"/>

<plugin
id="org.eclipse.chemclipse.xxd.converter.supplier.mzml"
version="0.0.0"/>

<plugin
id="org.eclipse.chemclipse.wsd.converter.supplier.mzml.ui"
version="0.0.0"/>

</feature>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Automatic-Module-Name: org.eclipse.chemclipse.msd.converter.supplier.mzml.ui
Bundle-ManifestVersion: 2
Bundle-Name: mzML UI
Bundle-Name: mzML MSD 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 Lablicate GmbH.
* Copyright (c) 2021, 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
Expand Down Expand Up @@ -29,13 +29,15 @@ public PreferencePage() {
setDescription("mzML Converter");
}

@Override
public void createFieldEditors() {

addField(new SpacerFieldEditor(getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceSupplier.P_CHROMATOGRAM_VERSION_SAVE, "Save (*.mzML) as version:", PreferenceSupplier.getChromatogramVersions(), getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceSupplier.P_CHROMATOGRAM_SAVE_COMPRESSION, "Compress values", getFieldEditorParent()));
}

@Override
public void init(IWorkbench workbench) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Bundle-ActivationPolicy: lazy
Import-Package: jakarta.xml.bind,
jakarta.xml.bind.annotation,
jakarta.xml.bind.annotation.adapters
Export-Package: org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.io,
org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter,
org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.v110.model
Export-Package: org.eclipse.chemclipse.msd.converter.supplier.mzml,
org.eclipse.chemclipse.msd.converter.supplier.mzml.converter,
org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.io,
org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.model,
org.eclipse.chemclipse.msd.converter.supplier.mzml.io,
org.eclipse.chemclipse.msd.converter.supplier.mzml.preferences
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
description="Reads mzML Chromatograms"
exportConverter="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.ChromatogramExportConverter"
fileExtension=".mzML"
filterName="mzML Chromatogram (*.mzML)"
filterName="MSD Chromatogram (*.mzML)"
id="org.eclipse.chemclipse.msd.converter.supplier.mzml"
importContentMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.ChromatogramFileContentMatcher"
importConverter="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.ChromatogramImportConverter"
importMagicNumberMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.MagicNumberMatcher"
importMagicNumberMatcher="org.eclipse.chemclipse.xxd.converter.supplier.mzml.converter.MagicNumberMatcher"
isExportable="true"
isImportable="true">
</ChromatogramSupplier>
Expand All @@ -26,7 +26,7 @@
id="org.eclipse.chemclipse.msd.converter.supplier.mzml.ms"
importContentMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.MassSpectrumFileContentMatcher"
importConverter="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.MassSpectrumImportConverter"
importMagicNumberMatcher="org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.MagicNumberMatcher"
importMagicNumberMatcher="org.eclipse.chemclipse.xxd.converter.supplier.mzml.converter.MagicNumberMatcher"
isExportable="false"
isImportable="true">
</MassSpectrumSupplier>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2018 Lablicate GmbH.
* Copyright (c) 2013, 2024 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -25,7 +25,7 @@ public class PathResolver {
/**
* Returns a absolute path of the specified Folder. For example
* TESTDATA_IMPORT_EMPTY as an absolute Path:
* $PluginPath$/testData/files/EMPTY.D/DATA.MS
* $PluginPath$/testData/files/data.mzML
*
* @param string
* @return String absolutePath
Expand All @@ -36,7 +36,7 @@ public static String getAbsolutePath(String string) {
IPath path = new Path(string);
URL url = FileLocator.find(bundle, path, null);
try {
return FileLocator.resolve(url).getPath().toString();
return FileLocator.resolve(url).getPath();
} catch(IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.eclipse.chemclipse.model.core.IPeak;
import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDWriter;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.io.ChromatogramWriter;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.SpecificationValidator;
import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
Expand All @@ -38,7 +37,6 @@ public class ChromatogramExportConverter extends AbstractChromatogramExportConve
@Override
public IProcessingInfo<File> convert(File file, IChromatogram<? extends IPeak> chromatogram, IProgressMonitor monitor) {

file = SpecificationValidator.validateSpecification(file);
IProcessingInfo<File> processingInfo = super.validate(file);
if(!processingInfo.hasErrorMessages() && chromatogram instanceof IChromatogramMSD chromatogramMSD) {
monitor.subTask(EXPORT_CHROMATOGRAM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public boolean checkFileFormat(File file) {
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(new FileInputStream(file));
boolean hasChromatogramList = false;
boolean hasRootElement = false;
boolean hasMS = false;
while(xmlStreamReader.hasNext()) {
int eventType = xmlStreamReader.next();
if(eventType == XMLStreamConstants.START_ELEMENT) {
Expand All @@ -44,8 +45,24 @@ public boolean checkFileFormat(File file) {
hasRootElement = true;
} else if(elementName.equals("chromatogramList")) {
hasChromatogramList = true;
} else if(elementName.equals("fileContent")) {
while(xmlStreamReader.hasNext()) {
int innerEventType = xmlStreamReader.next();
if(innerEventType == XMLStreamConstants.START_ELEMENT && xmlStreamReader.getLocalName().equals("cvParam")) {
String accession = xmlStreamReader.getAttributeValue(null, "accession");
String paramName = xmlStreamReader.getAttributeValue(null, "name");
if(accession.equals("MS:1000579") && paramName.equals("MS1 spectrum") || //
accession.equals("MS:1000580") && paramName.equals("MSn spectrum")) {
hasMS = true;
break;
}
}
if(innerEventType == XMLStreamConstants.END_ELEMENT && xmlStreamReader.getLocalName().equals("fileContent")) {
break;
}
}
}
if(hasRootElement && hasChromatogramList) {
if(hasRootElement && hasChromatogramList && hasMS) {
isValidFormat = true;
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2023 Lablicate GmbH.
* Copyright (c) 2013, 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
Expand All @@ -20,7 +20,6 @@
import org.eclipse.chemclipse.model.core.IChromatogramOverview;
import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDReader;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.converter.io.ChromatogramReader;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.SpecificationValidator;
import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
Expand All @@ -41,7 +40,6 @@ public IProcessingInfo<IChromatogramMSD> convert(File file, IProgressMonitor mon
/*
* Read the chromatogram.
*/
file = SpecificationValidator.validateSpecification(file);
IChromatogramMSDReader reader = new ChromatogramReader();
monitor.subTask(IMPORT_CHROMATOGRAM);
try {
Expand All @@ -64,7 +62,6 @@ public IProcessingInfo<IChromatogramOverview> convertOverview(File file, IProgre

IProcessingInfo<IChromatogramOverview> processingInfo = super.validate(file);
if(!processingInfo.hasErrorMessages()) {
file = SpecificationValidator.validateSpecification(file);
IChromatogramMSDReader reader = new ChromatogramReader();
monitor.subTask(IMPORT_CHROMATOGRAM_OVERVIEW);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2022 Lablicate GmbH.
* Copyright (c) 2021, 2024 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -17,14 +17,15 @@

import org.eclipse.chemclipse.converter.exceptions.FileIsEmptyException;
import org.eclipse.chemclipse.converter.exceptions.FileIsNotReadableException;
import org.eclipse.chemclipse.converter.l10n.ConverterMessages;
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.mzml.converter.io.MassSpectrumReader;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.SpecificationValidator;
import org.eclipse.chemclipse.msd.model.core.IMassSpectra;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;

public class MassSpectrumImportConverter extends AbstractMassSpectrumImportConverter {

Expand All @@ -37,26 +38,25 @@ public IProcessingInfo<IMassSpectra> convert(File file, IProgressMonitor monitor
IProcessingInfo<IMassSpectra> processingInfo = super.validate(file);
if(!processingInfo.hasErrorMessages()) {
try {
file = SpecificationValidator.validateSpecification(file);
IMassSpectraReader massSpectraReader = new MassSpectrumReader();
IMassSpectra massSpectra = massSpectraReader.read(file, monitor);
if(massSpectra != null && !massSpectra.isEmpty()) {
processingInfo.setProcessingResult(massSpectra);
} else {
processingInfo.addErrorMessage(DESCRIPTION, "No mass spectra are stored." + file.getAbsolutePath());
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.noMassSpectraStored, file.getAbsolutePath()));
}
} catch(FileNotFoundException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, "The file couldn't be found: " + file.getAbsolutePath());
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotFound, file.getAbsolutePath()));
} catch(FileIsNotReadableException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, "The file is not readable: " + file.getAbsolutePath());
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.fileNotReadable, file.getAbsolutePath()));
} catch(FileIsEmptyException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, "The file is empty: " + file.getAbsolutePath());
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.emptyFile, file.getAbsolutePath()));
} catch(IOException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, "Something has gone completely wrong: " + file.getAbsolutePath());
processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.failedToReadFile, file.getAbsolutePath()));
}
}
return processingInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2023 Lablicate GmbH.
* Copyright (c) 2014, 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
Expand All @@ -16,15 +16,15 @@
import java.io.FileReader;
import java.io.IOException;

import org.eclipse.chemclipse.converter.exceptions.UnknownVersionException;
import org.eclipse.chemclipse.model.core.IChromatogramOverview;
import org.eclipse.chemclipse.msd.converter.io.AbstractChromatogramMSDReader;
import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDReader;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.XmlReader10;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.XmlReader110;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.io.ChromatogramReaderVersion10;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.io.ChromatogramReaderVersion110;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.io.ChromatogramReaderVersion10;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.io.ChromatogramReaderVersion110;
import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD;
import org.eclipse.chemclipse.xxd.converter.supplier.io.exception.UnknownVersionException;
import org.eclipse.chemclipse.xxd.converter.supplier.mzml.io.XmlReader10;
import org.eclipse.chemclipse.xxd.converter.supplier.mzml.io.XmlReader110;
import org.eclipse.core.runtime.IProgressMonitor;

public class ChromatogramReader extends AbstractChromatogramMSDReader implements IChromatogramMSDReader {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2023 Lablicate GmbH.
* Copyright (c) 2014, 2024 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -18,10 +18,10 @@
import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException;
import org.eclipse.chemclipse.converter.io.AbstractChromatogramWriter;
import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDWriter;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.XmlReader110;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.io.ChromatogramWriterVersion110;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.io.ChromatogramWriterVersion110;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD;
import org.eclipse.chemclipse.xxd.converter.supplier.mzml.io.XmlReader110;
import org.eclipse.core.runtime.IProgressMonitor;

public class ChromatogramWriter extends AbstractChromatogramWriter implements IChromatogramMSDWriter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2013, 2023 Lablicate GmbH.
*
* Copyright (c) 2013, 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 which accompanies this distribution,
Expand All @@ -15,12 +15,12 @@
import java.io.FileReader;
import java.io.IOException;

import org.eclipse.chemclipse.converter.exceptions.UnknownVersionException;
import org.eclipse.chemclipse.msd.converter.io.AbstractMassSpectraReader;
import org.eclipse.chemclipse.msd.converter.io.IMassSpectraReader;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.converter.XmlReader110;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.internal.io.MassSpectrumReaderVersion110;
import org.eclipse.chemclipse.msd.converter.supplier.mzml.io.MassSpectrumReaderVersion110;
import org.eclipse.chemclipse.msd.model.core.IMassSpectra;
import org.eclipse.chemclipse.xxd.converter.supplier.io.exception.UnknownVersionException;
import org.eclipse.chemclipse.xxd.converter.supplier.mzml.io.XmlReader110;
import org.eclipse.core.runtime.IProgressMonitor;

public class MassSpectrumReader extends AbstractMassSpectraReader implements IMassSpectraReader {
Expand Down
Loading

0 comments on commit 12cde19

Please sign in to comment.