private IqResult SelectBestChargeStateChildResult(IqResult result) { var filteredChargeStateResults = result.ChildResults().Where(p => p.FavoriteChild != null).ToList(); if (filteredChargeStateResults.Count == 0) { return(null); } if (filteredChargeStateResults.Count == 1) { return(filteredChargeStateResults.First()); } //now to deal with the tough issue of multiple charge states having a possible results. var filter2 = filteredChargeStateResults.Where(p => p.CorrelationData.CorrelationDataItems.First().CorrelationRSquaredVal > 0.7).ToList(); if (filter2.Count == 0) { filter2 = filteredChargeStateResults.Where(p => p.CorrelationData.CorrelationDataItems.First().CorrelationRSquaredVal > 0.5).ToList(); } if (filter2.Count == 0) { filter2 = filteredChargeStateResults.Where(p => p.CorrelationData.CorrelationDataItems.First().CorrelationRSquaredVal > 0.3).ToList(); } if (filter2.Count == 0) { //correlation values are no good. Now will sort by fit score. filter2 = filteredChargeStateResults.OrderBy(p => p.FitScore).Take(1).ToList(); //sort by fit score let the first one be selected } if (filter2.Count == 1) { return(filter2.First()); } else if (filter2.Count > 1) { //if we reached here, there are multiple charge state results with good correlation scores. Take the one of highest intensity. return(filter2.OrderByDescending(p => p.Abundance).First()); } return(null); }
public List <IqResult> FlattenOutResultTree(IqResult iqResult) { var flattenedResults = new List <IqResult>(); if (iqResult.HasChildren()) { var childresults = iqResult.ChildResults(); foreach (var childResult in childresults) { var moreResults = FlattenOutResultTree(childResult); flattenedResults.AddRange(moreResults); } } flattenedResults.Add(iqResult); return(flattenedResults); }