Skip to content

Commit

Permalink
Fixed #797 - PeakBuilderWSD - add MM option
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Oct 23, 2021
1 parent d0da255 commit 80e013e
Showing 1 changed file with 51 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,36 +104,8 @@ public static IChromatogramPeakWSD createPeak(IChromatogramWSD chromatogram, ISc

public static IChromatogramPeakWSD createPeak(IChromatogramWSD chromatogram, IScanRange scanRange, boolean calculatePeakIncludedBackground, Set<Integer> traces) throws PeakException {

/*
* Validate the given objects.
*/
validateChromatogram(chromatogram);
validateScanRange(scanRange);
checkScanRange(chromatogram, scanRange);
/*
* Filter the extracted signals.
*/
IExtractedWavelengthSignals extractedWavelengthSignals = getExtractedWavelengthSignals(chromatogram, scanRange);
for(IExtractedWavelengthSignal extractedWavelengthSignal : extractedWavelengthSignals.getExtractedWavelengthSignals()) {
for(int i = extractedWavelengthSignal.getStartWavelength(); i <= extractedWavelengthSignal.getStopWavelength(); i++) {
/*
* Skip if trace shall be used.
*/
if(traces.contains(i)) {
continue;
}
/*
* Set to 0.
*/
extractedWavelengthSignal.setAbundance(i, 0);
}
}
/*
* Retrieve the start and stop signals of the peak to calculate its
* chromatogram and eventually peak internal background, if the start
* abundance is higher than the stop abundance or vice versa.
*/
try {
IExtractedWavelengthSignals extractedWavelengthSignals = getExtractedWavelengthSignals(chromatogram, scanRange, traces);
IExtractedWavelengthSignal extractedWavelengthSignalStart = extractedWavelengthSignals.getExtractedWavelengthSignal(scanRange.getStartScan());
float startBackgroundAbundance = extractedWavelengthSignalStart.getTotalSignal();
IExtractedWavelengthSignal extractedWavelengthSignalStop = extractedWavelengthSignals.getExtractedWavelengthSignal(scanRange.getStopScan());
Expand All @@ -155,6 +127,35 @@ public static IChromatogramPeakWSD createPeak(IChromatogramWSD chromatogram, ISc
float base = Math.min(startBackgroundAbundance, stopBackgroundAbundance);
backgroundAbundanceRange = new BackgroundAbundanceRange(base, base);
}
//
return createPeak(chromatogram, scanRange, backgroundAbundanceRange.getStartBackgroundAbundance(), backgroundAbundanceRange.getStopBackgroundAbundance(), traces);
} catch(Exception e) {
throw new PeakException();
}
}

public static IChromatogramPeakWSD createPeak(IChromatogramWSD chromatogram, IScanRange scanRange, float startIntensity, float stopIntensity, Set<Integer> traces) throws PeakException {

/*
* Validate the given objects.
*/
validateChromatogram(chromatogram);
validateScanRange(scanRange);
checkScanRange(chromatogram, scanRange);
/*
* Filter the extracted signals.
*/
IExtractedWavelengthSignals extractedWavelengthSignals = getExtractedWavelengthSignals(chromatogram, scanRange, traces);
/*
* Retrieve the start and stop signals of the peak to calculate its
* chromatogram and eventually peak internal background, if the start
* abundance is higher than the stop abundance or vice versa.
*/
try {
/*
* Background
*/
IBackgroundAbundanceRange backgroundAbundanceRange = new BackgroundAbundanceRange(startIntensity, stopIntensity);
/*
* Calculate the intensity values.
*/
Expand Down Expand Up @@ -287,6 +288,27 @@ protected static ITotalScanSignals getTotalScanSignals(IChromatogramWSD chromato
}
}

protected static IExtractedWavelengthSignals getExtractedWavelengthSignals(IChromatogramWSD chromatogram, IScanRange scanRange, Set<Integer> traces) {

IExtractedWavelengthSignals extractedWavelengthSignals = getExtractedWavelengthSignals(chromatogram, scanRange);
for(IExtractedWavelengthSignal extractedWavelengthSignal : extractedWavelengthSignals.getExtractedWavelengthSignals()) {
for(int i = extractedWavelengthSignal.getStartWavelength(); i <= extractedWavelengthSignal.getStopWavelength(); i++) {
/*
* Skip if trace shall be used.
*/
if(traces.contains(i)) {
continue;
}
/*
* Set to 0.
*/
extractedWavelengthSignal.setAbundance(i, 0);
}
}
//
return extractedWavelengthSignals;
}

protected static IExtractedWavelengthSignals getExtractedWavelengthSignals(IChromatogramWSD chromatogram, IScanRange scanRange) throws PeakException {

assert (chromatogram != null) : "The chromatogram must not be null.";
Expand Down

0 comments on commit 80e013e

Please sign in to comment.