Exemplo n.º 1
0
 public ReplicateGroup(string groupName, ReplicateIndexSet replicateIndexes, ChromFileInfo fileInfo = null, bool isAllGroup = false)
 {
     GroupName        = groupName;
     FileInfo         = fileInfo;
     ReplicateIndexes = replicateIndexes;
     IsAllGroup       = isAllGroup;
 }
Exemplo n.º 2
0
            private void AddReplicateGroup(ICollection <ReplicateGroup> replicateGroups, DocNode docNode, int replicateIndex)
            {
                var nodeGroup = docNode as TransitionGroupDocNode;

                if (nodeGroup != null)
                {
                    var chromSet = _document.MeasuredResults.Chromatograms[replicateIndex];
                    foreach (var c in nodeGroup.ChromInfos)
                    {
                        var info = chromSet.GetFileInfo(c.FileId);
                        if (info != null)
                        {
                            replicateGroups.Add(new ReplicateGroup(chromSet.Name, ReplicateIndexSet.Singleton(replicateIndex), info));
                        }
                    }
                    return;
                }

                var nodePep = docNode as PeptideDocNode;

                if (nodePep != null)
                {
                    nodePep.TransitionGroups.ForEach(n => AddReplicateGroup(replicateGroups, n, replicateIndex));
                }
            }
Exemplo n.º 3
0
            private void InsertAllGroupsAndPointPairLists(string[] uniqueGroupNames, int docNodeCount)
            {
                var uniqueGroups = uniqueGroupNames.Select(n => new ReplicateGroup(n,
                                                                                   ReplicateIndexSet.OfValues(ReplicateGroups.Where(r => r.GroupName == n).SelectMany(r => r.ReplicateIndexes)),
                                                                                   null, true));

                var newGroups = ReplicateGroups.ToList();

                foreach (var group in uniqueGroups)
                {
                    var group1     = group;
                    var firstIndex = newGroups.IndexOf(r => r.GroupName == group1.GroupName);
                    newGroups.Insert(firstIndex, group);

                    for (var node = 0; node < docNodeCount; ++node)
                    {
                        for (var step = 0; step < PointPairLists[node].Count; ++step)
                        {
                            if (PointPairLists[node][step].Any())
                            {
                                PointPairLists[node][step].Insert(firstIndex, new PointPair(firstIndex, double.NaN));
                            }
                        }
                    }
                }
                ReplicateGroups = newGroups;
            }
            private IEnumerable <ReplicateGroup> GetReplicateGroups(IEnumerable <int> replicateIndexes)
            {
                var chromatograms = _document.Settings.MeasuredResults.Chromatograms;

                if (ReplicateGroupOp.GroupByAnnotation == null)
                {
                    return
                        (replicateIndexes.Select(replicateIndex
                                                 => new ReplicateGroup(chromatograms[replicateIndex].Name,
                                                                       ReplicateIndexSet.Singleton(replicateIndex))));
                }
                var lookup = replicateIndexes.ToLookup(replicateIndex => chromatograms[replicateIndex].Annotations.GetAnnotation(ReplicateGroupOp.GroupByAnnotation));
                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();
// ReSharper disable AssignNullToNotNullAttribute
                return(keys.Select(key => new ReplicateGroup((key ?? string.Empty).ToString(), ReplicateIndexSet.OfValues(lookup[key]))));
// ReSharper restore AssignNullToNotNullAttribute
            }
Exemplo n.º 5
0
            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());
            }
 public ReplicateGroup(string groupName, ReplicateIndexSet replicateIndexes)
 {
     GroupName        = groupName;
     ReplicateIndexes = replicateIndexes;
 }