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();
        }
        public IPeptideMassCalculator GetPeptideMassCalculator()
        {
            bool isMono = IsPrecursorMonoisotopic();

            var aas = new Aminoacids();
            Dictionary <char, double> staticModifications = GetStaticAminoacidModification();

            foreach (char aa in staticModifications.Keys)
            {
                aas[aa].ResetMass(aas[aa].MonoMass + staticModifications[aa], aas[aa].AverageMass + staticModifications[aa]);
            }

            var diff = new[] { '*', '#', '@', '^', '~', '$' };
            int i    = 0;

            foreach (double mod in Diff_search_options.Values)
            {
                aas[diff[i++]].ResetMass(mod, mod);
            }

            double nterm = isMono ? Atom.H.MonoMass : Atom.H.AverageMass;
            double cterm = isMono ? Atom.H.MonoMass + Atom.O.MonoMass : Atom.H.AverageMass + Atom.O.AverageMass;

            if (this.term_diff_search_options.First != 0.0 || this.term_diff_search_options.Second != 0.0)
            {
                throw new Exception(
                          "Term dynamic modification has not been implemented into this function, call author to fix it.");
            }

            IPeptideMassCalculator result;

            if (isMono)
            {
                result = new MonoisotopicPeptideMassCalculator(aas, nterm, cterm);
            }
            else
            {
                result = new AveragePeptideMassCalculator(aas, nterm, cterm);
            }

            return(result);
        }
        public IIdentifiedResult Build(List <IIdentifiedProteinGroup> groups)
        {
            IdentifiedResult result = new IdentifiedResult();

            result.AddRange(groups);
            result.Sort();
            result.BuildGroupIndex();

            if (FillSequence(result))
            {
                AveragePeptideMassCalculator massCalc = new AveragePeptideMassCalculator(new Aminoacids(), Atom.H.AverageMass, Atom.H.AverageMass + Atom.O.AverageMass);

                Progress.SetMessage("Calculating coverage and mass weight ...");
                foreach (IIdentifiedProteinGroup group in result)
                {
                    foreach (IIdentifiedProtein protein in group)
                    {
                        if (!string.IsNullOrEmpty(protein.Sequence))
                        {
                            try
                            {
                                protein.CalculateCoverage();
                                protein.MolecularWeight = massCalc.GetMass(protein.Sequence);
                            }
                            catch (Exception ex)
                            {
                                var error = "Calculating coverage and mass weight error:" + ex.Message;
                                Progress.SetMessage(error);
                                Console.Error.WriteLine(error);
                            }
                        }
                    }
                }
            }

            return(result);
        }