Skip to content

Commit

Permalink
Fix decon (#260)
Browse files Browse the repository at this point in the history
* Ordinal

* noice

* Aaha

* fix
  • Loading branch information
stefanks authored Oct 17, 2017
1 parent 824c9d5 commit 74ae37d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion MS2decon/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using IO.MzML;
using IO.Thermo;
using MassSpectrometry;
using MzLibUtil;
using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -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<DeconvolutionFeatureWithMassesAndScans> currentListOfGroups = new List<DeconvolutionFeatureWithMassesAndScans>();

Expand Down
14 changes: 9 additions & 5 deletions MassSpectrometry/DeconvolutionFeatureWithMassesAndScans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion MassSpectrometry/MsDataFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// You should have received a copy of the GNU Lesser General Public
// License along with MassSpectrometry. If not, see <http://www.gnu.org/licenses/>.

using MzLibUtil;
using System;
using System.Collections;
using System.Collections.Concurrent;
Expand Down Expand Up @@ -141,7 +142,7 @@ public IEnumerable<DeconvolutionFeatureWithMassesAndScans> 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();
}
});

Expand Down

0 comments on commit 74ae37d

Please sign in to comment.