-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial write support for mzXML chromatograms.
- Loading branch information
1 parent
94fa019
commit d010a15
Showing
16 changed files
with
370 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
chemclipse/plugins/org.eclipse.chemclipse.msd.converter.supplier.mzxml.ui/plugin.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension | ||
point="org.eclipse.ui.preferencePages"> | ||
<page | ||
category="org.eclipse.chemclipse.msd.converter.ui.converterPreferencePage" | ||
class="org.eclipse.chemclipse.msd.converter.supplier.mzxml.ui.preferences.PreferencePage" | ||
id="org.eclipse.chemclipse.msd.converter.supplier.mzxml.ui.preferences.converterPreferencePage" | ||
name="mzXML Converter"> | ||
</page> | ||
</extension> | ||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...rc/org/eclipse/chemclipse/msd/converter/supplier/mzxml/ui/preferences/PreferencePage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* 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.msd.converter.supplier.mzxml.ui.preferences; | ||
|
||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.preferences.PreferenceSupplier; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.ui.Activator; | ||
import org.eclipse.chemclipse.support.ui.preferences.fieldeditors.SpacerFieldEditor; | ||
import org.eclipse.jface.preference.ComboFieldEditor; | ||
import org.eclipse.jface.preference.FieldEditorPreferencePage; | ||
import org.eclipse.ui.IWorkbench; | ||
import org.eclipse.ui.IWorkbenchPreferencePage; | ||
|
||
public class PreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { | ||
|
||
public PreferencePage() { | ||
|
||
super(GRID); | ||
setPreferenceStore(Activator.getDefault().getPreferenceStore()); | ||
setDescription("mzXML Converter"); | ||
} | ||
|
||
public void createFieldEditors() { | ||
|
||
addField(new SpacerFieldEditor(getFieldEditorParent())); | ||
addField(new ComboFieldEditor(PreferenceSupplier.P_CHROMATOGRAM_VERSION_SAVE, "Save (*.mzxml) as version:", PreferenceSupplier.getChromatogramVersions(), getFieldEditorParent())); | ||
} | ||
|
||
public void init(IWorkbench workbench) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...org/eclipse/chemclipse/msd/converter/supplier/mzxml/internal/io/ChromatogramWriter32.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/******************************************************************************* | ||
* 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.msd.converter.supplier.mzxml.internal.io; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.math.BigInteger; | ||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
import java.nio.DoubleBuffer; | ||
import java.util.List; | ||
|
||
import javax.xml.bind.JAXBContext; | ||
import javax.xml.bind.JAXBException; | ||
import javax.xml.bind.Marshaller; | ||
import javax.xml.datatype.DatatypeConfigurationException; | ||
import javax.xml.datatype.DatatypeFactory; | ||
|
||
import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException; | ||
import org.eclipse.chemclipse.converter.io.AbstractChromatogramWriter; | ||
import org.eclipse.chemclipse.logging.core.Logger; | ||
import org.eclipse.chemclipse.model.core.IScan; | ||
import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDWriter; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model.MsRun; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model.MzXML; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model.Peaks; | ||
import org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model.Scan; | ||
import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD; | ||
import org.eclipse.chemclipse.msd.model.core.IIon; | ||
import org.eclipse.chemclipse.msd.model.core.IScanMSD; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
|
||
public class ChromatogramWriter32 extends AbstractChromatogramWriter implements IChromatogramMSDWriter { | ||
|
||
private static final Logger logger = Logger.getLogger(ChromatogramWriter32.class); | ||
|
||
@Override | ||
public void writeChromatogram(File file, IChromatogramMSD chromatogram, IProgressMonitor monitor) throws FileNotFoundException, FileIsNotWriteableException, IOException { | ||
|
||
try { | ||
JAXBContext jaxbContext = JAXBContext.newInstance(org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model.MzXML.class); | ||
Marshaller marshaller = jaxbContext.createMarshaller(); | ||
MsRun msRun = new MsRun(); | ||
for(IScan sourceScan : chromatogram.getScans()) { | ||
Scan exportScan = new Scan(); | ||
exportScan.setTotIonCurrent(sourceScan.getTotalSignal()); | ||
exportScan.setRetentionTime(DatatypeFactory.newInstance().newDuration(sourceScan.getRetentionTime())); | ||
IScanMSD scanMSD = (IScanMSD)sourceScan; | ||
List<IIon> ions = scanMSD.getIons(); | ||
double[] values = new double[ions.size() * 2]; | ||
int i = 0; | ||
for(IIon ion : ions) { | ||
values[i] = ion.getIon(); | ||
values[i + 1] = ion.getAbundance(); | ||
i += 2; | ||
} | ||
exportScan.setMsLevel(BigInteger.valueOf(1)); // TODO | ||
Peaks peaks = new Peaks(); | ||
DoubleBuffer doubleBuffer = DoubleBuffer.wrap(values); | ||
ByteBuffer byteBuffer = ByteBuffer.allocate(doubleBuffer.capacity() * Double.BYTES); | ||
peaks.setPrecision(BigInteger.valueOf(64)); | ||
peaks.setByteOrder("network"); | ||
byteBuffer.order(ByteOrder.BIG_ENDIAN); // TODO: preferences | ||
// TODO: compression | ||
byteBuffer.asDoubleBuffer().put(doubleBuffer); | ||
peaks.setValue(byteBuffer.array()); | ||
exportScan.getPeaks().add(peaks); | ||
msRun.getScan().add(exportScan); | ||
} | ||
MzXML mzXML = new MzXML(); | ||
mzXML.setMsRun(msRun); | ||
marshaller.marshal(mzXML, file); | ||
} catch(JAXBException e) { | ||
logger.warn(e); | ||
} catch(DatatypeConfigurationException e) { | ||
logger.warn(e); | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...er.mzxml/src/org/eclipse/chemclipse/msd/converter/supplier/mzxml/internal/io/IFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************* | ||
* 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 | ||
*******************************************************************************/ | ||
package org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.io; | ||
|
||
public interface IFormat { | ||
|
||
String CONTEXT_PATH_V_200 = "org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v20.model"; | ||
String CONTEXT_PATH_V_210 = "org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v21.model"; | ||
String CONTEXT_PATH_V_220 = "org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v22.model"; | ||
String CONTEXT_PATH_V_300 = "org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v30.model"; | ||
String CONTEXT_PATH_V_310 = "org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v31.model"; | ||
String CONTEXT_PATH_V_320 = "org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model"; | ||
String MZXML_V_200 = "mzXML_2.0"; | ||
String MZXML_V_210 = "mzXML_2.1"; | ||
String MZXML_V_220 = "mzXML_2.2"; | ||
String MZXML_V_300 = "mzXML_3.0"; | ||
String MZXML_V_310 = "mzXML_3.1"; | ||
String MZXML_V_320 = "mzXML_3.2"; | ||
String CHROMATOGRAM_VERSION_LATEST = MZXML_V_320; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...xml/src/org/eclipse/chemclipse/msd/converter/supplier/mzxml/internal/v32/model/MzXML.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* 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ände - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.chemclipse.msd.converter.supplier.mzxml.internal.v32.model; | ||
|
||
import java.io.Serializable; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlElement; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import javax.xml.bind.annotation.XmlType; | ||
|
||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@XmlType(name = "", propOrder = {"msRun"}) | ||
@XmlRootElement(name = "mzXML", namespace = "http://sashimi.sourceforge.net/schema_revision/mzXML_3.2") | ||
public class MzXML implements Serializable { | ||
|
||
private final static long serialVersionUID = 320L; | ||
@XmlElement(required = true) | ||
private MsRun msRun; | ||
|
||
public MsRun getMsRun() { | ||
|
||
return msRun; | ||
} | ||
|
||
public void setMsRun(MsRun value) { | ||
|
||
this.msRun = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.