public GraphDataProperties(ReplicateValue group, NormalizeOption normalizeOption, object annotation, int minimumDetections) { Group = group; NormalizeOption = normalizeOption; Annotation = annotation; MinimumDetections = minimumDetections; }
public void SetGroupIndex(int index) { if (index == 0) { Program.MainWindow.SetAreaCVAnnotation(null, false); var results = _graphSummary.DocumentUIContainer.DocumentUI.MeasuredResults; toolStripNumericDetections.NumericUpDownControl.Maximum = results != null ? results.Chromatograms.Count : 0; } else { Program.MainWindow.SetAreaCVAnnotation(toolStripComboGroup.Items[index], false); var document = _graphSummary.DocumentUIContainer.DocumentUI; var groupByGroup = ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup); toolStripNumericDetections.NumericUpDownControl.Maximum = AnnotationHelper .GetReplicateIndices(document, groupByGroup, AreaGraphController.GroupByAnnotation).Length; } if (IsCurrentDataCached()) { _graphSummary.UpdateUIWithoutToolbar(); return; } _timer.Stop(); _timer.Start(); }
private static bool HasDistinctValues(SrmSettings settings, ReplicateValue replicateValue) { if (!settings.HasResults) { return(false); } var values = settings.MeasuredResults.Chromatograms.Select(replicateValue.GetValue).Distinct().ToArray(); return(values.Length > 1); }
public AreaCVGraphData Get(ReplicateValue group, object annotation, int minimumDetections, NormalizeOption normalizeOption) { lock (_cacheInfo) { // Linear search, but very short list return(_cacheInfo.Data.FirstOrDefault(d => Equals(d._graphSettings.Group, group) && Equals(d._graphSettings.Annotation, annotation) && d._graphSettings.MinimumDetections == minimumDetections && d._graphSettings.NormalizeOption == normalizeOption)); } }
public AreaCVGraphSettings(GraphTypeSummary graphType, NormalizeOption normalizeOption, ReplicateValue group, object annotation, PointsTypePeakArea pointsType, double qValueCutoff, double cvCutoff, int minimumDetections, double binwidth, AreaCVMsLevel msLevel, AreaCVTransitions transitions, int countTransitions) { GraphType = graphType; NormalizeOption = normalizeOption; Group = group; Annotation = annotation; PointsType = pointsType; QValueCutoff = qValueCutoff; CVCutoff = cvCutoff; MinimumDetections = minimumDetections; BinWidth = binwidth; MsLevel = msLevel; Transitions = transitions; CountTransitions = countTransitions; }
/// <summary> /// Returns the ReplicateGroupOp based on the current value of Settings.Default.GroupByReplicateAnnotation, /// and the specified AggregateOp. Note that if the ReplicateGroupOp is not grouping on an annotation, /// the AggregateOp will be override with the value MEAN. /// </summary> public static ReplicateGroupOp FromCurrentSettings(SrmDocument document, GraphValues.AggregateOp aggregateOp) { ReplicateValue replicateValue = null; string annotationName = Settings.Default.GroupByReplicateAnnotation; if (null != annotationName) { replicateValue = ReplicateValue.GetGroupableReplicateValues(document) .FirstOrDefault(value => value.ToPersistedString() == annotationName); } if (null == replicateValue) { aggregateOp = GraphValues.AggregateOp.MEAN; } return(new ReplicateGroupOp(replicateValue, aggregateOp)); }
public AreaCVGraphSettings(SrmSettings srmSettings, GraphTypeSummary graphType, bool convertToDecimal = true) { var factor = !Settings.Default.AreaCVShowDecimals && convertToDecimal ? 0.01 : 1.0; GraphType = graphType; MsLevel = AreaGraphController.AreaCVMsLevel; Transitions = AreaGraphController.AreaCVTransitions; CountTransitions = AreaGraphController.AreaCVTransitionsCount; NormalizeOption = AreaGraphController.AreaCVNormalizeOption; Group = ReplicateValue.FromPersistedString(srmSettings, AreaGraphController.GroupByGroup); Annotation = AreaGraphController.GroupByAnnotation; PointsType = AreaGraphController.PointsType; QValueCutoff = Settings.Default.AreaCVQValueCutoff; CVCutoff = Settings.Default.AreaCVCVCutoff * factor; MinimumDetections = AreaGraphController.MinimumDetections; BinWidth = Settings.Default.AreaCVHistogramBinWidth * factor; }
private bool IsCurrentDataCached() { var info = _graphSummary.GraphPanes.FirstOrDefault() as IAreaCVHistogramInfo; if (info == null) { return(false); } var document = _graphSummary.DocumentUIContainer.DocumentUI; var normalizeOption = AreaGraphController.AreaCVNormalizeOption; return(info.Cache.IsValidFor(document, new AreaCVGraphData.AreaCVGraphSettings(document.Settings, _graphSummary.Type)) && info.Cache.Get(ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup), AreaGraphController.GroupByAnnotation, AreaGraphController.MinimumDetections, normalizeOption) != null); }
public void OnDocumentChanged(SrmDocument oldDocument, SrmDocument newDocument) { var settingsNew = newDocument.Settings; var settingsOld = oldDocument.Settings; if (GraphSummary.Type == GraphTypeSummary.histogram || GraphSummary.Type == GraphTypeSummary.histogram2d) { if (GroupByGroup != null && !ReferenceEquals(settingsNew.DataSettings.AnnotationDefs, settingsOld.DataSettings.AnnotationDefs)) { var groups = ReplicateValue.GetGroupableReplicateValues(newDocument); // The group we were grouping by has been removed if (groups.All(group => group.ToPersistedString() != GroupByGroup)) { GroupByAnnotation = GroupByGroup = null; } } if (GroupByAnnotation != null && settingsNew.HasResults && settingsOld.HasResults && !ReferenceEquals(settingsNew.MeasuredResults.Chromatograms, settingsOld.MeasuredResults.Chromatograms)) { var annotations = AnnotationHelper.GetPossibleAnnotations(newDocument, ReplicateValue.FromPersistedString(settingsNew, GroupByGroup)); // The annotation we were grouping by has been removed if (!annotations.Contains(GroupByAnnotation)) { GroupByAnnotation = null; } var paneInfo = GraphSummary.GraphPanes.FirstOrDefault() as IAreaCVHistogramInfo; if (paneInfo != null) { paneInfo.Cache.Cancel(); } } } }
protected virtual IEnumerable <ReplicateGroup> GetReplicateGroups(IEnumerable <int> replicateIndexes) { if (_document.Settings.MeasuredResults == null) { return(new ReplicateGroup[0]); // Likely user removed all results while Mass Errors window was open } var annotationCalculator = new AnnotationCalculator(_document); var chromatograms = _document.Settings.MeasuredResults.Chromatograms; var result = new List <ReplicateGroup>(); if (ReplicateGroupOp.GroupByValue == null) { foreach (var index in replicateIndexes) { var chromatogram = _document.MeasuredResults.Chromatograms[index]; result.AddRange(chromatogram.MSDataFileInfos.Select(fileInfo => new ReplicateGroup(chromatogram.Name, ReplicateIndexSet.Singleton(index), fileInfo))); } var query = result.OrderBy(g => 0); if (!string.IsNullOrEmpty(OrderByReplicateAnnotation)) { var orderByReplicateValue = ReplicateValue.FromPersistedString(_document.Settings, OrderByReplicateAnnotation); if (orderByReplicateValue != null) { query = result.OrderBy( g => orderByReplicateValue.GetValue(annotationCalculator, chromatograms[g.ReplicateIndexes.First()]), CollectionUtil.ColumnValueComparer); } } if (ReplicateOrder == SummaryReplicateOrder.document) { result = new List <ReplicateGroup>(query.ThenBy(g => g.ReplicateIndexes.ToArray(), Comparer <int[]> .Create((a, b) => { for (var i = 0; i < Math.Min(a.Length, b.Length); ++i) { if (a[i] != b[i]) { return(a[i].CompareTo(b[i])); } } return(a.Length.CompareTo(b.Length)); })).ThenBy(g => g.FileInfo.FileIndex)); } else if (ReplicateOrder == SummaryReplicateOrder.time) { result = new List <ReplicateGroup>(query .ThenBy(g => g.FileInfo.RunStartTime, Comparer <DateTime?> .Create( (a, b) => (a ?? DateTime.MaxValue).CompareTo( b ?? DateTime.MaxValue))).ThenBy(g => g.FileInfo.FileIndex).ToList()); } } else { var lookup = replicateIndexes.ToLookup(replicateIndex => ReplicateGroupOp.GroupByValue.GetValue(annotationCalculator, chromatograms[replicateIndex])); var keys = lookup.Select(grouping => grouping.Key).ToList(); if (keys.Count > 2) { // If there are more than 2 groups then exclude replicates with blank annotation values. keys.Remove(null); } keys.Sort(CollectionUtil.ColumnValueComparer); // ReSharper disable AssignNullToNotNullAttribute foreach (var key in keys) { result.Add(new ReplicateGroup(key?.ToString() ?? string.Empty, ReplicateIndexSet.OfValues(lookup[key]))); } // ReSharper restore AssignNullToNotNullAttribute } return(result.Distinct()); }
private static bool HasDistinctValues(AnnotationCalculator annotationCalculator, ReplicateValue replicateValue) { var settings = annotationCalculator.SrmDocument.Settings; if (!settings.HasResults) { return(false); } var values = settings.MeasuredResults.Chromatograms.Select(chromSet => replicateValue.GetValue(annotationCalculator, chromSet)).Distinct().ToArray(); return(values.Length > 1); }
public override void UpdateUI() { var document = _graphSummary.DocumentUIContainer.DocumentUI; if (!document.Settings.HasResults) { return; } var groupsVisible = AreaGraphController.GroupByGroup != null; toolStripLabel1.Visible = toolStripComboGroup.Visible = groupsVisible; var detectionsVisiblePrev = toolStripLabel2.Visible && toolStripNumericDetections.Visible && toolStripLabel3.Visible; var detectionsVisible = AreaGraphController.ShouldUseQValues(document); toolStripLabel2.Visible = toolStripNumericDetections.Visible = toolStripLabel3.Visible = detectionsVisible; if (detectionsVisible) { toolStripNumericDetections.NumericUpDownControl.Minimum = 2; if (AreaGraphController.GroupByGroup == null || AreaGraphController.GroupByAnnotation == null) { toolStripNumericDetections.NumericUpDownControl.Maximum = document.MeasuredResults.Chromatograms.Count; } else { toolStripNumericDetections.NumericUpDownControl.Maximum = AnnotationHelper.GetReplicateIndices(document, ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup), AreaGraphController.GroupByAnnotation).Length; } if (!detectionsVisiblePrev) { toolStripNumericDetections.NumericUpDownControl.Value = 2; } } if (groupsVisible) { var annotations = new[] { Resources.GraphSummary_UpdateToolbar_All }.Concat( AnnotationHelper.GetPossibleAnnotations(document, ReplicateValue.FromPersistedString(document.Settings, AreaGraphController.GroupByGroup)) .Except(new object[] { null })).ToArray(); toolStripComboGroup.Items.Clear(); // ReSharper disable once CoVariantArrayConversion toolStripComboGroup.Items.AddRange(annotations); if (AreaGraphController.GroupByAnnotation != null) { toolStripComboGroup.SelectedItem = AreaGraphController.GroupByAnnotation; } else { toolStripComboGroup.SelectedIndex = 0; } ComboHelper.AutoSizeDropDown(toolStripComboGroup); } toolStripComboNormalizedTo.Items.Clear(); _normalizationMethods.Clear(); _normalizationMethods.Add(NormalizeOption.DEFAULT); _normalizationMethods.AddRange(NormalizeOption.AvailableNormalizeOptions(_graphSummary.DocumentUIContainer.DocumentUI)); _normalizationMethods.Add(NormalizeOption.NONE); toolStripComboNormalizedTo.Items.AddRange(_normalizationMethods.Select(item => item.Caption).ToArray()); toolStripComboNormalizedTo.SelectedIndex = _normalizationMethods.IndexOf(AreaGraphController.AreaCVNormalizeOption); ComboHelper.AutoSizeDropDown(toolStripComboNormalizedTo); }
private ReplicateGroupOp(ReplicateValue groupByValue, GraphValues.AggregateOp aggregateOp) { GroupByValue = groupByValue; AggregateOp = aggregateOp; }