예제 #1
0
 public GroupComparisonResults(
     GroupComparer groupComparer,
     IEnumerable <GroupComparisonResult> resultRows,
     DateTime startTime,
     DateTime endTime)
 {
     GroupComparer = groupComparer;
     ResultRows    = ImmutableList.ValueOf(resultRows);
     StartTime     = startTime;
     EndTime       = endTime;
 }
예제 #2
0
        private GroupComparisonResults ComputeComparisonResults(GroupComparer groupComparer, SrmDocument document,
                                                                CancellationToken cancellationToken)
        {
            DateTime startTime = DateTime.Now;

            List <GroupComparisonResult> results = new List <GroupComparisonResult>();

            if (groupComparer.IsValid)
            {
                results = ComputeResults(groupComparer, document, cancellationToken, _lock);
            }
            DateTime endTime = DateTime.Now;

            return(new GroupComparisonResults(groupComparer, results, startTime, endTime));
        }
예제 #3
0
        private void RestartCalculation()
        {
            var srmDocument        = Document;
            var groupComparisonDef = GroupComparisonDef;

            if (_results != null)
            {
                if (Equals(_results.Document, srmDocument) && Equals(_results.GroupComparer.ComparisonDef, groupComparisonDef))
                {
                    return;
                }
            }
            if (null != _cancellationTokenSource)
            {
                _cancellationTokenSource.Cancel();
                _cancellationTokenSource = null;
            }
            if (0 == _modelChangedListeners.Count)
            {
                return;
            }
            if (_groupComparer == null || !Equals(srmDocument, _groupComparer.SrmDocument) ||
                !Equals(groupComparisonDef, _groupComparer.ComparisonDef))
            {
                _groupComparer = new GroupComparer(groupComparisonDef, srmDocument, _qrFactorizationCache);
            }
            _cancellationTokenSource = new CancellationTokenSource();
            if (null != GroupComparisonDef && null != Document)
            {
                _percentComplete = 0;
                GroupComparer groupComparer     = _groupComparer;
                var           cancellationToken = _cancellationTokenSource.Token;
                AddErrorHandler(Task.Factory.StartNew(() =>
                {
                    var results = ComputeComparisonResults(groupComparer, srmDocument, cancellationToken);
                    lock (_lock)
                    {
                        if (!cancellationToken.IsCancellationRequested)
                        {
                            Results          = results;
                            _percentComplete = 100;
                        }
                    }
                }, _cancellationTokenSource.Token));
            }
        }
예제 #4
0
        public static List <GroupComparisonResult> ComputeResults(GroupComparer groupComparer, SrmDocument document,
                                                                  CancellationToken?cancellationToken, object _lock, SrmSettingsChangeMonitor progressMonitor = null)
        {
            var results       = new List <GroupComparisonResult>();
            var peptideGroups = document.MoleculeGroups.ToArray();

            for (int i = 0; i < peptideGroups.Length; i++)
            {
                if (_lock != null)
                {
                    lock (_lock)
                    {
                        if (cancellationToken.HasValue)
                        {
                            cancellationToken.Value.ThrowIfCancellationRequested();
                        }
                    }
                }

                var peptideGroup = peptideGroups[i];
                IEnumerable <PeptideDocNode> peptides;
                if (groupComparer.ComparisonDef.PerProtein)
                {
                    peptides = new PeptideDocNode[] { null };
                }
                else
                {
                    peptides = peptideGroup.Molecules;
                }
                foreach (var peptide in peptides)
                {
                    if (progressMonitor != null && progressMonitor.IsCanceled())
                    {
                        throw new OperationCanceledException();
                    }
                    if (progressMonitor != null)
                    {
                        progressMonitor.ProcessMolecule(peptide);
                    }
                    results.AddRange(groupComparer.CalculateFoldChanges(peptideGroup, peptide));
                }
            }

            return(results);
        }
예제 #5
0
        private GroupComparisonResults ComputeComparisonResults(GroupComparer groupComparer, SrmDocument document,
                                                                CancellationToken cancellationToken)
        {
            DateTime startTime = DateTime.Now;

            List <GroupComparisonResult> results = new List <GroupComparisonResult>();

            if (groupComparer.IsValid)
            {
                var peptideGroups = document.MoleculeGroups.ToArray();
                for (int i = 0; i < peptideGroups.Length; i++)
                {
                    int percentComplete = 100 * i / peptideGroups.Length;
                    lock (_lock)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        _percentComplete = percentComplete;
                    }
                    var peptideGroup = peptideGroups[i];
                    IEnumerable <PeptideDocNode> peptides;
                    if (groupComparer.ComparisonDef.PerProtein)
                    {
                        peptides = new PeptideDocNode[] { null };
                    }
                    else
                    {
                        peptides = peptideGroup.Molecules;
                    }
                    foreach (var peptide in peptides)
                    {
                        results.AddRange(groupComparer.CalculateFoldChanges(peptideGroup, peptide));
                    }
                }
            }
            DateTime endTime = DateTime.Now;

            return(new GroupComparisonResults(groupComparer, results, startTime, endTime));
        }