Exemple #1
0
        /// <summary>
        ///  Create PeptideModifications matching the modifications indicated in the library.
        /// </summary>
        /// <param name="settings">The settings for the document for which the matches will be made</param>
        public PeptideModifications CreateMatcherPeptideSettings(SrmSettings settings)
        {
            var lightMods = new List <StaticMod>();
            var heavyMods = new Dictionary <IsotopeLabelType, List <StaticMod> >();

            if (HasMatches)
            {
                foreach (var matchPair in Matches)
                {
                    var       structuralMod = matchPair.Value.StructuralMod;
                    StaticMod mod1          = structuralMod;
                    if (structuralMod != null && !lightMods.Contains(mod => mod.Equivalent(mod1)))
                    {
                        // Make all found structural mods variable, unless they are preexisting modifications.
                        if (!UserDefinedTypedMods.ContainsKey(structuralMod) || structuralMod.IsUserSet)
                        {
                            structuralMod = structuralMod.ChangeVariable(true);
                        }
                        // Set modification to be implicit if it appears to be implicit in the library.
                        if (!UserDefinedTypedMods.ContainsKey(structuralMod) && !IsVariableMod(structuralMod))
                        {
                            structuralMod = structuralMod.ChangeExplicit(false);
                        }
                        lightMods.Add(structuralMod);
                    }
                    var heavyMod = matchPair.Value.HeavyMod;
                    if (heavyMod == null)
                    {
                        continue;
                    }
                    IsotopeLabelType labelType;
                    if (!UserDefinedTypedMods.TryGetValue(heavyMod, out labelType))
                    {
                        labelType = DocDefHeavyLabelType;
                    }
                    heavyMod = heavyMod.ChangeExplicit(false);
                    if (!heavyMods.ContainsKey(labelType))
                    {
                        heavyMods.Add(labelType, new List <StaticMod> {
                            heavyMod
                        });
                    }
                    else if (!heavyMods[labelType].Contains(mod => mod.Equivalent(heavyMod)))
                    {
                        heavyMods[labelType].Add(heavyMod);
                    }
                }
            }
            var typedModifications = new List <TypedModifications>();

            foreach (var labelType in heavyMods.Keys)
            {
                typedModifications.Add(new TypedModifications(labelType, heavyMods[labelType]));
            }
            var mods = settings.PeptideSettings.Modifications;

            return(new PeptideModifications(lightMods, mods.MaxVariableMods, mods.MaxNeutralLosses,
                                            typedModifications, new[] { IsotopeLabelType.heavy }));
        }