Exemple #1
0
        /// <summary>
        /// Basic overview of how peptides can be used and modified
        /// </summary>
        private static void PeptideExamples()
        {
            Console.WriteLine("**Peptide Examples**");

            // Simple Peptide creation
            Peptide peptide1 = new Peptide("ACDEFGHIKLMNPQRSTVWY");

            WritePeptideToConsole(peptide1);

            // Fragmenting a peptide is simple, you can include as many fragment types as you want
            Console.WriteLine("{0,-4} {1,-20} {2,-10} {3,-10} {4,-5}", "Type", "Formula", "Mass", "m/z +1", "Sequence");
            foreach (Fragment fragment in peptide1.Fragment(FragmentTypes.b | FragmentTypes.y))
            {
                WriteFragmentToConsole(fragment);
            }

            // Modifications can be applied to any residue or termini
            Console.WriteLine("Lets add some Iron to our peptide...");
            peptide1.SetModification(new ChemicalFormula("Fe"), Terminus.C | Terminus.N);
            WritePeptideToConsole(peptide1);

            // A chemicalmodification is a simple wrapper for a chemical formula. You can name your mods if you want
            Console.WriteLine("Add a modification of Oxygen with the name \"Oxidation\" to all Methionines");
            ChemicalFormulaModification oxMod = new ChemicalFormulaModification("O", "Oxidation");

            peptide1.SetModification(oxMod, 'M');
            WritePeptideToConsole(peptide1);

            // If you fragment a modified peptide, the modifications stay part of the fragments
            Console.WriteLine("{0,-4} {1,-20} {2,-20} {3,-5}", "Type", "Formula", "Mass", "m/z +1");
            foreach (Fragment fragment in peptide1.Fragment(FragmentTypes.b | FragmentTypes.y, 2))
            {
                WriteFragmentToConsole(fragment);
            }
        }
Exemple #2
0
        public void PeptideCloneWithModification()
        {
            Peptide pepA = new Peptide("DEREK");

            pepA.SetModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H2O")), 'R');
            Peptide pepB = new Peptide(pepA);

            Assert.AreEqual(pepB, pepA);
        }
        public void PeptideInEqualityAminoAcidModification()
        {
            Peptide pepA = new Peptide("DEREK");
            Peptide pepB = new Peptide("DEREK");

            pepB.SetModification(new ChemicalFormula("H2O"), 'R');

            Assert.AreNotEqual(pepA, pepB);
        }
Exemple #4
0
        public void GenerateIsotopologues()
        {
            Peptide pep = new Peptide("DERLEK");
            var     a   = pep.GenerateAllModificationCombinations().ToArray();

            Assert.AreEqual(0, a.Count());
            var i = new ModificationWithMultiplePossibilitiesCollection("My Iso Mod", ModificationSites.E);

            i.AddModification(new OldSchoolModification(1, "My Mod1a", ModificationSites.E));
            i.AddModification(new OldSchoolModification(2, "My Mod2b", ModificationSites.E));
            pep.SetModification(i);
            var i2 = new ModificationWithMultiplePossibilitiesCollection("My Iso Mod2", ModificationSites.R);

            i2.AddModification(new OldSchoolModification(1, "My Mod2a", ModificationSites.R));
            i2.AddModification(new OldSchoolModification(2, "My Mod2b", ModificationSites.R));
            i2.AddModification(new OldSchoolModification(3, "My Mod2c", ModificationSites.R));
            pep.SetModification(i2);
            a = pep.GenerateAllModificationCombinations().ToArray();
            // Only 6 and not 12, because in the first modification, it is one choice that is substituted across all modification sites
            Assert.AreEqual(6, a.Count());
        }
Exemple #5
0
        public void PeptideParitalCloneInternalWithCTerminusModification()
        {
            Peptide pepA = new Peptide("DEREK");

            pepA.SetModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H2O")), Terminus.C);
            Peptide pepB = new Peptide(pepA, 2, 3);

            Peptide pepC = new Peptide("REK");

            pepC.SetModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H2O")), Terminus.C);

            Assert.AreEqual(pepC, pepB);
        }
Exemple #6
0
        private static void IsotopologueExample()
        {
            var iso1 = new Isotopologue("One", ModificationSites.K);

            iso1.AddModification(new ChemicalFormulaModification("C1", "Sample 1"));
            iso1.AddModification(new ChemicalFormulaModification("C2", "Sample 2"));

            var iso2 = new Isotopologue("Two", ModificationSites.R);

            iso2.AddModification(new ChemicalFormulaModification("C3", "Sample 3"));
            iso2.AddModification(Modification.Empty);

            Peptide peptide = new Peptide("DEREK");

            peptide.SetModification(iso1);
            peptide.SetModification(iso2);

            foreach (var iso in peptide.GenerateIsotopologues())
            {
                Console.WriteLine(iso + ", " + iso.MonoisotopicMass);
            }
        }
Exemple #7
0
        public void ParseCTerminalChemicalFormulaWithLastResidueModStringRepresentation()
        {
            Peptide peptide = new Peptide("TTGSSSSSSSK[H2O]-[C2H3NO]");

            Assert.AreEqual("TTGSSSSSSSK[H2O]-[C2H3NO]", peptide.GetSequenceWithModifications());

            peptide.NTerminus = new ChemicalFormulaTerminus(ChemicalFormula.ParseFormula("N"));

            Assert.AreEqual("TTGSSSSSSSK[H2O]-[C2H3NO]", peptide.GetSequenceWithModifications());

            ChemicalFormula formulaA = new ChemicalFormula(ChemicalFormula.ParseFormula("C39H70N14O23"));
            var             formulaB = peptide.GetChemicalFormula();

            Assert.AreEqual(formulaA, formulaB);

            peptide.AddModification(new ObjectWithMass100(), 0);

            Assert.AreEqual("[mass: 100]-TTGSSSSSSSK[H2O]-[C2H3NO]", peptide.GetSequenceWithModifications());

            Assert.AreEqual(1, peptide.AddModification(new ObjectWithMass100(), Terminus.C));

            Assert.AreEqual(3, peptide.ModificationCount());

            Assert.AreEqual(0, peptide.ReplaceModification(new ObjectWithMass100(), new ObjectWithMass100()));

            Assert.That(() => peptide.ReplaceModification(null, new ObjectWithMass100()),
                        Throws.TypeOf <MzLibException>()
                        .With.Property("Message")
                        .EqualTo("Cannot replace a null modification"));

            peptide.SetModification(new ObjectWithMass100(), new int[] { 1, 11 });
            Assert.AreEqual(4, peptide.ModificationCount());

            OldSchoolModification mod1 = new OldSchoolModification(5, "mass 5 on T", ModificationSites.T);

            peptide.SetModifications(new List <OldSchoolModification> {
                mod1
            });
            Assert.AreEqual(5, peptide.ModificationCount());
        }
Exemple #8
0
        public void PeptideParitalCloneInternalWithCTerminusModification()
        {
            Peptide pepA = new Peptide("DEREK");
            pepA.SetModification(new ChemicalFormula("H2O"), Terminus.C);
            Peptide pepB = new Peptide(pepA, 2, 3);

            Peptide pepC = new Peptide("REK");
            pepC.SetModification(new ChemicalFormula("H2O"), Terminus.C);

            Assert.AreEqual(pepB,pepC);
        }
Exemple #9
0
        public void PeptideInEqualityAminoAcidModification()
        {
            Peptide pepA = new Peptide("DEREK");
            Peptide pepB = new Peptide("DEREK");
            pepB.SetModification(new ChemicalFormula("H2O"), 'R');

            Assert.AreNotEqual(pepA,pepB);
        }
Exemple #10
0
        public void PeptideCloneWithModification()
        {
            Peptide pepA = new Peptide("DEREK");
            pepA.SetModification(new ChemicalFormula("H2O"), 'R');
            Peptide pepB = new Peptide(pepA);

            Assert.AreEqual(pepB, pepA);
        }
        public static IEnumerable <Peptide> GetUniquePeptides(Peptide peptide)
        {
            HashSet <QuantitationChannelSet> sets = new HashSet <QuantitationChannelSet>();
            Dictionary <IQuantitationChannel, HashSet <int> > locations = new Dictionary <IQuantitationChannel, HashSet <int> >();

            IMass[] mods      = peptide.Modifications;
            int     modLength = mods.Length;

            for (int i = 0; i < modLength; i++)
            {
                if (mods[i] != null)
                {
                    IMass mod = mods[i];

                    List <QuantitationChannelSet> channelsets = new List <QuantitationChannelSet>();

                    QuantitationChannelSet quantSetMod;
                    ModificationCollection modCol;
                    if ((modCol = mod as ModificationCollection) != null)
                    {
                        foreach (IMass mod2 in modCol)
                        {
                            if ((quantSetMod = mod2 as QuantitationChannelSet) != null)
                            {
                                channelsets.Add(quantSetMod);
                            }
                        }
                    }
                    else if ((quantSetMod = mod as QuantitationChannelSet) != null)
                    {
                        channelsets.Add(quantSetMod);
                    }

                    foreach (QuantitationChannelSet channelset in channelsets)
                    {
                        sets.Add(channelset);
                        foreach (IQuantitationChannel channel in channelset.GetChannels())
                        {
                            HashSet <int> residues;
                            if (locations.TryGetValue(channel, out residues))
                            {
                                residues.Add(i);
                            }
                            else
                            {
                                residues = new HashSet <int> {
                                    i
                                };
                                locations.Add(channel, residues);
                            }
                        }
                    }
                }
            }

            if (sets.Count == 0)
            {
                yield return(new Peptide(peptide, true));
            }
            else if (sets.Count == 1)
            {
                foreach (QuantitationChannelSet set in sets)
                {
                    foreach (IQuantitationChannel channel in set.GetChannels())
                    {
                        Peptide toReturn = new Peptide(peptide, true);
                        foreach (int residue in locations[channel])
                        {
                            toReturn.SetModification(channel, residue);
                        }
                        yield return(toReturn);
                    }
                }
            }
            else
            {
                List <HashSet <IQuantitationChannel> > quantChannels = new List <HashSet <IQuantitationChannel> >();

                GetUniquePeptides_helper(sets.ToList(), 0, new HashSet <IQuantitationChannel>(), quantChannels);

                foreach (HashSet <IQuantitationChannel> channelset in quantChannels)
                {
                    Peptide toReturn = new Peptide(peptide, true);
                    Dictionary <int, IMass> modsToAdd = new Dictionary <int, IMass>();
                    foreach (IQuantitationChannel channel in channelset)
                    {
                        foreach (int residue in locations[channel])
                        {
                            IMass modToAdd;
                            if (modsToAdd.TryGetValue(residue, out modToAdd))
                            {
                                ModificationCollection col = new ModificationCollection(channel, modToAdd);
                                modsToAdd[residue] = col;
                            }
                            else
                            {
                                modsToAdd.Add(residue, channel);
                            }
                        }
                    }
                    foreach (KeyValuePair <int, IMass> kvp in modsToAdd)
                    {
                        toReturn.SetModification(kvp.Value, kvp.Key);
                    }
                    yield return(toReturn);
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// Basic overview of how peptides can be used and modified
        /// </summary>
        private static void PeptideExamples()
        {
            Console.WriteLine("**Peptide Examples**");

            // Simple Peptide creation
            Peptide peptide1 = new Peptide("ACDEFGHIKLMNPQRSTVWY");
            WritePeptideToConsole(peptide1);

            // Fragmenting a peptide is simple, you can include as many fragment types as you want
            Console.WriteLine("{0,-4} {1,-20} {2,-10} {3,-10} {4,-5}", "Type", "Formula", "Mass", "m/z +1", "Sequence");
            foreach (Fragment fragment in peptide1.Fragment(FragmentTypes.b | FragmentTypes.y))
            {
                WriteFragmentToConsole(fragment);
            }

            // Modifications can be applied to any residue or termini
            Console.WriteLine("Lets add some Iron to our peptide...");
            peptide1.SetModification(new ChemicalFormula("Fe"), Terminus.C | Terminus.N);
            WritePeptideToConsole(peptide1);

            // A chemicalmodification is a simple wrapper for a chemical formula. You can name your mods if you want
            Console.WriteLine("Add a modification of Oxygen with the name \"Oxidation\" to all Methionines");
            ChemicalFormulaModification oxMod = new ChemicalFormulaModification("O", "Oxidation");
            peptide1.SetModification(oxMod, 'M');
            WritePeptideToConsole(peptide1);

            // If you fragment a modified peptide, the modifications stay part of the fragments
            Console.WriteLine("{0,-4} {1,-20} {2,-20} {3,-5}", "Type", "Formula", "Mass", "m/z +1");
            foreach (Fragment fragment in peptide1.Fragment(FragmentTypes.b | FragmentTypes.y, 2))
            {
                WriteFragmentToConsole(fragment);
            }
        }
Exemple #13
0
        private static void IsotopologueExample()
        {
            var iso1 = new Isotopologue("One", ModificationSites.K);
            iso1.AddModification(new ChemicalFormulaModification("C1", "Sample 1"));
            iso1.AddModification(new ChemicalFormulaModification("C2", "Sample 2"));

            var iso2 = new Isotopologue("Two", ModificationSites.R);
            iso2.AddModification(new ChemicalFormulaModification("C3", "Sample 3"));
            iso2.AddModification(Modification.Empty);

            Peptide peptide = new Peptide("DEREK");
            peptide.SetModification(iso1);
            peptide.SetModification(iso2);

            foreach (var iso in peptide.GenerateIsotopologues())
            {
                Console.WriteLine(iso + ", " + iso.MonoisotopicMass);
            }
        }
        public void SetAminoAcidModification()
        {
            ChemicalFormula formula = new ChemicalFormula("Fe");

            _mockPeptideEveryAminoAcid.SetModification(formula, AminoAcid.Asparagine);

            Assert.AreEqual("ACDEFGHIKLMN[Fe]PQRSTVWY", _mockPeptideEveryAminoAcid.ToString());
        }
        public static IEnumerable<Peptide> GetUniquePeptides(Peptide peptide)
        {
            QuantitationChannelSet quantSetMod;
            IMass mod;
            ModificationCollection modCol;
            HashSet<QuantitationChannelSet> sets = new HashSet<QuantitationChannelSet>();
            Dictionary<IQuantitationChannel, HashSet<int>> locations = new Dictionary<IQuantitationChannel, HashSet<int>>();
            HashSet<int> residues;

            IMass[] mods = peptide.Modifications;
            int modLength = mods.Length;

            for (int i = 0; i < modLength; i++)
            {
                if (mods[i] != null)
                {
                    mod = mods[i];

                    List<QuantitationChannelSet> channelsets = new List<QuantitationChannelSet>();

                    if ((modCol = mod as ModificationCollection) != null)
                    {
                        foreach (IMass mod2 in modCol)
                        {
                            if ((quantSetMod = mod2 as QuantitationChannelSet) != null)
                            {
                                channelsets.Add(quantSetMod);
                            }
                        }
                    }
                    else if ((quantSetMod = mod as QuantitationChannelSet) != null)
                    {
                        channelsets.Add(quantSetMod);
                    }

                    foreach (QuantitationChannelSet channelset in channelsets)
                    {
                        sets.Add(channelset);
                        foreach (IQuantitationChannel channel in channelset.GetChannels())
                        {
                            if (locations.TryGetValue(channel, out residues))
                            {
                                residues.Add(i);
                            }
                            else
                            {
                                residues = new HashSet<int>() { i };
                                locations.Add(channel, residues);
                            }
                        }
                    }
                }
            }

            if (sets.Count == 0)
            {
                yield return new Peptide(peptide, true);
            }
            else if (sets.Count == 1)
            {
                foreach (QuantitationChannelSet set in sets)
                {
                    foreach (IQuantitationChannel channel in set.GetChannels())
                    {
                        Peptide toReturn = new Peptide(peptide, true);
                        foreach (int residue in locations[channel])
                        {
                            toReturn.SetModification(channel, residue);
                        }
                        yield return toReturn;
                    }
                }
            }
            else
            {
                List<HashSet<IQuantitationChannel>> quantChannels = new List<HashSet<IQuantitationChannel>>();

                GetUniquePeptides_helper(sets.ToList(), 0, new HashSet<IQuantitationChannel>(), quantChannels);

                foreach (HashSet<IQuantitationChannel> channelset in quantChannels)
                {
                    Peptide toReturn = new Peptide(peptide, true);
                    Dictionary<int, IMass> modsToAdd = new Dictionary<int, IMass>();
                    IMass modToAdd;
                    foreach (IQuantitationChannel channel in channelset)
                    {
                        foreach (int residue in locations[channel])
                        {
                            if (modsToAdd.TryGetValue(residue, out modToAdd))
                            {
                                ModificationCollection col = new ModificationCollection(channel, modToAdd);
                                col.Add(channel);
                                col.Add(modToAdd);
                                modsToAdd[residue] = col;
                            }
                            else
                            {
                                modsToAdd.Add(residue, channel);
                            }
                        }
                    }
                    foreach (KeyValuePair<int, IMass> kvp in modsToAdd)
                    {
                        toReturn.SetModification(kvp.Value, kvp.Key);
                    }
                    yield return toReturn;
                }
            }
            yield break;
        }