Skip to content

Commit

Permalink
Merge pull request #140 from Mailaender/animl-msd
Browse files Browse the repository at this point in the history
Added support for MSD .animl chromatograms
  • Loading branch information
eselmeister authored Sep 17, 2021
2 parents ccc6048 + b98468b commit d2e7b26
Show file tree
Hide file tree
Showing 36 changed files with 1,313 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ http://www.eclipse.org/legal/epl-v10.html
version="0.0.0"
unpack="false"/>

<plugin
id="net.openchrom.msd.converter.supplier.animl"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
description="Writes AnIML Chromatograms."
exportConverter="net.openchrom.csd.converter.supplier.animl.converter.ChromatogramExportConverter"
fileExtension=".animl"
filterName="AnIML Chromatogram (*.animl)"
filterName="AnIML FID Chromatogram (*.animl)"
id="net.openchrom.csd.converter.supplier.animl"
importConverter="net.openchrom.csd.converter.supplier.animl.converter.ChromatogramImportConverter"
importMagicNumberMatcher="net.openchrom.csd.converter.supplier.animl.converter.MagicNumberMatcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;

import net.openchrom.csd.converter.supplier.animl.internal.converter.IConstants;
import net.openchrom.csd.converter.supplier.animl.internal.converter.SpecificationValidator;
import net.openchrom.csd.converter.supplier.animl.io.ChromatogramWriter;
import net.openchrom.xxd.converter.supplier.animl.internal.converter.IConstants;
import net.openchrom.xxd.converter.supplier.animl.internal.converter.SpecificationValidator;

public class ChromatogramExportConverter extends AbstractChromatogramExportConverter implements IChromatogramExportConverter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;

import net.openchrom.csd.converter.supplier.animl.internal.converter.IConstants;
import net.openchrom.csd.converter.supplier.animl.io.ChromatogramReader;
import net.openchrom.xxd.converter.supplier.animl.internal.converter.IConstants;

public class ChromatogramImportConverter extends AbstractChromatogramImportConverter<IChromatogramCSD> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,50 @@

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher;
import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import net.openchrom.xxd.converter.supplier.animl.internal.converter.IConstants;
import net.openchrom.xxd.converter.supplier.animl.internal.converter.SpecificationValidator;

public class MagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher {

@Override
public boolean checkFileFormat(File file) {

return checkFileExtension(file, ".animl");
boolean isValidFormat = false;
try {
file = SpecificationValidator.validateSpecification(file);
if(!file.exists()) {
return isValidFormat;
}
if(!checkFileExtension(file, ".animl")) {
return isValidFormat;
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
NodeList root = document.getElementsByTagName(IConstants.NODE_ANIML);
if(root.getLength() != 1) {
return isValidFormat;
}
NodeList techniquesList = document.getElementsByTagName(IConstants.NODE_TECHNIQUE);
int techniques = techniquesList.getLength();
for(int t = 0; t < techniques; t++) {
Element element = (Element)techniquesList.item(t);
if(element.getAttribute("name").equals("Flame Ionization Detector")) {
isValidFormat = true;
}
}
} catch(Exception e) {
// fail silently
}
return isValidFormat;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public IChromatogramCSD read(File file, IProgressMonitor monitor) throws FileNot
}
}
for(EncodedValueSetType encodedValueSet : series.getEncodedValueSet()) {
float[] decodedValues = BinaryReader.decodeArray(encodedValueSet.getValue());
float[] decodedValues = BinaryReader.decodeFloatArray(encodedValueSet.getValue());
for(float f : decodedValues) {
retentionTimes.add(multiplicator * f);
}
Expand All @@ -94,7 +94,7 @@ public IChromatogramCSD read(File file, IProgressMonitor monitor) throws FileNot
}
}
for(EncodedValueSetType encodedValueSet : series.getEncodedValueSet()) {
float[] decodedValues = BinaryReader.decodeArray(encodedValueSet.getValue());
float[] decodedValues = BinaryReader.decodeFloatArray(encodedValueSet.getValue());
for(float f : decodedValues) {
signals.add(f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ public void writeChromatogram(File file, IChromatogramCSD chromatogram, IProgres
logger.warn(e);
} catch(DatatypeConfigurationException e) {
logger.warn(e);
} catch(Exception e) // TODO remove
{
e.printStackTrace();
}
}

Expand Down Expand Up @@ -148,7 +145,7 @@ private ResultType createResult(IChromatogramCSD chromatogram) {
IndividualValueSetType totalSignals = new IndividualValueSetType();
for(IScan scan : chromatogram.getScans()) {
retentionTimes.getF().add((float)scan.getRetentionTime());
totalSignals.getF().add((float)scan.getTotalSignal());
totalSignals.getF().add(scan.getTotalSignal());
}
retentionTimeSeries.getIndividualValueSet().add(retentionTimes);
totalSignalSeries.getIndividualValueSet().add(totalSignals);
Expand Down Expand Up @@ -186,7 +183,7 @@ private TechniqueType createChromatographyTechnique() {

TechniqueType technique = new TechniqueType();
technique.setName("Chromatography");
technique.setUri("https://raw.githubusercontent.com/AnIML/techniques/6e30b1e593e6df661a44ae2a9892b6198def0641/chromatography.atdd");
technique.setUri("https://github.com/AnIML/techniques/blob/6e30b1e593e6df661a44ae2a9892b6198def0641/chromatography.atdd");
return technique;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.GAML;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Parameter;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Peaktable;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Peaktable.Peak;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Peaktable.Peak.Baseline;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Technique;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Trace;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Units;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Xdata;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Ydata;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Peaktable.Peak;
import net.openchrom.xxd.converter.supplier.gaml.internal.v100.model.Peaktable.Peak.Baseline;
import net.openchrom.xxd.converter.supplier.gaml.io.Reader100;

public class ChromatogramReaderVersion100 extends AbstractChromatogramReader implements IChromatogramCSDReader {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>net.openchrom.msd.converter.supplier.animl</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Wed Apr 21 08:55:45 CEST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Manifest-Version: 1.0
Automatic-Module-Name: net.openchrom.msd.converter.supplier.gaml
Eclipse-RegisterBuddy: org.eclipse.chemclipse.model, org.eclipse.chemclipse.msd.model
Bundle-ManifestVersion: 2
Bundle-Name: AnIML
Bundle-SymbolicName: net.openchrom.msd.converter.supplier.animl;singleton:=true
Bundle-Version: 1.4.0.qualifier
Bundle-Activator: net.openchrom.msd.converter.supplier.animl.Activator
Bundle-Vendor: OpenChrom
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.chemclipse.logging;bundle-version="0.8.0",
org.eclipse.chemclipse.msd.model;bundle-version="0.8.0",
org.eclipse.chemclipse.msd.converter;bundle-version="0.8.0",
org.eclipse.chemclipse.processing;bundle-version="0.8.0",
org.eclipse.chemclipse.converter;bundle-version="0.8.0",
org.eclipse.chemclipse.model;bundle-version="0.8.0",
org.eclipse.chemclipse.support;bundle-version="0.8.0",
org.eclipse.chemclipse.xxd.converter.supplier.chemclipse;bundle-version="0.8.0",
net.openchrom.xxd.converter.supplier.gaml,
net.openchrom.xxd.converter.supplier.animl
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
###############################################################################
# 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
###############################################################################
#Properties file
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
OSGI-INF/
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.chemclipse.msd.converter.chromatogramSupplier">
<ChromatogramSupplier
description="Reads Analytical Information Markup Language Chromatograms"
fileExtension=".animl"
filterName="AnIML MSD Chromatogram (*.animl)"
id="net.openchrom.msd.converter.supplier.animl.chromatogram"
importConverter="net.openchrom.msd.converter.supplier.animl.converter.ChromatogramImportConverter"
importMagicNumberMatcher="net.openchrom.msd.converter.supplier.animl.converter.MagicNumberMatcher"
exportConverter="net.openchrom.msd.converter.supplier.animl.converter.ChromatogramExportConverter"
isExportable="true"
isImportable="true">
</ChromatogramSupplier>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2008, 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:
* Dr. Philip Wenig - initial API and implementation
*******************************************************************************/
package net.openchrom.msd.converter.supplier.animl;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

private static BundleContext context;

public static BundleContext getContext() {

return context;
}

/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {

Activator.context = bundleContext;
}

/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {

Activator.context = null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2014, 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:
* Dr. Philip Wenig - initial API and implementation
*******************************************************************************/
package net.openchrom.msd.converter.supplier.animl.converter;

import java.io.File;

import org.eclipse.chemclipse.converter.chromatogram.AbstractChromatogramExportConverter;
import org.eclipse.chemclipse.converter.chromatogram.IChromatogramExportConverter;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.model.core.IChromatogram;
import org.eclipse.chemclipse.model.core.IPeak;
import org.eclipse.chemclipse.msd.converter.io.IChromatogramMSDWriter;
import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;

import net.openchrom.msd.converter.supplier.animl.io.ChromatogramWriter;
import net.openchrom.xxd.converter.supplier.animl.internal.converter.IConstants;
import net.openchrom.xxd.converter.supplier.animl.internal.converter.SpecificationValidator;

public class ChromatogramExportConverter extends AbstractChromatogramExportConverter implements IChromatogramExportConverter {

private static final Logger logger = Logger.getLogger(ChromatogramExportConverter.class);
private static final String DESCRIPTION = "AnIML Export Converter";

@Override
public IProcessingInfo<File> convert(File file, IChromatogram<? extends IPeak> chromatogram, IProgressMonitor monitor) {

file = SpecificationValidator.validateSpecification(file);
IProcessingInfo<File> processingInfo = super.validate(file);
/*
* Don't process if errors have occurred.
*/
if(!processingInfo.hasErrorMessages() && chromatogram instanceof IChromatogramMSD) {
IChromatogramMSD chromatogramMSD = (IChromatogramMSD)chromatogram;
monitor.subTask(IConstants.EXPORT_CHROMATOGRAM);
IChromatogramMSDWriter writer = new ChromatogramWriter();
try {
writer.writeChromatogram(file, chromatogramMSD, monitor);
} catch(Exception e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, "Something has definitely gone wrong with the file: " + file.getAbsolutePath());
}
processingInfo.setProcessingResult(file);
}
return processingInfo;
}
}
Loading

0 comments on commit d2e7b26

Please sign in to comment.