private void UpdateProteins()
        {
            tvResult.BeginUpdate();
            try
            {
                tvResult.Nodes.Clear();
                foreach (var g in proteins)
                {
                    var subNode = tvResult.Nodes.Add(string.Format("{0} ({1})", g[0].Name, g[0].Peptides.Count));
                    subNode.Tag = g;

                    var uniquePeptides = g[0].Peptides.GroupBy(m => PeptideUtils.GetMatchedSequence(m.Sequence)).OrderByDescending(n => n.Count()).ThenBy(n => n.Key);
                    foreach (var up in uniquePeptides)
                    {
                        var subPNode = subNode.Nodes.Add(string.Format("{0} ({1})", up.Key, up.Count()));
                        subPNode.Tag = new List <IIdentifiedSpectrum>(from p in up select p.Spectrum);

                        var peps = (from p in up
                                    orderby p.Spectrum.Query.FileScan.Experimental, p.Spectrum.Query.FileScan.FirstScan
                                    select p).ToList();

                        foreach (var p in peps)
                        {
                            var ppNode = subPNode.Nodes.Add(string.Format("{0}, {1:0.##}", p.Spectrum.Query.FileScan.LongFileName, p.Spectrum.Score));
                            ppNode.Tag = p.Spectrum;
                        }
                    }
                }
            }
            finally
            {
                tvResult.EndUpdate();
            }
        }
Exemplo n.º 2
0
        private ResultCorrelationItem BuildResult(IIdentifiedResult ir)
        {
            var result = new ResultCorrelationItem();

            result.ClassificationTitles = ClassificationSet.Keys.ToArray();
            foreach (var g in ir)
            {
                var pro     = g[0];
                var protein = new ProteinCorrelationItem();
                result.Add(protein);

                protein.Index        = g.Index;
                protein.Protein      = ParseItem(pro.Peptides, result.ClassificationTitles);
                protein.Protein.Name = pro.Name;

                var peps = pro.Peptides.GroupBy(m => PeptideUtils.GetMatchedSequence(m.Sequence));
                foreach (var pep in peps)
                {
                    var pepitem = ParseItem(pep.ToList(), result.ClassificationTitles);
                    protein.Peptides.Add(pepitem);

                    pepitem.Name        = pep.Key;
                    pepitem.Correlation = Correlation.Pearson(pepitem.Values, protein.Protein.Values);
                }
            }

            result.ForEach(m =>
            {
                m.Peptides.Sort((m1, m2) => m2.Correlation.CompareTo(m1.Correlation));
            });
            return(result);
        }
Exemplo n.º 3
0
        /**
         * 根据给定的sphc、pephits,以及classifiedNames进行统计各个classifiedNames对应的肽段个数。
         */
        public void ClassifyPeptideHit(Func <IIdentifiedPeptide, string> classifyFunc, string[] classifiedNames)
        {
            classifications = new Dictionary <string, Count>();

            if (classifiedNames != null)
            {
                foreach (string name in classifiedNames)
                {
                    classifications[name] = new Count();
                }
            }

            var s = from p in Peptides
                    let key                     = classifyFunc(p)
                                        let seq = PeptideUtils.GetPureSequence(p.Sequence)
                                                  group seq by key into ss
                                                  select new { Key = ss.Key, PeptideCount = ss.Count(), UniquePeptideCount = ss.Distinct().Count() };

            foreach (var item in s)
            {
                classifications[item.Key] = new Count()
                {
                    PeptideCount       = item.PeptideCount,
                    UniquePeptideCount = item.UniquePeptideCount
                };
            }
        }
        protected override void DoRealGo()
        {
            Aminoacids aas = Aminoacids.ParseModificationFromOutFileLine(modification.Text);

            IPeptideMassCalculator calc;

            if (isMonoisotopic.Checked)
            {
                calc = new MonoisotopicPeptideMassCalculator(aas);
            }
            else
            {
                calc = new AveragePeptideMassCalculator(aas);
            }

            string seq = PeptideUtils.GetMatchedSequence(sequence.Text);
            double value;

            if (isMH.Checked)
            {
                value = calc.GetMz(seq, 1);
            }
            else
            {
                value = calc.GetMass(seq);
            }
            txtResult.Text = value.ToString();
        }
        private void init(String modifiedAminoacids, String sequence,
                          char modifiedSign)
        {
            String matchSequence = PeptideUtils.GetMatchedSequence(sequence);

            this.pureSequence = PeptideUtils.GetPureSequence(matchSequence);

            modifiedCount = 0;

            for (int i = 0; i < matchSequence.Length; i++)
            {
                char c = matchSequence[i];
                if (char.IsLetter(c) && char.IsUpper(c))
                {
                    sites.Add(new Pair <char, char>(c, ' '));
                }
                else if (isCandidateModifiedAminoacid(modifiedAminoacids,
                                                      getLastPair().First))
                {
                    if (modifiedSign == ' ')
                    {
                        getLastPair().Second = c;
                    }
                    else
                    {
                        getLastPair().Second = modifiedSign;
                    }
                    modifiedCount++;
                }
            }
            calculate();
        }
Exemplo n.º 6
0
        public override IEnumerable <string> Process(string fileName)
        {
            MascotResultTextFormat format = new MascotResultTextFormat();

            IIdentifiedResult ir = format.ReadFromFile(fileName);

            List <IIdentifiedSpectrum> spectra = ir.GetSpectra();

            spectra.ForEach(m =>
            {
                for (int i = m.Peptides.Count - 1; i >= 0; i--)
                {
                    IIdentifiedPeptide peptide = m.Peptides[i];

                    string seq = PeptideUtils.GetMatchedSequence(peptide.Sequence);

                    if (!validator.Validate(seq))
                    {
                        m.RemovePeptideAt(i);
                        peptide.Spectrum = null;
                    }
                }
            });

            ir.Filter(m =>
            {
                return(m.Spectrum != null);
            });

            string result = fileName + ".Labeled";

            format.WriteToFile(result, ir);

            return(new[] { result });
        }
        public void CreateTargetsFromEmpiricalFormulaOnlyLargePeptideTest1()
        {
            var util = new IqTargetUtilities();

            var peptideSequence =
                "PEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDEPEPITIDE";

            var peptideUtil      = new PeptideUtils();
            var empiricalFormula = peptideUtil.GetEmpiricalFormulaForPeptideSequence(peptideSequence);



            var formulas = new string[] { empiricalFormula };


            var targets = util.CreateTargets(formulas);


            foreach (var parentTarget in targets)
            {
                Console.WriteLine(parentTarget.ID + "\t" + parentTarget.MonoMassTheor.ToString("0.00000") + "\tNumChildren= " + parentTarget.ChildTargets().Count());
                if (parentTarget.HasChildren())
                {
                    foreach (var childTarget in parentTarget.ChildTargets())
                    {
                        Console.WriteLine("\t\t\t" + childTarget.ID + "\t" + childTarget.MonoMassTheor.ToString("0.00000") + "\t" +
                                          childTarget.MZTheor.ToString("0.00000") + "\t" + childTarget.ChargeState + "\t" + (1.00235d / childTarget.ChargeState).ToString("0.0000"));
                    }
                }
            }
        }
        /// <summary>
        /// 根据序列构建氨基酸信息列表。该信息列表中已将修饰质量加到氨基酸上,可方便地用于构建离子列表。
        /// </summary>
        /// <param name="sequence">氨基酸序列,包含修饰字符。</param>
        /// <returns>氨基酸信息列表</returns>
        public List <AminoacidInfo> BuildInfo(string sequence)
        {
            var matchedSequence = PeptideUtils.GetMatchedSequence(sequence);

            var result = new List <AminoacidInfo>();

            foreach (char c in matchedSequence)
            {
                if (char.IsLetter(c) && char.IsUpper(c))
                {
                    var aai = new AminoacidInfo();
                    aai.Aminoacid    = c;
                    aai.Modification = ' ';
                    aai.Mass         = this[c].MonoMass;
                    result.Add(aai);
                }
                else
                {
                    AminoacidInfo aai = result.Last();
                    aai.Modification = c;
                    aai.Mass        += this[c].MonoMass;
                }
            }
            return(result);
        }
        public override IEnumerable <string> Process(string fileName)
        {
            var peptides = new MascotPeptideTextFormat().ReadFromFile(fileName);

            var seqs = (from p in peptides
                        let pep = p.Peptide
                                  select PeptideUtils.GetMatchedSequence(pep.Sequence)).ToList();

            var nmod = (from seq in seqs
                        where !char.IsLetter(seq[0])
                        select seq).Count();

            var kseqs = (from seq in seqs
                         where seq.Contains(modificationAminoacid)
                         select seq).Count();

            var kmod = (from seq in seqs
                        where seq.Contains(modificationAminoacid) && IsFullModifiedK(seq)
                        select seq).Count();

            var result = fileName + ".labelingEfficiency";

            using (StreamWriter sw = new StreamWriter(result))
            {
                sw.WriteLine("Total PSMs\t{0}", peptides.Count);
                sw.WriteLine("N-terminal modified PSMs\t{0}", nmod);
                sw.WriteLine("{0}-contained PSMs\t{1}", modificationAminoacid, kseqs);
                sw.WriteLine("{0}-full-modified PSMs\t{2}", modificationAminoacid, kmod);
            }

            return(new string[] { result });
        }
        public void checkModImport_Test1()
        {
            var importer         = new MassTagFromSqlDbImporter("MT_Shewanella_ProdTest_P352", "porky", _targetIDList);
            var targetCollection = importer.Import();

            var testPeptide1 = (PeptideTarget)targetCollection.TargetList[70];

            Assert.AreEqual(72, targetCollection.TargetList.Count);
            Assert.AreEqual(189684639, testPeptide1.ID);
            Assert.AreEqual("QALYEAENVLRDEQIALQK", testPeptide1.Code);
            Assert.AreEqual(2213.1326995m, (decimal)testPeptide1.MonoIsotopicMass);

            Assert.AreEqual(1, testPeptide1.ModCount);
            Assert.AreEqual("NH3_Loss:1", testPeptide1.ModDescription);
            Assert.AreEqual(true, testPeptide1.ContainsMods);
            Assert.AreEqual(696, testPeptide1.ObsCount);


            var peptideUtils = new PeptideUtils();

            Assert.AreEqual("C97H159N27O33", peptideUtils.GetEmpiricalFormulaForPeptideSequence(testPeptide1.Code));


            Assert.AreNotEqual("C97H159N27O33", testPeptide1.EmpiricalFormula);
            Assert.AreEqual("C97H156N26O33", testPeptide1.EmpiricalFormula);
        }
Exemplo n.º 11
0
        public void GetEmpiricalFormulaForAminoAcidTest1()
        {
            var utils = new PeptideUtils();

            var testAminoAcid = 'A';

            Assert.AreEqual("C3H5NO", utils.GetEmpiricalFormulaForAminoAcidResidue(testAminoAcid));
        }
        public string GetMatchSequence()
        {
            if (this.Peptides.Count == 0)
            {
                return("");
            }

            return(PeptideUtils.GetMatchedSequence(this.Peptides[0].Sequence));
        }
        public void GenerateIsotopicProfileTest1()
        {
            var peptideUtils = new PeptideUtils();


            var empiricalFormula = peptideUtils.GetEmpiricalFormulaForPeptideSequence("SAMPLERSAMPLER");


            var featureGenerator = new JoshTheorFeatureGenerator();
        }
Exemplo n.º 14
0
        public void GetIsotopicProfileTest2()
        {
            var peptideUtils = new PeptideUtils();
            var empFormula   = "S3";

            var isoCalc = IsotopicDistributionCalculator.Instance;
            var iso     = isoCalc.GetIsotopePattern(empFormula);


            TestUtilities.DisplayIsotopicProfileData(iso);
        }
Exemplo n.º 15
0
        public void GetIsotopicProfileTest1()
        {
            var peptideUtils = new PeptideUtils();
            var empFormula   = peptideUtils.GetEmpiricalFormulaForPeptideSequence("SAMPLERSAMPLER");

            var isoCalc = IsotopicDistributionCalculator.Instance;
            var iso     = isoCalc.GetIsotopePattern(empFormula);


            TestUtilities.DisplayIsotopicProfileData(iso);
        }
        private void InitTheoreticalPeaks()
        {
            Aminoacids aas = new Aminoacids();

            aas.SetModification(StaticModification);
            aas.SetModification(DynamicModification);

            CIDFragmentationBuilder <MatchedPeak> builder = new CIDFragmentationBuilder <MatchedPeak> (ExperimentalPeakList.PrecursorCharge, aas);

            ionSeries = builder.GetIonSeries(PeptideUtils.GetMatchedSequence(Peptide));
        }
        public void GetMonoisotopicMassFromEmpiricalFormulaTest1()
        {
            var testPeptide  = "SAMPLER";
            var peptideUtils = new PeptideUtils();
            var formula      = peptideUtils.GetEmpiricalFormulaForPeptideSequence(testPeptide);

            var monomass = EmpiricalFormulaUtilities.GetMonoisotopicMassFromEmpiricalFormula(formula);

            Assert.IsTrue(monomass > 0);
            Console.WriteLine("SAMPLER monoisotopic mass= \t" + monomass);

            Assert.AreEqual(802.40072m, (decimal)Math.Round(monomass, 5));    //note that Peptide Util reports 802.40071, as does MacCoss's lab: http://proteome.gs.washington.edu/cgi-bin/aa_calc.pl
        }
        protected void CheckTerminalExtension(List <SapPredicted> predicted, MS2Item query, MS2Item libms2, SapMatchedCount ms3match)
        {
            var bNterminalValid = libms2.Peptide.StartsWith("-");
            var bCterminalValid = libms2.Peptide.EndsWith("-");

            if (bNterminalValid || bCterminalValid)
            {
                foreach (var ne in options.ExtensionDeltaMassList)
                {
                    var neMz = libms2.Precursor + ne.DeltaMass / libms2.Charge;
                    if (neMz >= query.MinPrecursorMz && neMz <= query.MaxPrecursorMz)
                    {
                        var seq = PeptideUtils.GetPureSequence(libms2.Peptide);

                        if (bNterminalValid)
                        {
                            predicted.Add(new SapPredicted()
                            {
                                Ms2     = query,
                                LibMs2  = libms2,
                                Matched = ms3match,
                                Target  = new TargetVariant()
                                {
                                    Source     = PeptideUtils.GetPureSequence(libms2.Peptide),
                                    Target     = new HashSet <string>(from t in ne.Target select t + seq),
                                    DeltaMass  = ne.DeltaMass,
                                    TargetType = VariantType.NTerminalExtension
                                }
                            });
                        }

                        if (bCterminalValid)
                        {
                            predicted.Add(new SapPredicted()
                            {
                                Ms2     = query,
                                LibMs2  = libms2,
                                Matched = ms3match,
                                Target  = new TargetVariant()
                                {
                                    Source     = PeptideUtils.GetPureSequence(libms2.Peptide),
                                    Target     = new HashSet <string>(from t in ne.Target select seq + t),
                                    DeltaMass  = ne.DeltaMass,
                                    TargetType = VariantType.CTerminalExtension
                                }
                            });
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
 private void ValidateModifications(string seq)
 {
     char[] modifiedChars = PeptideUtils.GetModifiedChar(seq);
     if (modifiedChars.Length > 0)
     {
         foreach (char c in modifiedChars)
         {
             if (!_sciBuilder.IsModificationDefined(c))
             {
                 throw new ArgumentException(MyConvert.Format("Modification {0} was not defined in SILAC configuration file : {1}.", c, option.SilacParamFile));
             }
         }
     }
 }
Exemplo n.º 20
0
        private List <string> GetIdentifiedSpectrumKey(IIdentifiedSpectrum spectrum, SilacCompoundInfo sci)
        {
            int theoreticalMass = (int)(sci.Light.Mz * sci.Light.Charge + 0.5);
            int charge          = spectrum.Charge;

            List <string> keys = new List <string>();

            foreach (IIdentifiedPeptide peptide in spectrum.Peptides)
            {
                string sequenceCharge = PeptideUtils.GetPureSequence(peptide.Sequence) + "." + charge + "." + theoreticalMass;
                keys.Add(sequenceCharge);
            }
            return(keys);
        }
        public void addUnimodFormulaTest1()
        {
            var testPeptide = "SAMPLER";

            var peptideUtils = new PeptideUtils();
            var baseFormula  = peptideUtils.GetEmpiricalFormulaForPeptideSequence(testPeptide);

            var mod        = "H3 C2 N O";
            var modFormula = EmpiricalFormulaUtilities.AddFormula(baseFormula, mod);

            Console.WriteLine("Unmodified peptide= " + baseFormula);
            Console.WriteLine("Modified peptide= " + modFormula);

            Assert.AreEqual("C35H61N11O12S", modFormula);
        }
        private string GetModificationCount(IIdentifiedPeptide pep, string p)
        {
            var result     = 0;
            var matchedSeq = PeptideUtils.GetMatchedSequence(pep.Sequence);

            for (int i = 0; i < matchedSeq.Length - 1; i++)
            {
                if (p.Contains(matchedSeq[i]) && !Char.IsLetter(matchedSeq[i + 1]))
                {
                    result++;
                    i++;
                }
            }

            return(result.ToString());
        }
Exemplo n.º 23
0
        public void InitTerminalLoss(Aminoacids aa, int maxTerminalLossLength, int minSequenceLength)
        {
            this.TerminalLoss = new List <TerminalLossItem>();

            var seq     = PeptideUtils.GetMatchedSequence(this.Peptide);
            var pureseq = PeptideUtils.GetPureSequence(this.Peptide);

            var pos       = 0;
            var index     = 0;
            var maxIndex  = Math.Min(maxTerminalLossLength, pureseq.Length - minSequenceLength);
            var deltaMass = 0.0;

            while (index < maxIndex)
            {
                deltaMass += aa[seq[pos]].MonoMass;
                if (!char.IsUpper(seq[pos + 1]))
                {
                    pos++;
                    continue;
                }

                index++;
                pos++;

                var precursorLoss = this.Precursor - deltaMass / this.Charge;
                this.TerminalLoss.Add(new TerminalLossItem(true, pureseq.Substring(index), precursorLoss));
            }

            index     = 0;
            pos       = seq.Length - 1;
            deltaMass = 0.0;
            while (index < maxIndex)
            {
                deltaMass += aa[seq[pos]].MonoMass;
                if (!char.IsUpper(seq[pos]))
                {
                    pos--;
                    continue;
                }

                index++;
                pos--;

                var precursorLoss = this.Precursor - deltaMass / this.Charge;
                this.TerminalLoss.Add(new TerminalLossItem(false, pureseq.Substring(0, pureseq.Length - index), precursorLoss));
            }
        }
Exemplo n.º 24
0
        public void getN15IsotopicProfileTest1()
        {
            var isIt = isotopicDistributionCalculator.IsSetToLabeled;


            var utils = new PeptideUtils();
            //string formula = utils.GetEmpiricalFormulaForPeptideSequence("SAMPLERPAMPLERSAMPLERPAMPLERSAMPLERPAMPLERSAMPLERPAMPLER");
            var formula = utils.GetEmpiricalFormulaForPeptideSequence("SAMPLERPAMPLERSAMPLERPAMPLER");



            var numNitrogens = utils.GetNumAtomsForElement("N", formula);


            var iso1 = isotopicDistributionCalculator.GetIsotopePattern(formula);

            PeakUtilities.TrimIsotopicProfile(iso1, 0.001);

            TestUtilities.DisplayIsotopicProfileData(iso1);

            isotopicDistributionCalculator.SetLabeling("N", 14, 0.02, 15, 0.98);

            var iso2 = isotopicDistributionCalculator.GetIsotopePattern(formula);

            //PeakUtilities.TrimIsotopicProfile(iso2, 0.001);

            isotopicDistributionCalculator.ResetToUnlabeled();
            var iso3 = isotopicDistributionCalculator.GetIsotopePattern(formula);

            PeakUtilities.TrimIsotopicProfile(iso3, 0.001);


            Console.WriteLine();
            TestUtilities.DisplayIsotopicProfileData(iso2);


            for (var i = 0; i < iso1.Peaklist.Count; i++)
            {
                Assert.AreEqual((decimal)Math.Round(iso1.Peaklist[i].Height, 4), (decimal)Math.Round(iso3.Peaklist[i].Height, 4));
            }

            Console.WriteLine();
            TestUtilities.DisplayIsotopicProfileData(iso3);

            Console.WriteLine("Num nitrogens= " + numNitrogens);
        }
Exemplo n.º 25
0
        public void GetEmpiricalFormulaForPeptideSequenceTest2()
        {
            var utils = new PeptideUtils();

            var testSequence1 = "IPNFWVTTFVNHPQVSALLGEEDEEALHYLTR";

            var testSequence2 = "K.IPNFWVTTFVNHPQVSALLGEEDEEALHYLTR*.V";


            var empiricalFormula1 = utils.GetEmpiricalFormulaForPeptideSequence(testSequence1);

            var empiricalFormula2 = utils.GetEmpiricalFormulaForPeptideSequence(testSequence2);


            Assert.AreEqual(empiricalFormula1, empiricalFormula2);
            Assert.AreEqual((decimal)Math.Round(utils.GetMonoIsotopicMassForPeptideSequence(testSequence1), 5), (decimal)Math.Round(utils.GetMonoIsotopicMassForPeptideSequence(testSequence2), 5));
        }
Exemplo n.º 26
0
        public List <IqTarget> Import()
        {
            var targets = GetMassTagDataFromDb();

            if (IsEmpiricalFormulaExtracted)
            {
                GetModDataFromDb(_targetsContainingMods);

                var peptideUtils = new PeptideUtils();

                foreach (IqTargetDms iqTarget in targets)
                {
                    var baseEmpiricalFormula = peptideUtils.GetEmpiricalFormulaForPeptideSequence(iqTarget.Code);
                    if (!string.IsNullOrEmpty(iqTarget.ModDescription))
                    {
                        var target = iqTarget;
                        var mods   = (from n in _massTagModData where n.Item1 == target.ID select n);

                        foreach (var tuple in mods)
                        {
                            var modString = tuple.Item4;

                            try
                            {
                                baseEmpiricalFormula = EmpiricalFormulaUtilities.AddFormula(baseEmpiricalFormula, modString);
                            }
                            catch (Exception ex)
                            {
                                IqLogger.Log.Debug("Failed to calculate empirical formula for the Target " + target.ID + " (" + ex.Message + ")" +
                                                   "; Having trouble with the mod: " + modString + "; This Target was NOT imported!!");
                            }
                        }
                    }

                    iqTarget.EmpiricalFormula = baseEmpiricalFormula;

                    if (IsMonoMassCalculatedFromEmpiricalFormula)
                    {
                        iqTarget.MonoMassTheor = EmpiricalFormulaUtilities.GetMonoisotopicMassFromEmpiricalFormula(iqTarget.EmpiricalFormula);
                    }
                }
            }

            return(targets);
        }
Exemplo n.º 27
0
        public string GetPhosphoModificationString(string peptide)
        {
            string        matchedSequence = PeptideUtils.GetMatchedSequence(peptide);
            StringBuilder result          = new StringBuilder();

            for (int i = 0; i < matchedSequence.Length; i++)
            {
                if (!PeptideUtils.IsAminoacid(matchedSequence[i]))
                {
                    continue;
                }

                if (IsPhospho(matchedSequence, i))
                {
                    result.Append(matchedSequence[i]);
                }
            }
            return(result.ToString());
        }
        /// <summary>
        /// 根据原始蛋白质的序列,替换搜库结果中突变序列中对应位置的L为I
        /// </summary>
        /// <param name="mutSeq">搜库结果突变序列</param>
        /// <param name="oriPureSeq">原始蛋白质纯序列</param>
        /// <returns>修正后的突变序列</returns>
        public static string ReplaceLToI(string mutSeq, string oriPureSeq)
        {
            if (!oriPureSeq.Contains('I'))
            {
                return(mutSeq);
            }

            string        mutPureSeq   = PeptideUtils.GetPureSequence(mutSeq);
            StringBuilder mutPureSeqSb = new StringBuilder(mutPureSeq);

            for (int i = 0; i < oriPureSeq.Length && i < mutPureSeq.Length; i++)
            {
                if (oriPureSeq[i] == 'I' && mutPureSeqSb[i] == 'L')
                {
                    mutPureSeqSb[i] = oriPureSeq[i];
                }
            }

            StringBuilder mutSeqSb = new StringBuilder(mutSeq);
            int           curIndex = 0;

            if (mutSeq.Contains('.'))
            {
                for (int i = 2; i < mutSeqSb.Length - 2; i++)
                {
                    if (char.IsLetter(mutSeqSb[i]) && char.IsUpper(mutSeqSb[i]))
                    {
                        mutSeqSb[i] = mutPureSeqSb[curIndex++];
                    }
                }
            }
            else
            {
                for (int i = 0; i < mutSeqSb.Length; i++)
                {
                    if (char.IsLetter(mutSeqSb[i]) && char.IsUpper(mutSeqSb[i]))
                    {
                        mutSeqSb[i] = mutPureSeqSb[curIndex++];
                    }
                }
            }
            return(mutSeqSb.ToString());
        }
        public void AddPhosphorylationTest1()
        {
            const string testPeptide  = "SAMPLER";
            var          peptideUtils = new PeptideUtils();
            var          formula      = peptideUtils.GetEmpiricalFormulaForPeptideSequence(testPeptide);

            const string phosphorylationMod = "HPO3";

            var empiricalFormula = EmpiricalFormulaUtilities.AddFormula(formula, phosphorylationMod);

            var massUnmodified = EmpiricalFormulaUtilities.GetMonoisotopicMassFromEmpiricalFormula(formula);
            var massModified   = EmpiricalFormulaUtilities.GetMonoisotopicMassFromEmpiricalFormula(empiricalFormula);
            var diff           = Math.Round(massModified - massUnmodified, 1, MidpointRounding.AwayFromZero);

            Console.WriteLine(formula + "\t" + massUnmodified);
            Console.WriteLine(empiricalFormula + "\t" + massModified);
            Console.WriteLine("diff= " + diff);

            Assert.AreEqual(80.0, diff);
        }
        public void PyroglutamateTest1()
        {
            const string testPeptide  = "SAMPLER";
            var          peptideUtils = new PeptideUtils();
            var          formula      = peptideUtils.GetEmpiricalFormulaForPeptideSequence(testPeptide);

            const string pyroglutamateMod = "H3N1";

            var empiricalFormula = EmpiricalFormulaUtilities.SubtractFormula(formula, pyroglutamateMod);

            var massUnmodified = EmpiricalFormulaUtilities.GetMonoisotopicMassFromEmpiricalFormula(formula);
            var massModified   = EmpiricalFormulaUtilities.GetMonoisotopicMassFromEmpiricalFormula(empiricalFormula);
            var diff           = Math.Round(massModified - massUnmodified, 1, MidpointRounding.AwayFromZero);

            Console.WriteLine(formula + "\t" + massUnmodified);
            Console.WriteLine(empiricalFormula + "\t" + massModified);
            Console.WriteLine("diff= " + diff);

            Assert.AreEqual(-17.0, diff);
        }