Beispiel #1
0
 public TransitionLoss(StaticMod precursorMod, FragmentLoss loss, MassType massType)
     : this()
 {
     PrecursorMod = precursorMod;
     Loss         = loss;
     Mass         = Loss.GetMass(massType);
 }
Beispiel #2
0
        public void AddModification(StaticMod mod, ModType type)
        {
            if (mod == null)
            {
                return;
            }

            ImportPeptideSearch.UserDefinedTypedMods.Add(mod);

            PeptideModifications peptideModifications = SkylineWindow.Document.Settings.PeptideSettings.Modifications;

            if (type == ModType.structural)
            {
                peptideModifications = peptideModifications.ChangeStaticModifications(
                    peptideModifications.StaticModifications.Concat(new[] { mod }).ToArray());
            }
            else
            {
                peptideModifications = peptideModifications.AddHeavyModifications(new[] { mod });
            }

            SkylineWindow.ChangeSettings(SkylineWindow.Document.Settings.ChangePeptideSettings(
                                             SkylineWindow.Document.Settings.PeptideSettings.ChangeModifications(peptideModifications)),
                                         true,
                                         string.Format(Resources.MatchModificationsControl_AddModification_Add__0__modification__1_, type, mod.Name));
            SkylineWindow.Document.Settings.UpdateDefaultModifications(false);

            FillLists(SkylineWindow.Document);
        }
Beispiel #3
0
        private bool HasAppropriateLinkedPeptide(StaticMod staticMod, int indexAA)
        {
            if (staticMod?.CrosslinkerSettings == null)
            {
                return(true);
            }
            LinkedPeptide linkedPeptide;

            _linkedPeptides.TryGetValue(indexAA, out linkedPeptide);
            if (linkedPeptide == null)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(staticMod.AAs))
            {
                string sequence = linkedPeptide.PeptideSequence ?? NodePeptide.Peptide.Sequence;
                char   aa       = sequence[linkedPeptide.IndexAa];
                if (!staticMod.AAs.Contains(aa))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #4
0
        public void Add(double mass, StaticMod mod, bool allowDuplicates)
        {
            var list = _listMasses;

            switch (mod.Terminus)
            {
            case null:
                if (string.IsNullOrEmpty(mod.AAs))
                {
                    list = _listAllAAsMasses;
                }
                break;

            case ModTerminus.C:
                list = _listCTerminalMasses;
                break;

            case ModTerminus.N:
                list = _listNTerminalMasses;
                break;
            }
            if (allowDuplicates || !list.Contains(pair => pair.Key == mass))
            {
                list.Add(new KeyValuePair <double, StaticMod>(mass, mod));
            }
        }
        public void AddModification(StaticMod mod, ModType type)
        {
            if (mod == null)
            {
                return;
            }

            ImportPeptideSearch.UserDefinedTypedMods.Add(mod);

            PeptideModifications peptideModifications = DocumentContainer.Document.Settings.PeptideSettings.Modifications;

            if (type == ModType.structural)
            {
                peptideModifications = peptideModifications.ChangeStaticModifications(
                    peptideModifications.StaticModifications.Concat(new[] { mod }).ToArray());
            }
            else
            {
                peptideModifications = peptideModifications.AddHeavyModifications(new[] { mod });
            }

            DocumentContainer.ModifyDocumentNoUndo(doc => doc.ChangeSettings(DocumentContainer.Document.Settings.ChangePeptideSettings(
                                                                                 DocumentContainer.Document.Settings.PeptideSettings.ChangeModifications(peptideModifications))));

            DocumentContainer.Document.Settings.UpdateDefaultModifications(false);

            FillLists(DocumentContainer.Document);
        }
Beispiel #6
0
        public void TestCrosslinkGetNeutralFormula()
        {
            var mainPeptide = new Peptide("MERCURY");
            var srmSettings = SrmSettingsList.GetDefault();

            srmSettings = srmSettings.ChangePeptideSettings(
                srmSettings.PeptideSettings.ChangeModifications(srmSettings.PeptideSettings.Modifications
                                                                .ChangeStaticModifications(new StaticMod[0])));
            var transitionGroup            = new TransitionGroup(mainPeptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light);
            var mainTransitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, srmSettings,
                                                                        null, null, ExplicitTransitionGroupValues.EMPTY, null, null, false);
            var unlinkedFormula = mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, null);

            Assert.AreEqual("C37H61N13O11S2Se", unlinkedFormula.ToString());

            var linkedPeptide = new LinkedPeptide(new Peptide("ARSENIC"), 2, null);

            var linkedPeptideFormula = linkedPeptide.GetNeutralFormula(srmSettings, IsotopeLabelType.light);

            Assert.AreEqual("C30H53N11O12S", linkedPeptideFormula.ToString());
            var crosslinkMod = new StaticMod("disulfide", null, null, "-H2");


            var explicitModsWithCrosslink = new ExplicitMods(mainPeptide,
                                                             new[] { new ExplicitMod(3, crosslinkMod).ChangeLinkedPeptide(linkedPeptide) },
                                                             new TypedExplicitModifications[0]);
            var crosslinkedFormula =
                mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, explicitModsWithCrosslink);

            Assert.AreEqual("C67H112N24O23S3Se", crosslinkedFormula.Molecule.ToString());
        }
 public void AddModification(StaticMod mod, IsotopeLabelType labelType)
 {
     if (MatcherPepMods.GetModificationTypes().Contains(labelType))
     {
         var newMods = MatcherPepMods.GetModifications(labelType)
                       .Where(existingMod => !existingMod.Equivalent(mod)).ToList();
         newMods.Add(mod);
         MatcherPepMods = MatcherPepMods.ChangeModifications(labelType, newMods);
     }
     else if (labelType.IsLight)
     {
         MatcherPepMods =
             new PeptideModifications(new List <StaticMod> {
             mod
         }, MatcherPepMods.GetHeavyModifications().ToArray());
     }
     else
     {
         var typedHeavyMods =
             new List <TypedModifications>(MatcherPepMods.GetHeavyModifications())
         {
             new TypedModifications(labelType, new List <StaticMod> {
                 mod
             })
         };
         MatcherPepMods = new PeptideModifications(MatcherPepMods.StaticModifications, typedHeavyMods);
     }
     MatchesUpdated = true;
 }
        private static string GetMatchString(AAModKey key, StaticMod staticMod, bool structural)
        {
            string formatString = structural ? @"{0}[{1}{2}]" : @"{0}{{{1}{2}}}";
            var    modMass      = Math.Round(GetDefaultModMass(key.AA, staticMod), key.RoundedTo);

            return(string.Format(formatString, key.AA, (modMass > 0 ? @"+" : string.Empty), modMass));
        }
Beispiel #9
0
        public void TestGetIonFormula()
        {
            SequenceMassCalc sequenceMassCalc = new SequenceMassCalc(MassType.Monoisotopic);

            Assert.AreEqual(147.11, sequenceMassCalc.GetPrecursorMass("K"), .1);
            Assert.AreEqual("C6H14N2O2", sequenceMassCalc.GetMolecularFormula("K"));

            var label13C6K = new StaticMod("label13C6K", "K", null, LabelAtoms.C13);

            sequenceMassCalc.AddStaticModifications(new [] { label13C6K });
            Assert.AreEqual(153.11, sequenceMassCalc.GetPrecursorMass("K"), .1);
            Assert.AreEqual("C'6H14N2O2", sequenceMassCalc.GetMolecularFormula("K"));

            var label15N2K = new StaticMod("label15N2K", "K", null, LabelAtoms.N15);

            sequenceMassCalc.AddStaticModifications(new[] { label15N2K });
            Assert.AreEqual(155.11, sequenceMassCalc.GetPrecursorMass("K"), .1);
            Assert.AreEqual("C'6H14N'2O2", sequenceMassCalc.GetMolecularFormula("K"));

            var labelLaK = new StaticMod("labelLaK", "K", null, "La");

            sequenceMassCalc.AddStaticModifications(new[] { labelLaK });
            Assert.AreEqual(294.033, sequenceMassCalc.GetPrecursorMass("K"), .1);
            Assert.AreEqual("C'6H14LaN'2O2", sequenceMassCalc.GetMolecularFormula("K"));

            // Check our ability to handle strangely constructed chemical formulas
            Assert.AreEqual(Molecule.Parse("C12H9S2P0").ToString(), Molecule.Parse("C12H9S2").ToString());  // P0 is weird
            Assert.AreEqual(Molecule.Parse("C12H9S2P1").ToString(), Molecule.Parse("C12H9S2P").ToString()); // P1 is weird
            Assert.AreEqual(Molecule.Parse("C12H9S0P").ToString(), Molecule.Parse("C12H9P").ToString());    // S0 is weird, and not at end
        }
        private AAModMatch?GetModByName(AAModInfo info)
        {
            bool      structural = false;
            StaticMod modMatch   = null;

            // First, look in the document/global settings.
            foreach (var mod in UserDefinedTypedMods.Keys)
            {
                bool matchStuctural = UserDefinedTypedMods[mod].IsLight;
                if (Equals(info.Name, mod.Name) &&
                    (!info.UserIndicatedHeavy || !matchStuctural))
                {
                    modMatch   = mod;
                    structural = matchStuctural;
                }
            }
            // If not found, then look in Unimod.
            modMatch = modMatch ?? UniMod.GetModification(info.Name, out structural);
            if (!info.IsModMatch(modMatch) || (info.UserIndicatedHeavy && structural))
            {
                return(null);
            }
            return(new AAModMatch
            {
                StructuralMod = structural ? modMatch : null,
                HeavyMod = !structural ? modMatch : null
            });
        }
        private StaticMod GetModByMassInSettings(AAModInfo info, double mass, bool structural)
        {
            StaticMod firstMatch = null;

            foreach (var match in EnumerateModMatchesInSettings(info, mass, structural))
            {
                firstMatch = firstMatch ?? match;
                // Keep looking if it is an isotope modification of the 15N variant where it applies to all amino acids
                if (structural || (info.AppearsToBeSpecificMod && (!string.IsNullOrEmpty(match.AAs) || match.Terminus != null)) ||
                    (!info.AppearsToBeSpecificMod && string.IsNullOrEmpty(match.AAs) && match.Terminus == null))
                {
                    firstMatch = match;
                    break;
                }
            }
            if (firstMatch == null)
            {
                return(null);
            }
            // TODO: Is this necessary
            if (!IsInSettings(firstMatch) && !firstMatch.IsVariable)
            {
                firstMatch = firstMatch.ChangeExplicit(true);
            }
            return(firstMatch);
        }
        public void AddModification(StaticMod mod, ModType type)
        {
            if (mod == null)
            {
                return;
            }

            ImportPeptideSearch.UserDefinedTypedMods.Add(mod);

            PeptideSettings newPeptideSettings = SkylineWindow.Document.Settings.PeptideSettings;
            var             newMods            = new List <StaticMod>(
                (type == ModType.structural ? newPeptideSettings.Modifications.StaticModifications : newPeptideSettings.Modifications.HeavyModifications)
                )
            {
                mod
            };

            newPeptideSettings = (type == ModType.structural)
                                     ? newPeptideSettings.ChangeModifications(newPeptideSettings.Modifications.ChangeStaticModifications(newMods))
                                     : newPeptideSettings.ChangeModifications(newPeptideSettings.Modifications.ChangeHeavyModifications(newMods));

            SkylineWindow.ChangeSettings(SkylineWindow.Document.Settings.ChangePeptideSettings(newPeptideSettings), true,
                                         string.Format(Resources.MatchModificationsControl_AddModification_Add__0__modification__1_, type, mod.Name));
            SkylineWindow.Document.Settings.UpdateDefaultModifications(false);

            FillLists(SkylineWindow.Document);
        }
 public bool IsModMatch(StaticMod mod)
 {
     return(mod != null &&
            (string.IsNullOrEmpty(mod.AAs) ||
             mod.AminoAcids.ContainsAA(AA.ToString(CultureInfo.InvariantCulture))) &&
            ((mod.Terminus == null) || Equals(mod.Terminus, Terminus)));
 }
Beispiel #14
0
        /// <summary>
        /// Returns the number of StaticMod values in the dictionary that are equivalent to modToMatch.
        /// </summary>
        /// <param name="dict">Dictionary containing StaticMod values.</param>
        /// <param name="modToMatch">StaticMod we're comparing to values in dictionary.</param>
        /// <param name="equivMods">Dictionary we add count for StaticMods equivalent to modToMatch.</param>
        /// <param name="index">Index of modToMatch in dict.</param>
        /// <returns>Number of StaticMods equivalent to modToMatch. If there are no equivalent values, function will return 1.</returns>
        public int CountEquivalent(KeyValuePair <string, StaticMod>[] dict, StaticMod modToMatch, SortedDictionary <string, int> equivMods, int index)
        {
            int totalCount = 0;

            for (int i = 0; i < dict.Length; i++)
            {
                int       count = 0;
                StaticMod mod   = dict[i].Value;

                if (index != -1 && index == i)
                {
                    Assert.IsTrue(mod.Equivalent(modToMatch));
                }

                if (mod.Equivalent(modToMatch))
                {
                    count++;
                }
                if (!equivMods.ContainsKey(mod.Name))
                {
                    equivMods.Add(mod.Name, count);
                }
                else
                {
                    equivMods[mod.Name] += count;
                }
                totalCount += count;
            }

            return(totalCount);
        }
        public List <int> PotentiallyModifiedResidues(PeptideDocNode peptideDocNode, StaticMod mod)
        {
            List <int> indexes  = new List <int>();
            var        sequence = peptideDocNode.Peptide.Sequence;

            for (int index = 0; index < sequence.Length; index++)
            {
                if (mod.Terminus == ModTerminus.N && index != 0)
                {
                    continue;
                }

                if (mod.Terminus == ModTerminus.C && index != sequence.Length - 1)
                {
                    continue;
                }

                if (mod.AAs != null)
                {
                    var aa = sequence[index];
                    if (mod.AAs.IndexOf(aa) < 0)
                    {
                        continue;
                    }
                }
                indexes.Add(index);
            }

            return(indexes);
        }
        /// <summary>
        /// Merge the modifications found by the matcher with the modifications in the document,
        /// checking for conflicts with peptides already in the document.
        /// </summary>
        public PeptideModifications SafeMergeImplicitMods(SrmDocument document)
        {
            var newMods                = MatcherPepMods;
            var docModifications       = document.Settings.PeptideSettings.Modifications;
            var docPeptides            = document.Molecules.ToArray();
            List <StaticMod> lightMods = new List <StaticMod>(docModifications.StaticModifications);
            List <StaticMod> heavyMods = new List <StaticMod>(docModifications.HeavyModifications);

            // Merge light mods.
            foreach (var mod in newMods.StaticModifications)
            {
                StaticMod mod1 = mod;
                if (!lightMods.Contains(docMod => docMod.Equivalent(mod1)) &&
                    (!docPeptides.Any() || !ModAppliesToDoc(mod, true, true, docPeptides)))
                {
                    lightMods.Add(mod1);
                }
            }
            // Merge heavy mods.
            foreach (var mod in newMods.GetModifications(DocDefHeavyLabelType))
            {
                var mod1 = mod;
                if (!heavyMods.Contains(docMod => docMod.Equivalent(mod1)) &&
                    (!docPeptides.Any() || !ModAppliesToDoc(mod, false, true, docPeptides)))
                {
                    heavyMods.Add(mod1);
                }
            }
            return(document.Settings.PeptideSettings.Modifications.ChangeStaticModifications(lightMods).
                   ChangeModifications(DocDefHeavyLabelType, heavyMods));
        }
Beispiel #17
0
        public void TestSingleAminoAcidLinkedPeptide()
        {
            var srmSettings                = SrmSettingsList.GetDefault();
            var mainPeptide                = new Peptide("A");
            var staticMod                  = new StaticMod("crosslinker", null, null, "-C2");
            var linkedPeptide              = new LinkedPeptide(new Peptide("D"), 0, null);
            var mainTransitionGroup        = new TransitionGroup(mainPeptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light);
            var mainTransitionGroupDocNode = new TransitionGroupDocNode(mainTransitionGroup,
                                                                        Annotations.EMPTY, srmSettings, null, null,
                                                                        ExplicitTransitionGroupValues.EMPTY, null, new TransitionDocNode[0], false);
            var modsWithoutLinkedPeptide = new ExplicitMods(mainPeptide, new[] { new ExplicitMod(0, staticMod), }, new TypedExplicitModifications[0]);

            Assert.AreEqual("C3H7NO2", AminoAcidFormulas.Default.GetFormula("A").ToString());
            Assert.AreEqual("C3H7NO2", mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, null).Molecule.ToString());
            Assert.AreEqual("CH7NO2", mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, modsWithoutLinkedPeptide).Molecule.ToString());
            Assert.AreEqual("C4H7NO4", AminoAcidFormulas.Default.GetFormula("D").ToString());
            var modsWithLinkedPeptide = new ExplicitMods(mainPeptide,
                                                         new[] { new ExplicitMod(0, staticMod).ChangeLinkedPeptide(linkedPeptide) },
                                                         new TypedExplicitModifications[0]);

            Assert.AreEqual("C5H14N2O6", mainTransitionGroupDocNode.GetNeutralFormula(srmSettings, modsWithLinkedPeptide).Molecule.ToString());
            var mainComplexFragmentIon   = new ComplexFragmentIon(new Transition(mainTransitionGroup, IonType.precursor, mainPeptide.Length - 1, 0, Adduct.SINGLY_PROTONATED), null, modsWithLinkedPeptide.Crosslinks);
            var linkedComplexFragmentIon = new ComplexFragmentIon(
                new Transition(linkedPeptide.GetTransitionGroup(IsotopeLabelType.light, Adduct.SINGLY_PROTONATED),
                               IonType.precursor, linkedPeptide.Peptide.Length - 1, 0, Adduct.SINGLY_PROTONATED), null, LinkedPeptide.EMPTY_CROSSLINK_STRUCTURE);
            var complexFragmentIon =
                mainComplexFragmentIon.AddChild(new ModificationSite(0, staticMod.Name), linkedComplexFragmentIon);
            var transition       = complexFragmentIon.MakeTransitionDocNode(srmSettings, modsWithLinkedPeptide, null);
            var sequenceMassCalc = new SequenceMassCalc(MassType.Monoisotopic);
            var expectedMz       = sequenceMassCalc.GetPrecursorMass("A") + sequenceMassCalc.GetPrecursorMass("D") - 24 - BioMassCalc.MassProton;

            Assert.AreEqual(expectedMz, transition.Mz, .00001);
        }
Beispiel #18
0
        public void TestComplexIonMz()
        {
            var srmSettings      = SrmSettingsList.GetDefault();
            var peptide          = new Peptide("DLGEEHFKGLVLIAFSQYLQQCPFDEHVK");
            var linkedPeptide    = new LinkedPeptide(new Peptide("LVNELTEFAKTCVADESHAGCEK"), 9, null);
            var transitionGroup  = new TransitionGroup(peptide, Adduct.QUADRUPLY_PROTONATED, IsotopeLabelType.light);
            var crosslinkMod     = new StaticMod("linker", "K", null, "C8H10O2");
            var explicitMod      = new ExplicitMod(7, crosslinkMod).ChangeLinkedPeptide(linkedPeptide);
            var explicitMods     = new ExplicitMods(peptide, new[] { explicitMod }, new List <TypedExplicitModifications>());
            var linkedTransition =
                new Transition(linkedPeptide.GetTransitionGroup(IsotopeLabelType.light, Adduct.SINGLY_PROTONATED),
                               IonType.precursor, linkedPeptide.Peptide.Length - 1, 0, Adduct.SINGLY_PROTONATED);
            var expectedMzs = new[]
            {
                Tuple.Create(IonType.b, 2, 1, 229.1183),
                Tuple.Create(IonType.b, 10, 3, 1291.2766)
            };

            foreach (var tuple in expectedMzs)
            {
                int offset             = Transition.OrdinalToOffset(tuple.Item1, tuple.Item2, peptide.Sequence.Length);
                var transition         = new Transition(transitionGroup, tuple.Item1, offset, 0, Adduct.FromChargeProtonated(tuple.Item3));
                var complexFragmentIon = new ComplexFragmentIon(transition, null, explicitMods.Crosslinks);
                if (complexFragmentIon.IncludesAaIndex(explicitMod.IndexAA))
                {
                    complexFragmentIon = complexFragmentIon.AddChild(explicitMod.ModificationSite,
                                                                     new ComplexFragmentIon(linkedTransition, null, LinkedPeptide.EMPTY_CROSSLINK_STRUCTURE));
                }
                var complexTransitionDocNode = complexFragmentIon.MakeTransitionDocNode(srmSettings, explicitMods, null);
                Assert.AreEqual(tuple.Item4, complexTransitionDocNode.Mz, .0001, "{0}{1}{2}", tuple.Item1, tuple.Item2,
                                Transition.GetChargeIndicator(Adduct.FromChargeProtonated(tuple.Item3)));
            }
        }
Beispiel #19
0
        public void TestCrosslinkModSerialization()
        {
            var settings       = SrmSettingsList.GetDefault();
            var crosslinkerDef = new StaticMod("disulfide", null, null, "-H2")
                                 .ChangeCrosslinkerSettings(CrosslinkerSettings.EMPTY);

            settings = settings.ChangePeptideSettings(settings.PeptideSettings.ChangeModifications(
                                                          settings.PeptideSettings.Modifications.ChangeStaticModifications(new[] { crosslinkerDef })));
            settings = settings.ChangeTransitionSettings(settings.TransitionSettings.ChangeFilter(
                                                             settings.TransitionSettings.Filter
                                                             .ChangeFragmentRangeFirstName(TransitionFilter.StartFragmentFinder.ION_1.Name)
                                                             .ChangeFragmentRangeLastName(@"last ion")
                                                             .ChangePeptideIonTypes(new[] { IonType.precursor, IonType.y, IonType.b })
                                                             )); var mainPeptide = new Peptide("MERCURY");
            var transitionGroup           = new TransitionGroup(mainPeptide, Adduct.DOUBLY_PROTONATED, IsotopeLabelType.light);
            var linkedPeptide             = new LinkedPeptide(new Peptide("ARSENIC"), 2, null);
            var crosslinkMod              = new ExplicitMod(3, crosslinkerDef).ChangeLinkedPeptide(linkedPeptide);
            var explicitModsWithCrosslink = new ExplicitMods(mainPeptide, new[] { crosslinkMod }, new TypedExplicitModifications[0]);
            var transitionGroupDocNode    = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, settings,
                                                                       explicitModsWithCrosslink, null, ExplicitTransitionGroupValues.EMPTY, null, null, true);

            var peptideDocNode = new PeptideDocNode(mainPeptide, settings, explicitModsWithCrosslink, null, ExplicitRetentionTimeInfo.EMPTY, new [] { transitionGroupDocNode }, false);

            peptideDocNode = peptideDocNode.ChangeSettings(settings, SrmSettingsDiff.ALL);
            Assert.AreNotEqual(0, peptideDocNode.TransitionCount);
            var peptideGroupDocNode = new PeptideGroupDocNode(new PeptideGroup(), Annotations.EMPTY, "Peptides", null, new [] { peptideDocNode });
            var srmDocument         = (SrmDocument) new SrmDocument(settings).ChangeChildren(new[] { peptideGroupDocNode });

            AssertEx.Serializable(srmDocument);
            string docXML = null;

            AssertEx.RoundTrip(srmDocument, ref docXML);
            Assert.IsNotNull(docXML);
        }
Beispiel #20
0
        public void TestPermuteComplexIons()
        {
            var mainPeptide      = new Peptide("MERCURY");
            var srmSettings      = SrmSettingsList.GetDefault();
            var transitionFilter = srmSettings.TransitionSettings.Filter;

            transitionFilter = transitionFilter
                               .ChangeFragmentRangeFirstName(TransitionFilter.StartFragmentFinder.ION_1.Name)
                               .ChangeFragmentRangeLastName(@"last ion")
                               .ChangePeptideIonTypes(new[] { IonType.precursor, IonType.y, IonType.b });
            srmSettings = srmSettings.ChangeTransitionSettings(
                srmSettings.TransitionSettings.ChangeFilter(transitionFilter));

            var transitionGroup           = new TransitionGroup(mainPeptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light);
            var crosslinkerDef            = new StaticMod("disulfide", "C", null, "-H2");
            var linkedPeptide             = new LinkedPeptide(new Peptide("ARSENIC"), 6, null);
            var crosslinkMod              = new ExplicitMod(3, crosslinkerDef).ChangeLinkedPeptide(linkedPeptide);
            var explicitModsWithCrosslink = new ExplicitMods(mainPeptide, new[] { crosslinkMod }, new TypedExplicitModifications[0]);
            var transitionGroupDocNode    = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, srmSettings,
                                                                       explicitModsWithCrosslink, null, ExplicitTransitionGroupValues.EMPTY, null, null, false);
            var choices = transitionGroupDocNode.GetPrecursorChoices(srmSettings, explicitModsWithCrosslink, true)
                          .Cast <TransitionDocNode>().ToArray();
            var complexFragmentIons = choices.Select(transition => transition.ComplexFragmentIon.GetName()).ToArray();

            Assert.AreNotEqual(0, complexFragmentIons.Length);
        }
Beispiel #21
0
        public void TestComplexIonGetNeutralFormula()
        {
            var srmSettings         = SrmSettingsList.GetDefault();
            var fullTransitionGroup = new TransitionGroupDocNode(
                new TransitionGroup(new Peptide("ELVIS"), Adduct.SINGLY_PROTONATED, IsotopeLabelType.light),
                Annotations.EMPTY, srmSettings, null, null, ExplicitTransitionGroupValues.EMPTY,
                null, null, false);
            var fullFormula = fullTransitionGroup.GetNeutralFormula(srmSettings, null);

            Assert.AreEqual("C25H45N5O9", fullFormula.Molecule.ToString());

            var hydrolysisDef = new StaticMod("hydrolysis", null, ModTerminus.C, "-H2O")
                                .ChangeCrosslinkerSettings(CrosslinkerSettings.EMPTY);
            var crossLinkMod = new ExplicitMod(1, hydrolysisDef)
                               .ChangeLinkedPeptide(new LinkedPeptide(new Peptide("VIS"), 0, null));
            var mainPeptide         = new Peptide("EL");
            var explicitMods        = new ExplicitMods(mainPeptide, new[] { crossLinkMod }, new TypedExplicitModifications[0]);
            var mainTransitionGroup = new TransitionGroupDocNode(
                new TransitionGroup(mainPeptide, Adduct.SINGLY_PROTONATED, IsotopeLabelType.light),
                Annotations.EMPTY, srmSettings,
                explicitMods, null,
                ExplicitTransitionGroupValues.EMPTY,
                null, null, false);
            var mainFullFormula = mainTransitionGroup.GetNeutralFormula(srmSettings, explicitMods);

            Assert.AreEqual(fullFormula, mainFullFormula);
        }
Beispiel #22
0
        public void NeutralLossListTest()
        {
            TestSmallMolecules = false; // No concept of neutral loss for small molecules

            var phosphoLossMod = new StaticMod("Phospho Loss", "S, T, Y", null, false, "HPO3",
                                               LabelAtoms.None, RelativeRT.Matching, null, null, new[] { new FragmentLoss("H3PO4"), });

            SrmDocument document = new SrmDocument(SrmSettingsList.GetDefault().ChangePeptideModifications(mods =>
                                                                                                           mods.ChangeStaticModifications(new List <StaticMod>(mods.StaticModifications)
            {
                phosphoLossMod
            })));
            IdentityPath path     = IdentityPath.ROOT;
            SrmDocument  docFasta = document.ImportFasta(new StringReader(TEXT_FASTA_YEAST_7), false, path, out path);

            Assert.AreEqual(0, GetLossCount(docFasta, 1));

            // Insert losses into the first transition group
            var pathPeptide  = docFasta.GetPathTo((int)SrmDocument.Level.Molecules, 0);
            var nodePep      = (PeptideDocNode)docFasta.FindNode(pathPeptide);
            var nodeGroup    = (TransitionGroupDocNode)nodePep.Children[0];
            var listChildren = new List <DocNode>(nodeGroup.Children);

            foreach (var nodeTran in nodeGroup.GetTransitions(docFasta.Settings,
                                                              nodePep.ExplicitMods, nodeGroup.PrecursorMz, null, null, null, false))
            {
                if (!nodeTran.HasLoss)
                {
                    continue;
                }

                var tran       = nodeTran.Transition;
                int matchIndex = listChildren.IndexOf(node =>
                                                      Equals(tran, ((TransitionDocNode)node).Transition));
                if (matchIndex == -1)
                {
                    continue;
                }

                while (matchIndex < listChildren.Count &&
                       Equals(tran, ((TransitionDocNode)listChildren[matchIndex]).Transition))
                {
                    matchIndex++;
                }
                listChildren.Insert(matchIndex, nodeTran);
            }

            var docLosses = (SrmDocument)docFasta.ReplaceChild(pathPeptide,
                                                               nodeGroup.ChangeChildren(listChildren));

            int lossCount = GetLossCount(docLosses, 1);

            Assert.IsTrue(lossCount > 0);
            var docRoundTripped = AssertEx.RoundTripTransitionList(new ThermoMassListExporter(docLosses));

            Assert.AreEqual(lossCount, GetLossCount(docRoundTripped, 1));
            docRoundTripped = AssertEx.RoundTripTransitionList(new AgilentMassListExporter(docLosses));
            Assert.AreEqual(lossCount, GetLossCount(docRoundTripped, 1));
        }
Beispiel #23
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 }));
        }
 private Modification GenerateNewModification(StaticMod mod, char a)
 {
     return(new Modification(mod.ShortName ?? mod.Name, mod.Name, mod.MonoisotopicMass ?? 0.0,
                             mod.AverageMass ?? 0.0, a, !mod.IsVariable, mod.Losses?.Select(l => l.MonoisotopicMass).ToArray() ?? new double[0],
                             mod.Terminus.HasValue && mod.Terminus.Value == ModTerminus.N,
                             mod.Terminus.HasValue && mod.Terminus.Value == ModTerminus.C,
                             mod.UnimodId ?? 0, false));
 }
 public IsotopeModificationPermuter(StaticMod isotopeModification, bool simplePermutation, IsotopeLabelType fullHeavyLabelType, List <StaticMod> globalStaticMods, List <StaticMod> globalIsotopeMods)
 {
     IsotopeModification = isotopeModification;
     SimplePermutation   = simplePermutation;
     FullyHeavyLabelType = fullHeavyLabelType;
     GlobalStaticMods    = globalStaticMods;
     GlobalIsotopeMods   = globalIsotopeMods;
 }
Beispiel #26
0
 private bool EnsureLinkedPeptide(StaticMod staticMod, int indexAA)
 {
     if (HasAppropriateLinkedPeptide(staticMod, indexAA))
     {
         return(true);
     }
     EditLinkedPeptide(indexAA);
     return(HasAppropriateLinkedPeptide(staticMod, indexAA));
 }
Beispiel #27
0
        /// <summary>
        /// Compares the modifications indicated in the sequence string to the calculated masses.
        /// </summary>
        /// <param name="seq">The modified sequence.</param>
        /// <param name="calc">Calculator used to calculate the masses.</param>
        /// <param name="calcLight">
        /// Additional light calculator if necessary to isolate mass changes
        /// caused by heavy modifications alone.
        /// </param>
        /// <returns>
        /// True if the given calculators explain the modifications indicated on the sequence,
        /// false otherwise.
        /// </returns>
        private bool EqualsModifications(string seq, IPrecursorMassCalc calc, IPrecursorMassCalc calcLight)
        {
            var    modifications = Settings.PeptideSettings.Modifications;
            bool   structural    = calcLight == null;
            string aas           = FastaSequence.StripModifications(seq);

            foreach (var info in EnumerateSequenceInfos(seq, true))
            {
                int indexAA   = info.IndexAA; // ReSharper
                var aa        = aas[indexAA];
                var roundedTo = info.RoundedTo;
                // If the user has indicated the modification by name, find that modification
                // and calculate the mass.
                double massKey;
                if (info.Mass != null)
                {
                    massKey = (double)info.Mass;
                }
                else
                {
                    var       info1    = info;
                    StaticMod modMatch = null;
                    int       index;
                    if (structural &&
                        ((index = modifications.StaticModifications.IndexOf(mod => Equals(mod.Name, info1.Name)))
                         != -1))
                    {
                        modMatch = modifications.StaticModifications[index];
                    }
                    if (!structural &&
                        ((index = modifications.HeavyModifications.IndexOf(mod => Equals(mod.Name, info1.Name)))
                         != -1))
                    {
                        modMatch = modifications.HeavyModifications[index];
                    }

                    if (modMatch == null)
                    {
                        return(false);
                    }
                    roundedTo = DEFAULT_ROUNDING_DIGITS;
                    massKey   = Math.Round(GetDefaultModMass(aa, modMatch), roundedTo);
                }
                double massMod = Math.Round(calc.GetAAModMass(aas[indexAA], indexAA, aas.Length), roundedTo);
                // Subtract the mass difference of the light
                // modifications to isolate the masses of the heavy modifications.
                if (calcLight != null)
                {
                    massMod -= Math.Round(calcLight.GetAAModMass(aas[indexAA], indexAA, aas.Length), roundedTo);
                }
                if (!Equals(massKey, massMod))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #28
0
        public void MultiLabelExplicitSerialTest()
        {
            // Create a simple document and add two peptides
            SrmDocument  document     = new SrmDocument(SrmSettingsList.GetDefault());
            const string pepSequence1 = "QFVLSCVILR";
            const string pepSequence2 = "DIEVYCDGAITTK";
            var          reader       = new StringReader(string.Join("\n", new[] { ">peptides1", pepSequence1, pepSequence2 }));
            IdentityPath path;

            document = document.ImportFasta(reader, true, IdentityPath.ROOT, out path);
            Assert.AreEqual(2, document.PeptideCount);

            // Add some modifications in two new label types
            var modCarb      = new StaticMod("Carbamidomethyl Cysteine", "C", null, "C2H3ON");
            var modOther     = new StaticMod("Another Cysteine", "C", null, "CO8N2");
            var staticMods   = new[] { modCarb, modOther };
            var mod15N       = new StaticMod("All 15N", null, null, null, LabelAtoms.N15, null, null);
            var modK13C      = new StaticMod("13C K", "K", ModTerminus.C, null, LabelAtoms.C13, null, null);
            var modR13C      = new StaticMod("13C R", "R", ModTerminus.C, null, LabelAtoms.C13, null, null);
            var modV13C      = new StaticMod("Heavy V", "V", null, null, LabelAtoms.C13 | LabelAtoms.N15, null, null);
            var heavyMods    = new[] { mod15N, modK13C, modR13C, modV13C };
            var labelTypeAA  = new IsotopeLabelType("heavy AA", IsotopeLabelType.FirstHeavy);
            var labelTypeAll = new IsotopeLabelType("heavy All", IsotopeLabelType.FirstHeavy + 1);

            var settings = document.Settings;

            settings = settings.ChangePeptideModifications(mods =>
                                                           new PeptideModifications(mods.StaticModifications,
                                                                                    new[]
            {
                new TypedModifications(labelTypeAA, new[] { modK13C, modR13C }),
                new TypedModifications(labelTypeAll, new[] { mod15N })
            }));
            document = document.ChangeSettings(settings);
            Assert.AreEqual(6, document.PeptideTransitionGroupCount);

            // Add modifications to light and heavy AA in the first peptide
            path = document.GetPathTo((int)SrmDocument.Level.Molecules, 0);
            var nodePepMod  = (PeptideDocNode)document.FindNode(path);
            var explicitMod = new ExplicitMods(nodePepMod.Peptide,
                                               new[] { new ExplicitMod(pepSequence1.IndexOf('C'), modOther) },
                                               new[] { new TypedExplicitModifications(nodePepMod.Peptide, labelTypeAA, new ExplicitMod[0]) });

            document = document.ChangePeptideMods(path, explicitMod, staticMods, heavyMods);
            Assert.AreEqual(5, document.PeptideTransitionGroupCount);

            // Add a modification to heavy All in the second peptide
            path        = document.GetPathTo((int)SrmDocument.Level.Molecules, 1);
            nodePepMod  = (PeptideDocNode)document.FindNode(path);
            explicitMod = new ExplicitMods(nodePepMod.Peptide, null,
                                           new[] { new TypedExplicitModifications(nodePepMod.Peptide, labelTypeAll,
                                                                                  new[] { new ExplicitMod(pepSequence2.IndexOf('V'), modV13C) }) });
            document = document.ChangePeptideMods(path, explicitMod, staticMods, heavyMods);
            Assert.AreEqual(5, document.PeptideTransitionGroupCount);

            AssertEx.Serializable(document, 3, AssertEx.DocumentCloned);
        }
Beispiel #29
0
 public void Add(char aa, StaticMod mod, bool structural, bool allowDuplicates)
 {
     if (_completed)
     {
         throw new InvalidOperationException(Resources.ModMassLookup_Add_Invalid_attempt_to_add_data_to_completed_MassLookup);
     }
     // If structural, store in lowercase AA.
     _aaMassLookups[structural ? ToStructuralIndex(aa) : ToIsotopeIndex(aa)]
     .Add(CALC.GetModMass(aa, mod), mod, allowDuplicates);
 }
 public void RemoveModification(StaticMod mod, IsotopeLabelType labelType)
 {
     if (MatcherPepMods.GetModificationTypes().Contains(labelType))
     {
         var newMods = MatcherPepMods.GetModifications(labelType)
                       .Where(existingMod => !existingMod.Equivalent(mod)).ToArray();
         MatcherPepMods = MatcherPepMods.ChangeModifications(labelType, newMods);
     }
     MatchesUpdated = true;
 }