Skip to content

Commit

Permalink
Read support for SCF trace files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Dec 4, 2024
1 parent ca2f595 commit e4d1908
Show file tree
Hide file tree
Showing 47 changed files with 1,457 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,8 @@
id="org.eclipse.chemclipse.chromatogram.xxd.identifier.supplier.timeranges.feature"
version="0.0.0"/>

<includes
id="org.eclipse.chemclipse.wsd.converter.supplier.scf.feature"
version="0.0.0"/>

</feature>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.chemclipse.wsd.converter.supplier.scf.feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=utf8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin.includes = feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="org.eclipse.chemclipse.wsd.converter.supplier.scf.feature"
label="SCF Converter"
version="0.9.0.qualifier"
provider-name="ChemClipse"
plugin="org.eclipse.chemclipse.feature.branding"
license-feature="org.eclipse.license"
license-feature-version="1.0.0.qualifier">

<description url="http://www.chemclipse.net">
SCF DNA sequencing data converter
</description>

<copyright url="http://www.lablicate.com">
Copyright (c) 2024 Lablicate GmbH.
</copyright>

<license url="%licenseURL">
%license
</license>

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

</feature>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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-17"/>
<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>org.eclipse.chemclipse.wsd.converter.supplier.scf</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,2 @@
eclipse.preferences.version=1
encoding/<project>=utf8
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Properties file
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.chemclipse.wsd.converter.chromatogramSupplier">
<ChromatogramSupplier
description="Reads Staden Trace Files."
fileExtension=".scf"
filterName="Standard Chromatogram Format (*.scf)"
id="org.eclipse.chemclipse.wsd.converter.supplier.scf"
importConverter="org.eclipse.chemclipse.wsd.converter.supplier.scf.core.ChromatogramImportConverter"
importMagicNumberMatcher="org.eclipse.chemclipse.wsd.converter.supplier.scf.core.MagicNumberMatcher"
isExportable="false"
isImportable="true">
</ChromatogramSupplier>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<IChromatogramWSD> {

private static final Logger logger = Logger.getLogger(ChromatogramImportConverter.class);
private static final String DESCRIPTION = "SCF Import Converter";

@Override
public IProcessingInfo<IChromatogramWSD> convert(File file, IProgressMonitor monitor) {

IProcessingInfo<IChromatogramWSD> 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<IChromatogramOverview> convertOverview(File file, IProgressMonitor monitor) {

IProcessingInfo<IChromatogramOverview> 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;
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading

0 comments on commit e4d1908

Please sign in to comment.