Skip to content

Commit

Permalink
Parameterize generic type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Dec 12, 2023
1 parent 0a524c5 commit 8fee5fc
Show file tree
Hide file tree
Showing 74 changed files with 489 additions and 456 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public IProcessingInfo<IChromatogramFilterResult> validate(IChromatogramSelectio
* @param chromatogramSelection
* @return {@link IProcessingInfo}
*/
private IProcessingInfo<?> validateChromatogramSelection(IChromatogramSelectionCSD chromatogramSelection) {
private IProcessingInfo<IChromatogramFilterResult> validateChromatogramSelection(IChromatogramSelectionCSD chromatogramSelection) {

IProcessingInfo<?> processingInfo = new ProcessingInfo<>();
IProcessingInfo<IChromatogramFilterResult> processingInfo = new ProcessingInfo<>();
if(chromatogramSelection == null) {
processingInfo.addErrorMessage(ICategories.CHROMATOGRAM_FILTER, Messages.invalidChromatogramSelection);
} else {
Expand All @@ -60,9 +60,9 @@ private IProcessingInfo<?> validateChromatogramSelection(IChromatogramSelectionC
* @param chromatogramFilterSettings
* @return {@link IProcessingInfo}
*/
private IProcessingInfo<?> validateFilterSettings(IChromatogramFilterSettings chromatogramFilterSettings) {
private IProcessingInfo<IChromatogramFilterResult> validateFilterSettings(IChromatogramFilterSettings chromatogramFilterSettings) {

IProcessingInfo<?> processingInfo = new ProcessingInfo<>();
IProcessingInfo<IChromatogramFilterResult> processingInfo = new ProcessingInfo<>();
if(chromatogramFilterSettings == null) {
processingInfo.addErrorMessage(ICategories.CHROMATOGRAM_FILTER, Messages.invalidFilterSettings);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2020 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -13,6 +13,7 @@

import org.eclipse.chemclipse.chromatogram.msd.identifier.settings.IIdentifierSettingsMSD;
import org.eclipse.chemclipse.model.exceptions.ValueMustNotBeNullException;
import org.eclipse.chemclipse.model.identifier.IChromatogramIdentificationResult;
import org.eclipse.chemclipse.msd.model.core.selection.IChromatogramSelectionMSD;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.ProcessingInfo;
Expand All @@ -21,9 +22,9 @@ public abstract class AbstractChromatogramIdentifier implements IChromatogramIde

private static final String DESCRIPTION = "ChromatogramIdentifier";

public IProcessingInfo<?> validate(IChromatogramSelectionMSD chromatogramSelection, IIdentifierSettingsMSD identifierSettings) {
public IProcessingInfo<IChromatogramIdentificationResult> validate(IChromatogramSelectionMSD chromatogramSelection, IIdentifierSettingsMSD identifierSettings) {

IProcessingInfo<?> processingInfo = new ProcessingInfo<>();
IProcessingInfo<IChromatogramIdentificationResult> processingInfo = new ProcessingInfo<>();
try {
validateChromatogramSelection(chromatogramSelection);
validateSettings(identifierSettings);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2020 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -13,6 +13,7 @@

import org.eclipse.chemclipse.chromatogram.msd.identifier.settings.IChromatogramIdentifierSettings;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.model.identifier.IChromatogramIdentificationResult;
import org.eclipse.chemclipse.model.identifier.core.Identifier;
import org.eclipse.chemclipse.msd.model.core.selection.IChromatogramSelectionMSD;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
Expand Down Expand Up @@ -54,9 +55,9 @@ private ChromatogramIdentifier() {
* @param monitor
* @return {@link IProcessingInfo}
*/
public static IProcessingInfo<?> identify(IChromatogramSelectionMSD chromatogramSelection, IChromatogramIdentifierSettings identifierSettings, String identifierId, IProgressMonitor monitor) {
public static IProcessingInfo<IChromatogramIdentificationResult> identify(IChromatogramSelectionMSD chromatogramSelection, IChromatogramIdentifierSettings identifierSettings, String identifierId, IProgressMonitor monitor) {

IProcessingInfo<?> processingInfo;
IProcessingInfo<IChromatogramIdentificationResult> processingInfo;
IChromatogramIdentifier chromatogramIdentifier = getChromatogramIdentifier(identifierId);
if(chromatogramIdentifier != null) {
processingInfo = chromatogramIdentifier.identify(chromatogramSelection, identifierSettings, monitor);
Expand All @@ -74,9 +75,9 @@ public static IProcessingInfo<?> identify(IChromatogramSelectionMSD chromatogram
* @param monitor
* @return {@link IProcessingInfo}
*/
public static IProcessingInfo<?> identify(IChromatogramSelectionMSD chromatogramSelection, String identifierId, IProgressMonitor monitor) {
public static IProcessingInfo<IChromatogramIdentificationResult> identify(IChromatogramSelectionMSD chromatogramSelection, String identifierId, IProgressMonitor monitor) {

IProcessingInfo<?> processingInfo;
IProcessingInfo<IChromatogramIdentificationResult> processingInfo;
IChromatogramIdentifier chromatogramIdentifier = getChromatogramIdentifier(identifierId);
if(chromatogramIdentifier != null) {
processingInfo = chromatogramIdentifier.identify(chromatogramSelection, monitor);
Expand Down Expand Up @@ -163,9 +164,9 @@ private static IConfigurationElement getConfigurationElement(final String filter
return null;
}

private static IProcessingInfo<?> getNoIdentifierAvailableProcessingInfo() {
private static IProcessingInfo<IChromatogramIdentificationResult> getNoIdentifierAvailableProcessingInfo() {

IProcessingInfo<?> processingInfo = new ProcessingInfo<>();
IProcessingInfo<IChromatogramIdentificationResult> processingInfo = new ProcessingInfo<>();
IProcessingMessage processingMessage = new ProcessingMessage(MessageType.ERROR, "Chromatogram Identifier", NO_IDENTIFIER_AVAILABLE);
processingInfo.addMessage(processingMessage);
return processingInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2020 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -12,6 +12,7 @@
package org.eclipse.chemclipse.chromatogram.msd.identifier.chromatogram;

import org.eclipse.chemclipse.chromatogram.msd.identifier.settings.IChromatogramIdentifierSettings;
import org.eclipse.chemclipse.model.identifier.IChromatogramIdentificationResult;
import org.eclipse.chemclipse.msd.model.core.selection.IChromatogramSelectionMSD;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.core.runtime.IProgressMonitor;
Expand All @@ -28,7 +29,7 @@ public interface IChromatogramIdentifier {
* @param monitor
* @return {@link IProcessingInfo}
*/
IProcessingInfo<?> identify(IChromatogramSelectionMSD chromatogramSelection, IChromatogramIdentifierSettings identifierSettings, IProgressMonitor monitor);
IProcessingInfo<IChromatogramIdentificationResult> identify(IChromatogramSelectionMSD chromatogramSelection, IChromatogramIdentifierSettings identifierSettings, IProgressMonitor monitor);

/**
* The same as the other method but without settings.
Expand All @@ -37,5 +38,5 @@ public interface IChromatogramIdentifier {
* @param monitor
* @return {@link IProcessingInfo}
*/
IProcessingInfo<?> identify(IChromatogramSelectionMSD chromatogramSelection, IProgressMonitor monitor);
IProcessingInfo<IChromatogramIdentificationResult> identify(IChromatogramSelectionMSD chromatogramSelection, IProgressMonitor monitor);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 Lablicate GmbH.
* Copyright (c) 2019, 2023 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 @@ -19,6 +19,7 @@
import org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.support.PeakProcessorSupport;
import org.eclipse.chemclipse.model.core.IPeaks;
import org.eclipse.chemclipse.msd.converter.peak.PeakConverterMSD;
import org.eclipse.chemclipse.msd.model.core.IPeakMSD;
import org.eclipse.chemclipse.processing.core.DefaultProcessingResult;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.IProcessingMessage;
Expand All @@ -44,9 +45,9 @@ public AMDISParser(File fileChromatogram) {
resFile = getFile(fileChromatogram, "RES");
}

public IProcessingResult<IPeaks<?>> parse(IProgressMonitor monitor) throws InterruptedException {
public IProcessingResult<IPeaks<IPeakMSD>> parse(IProgressMonitor monitor) throws InterruptedException {

DefaultProcessingResult<IPeaks<?>> result = new DefaultProcessingResult<>();
DefaultProcessingResult<IPeaks<IPeakMSD>> result = new DefaultProcessingResult<>();
try {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
if(!waitForFile(eluFile, WAIT_TIMEOUT_ELU, TimeUnit.SECONDS, subMonitor.split(10, SubMonitor.SUPPRESS_NONE))) {
Expand All @@ -55,7 +56,7 @@ public IProcessingResult<IPeaks<?>> parse(IProgressMonitor monitor) throws Inter
if(!waitForFileComplete(eluFile, WAIT_TIMEOUT_COMPLETE, TimeUnit.MINUTES, subMonitor.split(10, SubMonitor.SUPPRESS_NONE))) {
throw new InterruptedException("AMDIS does not finished writing file within the time bounds");
}
IProcessingInfo<IPeaks<?>> peaksResult = PeakConverterMSD.convert(eluFile, PeakProcessorSupport.PEAK_CONVERTER_ID, subMonitor.split(70));
IProcessingInfo<IPeaks<IPeakMSD>> peaksResult = PeakConverterMSD.convert(eluFile, PeakProcessorSupport.PEAK_CONVERTER_ID, subMonitor.split(70));
if(peaksResult == null) {
result.addErrorMessage(PreferenceSupplier.IDENTIFIER, "PeakParser returned no result");
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.settings.IOnsiteSettings;
import org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.settings.SettingsAMDIS;
import org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.support.PeakProcessorSupport;
import org.eclipse.chemclipse.model.core.IPeak;
import org.eclipse.chemclipse.model.core.IPeaks;
import org.eclipse.chemclipse.msd.converter.chromatogram.ChromatogramConverterMSD;
import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD;
import org.eclipse.chemclipse.msd.model.core.IPeakMSD;
import org.eclipse.chemclipse.msd.model.core.selection.IChromatogramSelectionMSD;
import org.eclipse.chemclipse.processing.core.DefaultProcessingResult;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
Expand All @@ -37,7 +37,6 @@

public class AmdisIdentifier {

@SuppressWarnings({"unchecked"})
public IProcessingResult<Void> calulateAndSetDeconvolutedPeaks(IChromatogramSelectionMSD chromatogramSelection, SettingsAMDIS settingsAMDIS, IProgressMonitor monitor) throws InterruptedException {

SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
Expand Down Expand Up @@ -76,13 +75,13 @@ public IProcessingResult<Void> calulateAndSetDeconvolutedPeaks(IChromatogramSele
*/
try {
AMDISParser parser = new AMDISParser(fileChromatogram);
IProcessingResult<IPeaks<?>> amdisPeaks = executeAMDIS(fileChromatogram, settingsAMDIS, parser, subMonitor.split(80));
IProcessingResult<IPeaks<IPeakMSD>> amdisPeaks = executeAMDIS(fileChromatogram, settingsAMDIS, parser, subMonitor.split(80));
result.addMessages(amdisPeaks);
if(result.hasErrorMessages()) {
return result;
}
//
IPeaks<IPeak> peaks = (IPeaks<IPeak>)amdisPeaks.getProcessingResult();
IPeaks<IPeakMSD> peaks = amdisPeaks.getProcessingResult();
if(peaks == null) {
result.addErrorMessage(PreferenceSupplier.IDENTIFIER, "Parsing peaks does not return a result");
return result;
Expand All @@ -97,7 +96,7 @@ public IProcessingResult<Void> calulateAndSetDeconvolutedPeaks(IChromatogramSele
return result;
}

private IProcessingResult<IPeaks<?>> executeAMDIS(File fileChromatogram, SettingsAMDIS settingsAMDIS, AMDISParser parser, IProgressMonitor monitor) throws InterruptedException {
private IProcessingResult<IPeaks<IPeakMSD>> executeAMDIS(File fileChromatogram, SettingsAMDIS settingsAMDIS, AMDISParser parser, IProgressMonitor monitor) throws InterruptedException {

IExtendedRuntimeSupport runtimeSupport;
String amdisApplication = settingsAMDIS.getAmdisFolder().getAbsolutePath() + File.separator + PreferenceSupplier.AMDIS_EXECUTABLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.settings.IProcessSettings;
import org.eclipse.chemclipse.chromatogram.msd.peak.detector.supplier.amdis.settings.ModelPeakOption;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.model.core.IPeak;
import org.eclipse.chemclipse.model.core.IPeakModel;
import org.eclipse.chemclipse.model.core.IPeaks;
import org.eclipse.chemclipse.msd.converter.io.IPeakReader;
Expand All @@ -42,11 +41,10 @@ public class PeakProcessorSupport {
public static final String DETECTOR_DESCRIPTION = "AMDIS (Extern)";
public static final String PEAK_CONVERTER_ID = "org.eclipse.chemclipse.msd.converter.supplier.amdis.peak.elu";

@SuppressWarnings({"unchecked", "rawtypes"})
public void extractEluFileAndSetPeaks(IChromatogramSelectionMSD chromatogramSelection, File file, IProcessSettings processSettings, IProgressMonitor monitor) {

IProcessingInfo<IPeaks<?>> processingInfo = PeakConverterMSD.convert(file, PEAK_CONVERTER_ID, monitor);
IPeaks peaks = processingInfo.getProcessingResult();
IProcessingInfo<IPeaks<IPeakMSD>> processingInfo = PeakConverterMSD.convert(file, PEAK_CONVERTER_ID, monitor);
IPeaks<IPeakMSD> peaks = processingInfo.getProcessingResult();
insertPeaks(chromatogramSelection, peaks.getPeaks(), processSettings, monitor);
}

Expand All @@ -59,7 +57,7 @@ public void extractEluFileAndSetPeaks(IChromatogramSelectionMSD chromatogramSele
* @param monitor
* @return
*/
public static IProcessingResult<Void> insertPeaks(IChromatogramSelectionMSD chromatogramSelection, List<IPeak> peaks, IProcessSettings processSettings, IProgressMonitor monitor) {
public static IProcessingResult<Void> insertPeaks(IChromatogramSelectionMSD chromatogramSelection, List<IPeakMSD> peaks, IProcessSettings processSettings, IProgressMonitor monitor) {

DefaultProcessingResult<Void> result = new DefaultProcessingResult<>();
IChromatogramMSD chromatogram = chromatogramSelection.getChromatogram();
Expand All @@ -68,70 +66,68 @@ public static IProcessingResult<Void> insertPeaks(IChromatogramSelectionMSD chro
ModelPeakOption modelPeakOption = processSettings.getModelPeakOption();
String modelPeakMarker = "MP" + modelPeakOption.value();
//
for(IPeak peak : peaks) {
if(peak instanceof IPeakMSD peakMSD) {
String header = peak.getTemporaryData();
try {
IPeakModelMSD peakModelMSD = peakMSD.getPeakModel();
//
int startScan = peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_START_SCAN) instanceof Integer ? (int)peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_START_SCAN) : 0;
int stopScan = peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_STOP_SCAN) instanceof Integer ? (int)peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_STOP_SCAN) : 0;
int maxScan = peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_MAX_SCAN) instanceof Integer ? (int)peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_MAX_SCAN) : 0;
for(IPeakMSD peak : peaks) {
String header = peak.getTemporaryData();
try {
IPeakModelMSD peakModelMSD = peak.getPeakModel();
//
int startScan = peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_START_SCAN) instanceof Integer ? (int)peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_START_SCAN) : 0;
int stopScan = peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_STOP_SCAN) instanceof Integer ? (int)peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_STOP_SCAN) : 0;
int maxScan = peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_MAX_SCAN) instanceof Integer ? (int)peakModelMSD.getTemporarilyInfo(IPeakReader.TEMP_INFO_MAX_SCAN) : 0;
/*
* There seems to be an offset of 1 scan.
* Why? No clue ...
*/
startScan++;
stopScan++;
maxScan++;
/*
* Add only peaks above the given minSignalToNoiseRatio and within the
* chromatogram selection.
*/
IChromatogramPeakMSD chromatogramPeakMSD = new ChromatogramPeakMSD(peakModelMSD, chromatogram);
chromatogramPeakMSD.setDetectorDescription(DETECTOR_DESCRIPTION);
if(isValidPeak(chromatogramPeakMSD, startRetentionTime, stopRetentionTime, processSettings)) {
/*
* There seems to be an offset of 1 scan.
* Why? No clue ...
* Pre-check
*/
startScan++;
stopScan++;
maxScan++;
/*
* Add only peaks above the given minSignalToNoiseRatio and within the
* chromatogram selection.
*/
IChromatogramPeakMSD chromatogramPeakMSD = new ChromatogramPeakMSD(peakModelMSD, chromatogram);
chromatogramPeakMSD.setDetectorDescription(DETECTOR_DESCRIPTION);
if(isValidPeak(chromatogramPeakMSD, startRetentionTime, stopRetentionTime, processSettings)) {
/*
* Pre-check
*/
if(startScan > 0 && stopScan > startScan && maxScan > startScan) {
List<Integer> retentionTimes = new ArrayList<>();
for(int scan = startScan; scan <= stopScan; scan++) {
retentionTimes.add(chromatogram.getScan(scan).getRetentionTime());
}
/*
* Adjust the peak retention times if possible.
*/
chromatogramPeakMSD.getPeakModel().replaceRetentionTimes(retentionTimes);
}
/*
* Post-check
*/
if(!ModelPeakOption.ALL.equals(modelPeakOption)) {
if(header == null || !header.contains(modelPeakMarker)) {
chromatogramPeakMSD = null;
}
if(startScan > 0 && stopScan > startScan && maxScan > startScan) {
List<Integer> retentionTimes = new ArrayList<>();
for(int scan = startScan; scan <= stopScan; scan++) {
retentionTimes.add(chromatogram.getScan(scan).getRetentionTime());
}
/*
* Add the peak
* Adjust the peak retention times if possible.
*/
if(chromatogramPeakMSD != null) {
chromatogram.addPeak(chromatogramPeakMSD);
logger.info("Add Peak (ELU): " + header);
} else {
String message = "Skip Peak (ELU): " + header;
logger.info(message);
result.addInfoMessage(PreferenceSupplier.IDENTIFIER, message);
chromatogramPeakMSD.getPeakModel().replaceRetentionTimes(retentionTimes);
}
/*
* Post-check
*/
if(!ModelPeakOption.ALL.equals(modelPeakOption)) {
if(header == null || !header.contains(modelPeakMarker)) {
chromatogramPeakMSD = null;
}
}
/*
* Add the peak
*/
if(chromatogramPeakMSD != null) {
chromatogram.addPeak(chromatogramPeakMSD);
logger.info("Add Peak (ELU): " + header);
} else {
String message = "Invalid Peak (ELU): " + header;
String message = "Skip Peak (ELU): " + header;
logger.info(message);
result.addInfoMessage(PreferenceSupplier.IDENTIFIER, message);
}
} catch(Exception e) {
logger.warn(e);
result.addWarnMessage(PreferenceSupplier.IDENTIFIER, "Peak Error (ELU): " + header);
} else {
String message = "Invalid Peak (ELU): " + header;
logger.info(message);
result.addInfoMessage(PreferenceSupplier.IDENTIFIER, message);
}
} catch(Exception e) {
logger.warn(e);
result.addWarnMessage(PreferenceSupplier.IDENTIFIER, "Peak Error (ELU): " + header);
}
}
return result;
Expand Down
Loading

0 comments on commit 8fee5fc

Please sign in to comment.