当前位置: 首页>>代码示例>>C#>>正文


C# SrmDocument.ChangeChildrenChecked方法代码示例

本文整理汇总了C#中SrmDocument.ChangeChildrenChecked方法的典型用法代码示例。如果您正苦于以下问题:C# SrmDocument.ChangeChildrenChecked方法的具体用法?C# SrmDocument.ChangeChildrenChecked怎么用?C# SrmDocument.ChangeChildrenChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SrmDocument的用法示例。


在下文中一共展示了SrmDocument.ChangeChildrenChecked方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LookupProteinMetadata


//.........这里部分代码省略.........
                                                progressStatus =
                                                    progressStatus.ChangePercentComplete(100*nResolved++/nUnresolved));
                                        }
                                    }
                                    if (progressMonitor.IsCanceled)
                                    {
                                        progressMonitor.UpdateProgress(progressStatus.Cancel());
                                        return null;
                                    }
                                }
                            }
                        }
                        // ReSharper disable once EmptyGeneralCatchClause
                        catch
                        {
                            // The protDB file is busy, or some other issue - just go directly to web
                        }
                    }
                }
                if (nResolved != nUnresolved)
                {
                    try
                    {
                        // Now go to the web for more protein metadata (or pretend to, depending on WebEnabledFastaImporter.DefaultWebAccessMode)
                        var docNodesWithUnresolvedProteinMetadata = new Dictionary<ProteinSearchInfo,PeptideGroupDocNode>();
                        var proteinsToSearch = new List<ProteinSearchInfo>();
                        foreach (PeptideGroupDocNode node in docOrig.PeptideGroups)
                        {
                            if (node.ProteinMetadata.NeedsSearch() && !_processedNodes.ContainsKey(node.Id.GlobalIndex)) // Did we already process this?
                            {
                                var proteinMetadata = node.ProteinMetadata;
                                if (proteinMetadata.WebSearchInfo.IsEmpty()) // Never even been hit with regex
                                {
                                    // Use Regexes to get some metadata, and a search term
                                    var parsedProteinMetaData = FastaImporter.ParseProteinMetaData(proteinMetadata);
                                    if ((parsedProteinMetaData == null) || Equals(parsedProteinMetaData.Merge(proteinMetadata),proteinMetadata.SetWebSearchCompleted()))
                                    {
                                        // That didn't parse well enough to make a search term, or didn't add any new info - just set it as searched so we don't keep trying
                                        _processedNodes.Add(node.Id.GlobalIndex, proteinMetadata.SetWebSearchCompleted());
                                        progressMonitor.UpdateProgress(progressStatus = progressStatus.ChangePercentComplete(100 * nResolved++ / nUnresolved));
                                        proteinMetadata = null;  // No search to be done
                                    }
                                    else
                                    {
                                        proteinMetadata = proteinMetadata.Merge(parsedProteinMetaData);  // Fill in any gaps with parsed info
                                    }
                                }
                                if (proteinMetadata != null)
                                {
                                    // We note the sequence length because it's useful in disambiguating search results
                                    proteinsToSearch.Add(new ProteinSearchInfo(new DbProteinName(null, proteinMetadata),
                                        node.PeptideGroup.Sequence == null ? 0 : node.PeptideGroup.Sequence.Length));
                                    docNodesWithUnresolvedProteinMetadata.Add(proteinsToSearch.Last(), node);
                                }
                            }
                        }
                        if (progressMonitor.IsCanceled)
                        {
                            progressMonitor.UpdateProgress(progressStatus.Cancel());
                            return null;
                        }
                        progressMonitor.UpdateProgress(progressStatus = progressStatus.ChangePercentComplete(100 * nResolved / nUnresolved));

                        // Now we actually hit the internet
                        if (proteinsToSearch.Any())
                        {
                            foreach (var result in FastaImporter.DoWebserviceLookup(proteinsToSearch, progressMonitor, false)) // Resolve them all, now
                            {
                                Debug.Assert(!result.GetProteinMetadata().NeedsSearch());
                                _processedNodes.Add(docNodesWithUnresolvedProteinMetadata[result].Id.GlobalIndex, result.GetProteinMetadata());
                                progressMonitor.UpdateProgress(progressStatus = progressStatus.ChangePercentComplete(100 * nResolved++ / nUnresolved));
                            }
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        progressMonitor.UpdateProgress(progressStatus.Cancel());
                        return null;
                    }

                }

                // And finally write back to the document
                var listProteins = new List<PeptideGroupDocNode>();
                foreach (PeptideGroupDocNode node in docOrig.MoleculeGroups)
                {
                    if (_processedNodes.ContainsKey(node.Id.GlobalIndex))
                    {
                        listProteins.Add(node.ChangeProteinMetadata(_processedNodes[node.Id.GlobalIndex]));
                    }
                    else
                    {
                        listProteins.Add(node);
                    }
                }
                var docNew = docOrig.ChangeChildrenChecked(listProteins.Cast<DocNode>().ToArray());
                progressMonitor.UpdateProgress(progressStatus.Complete());
                return (SrmDocument)docNew;
            }
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:ProteinMetadataManager.cs

示例2: Refine

        public SrmDocument Refine(SrmDocument document, SrmSettingsChangeMonitor progressMonitor)
        {
            HashSet<int> outlierIds = new HashSet<int>();
            if (RTRegressionThreshold.HasValue)
            {
                // TODO: Move necessary code into Model.
                var outliers = RTLinearRegressionGraphPane.CalcOutliers(document,
                    RTRegressionThreshold.Value, RTRegressionPrecision, UseBestResult);

                foreach (var nodePep in outliers)
                    outlierIds.Add(nodePep.Id.GlobalIndex);
            }

            HashSet<RefinementIdentity> includedPeptides = (RemoveRepeatedPeptides ? new HashSet<RefinementIdentity>() : null);
            HashSet<RefinementIdentity> repeatedPeptides = (RemoveDuplicatePeptides ? new HashSet<RefinementIdentity>() : null);
            Dictionary<RefinementIdentity, List<int>> acceptedPeptides = null;
            if (AcceptedPeptides != null)
            {
                acceptedPeptides = new Dictionary<RefinementIdentity, List<int>>();
                foreach (var peptideCharge in AcceptedPeptides)
                {
                    List<int> charges;
                    if (!acceptedPeptides.TryGetValue(new RefinementIdentity(peptideCharge.Sequence), out charges))
                    {
                        charges = (peptideCharge.Charge.HasValue ? new List<int> {peptideCharge.Charge.Value} : null);
                        acceptedPeptides.Add(new RefinementIdentity(peptideCharge.Sequence), charges);
                    }
                    else if (charges != null)
                    {
                        if (peptideCharge.Charge.HasValue)
                            charges.Add(peptideCharge.Charge.Value);
                        else
                            acceptedPeptides[new RefinementIdentity(peptideCharge.Sequence)] = null;
                    }
                }
            }
            HashSet<string> acceptedProteins = (AcceptedProteins != null ? new HashSet<string>(AcceptedProteins) : null);

            var listPepGroups = new List<PeptideGroupDocNode>();
            // Excluding proteins with too few peptides, since they can impact results
            // of the duplicate peptide check.
            int minPeptides = MinPeptidesPerProtein ?? 0;
            foreach (PeptideGroupDocNode nodePepGroup in document.Children)
            {
                if (progressMonitor != null)
                    progressMonitor.ProcessGroup(nodePepGroup);

                if (acceptedProteins != null && !acceptedProteins.Contains(GetAcceptProteinKey(nodePepGroup)))
                    continue;

                PeptideGroupDocNode nodePepGroupRefined = nodePepGroup;
                // If auto-managing all peptides, make sure this flag is set correctly,
                // and update the peptides list, if necessary.
                if (AutoPickPeptidesAll && nodePepGroup.AutoManageChildren == AutoPickChildrenOff)
                {
                    nodePepGroupRefined =
                        (PeptideGroupDocNode) nodePepGroupRefined.ChangeAutoManageChildren(!AutoPickChildrenOff);
                    var settings = document.Settings;
                    if (!AutoPickChildrenOff && !settings.PeptideSettings.Filter.AutoSelect)
                        settings = settings.ChangePeptideFilter(filter => filter.ChangeAutoSelect(true));
                    nodePepGroupRefined = nodePepGroupRefined.ChangeSettings(settings,
                        new SrmSettingsDiff(true, false, false, false, false, false));
                }

                nodePepGroupRefined = Refine(nodePepGroupRefined, document, outlierIds,
                        includedPeptides, repeatedPeptides, acceptedPeptides, progressMonitor);

                if (nodePepGroupRefined.Children.Count < minPeptides)
                    continue;

                listPepGroups.Add(nodePepGroupRefined);
            }

            // Need a second pass, if all duplicate peptides should be removed,
            // and duplicates were found.
            if (repeatedPeptides != null && repeatedPeptides.Count > 0)
            {
                var listPepGroupsFiltered = new List<PeptideGroupDocNode>();
                foreach (PeptideGroupDocNode nodePepGroup in listPepGroups)
                {
                    var listPeptides = new List<PeptideDocNode>();
                    foreach (PeptideDocNode nodePep in nodePepGroup.Children)
                    {
                        var identity = nodePep.Peptide.IsCustomIon
                            ? new RefinementIdentity(nodePep.Peptide.CustomIon)
                            : new RefinementIdentity(document.Settings.GetModifiedSequence(nodePep));
                        if (!repeatedPeptides.Contains(identity))
                            listPeptides.Add(nodePep);
                    }

                    PeptideGroupDocNode nodePepGroupRefined = (PeptideGroupDocNode)
                        nodePepGroup.ChangeChildrenChecked(listPeptides.ToArray(), true);

                    if (nodePepGroupRefined.Children.Count < minPeptides)
                        continue;

                    listPepGroupsFiltered.Add(nodePepGroupRefined);
                }

                listPepGroups = listPepGroupsFiltered;
//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:RefinementSettings.cs

示例3: UpdateExistingPeptides

 /// <summary>
 /// Enumerate all document peptides. If a library peptide already exists in the
 /// current document, update the transition groups for that document peptide and
 /// remove the peptide from the list to add.
 /// </summary>
 /// <param name="document">The starting document</param>
 /// <param name="dictCopy">A dictionary of peptides to peptide matches. All added
 /// peptides are removed</param>
 /// <param name="toPath">Currently selected path.</param>
 /// <param name="selectedPath">Selected path after the nodes have been added</param>
 /// <returns>A new document with precursors for existing petides added</returns>
 private SrmDocument UpdateExistingPeptides(SrmDocument document,
     Dictionary<PeptideSequenceModKey, PeptideMatch> dictCopy,
     IdentityPath toPath, out IdentityPath selectedPath)
 {
     selectedPath = toPath;
     IList<DocNode> nodePepGroups = new List<DocNode>();
     foreach (PeptideGroupDocNode nodePepGroup in document.PeptideGroups)
     {
         IList<DocNode> nodePeps = new List<DocNode>();
         foreach (PeptideDocNode nodePep in nodePepGroup.Children)
         {
             var key = nodePep.SequenceKey;
             PeptideMatch peptideMatch;
             // If this peptide is not in our list of peptides to add,
             // or if we are in a peptide list and this peptide has been matched to protein(s),
             // then we don't touch this particular node.
             if (!dictCopy.TryGetValue(key, out peptideMatch) ||
                 (nodePepGroup.IsPeptideList &&
                 (peptideMatch.Proteins != null && peptideMatch.Proteins.Any())))
                 nodePeps.Add(nodePep);
             else
             {
                 var proteinName = nodePepGroup.PeptideGroup.Name;
                 int indexProtein = -1;
                 if (peptideMatch.Proteins != null)
                 {
                     indexProtein =
                         peptideMatch.Proteins.IndexOf(protein => Equals(protein.ProteinMetadata.Name, proteinName));
                     // If the user has opted to filter duplicate peptides, remove this peptide from the list to
                     // add and continue.
                     if(FilterMultipleProteinMatches == BackgroundProteome.DuplicateProteinsFilter.NoDuplicates && peptideMatch.Proteins.Count > 1)
                     {
                         dictCopy.Remove(key);
                         nodePeps.Add(nodePep);
                         continue;
                     }
                     // [1] If this protein is not the first match, and the user has opted to add only the first occurence,
                     // [2] or if this protein is not one of the matches, and [2a] we are either not in a peptide list
                     // [2b] or the user has opted to filter unmatched peptides, ignore this particular node.
                     if((indexProtein > 0 && FilterMultipleProteinMatches == BackgroundProteome.DuplicateProteinsFilter.FirstOccurence) ||
                        (indexProtein == -1 &&
                        (!nodePepGroup.IsPeptideList || !Properties.Settings.Default.LibraryPeptidesAddUnmatched)))
                     {
                         nodePeps.Add(nodePep);
                         continue;
                     }
                 }
                 // Update the children of the peptide in the document to include the charge state of the peptide we are adding.
                 PeptideDocNode nodePepMatch = peptideMatch.NodePep;
                 PeptideDocNode nodePepSettings = null;
                 var newChildren = nodePep.Children.ToList();
                 Identity nodeGroupChargeId = newChildren.Count > 0 ? newChildren[0].Id : null;
                 foreach (TransitionGroupDocNode nodeGroup in nodePepMatch.Children)
                 {
                     int chargeGroup = nodeGroup.TransitionGroup.PrecursorCharge;
                     if (nodePep.HasChildCharge(chargeGroup))
                         SkippedPeptideCount++;
                     else
                     {
                         if (nodePepSettings == null)
                             nodePepSettings = nodePepMatch.ChangeSettings(document.Settings, SrmSettingsDiff.ALL);
                         TransitionGroupDocNode nodeGroupCharge = (TransitionGroupDocNode) nodePepSettings.FindNode(nodeGroup.TransitionGroup);
                         if (nodeGroupCharge == null)
                         {
                             continue;
                         }
                         if(peptideMatch.Proteins != null && peptideMatch.Proteins.Count() > 1)
                         {
                             // If we may be adding this specific node to the document more than once, create a copy of it so that
                             // we don't have two nodes with the same global id.
                             nodeGroupCharge = (TransitionGroupDocNode) nodeGroupCharge.CopyId();
                             nodeGroupCharge = (TransitionGroupDocNode) nodeGroupCharge.ChangeChildren(
                                 nodeGroupCharge.Children.ToList().ConvertAll(child => child.CopyId()));
                         }
                         nodeGroupChargeId = nodeGroupCharge.Id;
                         newChildren.Add(nodeGroupCharge);
                     }
                 }
                 // Sort the new peptide children.
                 newChildren.Sort(Peptide.CompareGroups);
                 var nodePepAdd = nodePep.ChangeChildrenChecked(newChildren);
                 // If we have changed the children, need to set automanage children to false.
                 if (nodePep.AutoManageChildren && !ReferenceEquals(nodePep, nodePepAdd))
                     nodePepAdd = nodePepAdd.ChangeAutoManageChildren(false);
                 // Change the selected path.
                 if (PeptideMatches.Count == 1)
                 {
                     selectedPath = nodeGroupChargeId == null
                                         ? new IdentityPath(new[] { nodePepGroup.Id, nodePepAdd.Id })
//.........这里部分代码省略.........
开发者ID:lgatto,项目名称:proteowizard,代码行数:101,代码来源:ViewLibraryPepMatching.cs


注:本文中的SrmDocument.ChangeChildrenChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。