Skip to content

Commit

Permalink
Fix AssumptionException in PeakMatcher.cs (#3190)
Browse files Browse the repository at this point in the history
Fixed error doing "Apply peak to all" when a particular replicate has no chromatograms that match transitions in the document but does have some hidden MS1 chromatograms (reported by Jeannie)
  • Loading branch information
nickshulman authored Oct 11, 2024
1 parent bc93c28 commit 09d14b9
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pwiz_tools/Skyline/Model/PeakMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ private static void GetReferenceData(SrmDocument doc, PeptideDocNode nodePep, Tr
var chromGroupInfo = chromGroupInfos.FirstOrDefault(info => Equals(chromSet.GetFileInfo(tranGroupChromInfo.FileId).FilePath, info.FilePath));
if (chromGroupInfo == null || chromGroupInfo.NumPeaks == 0 || !chromGroupInfo.TimeIntensitiesGroup.HasAnyPoints)
return;
if (!GetTransitionChromatogramInfos(nodeTranGroup, chromGroupInfo, mzMatchTolerance).Any())
return;

runTime = chromGroupInfo.RunStartTime;

Expand Down Expand Up @@ -221,6 +223,8 @@ private static PeakMatch GetPeakMatch(SrmDocument doc, ChromatogramSet chromSet,
var chromGroupInfo = loadInfos.FirstOrDefault(info => Equals(info.FilePath, fileInfo.FilePath));
if (chromGroupInfo == null || chromGroupInfo.NumPeaks == 0 || !chromGroupInfo.TimeIntensitiesGroup.HasAnyPoints)
return null;
if (!GetTransitionChromatogramInfos(nodeTranGroup, chromGroupInfo, mzMatchTolerance).Any())
return null;

var matchData = new List<PeakMatchData>();
double totalArea = chromGroupInfo.TransitionPointSets.Sum(chromInfo => chromInfo.Peaks.Sum(peak => peak.Area));
Expand Down Expand Up @@ -306,18 +310,23 @@ private static PeakMatch GetPeakMatch(SrmDocument doc, ChromatogramSet chromSet,
ChromatogramGroupInfo chromGroupInfo, int peakIndex, float mzMatchTolerance)
{
ChromPeak? largestPeak = null;
foreach (var peak in
from transitionDocNode in nodeTranGroup.Transitions
select chromGroupInfo.GetTransitionInfo(transitionDocNode, mzMatchTolerance)
into chromInfo where chromInfo != null
select chromInfo.GetPeak(peakIndex))
foreach (var peak in GetTransitionChromatogramInfos(nodeTranGroup, chromGroupInfo, mzMatchTolerance)
.Select(chromInfo => chromInfo.GetPeak(peakIndex)))
{
if (largestPeak == null || peak.Height > largestPeak.Value.Height)
largestPeak = peak;
}
return largestPeak;
}

private static IEnumerable<ChromatogramInfo> GetTransitionChromatogramInfos(TransitionGroupDocNode nodeTranGroup,
ChromatogramGroupInfo chromGroupInfo, float mzMatchTolerance)
{
return nodeTranGroup.Transitions
.Select(transition => chromGroupInfo.GetTransitionInfo(transition, mzMatchTolerance))
.Where(chromatogramInfo => chromatogramInfo != null);
}

private static PeakMatch MakePeakMatchBetween(float scale, PeakMatchData referenceTarget, PeakAlignment prev, PeakAlignment next)
{
if (prev == null && next == null)
Expand Down

0 comments on commit 09d14b9

Please sign in to comment.