Skip to content

Commit

Permalink
#899 - DAD Scan Rasterizer: a null check has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Feb 9, 2022
1 parent ae6fffc commit c983f4e
Showing 1 changed file with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,40 @@ public class ScanRasterizer {

public static void normalize(IChromatogramWSD chromatogramWSD, int steps) {

for(IScan scan : chromatogramWSD.getScans()) {
if(scan instanceof IScanWSD) {
IScanWSD scanWSD = (IScanWSD)scan;
normalize(scanWSD, steps);
if(chromatogramWSD != null) {
for(IScan scan : chromatogramWSD.getScans()) {
if(scan instanceof IScanWSD) {
IScanWSD scanWSD = (IScanWSD)scan;
normalize(scanWSD, steps);
}
}
}
}

public static void normalize(IScanWSD scanWSD, int steps) {

if(steps >= RasterizeCalculator.MIN_STEPS && steps <= RasterizeCalculator.MAX_STEPS) {
/*
* Collect the data
*/
TreeMap<Double, Float> wavelengthOriginal = new TreeMap<>();
for(IScanSignalWSD scanSignalWSD : scanWSD.getScanSignals()) {
wavelengthOriginal.put(scanSignalWSD.getWavelength(), scanSignalWSD.getAbundance());
}
//
Map<Integer, Float> wavelengthsAdjusted = RasterizeCalculator.apply(wavelengthOriginal, steps);
if(wavelengthsAdjusted != null) {
if(scanWSD != null) {
if(steps >= RasterizeCalculator.MIN_STEPS && steps <= RasterizeCalculator.MAX_STEPS) {
/*
* Rasterized Data
* Collect the data
*/
List<Integer> wavelengths = new ArrayList<>(wavelengthsAdjusted.keySet());
Collections.sort(wavelengths);
TreeMap<Double, Float> wavelengthOriginal = new TreeMap<>();
for(IScanSignalWSD scanSignalWSD : scanWSD.getScanSignals()) {
wavelengthOriginal.put(scanSignalWSD.getWavelength(), scanSignalWSD.getAbundance());
}
//
scanWSD.deleteScanSignals();
for(int wavelength : wavelengths) {
scanWSD.addScanSignal(new ScanSignalWSD(wavelength, wavelengthsAdjusted.get(wavelength)));
Map<Integer, Float> wavelengthsAdjusted = RasterizeCalculator.apply(wavelengthOriginal, steps);
if(wavelengthsAdjusted != null) {
/*
* Rasterized Data
*/
List<Integer> wavelengths = new ArrayList<>(wavelengthsAdjusted.keySet());
Collections.sort(wavelengths);
//
scanWSD.deleteScanSignals();
for(int wavelength : wavelengths) {
scanWSD.addScanSignal(new ScanSignalWSD(wavelength, wavelengthsAdjusted.get(wavelength)));
}
}
}
}
Expand Down

0 comments on commit c983f4e

Please sign in to comment.