Skip to content

Commit

Permalink
Add services needed for automated multiple chromatogram segmentation
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenz Gerber <[email protected]>
  • Loading branch information
lorenzgerber authored and eselmeister committed Dec 12, 2024
1 parent 6c080f4 commit 1356ca9
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Lablicate GmbH.
* Copyright (c) 2023, 2024 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -17,9 +17,13 @@
import org.osgi.util.tracker.ServiceTracker;

import net.openchrom.xxd.base.ui.services.IAlignmentService;
import net.openchrom.xxd.base.ui.services.IAnalysisSegmentService;
import net.openchrom.xxd.base.ui.services.IAverageChromatogramService;
import net.openchrom.xxd.base.ui.services.IDeconvolutionBatchService;
import net.openchrom.xxd.base.ui.services.IDeconvolutionService;
import net.openchrom.xxd.base.ui.services.IIdentificationService;
import net.openchrom.xxd.base.ui.services.ILocalMaximaScanService;
import net.openchrom.xxd.base.ui.services.ILocalMinimaScanService;

public class Activator extends AbstractActivatorUI {

Expand All @@ -30,6 +34,10 @@ public class Activator extends AbstractActivatorUI {
private ServiceTracker<IDeconvolutionBatchService, IDeconvolutionBatchService> deconvolutionBatchServiceTracker = null;
private ServiceTracker<IIdentificationService, IIdentificationService> identificationServiceTracker = null;
private ServiceTracker<IAlignmentService, IAlignmentService> alignmentServiceTracker = null;
private ServiceTracker<IAverageChromatogramService, IAverageChromatogramService> averageChromatogramServiceTracker = null;
private ServiceTracker<ILocalMinimaScanService, ILocalMinimaScanService> localMinimaScanServiceTracker = null;
private ServiceTracker<ILocalMaximaScanService, ILocalMaximaScanService> localMaximaScanServiceTracker = null;
private ServiceTracker<IAnalysisSegmentService, IAnalysisSegmentService> analysisSegmentServiceTracker = null;

public static BundleContext getContext() {

Expand Down Expand Up @@ -77,6 +85,26 @@ public Object[] getAlignmentServices() {
return alignmentServiceTracker.getServices();
}

public Object[] getAverageChromatogramServices() {

return averageChromatogramServiceTracker.getServices();
}

public Object[] getLocalMinimaScanServices() {

return localMinimaScanServiceTracker.getServices();
}

public Object[] getLocalMaximaScanServices() {

return localMaximaScanServiceTracker.getServices();
}

public Object[] getAnalysisSegmentServices() {

return analysisSegmentServiceTracker.getServices();
}

private void startServices(BundleContext context) {

deconvolutionServiceTracker = new ServiceTracker<>(context, IDeconvolutionService.class, null);
Expand All @@ -90,6 +118,18 @@ private void startServices(BundleContext context) {
//
alignmentServiceTracker = new ServiceTracker<>(context, IAlignmentService.class, null);
alignmentServiceTracker.open();
//
averageChromatogramServiceTracker = new ServiceTracker<>(context, IAverageChromatogramService.class, null);
averageChromatogramServiceTracker.open();
//
localMinimaScanServiceTracker = new ServiceTracker<>(context, ILocalMinimaScanService.class, null);
localMinimaScanServiceTracker.open();
//
localMaximaScanServiceTracker = new ServiceTracker<>(context, ILocalMaximaScanService.class, null);
localMaximaScanServiceTracker.open();
//
analysisSegmentServiceTracker = new ServiceTracker<>(context, IAnalysisSegmentService.class, null);
analysisSegmentServiceTracker.open();
}

private void stopServices() {
Expand All @@ -98,5 +138,9 @@ private void stopServices() {
deconvolutionBatchServiceTracker.close();
identificationServiceTracker.close();
alignmentServiceTracker.close();
averageChromatogramServiceTracker.close();
localMinimaScanServiceTracker.close();
localMaximaScanServiceTracker.close();
analysisSegmentServiceTracker.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************
* 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:
* Lorenz Gerber - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.base.ui.services;

import java.util.List;

import org.eclipse.chemclipse.model.core.IChromatogram;
import org.eclipse.chemclipse.model.core.IScan;
import org.eclipse.chemclipse.model.support.IAnalysisSegment;
import org.eclipse.chemclipse.model.types.DataType;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPreferencePage;

public interface IAnalysisSegmentService {

String getName();

String getDescription();

String getVersion();

DataType getDataType();

IProcessingInfo<List<IAnalysisSegment>> calculate(IChromatogram<?> chromatogram, List<? extends IScan> scans, IProgressMonitor monitor);

Class<? extends IWorkbenchPreferencePage> getPreferencePage();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*******************************************************************************
* 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:
* Lorenz Gerber - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.base.ui.services;

import java.util.List;

import org.eclipse.chemclipse.model.core.IChromatogram;
import org.eclipse.chemclipse.model.types.DataType;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPreferencePage;

public interface IAverageChromatogramService {

String getName();

String getDescription();

String getVersion();

DataType getDataType();

IProcessingInfo<IChromatogram<?>> calculate(List<IChromatogram<?>> chromatograms, IProgressMonitor monitor);

Class<? extends IWorkbenchPreferencePage> getPreferencePage();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* 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:
* Lorenz Gerber - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.base.ui.services;

import java.util.List;

import org.eclipse.chemclipse.model.core.IScan;
import org.eclipse.chemclipse.model.selection.IChromatogramSelection;
import org.eclipse.chemclipse.model.types.DataType;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPreferencePage;

public interface ILocalMaximaScanService {

String getName();

String getDescription();

String getVersion();

DataType getDataType();

IProcessingInfo<List<? extends IScan>> calculate(IChromatogramSelection<?, ?> chromatogram, IProgressMonitor monitor);

Class<? extends IWorkbenchPreferencePage> getPreferencePage();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* 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:
* Lorenz Gerber - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.base.ui.services;

import java.util.List;

import org.eclipse.chemclipse.model.core.IScan;
import org.eclipse.chemclipse.model.selection.IChromatogramSelection;
import org.eclipse.chemclipse.model.types.DataType;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IWorkbenchPreferencePage;

public interface ILocalMinimaScanService {

String getName();

String getDescription();

String getVersion();

DataType getDataType();

IProcessingInfo<List<? extends IScan>> calculate(IChromatogramSelection<?, ?> chromatogram, IProgressMonitor monitor);

Class<? extends IWorkbenchPreferencePage> getPreferencePage();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* 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:
* Lorenz Gerber - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.base.ui.support;

import org.eclipse.chemclipse.model.types.DataType;

import net.openchrom.xxd.base.ui.Activator;
import net.openchrom.xxd.base.ui.services.IAnalysisSegmentService;

public class AnalysisSegmentSupport {

public static IAnalysisSegmentService getAnalysisSegmentService(DataType dataType) {

Object[] services = Activator.getDefault().getAnalysisSegmentServices();
if(services != null) {
for(Object service : services) {
if(service instanceof IAnalysisSegmentService analysisSegmentService) {
if(dataType.equals(analysisSegmentService.getDataType())) {
return analysisSegmentService;
}
}
}
}
//
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* 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:
* Lorenz Gerber - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.base.ui.support;

import org.eclipse.chemclipse.model.types.DataType;

import net.openchrom.xxd.base.ui.Activator;
import net.openchrom.xxd.base.ui.services.IAverageChromatogramService;

public class AverageChromatogramSupport {

public static IAverageChromatogramService getAverageChromatogramService(DataType dataType) {

Object[] services = Activator.getDefault().getAverageChromatogramServices();
if(services != null) {
for(Object service : services) {
if(service instanceof IAverageChromatogramService averageChromatogramService) {
if(dataType.equals(averageChromatogramService.getDataType())) {
return averageChromatogramService;
}
}
}
}
//
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* 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:
* Lorenz Gerber - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.base.ui.support;

import org.eclipse.chemclipse.model.types.DataType;

import net.openchrom.xxd.base.ui.Activator;
import net.openchrom.xxd.base.ui.services.ILocalMaximaScanService;

public class LocalMaximaScanSupport {

public static ILocalMaximaScanService getLocalMaximaScanService(DataType dataType) {

Object[] services = Activator.getDefault().getLocalMaximaScanServices();
if(services != null) {
for(Object service : services) {
if(service instanceof ILocalMaximaScanService localMaximaScanService) {
if(dataType.equals(localMaximaScanService.getDataType())) {
return localMaximaScanService;
}
}
}
}
//
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* 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:
* Lorenz Gerber - initial API and implementation
*******************************************************************************/
package net.openchrom.xxd.base.ui.support;

import org.eclipse.chemclipse.model.types.DataType;

import net.openchrom.xxd.base.ui.Activator;
import net.openchrom.xxd.base.ui.services.ILocalMinimaScanService;

public class LocalMinimaScanSupport {

public static ILocalMinimaScanService getLocalMinimaScanService(DataType dataType) {

Object[] services = Activator.getDefault().getLocalMinimaScanServices();
if(services != null) {
for(Object service : services) {
if(service instanceof ILocalMinimaScanService localMinimaScanService) {
if(dataType.equals(localMinimaScanService.getDataType())) {
return localMinimaScanService;
}
}
}
}
//
return null;
}
}

0 comments on commit 1356ca9

Please sign in to comment.