diff --git a/chemclipse/features/org.eclipse.chemclipse.rcp.app.compilation.core.feature/feature.xml b/chemclipse/features/org.eclipse.chemclipse.rcp.app.compilation.core.feature/feature.xml index 1d00d03072..72c699c39b 100644 --- a/chemclipse/features/org.eclipse.chemclipse.rcp.app.compilation.core.feature/feature.xml +++ b/chemclipse/features/org.eclipse.chemclipse.rcp.app.compilation.core.feature/feature.xml @@ -320,4 +320,8 @@ id="org.eclipse.chemclipse.chromatogram.xxd.identifier.supplier.timeranges.feature" version="0.0.0"/> + + diff --git a/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/.project b/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/.project new file mode 100644 index 0000000000..154feeb243 --- /dev/null +++ b/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/.project @@ -0,0 +1,17 @@ + + + org.eclipse.chemclipse.wsd.converter.supplier.scf.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/.settings/org.eclipse.core.resources.prefs b/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..801fab74d0 --- /dev/null +++ b/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=utf8 diff --git a/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/build.properties b/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/feature.xml b/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/feature.xml new file mode 100644 index 0000000000..6940a114b7 --- /dev/null +++ b/chemclipse/features/org.eclipse.chemclipse.wsd.converter.supplier.scf.feature/feature.xml @@ -0,0 +1,30 @@ + + + + + SCF DNA sequencing data converter + + + + Copyright (c) 2024 Lablicate GmbH. + + + + %license + + + + + diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.classpath b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.classpath new file mode 100644 index 0000000000..81fe078c20 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.gitignore b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.project b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.project new file mode 100644 index 0000000000..52c5d763f9 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.project @@ -0,0 +1,28 @@ + + + org.eclipse.chemclipse.wsd.converter.supplier.scf + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.settings/org.eclipse.core.resources.prefs b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..801fab74d0 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=utf8 diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.settings/org.eclipse.jdt.core.prefs b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..9154beff79 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=17 diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/META-INF/MANIFEST.MF b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..d657fce57e --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: net.openchrom.wsd.converter.supplier.abif +Bundle-ManifestVersion: 2 +Bundle-Name: SCF Converter +Bundle-SymbolicName: org.eclipse.chemclipse.wsd.converter.supplier.scf;singleton:=true +Bundle-Version: 0.9.0.qualifier +Bundle-Activator: org.eclipse.chemclipse.wsd.converter.supplier.scf.Activator +Bundle-Vendor: ChemClipse +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.chemclipse.converter;bundle-version="0.8.0", + org.eclipse.chemclipse.wsd.converter;bundle-version="0.8.0", + org.eclipse.chemclipse.model;bundle-version="0.8.0", + org.eclipse.chemclipse.wsd.model;bundle-version="0.8.0", + org.eclipse.chemclipse.logging;bundle-version="0.8.0", + org.eclipse.chemclipse.processing;bundle-version="0.8.0", + org.eclipse.chemclipse.support;bundle-version="0.8.0", + org.apache.commons.lang3 +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Bundle-ActivationPolicy: lazy diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/OSGI-INF/l10n/bundle_en.properties b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/OSGI-INF/l10n/bundle_en.properties new file mode 100644 index 0000000000..597fd0bfba --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/OSGI-INF/l10n/bundle_en.properties @@ -0,0 +1 @@ +#Properties file diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/build.properties b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/build.properties new file mode 100644 index 0000000000..948f0bdf02 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/,\ + plugin.xml diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/plugin.xml b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/plugin.xml new file mode 100644 index 0000000000..7c6daf7d51 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/plugin.xml @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/Activator.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/Activator.java new file mode 100644 index 0000000000..2bc6d4f1d7 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/Activator.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Philip Wenig - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf; + +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) + */ + @Override + public void start(BundleContext bundleContext) throws Exception { + + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext bundleContext) throws Exception { + + Activator.context = null; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/PathResolver.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/PathResolver.java new file mode 100644 index 0000000000..c0e09caa01 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/PathResolver.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Philip Wenig - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf; + +import java.io.IOException; +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.osgi.framework.Bundle; + +public class PathResolver { + + /** + * Returns a absolute path of the specified Folder. For example + * TESTDATA_IMPORT_EMPTY as an absolute Path: + * $PluginPath$/testData/test.scf + * + * @param string + * @return String absolutePath + */ + public static String getAbsolutePath(String string) { + + Bundle bundle = Platform.getBundle(Activator.getContext().getBundle().getSymbolicName()); + IPath path = new Path(string); + URL url = FileLocator.find(bundle, path, null); + try { + return FileLocator.resolve(url).getPath(); + } catch(IOException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/core/ChromatogramImportConverter.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/core/ChromatogramImportConverter.java new file mode 100644 index 0000000000..3231bb792c --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/core/ChromatogramImportConverter.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.core; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.chemclipse.converter.chromatogram.AbstractChromatogramImportConverter; +import org.eclipse.chemclipse.converter.l10n.ConverterMessages; +import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.model.core.IChromatogramOverview; +import org.eclipse.chemclipse.processing.core.IProcessingInfo; +import org.eclipse.chemclipse.wsd.converter.io.IChromatogramWSDReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.io.ChromatogramReader; +import org.eclipse.chemclipse.wsd.model.core.IChromatogramWSD; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osgi.util.NLS; + +public class ChromatogramImportConverter extends AbstractChromatogramImportConverter { + + private static final Logger logger = Logger.getLogger(ChromatogramImportConverter.class); + private static final String DESCRIPTION = "SCF Import Converter"; + + @Override + public IProcessingInfo convert(File file, IProgressMonitor monitor) { + + IProcessingInfo processingInfo = super.validate(file); + if(!processingInfo.hasErrorMessages()) { + IChromatogramWSDReader reader = new ChromatogramReader(); + monitor.subTask(ConverterMessages.importChromatogram); + try { + IChromatogramWSD chromatogram = reader.read(file, monitor); + processingInfo.setProcessingResult(chromatogram); + } catch(IOException e) { + logger.warn(e); + processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.failedToReadFile, file.getAbsolutePath())); + } + } + return processingInfo; + } + + @Override + public IProcessingInfo convertOverview(File file, IProgressMonitor monitor) { + + IProcessingInfo processingInfo = super.validate(file); + if(!processingInfo.hasErrorMessages()) { + IChromatogramWSDReader reader = new ChromatogramReader(); + monitor.subTask(ConverterMessages.importChromatogramOverview); + try { + IChromatogramOverview chromatogramOverview = reader.readOverview(file, monitor); + processingInfo.setProcessingResult(chromatogramOverview); + } catch(IOException e) { + logger.warn(e); + processingInfo.addErrorMessage(DESCRIPTION, NLS.bind(ConverterMessages.failedToReadFile, file.getAbsolutePath())); + } + } + return processingInfo; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/core/MagicNumberMatcher.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/core/MagicNumberMatcher.java new file mode 100644 index 0000000000..22de855bd7 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/core/MagicNumberMatcher.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.core; + +import java.io.File; + +import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher; +import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher; + +public class MagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher { + + private static final byte[] MAGIC_CODE = new byte[]{(byte)'.', (byte)'s', (byte)'c', (byte)'f'}; + + @Override + public boolean checkFileFormat(File file) { + + if(!checkFileExtension(file, ".scf")) { + return false; + } + return checkMagicCode(file, MAGIC_CODE); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/HeaderArrayReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/HeaderArrayReader.java new file mode 100644 index 0000000000..9dbdc0056b --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/HeaderArrayReader.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.chemclipse.converter.io.support.AbstractArrayReader; + +public class HeaderArrayReader extends AbstractArrayReader implements IHeaderArrayReader { + + public HeaderArrayReader(File file) throws IOException { + + super(file); + } + + @Override + public String readMagicNumber() { + + return readBytesAsString(4); + } + + @Override + public int readSampleNumber() { + + return read4BIntegerBE(); + } + + @Override + public int readSampleOffset() { + + return read4BIntegerBE(); + } + + @Override + public int readBaseNumber() { + + return read4BIntegerBE(); + } + + @Override + public int readBasesLeftClip() { + + return read4BIntegerBE(); + } + + @Override + public int readBasesRightClip() { + + return read4BIntegerBE(); + } + + @Override + public int readBasesOffset() { + + return read4BIntegerBE(); + } + + @Override + public int readCommentsSize() { + + return read4BIntegerBE(); + } + + @Override + public int readCommentsOffset() { + + return read4BIntegerBE(); + } + + @Override + public String readVersion() { + + return readBytesAsString(4); + } + + @Override + public int readSampleSize() { + + return read4BIntegerBE(); + } + + @Override + public int readCodeSet() { + + return read4BIntegerBE(); + } + + @Override + public int readPrivateSize() { + + return read4BIntegerBE(); + } + + @Override + public int readPrivateOffset() { + + return read4BIntegerBE(); + } + + @Override + public void skipSpare() { + + skipBytes(18); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/IHeaderArrayReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/IHeaderArrayReader.java new file mode 100644 index 0000000000..626be8131a --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/IHeaderArrayReader.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support; + +import org.eclipse.chemclipse.converter.io.support.IArrayReader; + +public interface IHeaderArrayReader extends IArrayReader { + + String readMagicNumber(); + + /** @return Number of elements in Samples matrix */ + int readSampleNumber(); + + /** @return Byte offset from start of file */ + int readSampleOffset(); + + /** @return Number of bases in Bases matrix */ + int readBaseNumber(); + + /** @return No. bases in left clip (vector) */ + @Deprecated + int readBasesLeftClip(); + + /** @return No. bases in right clip (qual) */ + @Deprecated + int readBasesRightClip(); + + /** @return Byte offset from start of file */ + int readBasesOffset(); + + /** @return Number of bytes in Comment section */ + int readCommentsSize(); + + /** @return Byte offset from start of file */ + int readCommentsOffset(); + + /** @return "version.revision", e.g. '3' '.' '0' '0' */ + String readVersion(); + + /** @return Size of samples in bytes */ + int readSampleSize(); + + /** @return code set used (but ignored) */ + int readCodeSet(); + + /** @return No. of bytes of Private data, 0 if none */ + int readPrivateSize(); + + /** @return Byte offset from start of file */ + int readPrivateOffset(); + + /** Unused */ + void skipSpare(); +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISamplePointsByteArrayReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISamplePointsByteArrayReader.java new file mode 100644 index 0000000000..74f689b071 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISamplePointsByteArrayReader.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support; + +import org.eclipse.chemclipse.converter.io.support.IArrayReader; + +public interface ISamplePointsByteArrayReader extends IArrayReader { + + byte[] readAdenine(int numberBases); + + byte[] readThymine(int numberBases); + + byte[] readGuanine(int numberBases); + + byte[] readCytosine(int numberBases); +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISamplePointsShortArrayReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISamplePointsShortArrayReader.java new file mode 100644 index 0000000000..fa8daebcc0 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISamplePointsShortArrayReader.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support; + +import org.eclipse.chemclipse.converter.io.support.IArrayReader; + +public interface ISamplePointsShortArrayReader extends IArrayReader { + + short[] readAdenine(int numberBases); + + short[] readThymine(int numberBases); + + short[] readGuanine(int numberBases); + + short[] readCytosine(int numberBases); +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISequenceInformationArrayReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISequenceInformationArrayReader.java new file mode 100644 index 0000000000..2680a6b9d5 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/ISequenceInformationArrayReader.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support; + +import org.eclipse.chemclipse.converter.io.support.IArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.model.Probability; + +public interface ISequenceInformationArrayReader extends IArrayReader { + + int[] readPeakIndices(int numberBases); + + Probability readProbabilities(int numberBases); + + char[] readBaseCalls(int numberBases); + + byte[] readSpares(int numberBases); +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SamplePointsByteArrayReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SamplePointsByteArrayReader.java new file mode 100644 index 0000000000..46571a7d57 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SamplePointsByteArrayReader.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.chemclipse.converter.io.support.AbstractArrayReader; + +public class SamplePointsByteArrayReader extends AbstractArrayReader implements ISamplePointsByteArrayReader { + + public SamplePointsByteArrayReader(File file) throws IOException { + + super(file); + } + + @Override + public byte[] readAdenine(int numberBases) { + + return readBytes(numberBases); + } + + @Override + public byte[] readThymine(int numberBases) { + + return readBytes(numberBases); + } + + @Override + public byte[] readGuanine(int numberBases) { + + return readBytes(numberBases); + } + + @Override + public byte[] readCytosine(int numberBases) { + + return readBytes(numberBases); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SamplePointsShortArrayReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SamplePointsShortArrayReader.java new file mode 100644 index 0000000000..89f7a87a5f --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SamplePointsShortArrayReader.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.chemclipse.converter.io.support.AbstractArrayReader; + +public class SamplePointsShortArrayReader extends AbstractArrayReader implements ISamplePointsShortArrayReader { + + public SamplePointsShortArrayReader(File file) throws IOException { + + super(file); + } + + @Override + public short[] readAdenine(int numberBases) { + + return readShorts(numberBases); + } + + @Override + public short[] readThymine(int numberBases) { + + return readShorts(numberBases); + } + + @Override + public short[] readGuanine(int numberBases) { + + return readShorts(numberBases); + } + + @Override + public short[] readCytosine(int numberBases) { + + return readShorts(numberBases); + } + + private short[] readShorts(int dataPoints) { + + short[] shortArray = new short[dataPoints]; + for(int i = 0; i < dataPoints; i++) { + shortArray[i] = read2BShortBE(); + } + return shortArray; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SequenceInformationArrayReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SequenceInformationArrayReader.java new file mode 100644 index 0000000000..4c1c977ab4 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/internal/support/SequenceInformationArrayReader.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.chemclipse.converter.io.support.AbstractArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.model.Probability; + +public class SequenceInformationArrayReader extends AbstractArrayReader implements ISequenceInformationArrayReader { + + public SequenceInformationArrayReader(File file) throws IOException { + + super(file); + } + + @Override + public int[] readPeakIndices(int numberBases) { + + return readIntegers(numberBases); + } + + @Override + public Probability readProbabilities(int numberBases) { + + return new Probability(readBytes(numberBases), readBytes(numberBases), readBytes(numberBases), readBytes(numberBases)); + } + + @Override + public char[] readBaseCalls(int numberBases) { + + return readCharacters(numberBases); + } + + @Override + public byte[] readSpares(int numberBases) { + + return readBytes(numberBases); + } + + private int[] readIntegers(int dataPoints) { + + int[] intArray = new int[dataPoints]; + for(int i = 0; i < dataPoints; i++) { + intArray[i] = read4BIntegerBE(); + } + return intArray; + } + + private char[] readCharacters(int dataPoints) { + + char[] charArray = new char[dataPoints]; + for(int i = 0; i < dataPoints; i++) { + charArray[i] = (char)readByte(); + } + return charArray; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ChromatogramReader.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ChromatogramReader.java new file mode 100644 index 0000000000..ec30712021 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ChromatogramReader.java @@ -0,0 +1,249 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.io; + +import java.io.File; +import java.io.IOException; +import java.text.ParseException; +import java.util.Date; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.NotImplementedException; +import org.apache.commons.lang3.time.DateUtils; +import org.eclipse.chemclipse.converter.exceptions.FileIsNotReadableException; +import org.eclipse.chemclipse.converter.io.support.DataArrayReader; +import org.eclipse.chemclipse.converter.io.support.IDataArrayReader; +import org.eclipse.chemclipse.logging.core.Logger; +import org.eclipse.chemclipse.model.core.IChromatogramOverview; +import org.eclipse.chemclipse.wsd.converter.io.AbstractChromatogramWSDReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support.HeaderArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support.IHeaderArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support.ISamplePointsByteArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support.ISamplePointsShortArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support.ISequenceInformationArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support.SamplePointsByteArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support.SamplePointsShortArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.internal.support.SequenceInformationArrayReader; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.model.IVendorChromatogram; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.model.IVendorScan; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.model.VendorChromatogram; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.model.VendorScan; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.model.VendorScanSignalDAD; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.model.Version; +import org.eclipse.chemclipse.wsd.model.core.IChromatogramWSD; +import org.eclipse.core.runtime.IProgressMonitor; + +/* + * Simon Dear, Rodger Staden (1992). + * A standard file format for data from DNA sequencing instruments. + * DNA Sequence, 3(2), 107–110. + * https://doi.org/10.3109/10425179209034003 + */ +public class ChromatogramReader extends AbstractChromatogramWSDReader { + + private static final Logger logger = Logger.getLogger(ChromatogramReader.class); + // + private int numberSamples; + private int offsetSamples; + private int sampleSize; + private int numberBases; + private int offsetBases; + private int offsetComments; + private int sizeComments; + private int offsetPrivate; + private int sizePrivate; + + @Override + public IChromatogramWSD read(File file, IProgressMonitor monitor) throws IOException { + + return readChromatogram(file); + } + + @Override + public IChromatogramOverview readOverview(File file, IProgressMonitor monitor) throws IOException { + + return readChromatogram(file); + } + + private IChromatogramWSD readChromatogram(File file) throws IOException { + + IVendorChromatogram chromatogram = new VendorChromatogram(); + chromatogram.setConverterId("SCF"); // to be exportable + chromatogram.setFile(file); + readHeader(file, chromatogram); + if(chromatogram.getVersion().getMajor() != 3) { + throw new NotImplementedException("Only version 3 is supported."); + } + if(numberSamples > 0) { + readSamples(file, chromatogram); + } + if(numberBases > 0) { + readSequenceInformation(file, chromatogram); + } + if(sizeComments > 0) { + readComments(file, chromatogram); + } + if(sizePrivate > 0) { + readPrivateData(file); + } + return chromatogram; + } + + @SuppressWarnings("deprecation") + private void readHeader(File file, IVendorChromatogram chromatogram) throws IOException { + + IHeaderArrayReader headerArrayReader = new HeaderArrayReader(file); + headerArrayReader.resetPosition(); + String magicNumber = headerArrayReader.readMagicNumber(); + if(!magicNumber.equals(".scf")) { + throw new FileIsNotReadableException("Not an SCF trace file."); + } + numberSamples = headerArrayReader.readSampleNumber(); + offsetSamples = headerArrayReader.readSampleOffset(); + numberBases = headerArrayReader.readBaseNumber(); + headerArrayReader.readBasesLeftClip(); + headerArrayReader.readBasesRightClip(); + offsetBases = headerArrayReader.readBasesOffset(); + sizeComments = headerArrayReader.readCommentsSize(); + offsetComments = headerArrayReader.readCommentsOffset(); + chromatogram.setVersion(new Version(headerArrayReader.readVersion())); + sampleSize = headerArrayReader.readSampleSize(); + headerArrayReader.readCodeSet(); + sizePrivate = headerArrayReader.readPrivateSize(); + offsetPrivate = headerArrayReader.readPrivateOffset(); + headerArrayReader.skipSpare(); + } + + private void readSamples(File file, IVendorChromatogram chromatogram) throws IOException { + + if(sampleSize == 1) { + ISamplePointsByteArrayReader samplesByteArrayReader = new SamplePointsByteArrayReader(file); + samplesByteArrayReader.resetPosition(); + samplesByteArrayReader.seek(offsetSamples); + samplesByteArrayReader.readCytosine(numberSamples); + samplesByteArrayReader.readGuanine(numberSamples); + samplesByteArrayReader.readThymine(numberSamples); + throw new NotImplementedException("Sample points with precision 1 are not yet supported."); + } else if(sampleSize == 2) { + ISamplePointsShortArrayReader samplesShortArrayReader = new SamplePointsShortArrayReader(file); + samplesShortArrayReader.resetPosition(); + samplesShortArrayReader.seek(offsetSamples); + // + addShortSignals(samplesShortArrayReader.readAdenine(numberSamples), chromatogram); + chromatogram.setDataName("Adenine"); + // + IVendorChromatogram referencedChromatogram1 = new VendorChromatogram(); + addShortSignals(samplesShortArrayReader.readCytosine(numberSamples), referencedChromatogram1); + referencedChromatogram1.setDataName("Cytosine"); + chromatogram.addReferencedChromatogram(referencedChromatogram1); + // + IVendorChromatogram referencedChromatogram2 = new VendorChromatogram(); + addShortSignals(samplesShortArrayReader.readGuanine(numberSamples), referencedChromatogram2); + referencedChromatogram2.setDataName("Guanine"); + chromatogram.addReferencedChromatogram(referencedChromatogram2); + // + IVendorChromatogram referencedChromatogram3 = new VendorChromatogram(); + addShortSignals(samplesShortArrayReader.readThymine(numberSamples), referencedChromatogram3); + referencedChromatogram3.setDataName("Thymine"); + chromatogram.addReferencedChromatogram(referencedChromatogram3); + } + } + + private void readSequenceInformation(File file, IVendorChromatogram chromatogram) throws IOException { + + ISequenceInformationArrayReader sequenceInformationArrayReader = new SequenceInformationArrayReader(file); + sequenceInformationArrayReader.resetPosition(); + sequenceInformationArrayReader.seek(offsetBases); + sequenceInformationArrayReader.readPeakIndices(numberBases); + sequenceInformationArrayReader.readProbabilities(numberBases); + chromatogram.setMiscInfo(new String(sequenceInformationArrayReader.readBaseCalls(numberBases))); + sequenceInformationArrayReader.readSpares(numberBases); + } + + private void readComments(File file, IVendorChromatogram chromatogram) throws IOException { + + IDataArrayReader dataArrayReader = new DataArrayReader(file); + dataArrayReader.resetPosition(); + dataArrayReader.seek(offsetComments); + String comments = dataArrayReader.readString(sizeComments); + Matcher fieldMatcher = Pattern.compile("([A-Z0-9]{4})=(.+)").matcher(comments); + while(fieldMatcher.find()) { + if(fieldMatcher.groupCount() == 2) { + String fieldId = fieldMatcher.group(1); + String value = fieldMatcher.group(2); + if(fieldId.equals("DATE")) { + chromatogram.setDate(parseDate(value)); + } + if(fieldId.equals("NAME")) { + chromatogram.setSampleName(value); + } + if(fieldId.equals("OPER")) { + chromatogram.setOperator(value); + } + if(fieldId.equals("MACH")) { + chromatogram.setInstrument(value); + } + } + } + } + + // vendor specific fields + private void readPrivateData(File file) throws IOException { + + IDataArrayReader dataArrayReader = new DataArrayReader(file); + dataArrayReader.resetPosition(); + dataArrayReader.seek(offsetPrivate); + dataArrayReader.readString(sizePrivate); + } + + // sadly not standardized + private Date parseDate(String value) { + + String[] formats = {"MMM dd yyyy HH:mm:ss", "EEE dd MMM HH:mm:ss yyyy"}; + try { + String[] dateParts = value.split(" to "); + if(dateParts.length > 1) { + return DateUtils.parseDate(dateParts[1], Locale.ENGLISH, formats); + } else { + return DateUtils.parseDate(value, Locale.ENGLISH, formats); + } + } catch(ParseException e) { + logger.warn(e); + } + return null; + } + + private void addShortSignals(short[] samples, IVendorChromatogram chromatogram) { + + short sample = 0; + sample = 0; + for(int i = 0; i < numberSamples; i++) { + samples[i] = (short)(samples[i] + sample); + sample = samples[i]; + } + sample = 0; + for(int i = 0; i < numberSamples; i++) { + samples[i] = (short)(samples[i] + sample); + sample = samples[i]; + } + for(short base : samples) { + VendorScanSignalDAD scanSignal = new VendorScanSignalDAD(); + scanSignal.setAbsorbance(base); + IVendorScan scan = new VendorScan(); + scan.addScanSignal(scanSignal); + chromatogram.addScan(scan); + } + chromatogram.recalculateRetentionTimes(); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ChromatogramWriter.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ChromatogramWriter.java new file mode 100644 index 0000000000..c4a3438fd1 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ChromatogramWriter.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.io; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.lang3.NotImplementedException; +import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException; +import org.eclipse.chemclipse.wsd.converter.io.AbstractChromatogramWSDWriter; +import org.eclipse.chemclipse.wsd.model.core.IChromatogramWSD; +import org.eclipse.core.runtime.IProgressMonitor; + +public class ChromatogramWriter extends AbstractChromatogramWSDWriter { + + @Override + public void writeChromatogram(File file, IChromatogramWSD chromatogram, IProgressMonitor monitor) throws FileIsNotWriteableException, IOException { + + throw new NotImplementedException(); + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorChromatogram.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorChromatogram.java new file mode 100644 index 0000000000..f69b3fe29f --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorChromatogram.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.model; + +import org.eclipse.chemclipse.wsd.model.core.IChromatogramWSD; + +public interface IVendorChromatogram extends IChromatogramWSD { + + Version getVersion(); + + void setVersion(Version version); +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorScan.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorScan.java new file mode 100644 index 0000000000..9806c5ac03 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorScan.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.model; + +import org.eclipse.chemclipse.wsd.model.core.IScanWSD; + +public interface IVendorScan extends IScanWSD { +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorScanSignalDAD.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorScanSignalDAD.java new file mode 100644 index 0000000000..2be7f52013 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/IVendorScanSignalDAD.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.model; + +import org.eclipse.chemclipse.wsd.model.core.IScanSignalWSD; + +public interface IVendorScanSignalDAD extends IScanSignalWSD { +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/Probability.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/Probability.java new file mode 100644 index 0000000000..d20d2fb803 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/Probability.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.model; + +public class Probability { + + private byte[] adenine; + private byte[] thymine; + private byte[] guanine; + private byte[] cytosine; + + public Probability(byte[] adenine, byte[] cytosine, byte[] guanine, byte[] thymine) { + + this.adenine = adenine; + this.cytosine = cytosine; + this.guanine = guanine; + this.thymine = thymine; + } + + public byte[] getAdenine() { + + return adenine; + } + + public byte[] getCytosine() { + + return cytosine; + } + + public byte[] getGuanine() { + + return guanine; + } + + public byte[] getThymine() { + + return thymine; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorChromatogram.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorChromatogram.java new file mode 100644 index 0000000000..2b27463014 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorChromatogram.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.model; + +import org.eclipse.chemclipse.wsd.model.core.AbstractChromatogramWSD; + +public class VendorChromatogram extends AbstractChromatogramWSD implements IVendorChromatogram { + + private static final long serialVersionUID = 2457872678347226000L; + // + private Version version; + + @Override + public Version getVersion() { + + return version; + } + + @Override + public void setVersion(Version version) { + + this.version = version; + } +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorScan.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorScan.java new file mode 100644 index 0000000000..a3767f5a0d --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorScan.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.model; + +import org.eclipse.chemclipse.wsd.model.core.AbstractScanWSD; + +public class VendorScan extends AbstractScanWSD implements IVendorScan { + + /** + * Renew the serialVersionUID any time you have changed some fields or + * methods. + */ + private static final long serialVersionUID = 3575508460954261124L; +} diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorScanSignalDAD.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorScanSignalDAD.java new file mode 100644 index 0000000000..25a0f16c7f --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/VendorScanSignalDAD.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.model; + +import org.eclipse.chemclipse.wsd.model.core.AbstractScanSignalWSD; + +public class VendorScanSignalDAD extends AbstractScanSignalWSD implements IVendorScanSignalDAD { + + private static final long serialVersionUID = -2457872678347226000L; +} \ No newline at end of file diff --git a/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/Version.java b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/Version.java new file mode 100644 index 0000000000..2496f35c4f --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.wsd.converter.supplier.scf/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/model/Version.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.model; + +public class Version implements Comparable { + + private int major; + private int revision; + + public Version(String version) { + + if(version == null || version.isEmpty()) { + throw new IllegalArgumentException("Version string cannot be null or empty"); + } + String[] parts = version.split("\\."); + if(parts.length != 2) { + throw new IllegalArgumentException("Version must follow 'version.revision' format"); + } + this.major = Integer.parseInt(parts[0]); + this.revision = Integer.parseInt(parts[1]); + } + + public int getMajor() { + + return major; + } + + public int getRevision() { + + return revision; + } + + @Override + public int compareTo(Version other) { + + if(this.major != other.major) { + return Integer.compare(this.major, other.major); + } + return Integer.compare(this.revision, other.revision); + } + + @Override + public String toString() { + + return major + "." + revision; + } +} diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.classpath b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.classpath new file mode 100644 index 0000000000..81fe078c20 --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.gitignore b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.gitignore new file mode 100644 index 0000000000..ae3c172604 --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.project b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.project new file mode 100644 index 0000000000..9318545d32 --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.project @@ -0,0 +1,28 @@ + + + org.eclipse.chemclipse.wsd.converter.supplier.scf.test + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.settings/org.eclipse.core.resources.prefs b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..801fab74d0 --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=utf8 diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.settings/org.eclipse.jdt.core.prefs b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..9154beff79 --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=17 diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/META-INF/MANIFEST.MF b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..62b83162e5 --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Automatic-Module-Name: org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test +Bundle-ManifestVersion: 2 +Bundle-Name: SCF Converter Test +Bundle-SymbolicName: org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test +Bundle-Version: 0.9.0.qualifier +Bundle-Vendor: ChemClipse +Fragment-Host: org.eclipse.chemclipse.wsd.converter.supplier.scf;bundle-version="0.9.0" +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Require-Bundle: org.junit;bundle-version="4.12.0", + org.eclipse.chemclipse.rcp.app.test;bundle-version="0.8.0" diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/build.properties b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/ChromatogramReaderTestCase.java b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/ChromatogramReaderTestCase.java new file mode 100644 index 0000000000..57736f1b74 --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/ChromatogramReaderTestCase.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf; + +import java.io.File; + +import org.eclipse.chemclipse.processing.core.IProcessingInfo; +import org.eclipse.chemclipse.wsd.converter.chromatogram.ChromatogramConverterWSD; +import org.eclipse.chemclipse.wsd.model.core.IChromatogramWSD; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.junit.Ignore; + +import junit.framework.TestCase; + +@Ignore("Template to be inherited.") +public class ChromatogramReaderTestCase extends TestCase { + + protected IChromatogramWSD chromatogram; + protected String extensionPointId; + protected String pathImport; + protected File fileImport; + + @Override + protected void setUp() throws Exception { + + super.setUp(); + fileImport = new File(this.pathImport); + IProcessingInfo processingInfo = ChromatogramConverterWSD.getInstance().convert(fileImport, extensionPointId, new NullProgressMonitor()); + chromatogram = processingInfo.getProcessingResult(); + } + + @Override + protected void tearDown() throws Exception { + + pathImport = null; + fileImport = null; + chromatogram = null; + // + super.tearDown(); + } +} diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/SCF.java b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/SCF.java new file mode 100644 index 0000000000..83f4716822 --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/SCF.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf; + +public class SCF extends PathResolver { + + public static final String EXTENSION_POINT_ID = "org.eclipse.chemclipse.wsd.converter.supplier.scf"; + /* + * IMPORT + */ + public static final String TESTFILE_IMPORT_ABCZ_F = "testdata/abcZ_F.scf"; +} diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ABCZ_F_ITest.java b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ABCZ_F_ITest.java new file mode 100644 index 0000000000..f56eda995b --- /dev/null +++ b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/src/org/eclipse/chemclipse/wsd/converter/supplier/scf/io/ABCZ_F_ITest.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 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, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthias Mailänder - initial API and implementation + *******************************************************************************/ +package org.eclipse.chemclipse.wsd.converter.supplier.scf.io; + +import java.time.ZoneId; + +import org.eclipse.chemclipse.wsd.converter.supplier.scf.ChromatogramReaderTestCase; +import org.eclipse.chemclipse.wsd.converter.supplier.scf.SCF; +import org.junit.Test; + +public class ABCZ_F_ITest extends ChromatogramReaderTestCase { + + @Override + protected void setUp() throws Exception { + + extensionPointId = SCF.EXTENSION_POINT_ID; + pathImport = SCF.getAbsolutePath(SCF.TESTFILE_IMPORT_ABCZ_F); + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + + super.tearDown(); + } + + @Test + public void testChromatogram() { + + assertNotNull(chromatogram); + assertEquals(7831, chromatogram.getNumberOfScans()); + assertEquals(3, chromatogram.getReferencedChromatograms().size()); + assertEquals("NM-1999-13-abcZ", chromatogram.getSampleName()); + assertEquals(2004, chromatogram.getDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().getYear()); + assertEquals("Zoo3730-1519-025", chromatogram.getInstrument()); + assertEquals("A-G-GCACCGTATTTGATCCGTTGCCGAAGGTTTGGGTAAAATTCGCGATTTATTGCGCCGTTACCACCGCGTCGGTCATGAGTTGGAAAACGGTTCGGG" + // + "TGAGGCTTTGTTGAAAGAACTCAACGAATTACAACTTGAAATCGAAGCGAAGGACGGCTGGAAGCTGGATGCGGCAGTCAAGCAGACTTTGGGCGAACTCGGTTT" + // + "GCCGGAAAACGAAAAAATCGGCAACCTTTCCGGCGGTCAGAAAAAGCGTGTCGCCTTGGCGCAGGCTTGGGTGCAGAAGCCCGACGTATTGCTGCTGGACGAACC" + // + "GACCAACCATTTGGATATTGACGCGATTATCTGGTTGGAAAACCTGCTCAAGGCGTTTGAAGGCAGCTTGGTCGTGATTACCCACGACCGCCGTTTTTTGGATAA" + // + "TATCGCTACGCGGATTGTTGAACTTGACCGCGGCATTCTACGTTCCTATCCCGGCTCGTTCTCTAAATACAGTGAGAAAAAAGCGCAAGAGTTGGCAGTCAAAAC" + // + "C-G-AACAAA----------------------------------------------" + // + "T----------------------------------------------------------------------------T", chromatogram.getMiscInfo()); + } +} diff --git a/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/testdata/abcZ_F.scf b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/testdata/abcZ_F.scf new file mode 100644 index 0000000000..f4c8e24cb2 Binary files /dev/null and b/chemclipse/tests/org.eclipse.chemclipse.wsd.converter.supplier.scf.fragment.test/testdata/abcZ_F.scf differ