コード例 #1
0
        private void WriteExplicitMods(XmlWriter writer, string name,
                                       string nameElMod, IsotopeLabelType labelType, IEnumerable <ExplicitMod> mods,
                                       string sequence)
        {
            if (mods == null || (labelType == null && string.IsNullOrEmpty(sequence)))
            {
                return;
            }
            writer.WriteStartElement(name);
            if (labelType != null)
            {
                writer.WriteAttribute(ATTR.isotope_label, labelType);
            }

            if (!string.IsNullOrEmpty(sequence))
            {
                SequenceMassCalc massCalc = Settings.TransitionSettings.Prediction.PrecursorMassType == MassType.Monoisotopic ?
                                            SrmSettings.MonoisotopicMassCalc : SrmSettings.AverageMassCalc;
                foreach (ExplicitMod mod in mods)
                {
                    writer.WriteStartElement(nameElMod);
                    writer.WriteAttribute(ATTR.index_aa, mod.IndexAA);
                    writer.WriteAttribute(ATTR.modification_name, mod.Modification.Name);

                    double massDiff = massCalc.GetModMass(sequence[mod.IndexAA], mod.Modification);

                    writer.WriteAttribute(ATTR.mass_diff,
                                          string.Format(CultureInfo.InvariantCulture, @"{0}{1}", (massDiff < 0 ? string.Empty : @"+"),
                                                        Math.Round(massDiff, 1)));

                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();
        }
コード例 #2
0
ファイル: UniMod.cs プロジェクト: suchp-max/proteowizard
 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);
 }
コード例 #3
0
ファイル: Modification.cs プロジェクト: lgatto/proteowizard
 private static double[] CalcModMasses(Peptide peptide, IEnumerable<ExplicitMod> mods,
     SequenceMassCalc massCalc)
 {
     double[] masses = new double[peptide.Length];
     string seq = peptide.Sequence;
     foreach (ExplicitMod mod in mods)
         masses[mod.IndexAA] += massCalc.GetModMass(seq[mod.IndexAA], mod.Modification);
     return masses;
 }