From 74ae37dbc6810e48ea01d137793d2297ed3d39bf Mon Sep 17 00:00:00 2001 From: stefanks Date: Tue, 17 Oct 2017 14:38:36 -0500 Subject: [PATCH] Fix decon (#260) * Ordinal * noice * Aaha * fix --- MS2decon/Program.cs | 3 ++- .../DeconvolutionFeatureWithMassesAndScans.cs | 14 +++++++++----- MassSpectrometry/MsDataFile.cs | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/MS2decon/Program.cs b/MS2decon/Program.cs index c1ff8e9b4..5bfdf2768 100644 --- a/MS2decon/Program.cs +++ b/MS2decon/Program.cs @@ -2,6 +2,7 @@ using IO.MzML; using IO.Thermo; using MassSpectrometry; +using MzLibUtil; using System; using System.Collections.Generic; using System.Globalization; @@ -62,7 +63,7 @@ private static void Main(string[] args) { if ((!p.Object.MinScan.HasValue || ok.OneBasedScanNumber >= p.Object.MinScan) && (!p.Object.MaxScan.HasValue || ok.OneBasedScanNumber <= p.Object.MaxScan)) { - var hmm = ok.MassSpectrum.Deconvolute(ok.ScanWindowRange, p.Object.MaxAssumedChargeState, p.Object.DeconvolutionTolerancePpm, p.Object.IntensityRatioLimit).ToList(); + var hmm = ok.MassSpectrum.Deconvolute(new MzRange(0, double.PositiveInfinity), p.Object.MaxAssumedChargeState, p.Object.DeconvolutionTolerancePpm, p.Object.IntensityRatioLimit).ToList(); List currentListOfGroups = new List(); diff --git a/MassSpectrometry/DeconvolutionFeatureWithMassesAndScans.cs b/MassSpectrometry/DeconvolutionFeatureWithMassesAndScans.cs index 81f27b96c..c3c86271b 100644 --- a/MassSpectrometry/DeconvolutionFeatureWithMassesAndScans.cs +++ b/MassSpectrometry/DeconvolutionFeatureWithMassesAndScans.cs @@ -80,18 +80,22 @@ public void AddEnvelope(IsotopicEnvelope isotopicEnvelope, int scanIndex, double MaxScanIndex = Math.Max(scanIndex, MaxScanIndex); MinElutionTime = Math.Min(elutionTime, MinElutionTime); MaxElutionTime = Math.Max(elutionTime, MaxElutionTime); + bool added = false; foreach (var massGroup in groups) { if (Math.Abs(massGroup.Mass - isotopicEnvelope.monoisotopicMass) < 0.5) { massGroup.AddEnvelope(isotopicEnvelope); - Mass = groups.OrderBy(b => -b.NumPeaks).First().Mass; - return; + added = true; + break; } } - var newMassGroup = new DeconvolutionFeature(); - newMassGroup.AddEnvelope(isotopicEnvelope); - groups.Add(newMassGroup); + if (!added) + { + var newMassGroup = new DeconvolutionFeature(); + newMassGroup.AddEnvelope(isotopicEnvelope); + groups.Add(newMassGroup); + } Mass = groups.OrderBy(b => -b.NumPeaks).First().Mass; TotalIntensity += isotopicEnvelope.peaks.Sum(b => b.Item2); diff --git a/MassSpectrometry/MsDataFile.cs b/MassSpectrometry/MsDataFile.cs index 1170ab041..eae022593 100644 --- a/MassSpectrometry/MsDataFile.cs +++ b/MassSpectrometry/MsDataFile.cs @@ -16,6 +16,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with MassSpectrometry. If not, see . +using MzLibUtil; using System; using System.Collections; using System.Collections.Concurrent; @@ -141,7 +142,7 @@ public IEnumerable Deconvolute(int? minS { var theScan = GetOneBasedScan(scanIndex); if (scanFilterFunc(theScan)) - allAggregateGroups[scanIndex - minScan.Value] = theScan.MassSpectrum.Deconvolute(theScan.ScanWindowRange, maxAssumedChargeState, deconvolutionTolerancePpm, intensityRatioLimit).ToList(); + allAggregateGroups[scanIndex - minScan.Value] = theScan.MassSpectrum.Deconvolute(new MzRange(0, double.PositiveInfinity), maxAssumedChargeState, deconvolutionTolerancePpm, intensityRatioLimit).ToList(); } });