Example #1
0
        public IEnumerable <ColumnDescriptor> EnumerateAllColumnDescriptors(DataSchema dataSchema,
                                                                            ICollection <Type> startingTypes)
        {
            var typeQueue      = new Queue <Type>(startingTypes);
            var processedTypes = new HashSet <Type>();

            while (typeQueue.Count > 0)
            {
                var type = typeQueue.Dequeue();
                if (!processedTypes.Add(type))
                {
                    continue;
                }

                foreach (var uiMode in UiModes.AllModes)
                {
                    var rootColumn = ColumnDescriptor.RootColumn(dataSchema, type, uiMode.Name);
                    foreach (var child in GetChildColumns(rootColumn))
                    {
                        typeQueue.Enqueue(child.PropertyType);
                        yield return(child);

                        foreach (var grandChild in GetChildColumns(child))
                        {
                            yield return(grandChild);

                            if (grandChild.GetAttributes().OfType <ChildDisplayNameAttribute>().Any() &&
                                child.GetAttributes().OfType <ChildDisplayNameAttribute>().Any())
                            {
                                Assert.Fail("Two levels of child display names found on property {0} of type {1}",
                                            grandChild.PropertyPath, rootColumn.PropertyType);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private void UpdateViewContext()
        {
            RememberActiveView();
            IRowSource rowSource       = null;
            Type       rowType         = null;
            string     builtInViewName = null;

            if (_selectedIdentityPaths.Count == 1)
            {
                var identityPath = _selectedIdentityPaths[0];
                if (identityPath.Length == 2)
                {
                    rowSource       = new PeptideResultList(new Peptide(_dataSchema, identityPath));
                    rowType         = typeof(PeptideResult);
                    builtInViewName = "Peptide Results"; // Not L10N
                }
                else if (identityPath.Length == 3)
                {
                    rowSource       = new PrecursorResultList(new Precursor(_dataSchema, identityPath));
                    rowType         = typeof(PrecursorResult);
                    builtInViewName = "Precursor Results"; // Not L10N
                }
                else if (identityPath.Length == 4)
                {
                    rowSource       = new TransitionResultList(new Transition(_dataSchema, identityPath));
                    rowType         = typeof(TransitionResult);
                    builtInViewName = "Transition Results"; // Not L10N
                }
            }
            else
            {
                // ReSharper disable PossibleMultipleEnumeration
                var pathLengths = _selectedIdentityPaths.Select(path => path.Length).Distinct().ToArray();
                if (pathLengths.Length == 1)
                {
                    var pathLength = pathLengths[0];
                    if (pathLength == 3)
                    {
                        rowSource = new MultiPrecursorResultList(_dataSchema,
                                                                 _selectedIdentityPaths.Select(idPath => new Precursor(_dataSchema, idPath)));
                        rowType         = typeof(MultiPrecursorResult);
                        builtInViewName = "Multiple Precursor Results"; // Not L10N
                    }
                    if (pathLength == 4)
                    {
                        rowSource = new MultiTransitionResultList(_dataSchema,
                                                                  _selectedIdentityPaths.Select(idPath => new Transition(_dataSchema, idPath)));
                        rowType         = typeof(MultiTransitionResult);
                        builtInViewName = "Multiple Transition Results"; // Not L10N
                    }
                }
                // ReSharper restore PossibleMultipleEnumeration
            }
            if (rowSource == null)
            {
                rowSource       = new ReplicateList(_dataSchema);
                rowType         = typeof(Replicate);
                builtInViewName = "Replicates"; // Not L10N
            }
            var parentColumn    = ColumnDescriptor.RootColumn(_dataSchema, rowType);
            var builtInViewSpec = SkylineViewContext.GetDefaultViewInfo(parentColumn).GetViewSpec()
                                  .SetName(builtInViewName).SetRowType(rowType);

            if (null == BindingListSource.ViewContext ||
                !BindingListSource.ViewContext.GetViewSpecList(ViewGroup.BUILT_IN.Id).ViewSpecs.Contains(builtInViewSpec))
            {
                var oldViewContext = BindingListSource.ViewContext as ResultsGridViewContext;
                if (null != oldViewContext)
                {
                    oldViewContext.RememberColumnWidths(DataGridView);
                }
                Debug.Assert(null != builtInViewName);
                var builtInView   = new ViewInfo(parentColumn, builtInViewSpec).ChangeViewGroup(ViewGroup.BUILT_IN);
                var rowSourceInfo = new RowSourceInfo(rowSource, builtInView);
                var viewContext   = new ResultsGridViewContext(_dataSchema,
                                                               new[] { rowSourceInfo });
                ViewInfo activeView = null;
                string   activeViewName;
                if (Settings.Default.ResultsGridActiveViews.TryGetValue(rowSourceInfo.Name, out activeViewName))
                {
                    activeView = viewContext.GetViewInfo(ViewName.Parse(activeViewName));
                }
                activeView = activeView ?? builtInView;
                BindingListSource.SetViewContext(viewContext, activeView);
            }
            BindingListSource.RowSource = rowSource;
        }
        private void btnRequery_Click(object sender, EventArgs e)
        {
            var halfLifeCalculator = new HalfLifeCalculator(Workspace, HalfLifeSettings)
            {
                ByFile = cbxGroupByFile.Checked,
            };

            using (var longWaitDialog = new LongWaitDialog(TopLevelControl, "Calculating Half Lives"))
            {
                var longOperationBroker = new LongOperationBroker(halfLifeCalculator.Run, longWaitDialog);
                if (!longOperationBroker.LaunchJob())
                {
                    return;
                }
            }
            bool byCohort    = cbxGroupByCohort.Checked;
            bool byTimePoint = cbxGroupByTimePoint.Checked;
            bool bySample    = cbxGroupBySample.Checked;
            bool byFile      = cbxGroupByFile.Checked;
            var  displayRows = new List <DisplayRow>();

            foreach (var resultRow in halfLifeCalculator.ResultRows)
            {
                var displayRow       = new DisplayRow(halfLifeCalculator, resultRow);
                var rowDatasByCohort = new Dictionary <GroupKey, List <HalfLifeCalculator.ProcessedRowData> >();
                foreach (var halfLife in resultRow.HalfLives)
                {
                    if (resultRow.HalfLives.Count > 1 && string.IsNullOrEmpty(halfLife.Key) != byCohort)
                    {
                        continue;
                    }
                    foreach (var rowData in halfLife.Value.FilteredRowDatas)
                    {
                        GroupKey cohortKey = new GroupKey(
                            byCohort ? rowData.RawRowData.MsDataFile.Cohort : null,
                            byTimePoint ? rowData.RawRowData.MsDataFile.TimePoint : null,
                            bySample ? rowData.RawRowData.MsDataFile.Sample : null,
                            byFile ? rowData.RawRowData.MsDataFile.Name : null);
                        List <HalfLifeCalculator.ProcessedRowData> list;
                        if (!rowDatasByCohort.TryGetValue(cohortKey, out list))
                        {
                            list = new List <HalfLifeCalculator.ProcessedRowData>();
                            rowDatasByCohort.Add(cohortKey, list);
                        }
                        list.Add(rowData);
                    }
                }
                foreach (var cohortRowDatas in rowDatasByCohort)
                {
                    displayRow.Results.Add(cohortRowDatas.Key, new GroupResult(this, displayRow, cohortRowDatas.Key, new ResultData(cohortRowDatas.Value)));
                }
                displayRows.Add(displayRow);
            }
            var viewInfo   = bindingSource1.ViewInfo;
            var dataSchema = new TopographDataSchema(Workspace);

            if (viewInfo == null || "default" == viewInfo.Name)
            {
                viewInfo = new ViewInfo(ColumnDescriptor.RootColumn(dataSchema, typeof(DisplayRow)),
                                        GetDefaultViewSpec(halfLifeCalculator.ByProtein));
            }
            var viewContext = new TopographViewContext(Workspace, typeof(DisplayRow), displayRows,
                                                       GetDefaultViewSpec(halfLifeCalculator.ByProtein));

            bindingSource1.SetViewContext(viewContext, viewInfo);
            bindingSource1.RowSource = displayRows;
            dataGridViewSummary.Rows.Clear();
            SetSummary("Tracer %", displayRows.Select(dr => dr.Results).SelectMany(r => r.Values
                                                                                   .Select(cohortResult => cohortResult.GetResultData().TracerPercentByArea)));
            SetSummary("Precursor Enrichment", displayRows.Select(dr => dr.Results).SelectMany(r => r.Values
                                                                                               .Select(cohortResult => cohortResult.GetResultData().IndPrecursorEnrichment)));
            SetSummary("Turnover", displayRows.Select(dr => dr.Results).SelectMany(r => r.Values
                                                                                   .Select(cohortResult => cohortResult.GetResultData().IndTurnover)));
            SetSummary("Area Under Curve", displayRows.Select(dr => dr.Results).SelectMany(r => r.Values
                                                                                           .Select(cohortResult => cohortResult.GetResultData().AreaUnderCurve)));
        }