コード例 #1
0
ファイル: GraphHelper.cs プロジェクト: lgatto/proteowizard
 private PaneKey(int? precusorCharge, IsotopeLabelType isotopeLabelType, bool? isProducts)
     : this()
 {
     PrecursorCharge = precusorCharge;
     IsotopeLabelType = isotopeLabelType;
     IsProducts = isProducts;
 }
コード例 #2
0
ファイル: IsotypeModTest.cs プロジェクト: lgatto/proteowizard
        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);
        }
コード例 #3
0
ファイル: Peptide.cs プロジェクト: austinkeller/pwiz
        public IEnumerable <TransitionGroup> GetTransitionGroups(SrmSettings settings, PeptideDocNode nodePep, ExplicitMods mods, bool useFilter)
        {
            if (IsCustomMolecule)
            {
                // TODO(bspratt) WHY NOT USING TRANSITION SETTINGS FILTER PRECURSOR ADDUCTS?
                // We can't generate precursors as we do with peptides, so just filter what we do have on instrument mz range
                //var precursorAdducts = settings.TransitionSettings.Filter.SmallMoleculePrecursorAdducts;
                // TODO(bspratt) generate precursor transitions if doc has no fragments
                // CONSIDER(bspratt) could we reasonably reuse fragments with proposed precursors of suitable charge and polarity (say, add an M+Na node that mimics an existing M+H node and children)
                foreach (var group in nodePep.TransitionGroups.Where(tranGroup => tranGroup.TransitionGroup.IsCustomIon))
                {
                    if (!useFilter || settings.TransitionSettings.IsMeasurablePrecursor(group.PrecursorMz))
                    {
                        yield return(group.TransitionGroup);
                    }
                }
            }
            else
            {
                var precursorCharges = settings.TransitionSettings.Filter.PeptidePrecursorCharges;
                if (!useFilter)
                {
                    precursorCharges = new List <Adduct>();
                    for (int i = TransitionGroup.MIN_PRECURSOR_CHARGE; i < TransitionGroup.MAX_PRECURSOR_CHARGE; i++)
                    {
                        precursorCharges.Add(Adduct.FromChargeProtonated(i));
                    }
                }

                var modSettings = settings.PeptideSettings.Modifications;

                var precursorMassLight  = settings.GetPrecursorMass(IsotopeLabelType.light, Target, mods);
                var listPrecursorMasses = new List <KeyValuePair <IsotopeLabelType, TypedMass> >
                {
                    new KeyValuePair <IsotopeLabelType, TypedMass>(IsotopeLabelType.light, precursorMassLight)
                };

                foreach (var typeMods in modSettings.GetHeavyModifications())
                {
                    IsotopeLabelType labelType = typeMods.LabelType;
                    var precursorMass          = precursorMassLight;
                    if (settings.HasPrecursorCalc(labelType, mods))
                    {
                        precursorMass = settings.GetPrecursorMass(labelType, Target, mods);
                    }

                    listPrecursorMasses.Add(new KeyValuePair <IsotopeLabelType, TypedMass>(labelType, precursorMass));
                }

                foreach (var adduct in precursorCharges)
                {
                    if (useFilter && !settings.Accept(settings, this, mods, adduct))
                    {
                        continue;
                    }

                    for (int i = 0; i < listPrecursorMasses.Count; i++)
                    {
                        var pair = listPrecursorMasses[i];
                        IsotopeLabelType labelType = pair.Key;
                        var precursorMass          = pair.Value;
                        // Only return a heavy group, if the precursor masses differ
                        // between the light and heavy calculators
                        if (i == 0 || precursorMass != precursorMassLight)
                        {
                            if (settings.TransitionSettings.IsMeasurablePrecursor(SequenceMassCalc.GetMZ(precursorMass, adduct)))
                            {
                                yield return(new TransitionGroup(this, adduct, labelType));
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Creates a text sequence with the fully modified peptide sequence text
        /// and font information for a given label type.
        /// </summary>
        private static TextSequence CreateTypeTextSequence(PeptideDocNode nodePep, SrmSettings settings,
            IsotopeLabelType labelType, ModFontHolder fonts)
        {
            var calc = settings.TryGetPrecursorCalc(labelType, nodePep.ExplicitMods);
            if (calc == null)
                return null;

            return new TextSequence
                       {
                           Text = nodePep.IsProteomic
                               ? calc.GetModifiedSequence(nodePep.Peptide.Sequence, true)
                               : nodePep.CustomIon.DisplayName,
                           Font = fonts.GetModFont(labelType),
                           Color = ModFontHolder.GetModColor(labelType)
                       };
        }
コード例 #5
0
 public static DocNodeCustomIon ConvertToSmallMolecule(ConvertToSmallMoleculesMode mode, 
     SrmDocument document, PeptideDocNode nodePep, int precursorCharge = 0, IsotopeLabelType isotopeLabelType = null)
 {
     // We're just using this masscalc to get the ion formula, so mono vs average doesn't matter
     isotopeLabelType = isotopeLabelType ?? IsotopeLabelType.light;
     var peptideSequence = nodePep.Peptide.Sequence;
     var masscalc = document.Settings.TryGetPrecursorCalc(isotopeLabelType, nodePep.ExplicitMods) ?? new SequenceMassCalc(MassType.Monoisotopic);
     // Determine the molecular formula of the charged/labeled peptide
     var moleculeFormula = masscalc.GetIonFormula(peptideSequence, precursorCharge);
     var moleculeCustomIon = new DocNodeCustomIon(moleculeFormula,
         SmallMoleculeNameFromPeptide(peptideSequence, precursorCharge));
     if (mode == ConvertToSmallMoleculesMode.masses_only)
     {
         // No formulas or names, just masses - see how we handle that
         moleculeCustomIon = new DocNodeCustomIon(moleculeCustomIon.MonoisotopicMass,
             moleculeCustomIon.AverageMass);
     }
     else if (mode == ConvertToSmallMoleculesMode.masses_and_names)
     {
         // Just masses and names - see how we handle that
         moleculeCustomIon = new DocNodeCustomIon(moleculeCustomIon.MonoisotopicMass,
             moleculeCustomIon.AverageMass, moleculeCustomIon.Name);
     }
     return moleculeCustomIon;
 }
コード例 #6
0
        public TransitionGroup(Peptide peptide, DocNodeCustomIon customIon, int precursorCharge, IsotopeLabelType labelType, bool unlimitedCharge, int?decoyMassShift)
        {
            _peptide        = peptide;
            CustomIon       = customIon ?? Peptide.CustomIon; // If parent molecule is a custom ion, and none specified, use that
            PrecursorCharge = precursorCharge;
            LabelType       = labelType;
            DecoyMassShift  = decoyMassShift;

            Validate(unlimitedCharge ? 0 : precursorCharge);
        }
コード例 #7
0
 public TransitionGroup(Peptide peptide, DocNodeCustomIon customIon, int precursorCharge, IsotopeLabelType labelType)
     : this(peptide, customIon, precursorCharge, labelType, false, null)
 {
 }
コード例 #8
0
ファイル: EditPepModsDlg.cs プロジェクト: lgatto/proteowizard
 private ComboBox InitModificationCombo(ComboBox combo, int indexAA, IsotopeLabelType type)
 {
     var modsDoc = DocSettings.PeptideSettings.Modifications;
     var modsExp = NodePeptide.ExplicitMods;
     return type.IsLight
         ? InitModificationCombo(combo, modsDoc.StaticModifications,
             modsExp != null ? modsExp.StaticModifications : null, StaticList, indexAA,
             modsExp != null && modsExp.IsVariableStaticMods)
         : InitModificationCombo(combo, modsDoc.GetModifications(type),
             modsExp != null ? modsExp.GetModifications(type) : null, HeavyList, indexAA,
             false);
 }
コード例 #9
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
            private RatioValue CalcTransitionGroupGlobalRatio(int precursorCharge, IsotopeLabelType labelType)
            {
                if (GlobalStandardArea == 0)
                    return null;

                double num = 0;
                foreach (var pair in GetAreaPairs(labelType))
                {
                    var key = pair.Key;
                    if (precursorCharge != -1 && key.PrecursorCharge != precursorCharge)
                        continue;
                    num += pair.Value;
                }

                return new RatioValue(num / GlobalStandardArea);
            }
コード例 #10
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
            public float? CalcTransitionRatio(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran, IsotopeLabelType labelTypeNum, IsotopeLabelType labelTypeDenom)
            {
                // Avoid 1.0 ratios for self-to-self
                if (ReferenceEquals(labelTypeNum, labelTypeDenom))
                    return null;

                float areaNum, areaDenom;
                var key = nodeTran.Key(nodeGroup);
                var keyNum = new TransitionKey(nodeGroup, key, labelTypeNum);
                var keyDenom = new TransitionKey(nodeGroup, key, labelTypeDenom);
                if (!TranAreas.TryGetValue(keyNum, out areaNum) ||
                    !TranAreas.TryGetValue(keyDenom, out areaDenom))
                    return null;
                return areaNum/areaDenom;
            }
コード例 #11
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
 public RatioValue CalcTransitionGroupRatio(TransitionGroupDocNode nodeGroup,
     IsotopeLabelType labelTypeNum,
     IsotopeLabelType labelTypeDenom)
 {
     return CalcTransitionGroupRatio(nodeGroup.TransitionGroup.PrecursorCharge,
                                     labelTypeNum, labelTypeDenom);
 }
コード例 #12
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
            public float? CalcTransitionGlobalRatio(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran, IsotopeLabelType labelType)
            {
                if (GlobalStandardArea == 0)
                    return null;

                float areaNum;
                var keyNum = new TransitionKey(nodeGroup, nodeTran.Key(nodeGroup), labelType);
                if (!TranAreas.TryGetValue(keyNum, out areaNum))
                    return null;
                return (float) (areaNum / GlobalStandardArea);
            }
コード例 #13
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
 public TransitionKey(TransitionKey key, IsotopeLabelType labelType)
 {
     _ionType = key._ionType;
     _customIonEquivalenceTestValue = key._customIonEquivalenceTestValue;
     _ionOrdinal = key._ionOrdinal;
     _massIndex = key._massIndex;
     _decoyMassShift = key._decoyMassShift;
     _charge = key._charge;
     _precursorCharge = key._precursorCharge;
     _losses = key._losses;
     _labelType = labelType;
 }
コード例 #14
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
 public TransitionKey(TransitionGroupDocNode nodeGroup, TransitionLossKey tranLossKey, IsotopeLabelType labelType)
 {
     var transition = tranLossKey.Transition;
     _ionType = transition.IonType;
     _customIonEquivalenceTestValue = tranLossKey.CustomIonEquivalenceTestValue;
     _ionOrdinal = transition.Ordinal;
     _massIndex = transition.MassIndex;
     _decoyMassShift = transition.DecoyMassShift;
     _charge = transition.Charge;
     _precursorCharge = nodeGroup.TransitionGroup.PrecursorCharge;
     _losses = tranLossKey.Losses;
     _labelType = labelType;
 }
コード例 #15
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
 public bool HasChildType(IsotopeLabelType labelType)
 {
     return Children.Contains(nodeGroup => ReferenceEquals(labelType,
                                                           ((TransitionGroupDocNode)nodeGroup).TransitionGroup.LabelType));
 }
コード例 #16
0
ファイル: EditPepModsDlg.cs プロジェクト: lgatto/proteowizard
 public void AddNewModification(int indexAA, IsotopeLabelType type)
 {
     ComboBox combo;
     if (type.IsLight)
         combo = _listComboStatic[indexAA];
     else
     {
         int indexHeavyList = _listLabelTypeHeavy.IndexOf(type);
         combo = _listListComboHeavy[indexHeavyList][indexAA];
     }
     combo.SelectedItem = Resources.SettingsListComboDriver_Add;
 }
コード例 #17
0
ファイル: EditPepModsDlg.cs プロジェクト: lgatto/proteowizard
 public void SetModification(int indexAA, IsotopeLabelType type, string modification)
 {
     ComboBox combo;
     if (type.IsLight)
         combo = _listComboStatic[indexAA];
     else
     {
         int indexHeavyList = _listLabelTypeHeavy.IndexOf(type);
         combo = _listListComboHeavy[indexHeavyList][indexAA];
     }
     combo.SelectedItem = modification;
 }
コード例 #18
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
            private RatioValue CalcTransitionGroupRatio(int precursorCharge,
                IsotopeLabelType labelTypeNum,
                IsotopeLabelType labelTypeDenom)
            {
                // Avoid 1.0 ratios for self-to-self
                if (ReferenceEquals(labelTypeNum, labelTypeDenom))
                {
                    return null;
                }

                // Delay allocation, which can be costly in DIA data with no ratios
                List<double> numerators = null;
                List<double> denominators = null;

                foreach (var pair in GetAreaPairs(labelTypeNum))
                {
                    var key = pair.Key;
                    if (precursorCharge != -1 && key.PrecursorCharge != precursorCharge)
                        continue;

                    float areaNum = pair.Value;
                    float areaDenom;
                    if (!TranAreas.TryGetValue(new TransitionKey(key, labelTypeDenom), out areaDenom))
                        continue;

                    if (numerators == null)
                    {
                        numerators = new List<double>();
                        denominators = new List<double>();
                    }
                    numerators.Add(areaNum);
                    denominators.Add(areaDenom);
                }

                if (numerators == null)
                    return null;

                return RatioValue.Calculate(numerators, denominators);
            }
コード例 #19
0
 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;
 }
コード例 #20
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
 private IEnumerable<KeyValuePair<TransitionKey, float>> GetAreaPairs(IsotopeLabelType labelType)
 {
     return from pair in TranAreas
            where ReferenceEquals(labelType, pair.Key.LabelType)
            select pair;
 }
コード例 #21
0
ファイル: SequenceUtil.cs プロジェクト: lgatto/proteowizard
 public ExplicitSequenceMassCalc(ExplicitMods mods, SequenceMassCalc massCalcBase, IsotopeLabelType labelType)
 {
     _massCalcBase = massCalcBase;
     _mods = new ExplicitSequenceMods
         { 
             Mods = mods.GetModifications(labelType),
             StaticBaseMods = mods.GetStaticBaseMods(labelType),
             ModMasses = mods.GetModMasses(_massCalcBase.MassType, labelType),
             RequiresAllCalcMods = mods.IsVariableStaticMods
         };
 }
コード例 #22
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
 public bool CanHaveImplicitHeavyMods(IsotopeLabelType labelType)
 {
     return !HasExplicitMods || !ExplicitMods.IsModified(labelType);
 }
コード例 #23
0
 public TransitionGroup(Peptide peptide, int precursorCharge, IsotopeLabelType labelType, bool unlimitedCharge, int?decoyMassShift)
     : this(peptide, null, precursorCharge, labelType, unlimitedCharge, decoyMassShift)
 {
 }
コード例 #24
0
 public IsotopeModificationPermuter(StaticMod isotopeModification, bool simplePermutation, IsotopeLabelType fullHeavyLabelType, List <StaticMod> globalStaticMods, List <StaticMod> globalIsotopeMods)
 {
     IsotopeModification = isotopeModification;
     SimplePermutation   = simplePermutation;
     FullyHeavyLabelType = fullHeavyLabelType;
     GlobalStaticMods    = globalStaticMods;
     GlobalIsotopeMods   = globalIsotopeMods;
 }
コード例 #25
0
        /// <summary>
        /// Constructs a ModifiedSequence from SrmSettings and PeptideDocNode.
        /// </summary>
        public static ModifiedSequence GetModifiedSequence(SrmSettings settings, PeptideDocNode docNode, IsotopeLabelType labelType)
        {
            if (docNode.Peptide.IsCustomMolecule)
            {
                return(null);
            }
            var  unmodifiedSequence          = docNode.Peptide.Sequence;
            bool includeStaticMods           = true;
            bool includeStaticHeavyMods      = false;
            List <Modification> explicitMods = new List <Modification>();

            if (null != docNode.ExplicitMods)
            {
                var staticBaseMods = docNode.ExplicitMods.GetStaticBaseMods(labelType);
                var labelMods      = docNode.ExplicitMods.GetModifications(labelType);
                if (labelMods == null && !labelType.IsLight)
                {
                    labelMods = docNode.ExplicitMods.GetModifications(IsotopeLabelType.light);
                    includeStaticHeavyMods = true;
                }
                if (labelMods != null || staticBaseMods != null)
                {
                    IEnumerable <ExplicitMod> modsToAdd = (labelMods ?? Enumerable.Empty <ExplicitMod>())
                                                          .Concat(staticBaseMods ?? Enumerable.Empty <ExplicitMod>());
                    foreach (var mod in modsToAdd)
                    {
                        explicitMods.Add(MakeModification(unmodifiedSequence, mod));
                    }
                    includeStaticMods = docNode.ExplicitMods.IsVariableStaticMods && staticBaseMods == null;
                }
            }

            if (includeStaticMods || includeStaticHeavyMods)
            {
                var peptideModifications = settings.PeptideSettings.Modifications;
                for (int i = 0; i < unmodifiedSequence.Length; i++)
                {
                    IEnumerable <StaticMod> staticMods = peptideModifications.GetModifications(labelType);
                    if (!labelType.IsLight && includeStaticMods)
                    {
                        staticMods = peptideModifications.GetModifications(IsotopeLabelType.light).Concat(staticMods);
                    }
                    foreach (var staticMod in staticMods)
                    {
                        if (staticMod.IsExplicit || staticMod.IsVariable)
                        {
                            continue;
                        }
                        if (staticMod.Terminus.HasValue)
                        {
                            if (staticMod.Terminus == ModTerminus.N && i != 0)
                            {
                                continue;
                            }
                            if (staticMod.Terminus == ModTerminus.C && i != unmodifiedSequence.Length - 1)
                            {
                                continue;
                            }
                        }
                        if (!string.IsNullOrEmpty(staticMod.AAs) && !staticMod.AAs.Contains(unmodifiedSequence[i]))
                        {
                            continue;
                        }
                        explicitMods.Add(MakeModification(unmodifiedSequence, new ExplicitMod(i, staticMod)));
                    }
                }
            }
            return(new ModifiedSequence(unmodifiedSequence, explicitMods, settings.TransitionSettings.Prediction.PrecursorMassType));
        }
コード例 #26
0
        public const string UnimodPrefix = "unimod:"; // Not L10N

        /// <summary>
        /// Constructs a ModifiedSequence from SrmSettings and PeptideDocNode.
        /// </summary>
        public static ModifiedSequence GetModifiedSequence(SrmSettings settings, PeptideDocNode docNode, IsotopeLabelType labelType)
        {
            if (docNode.Peptide.IsCustomMolecule)
            {
                return(null);
            }
            var  unmodifiedSequence          = docNode.Peptide.Sequence;
            bool includeStaticMods           = true;
            bool includeStaticHeavyMods      = false;
            List <Modification> explicitMods = new List <Modification>();

            if (null != docNode.ExplicitMods)
            {
                var staticBaseMods    = docNode.ExplicitMods.GetStaticBaseMods(labelType);
                var labelMods         = docNode.ExplicitMods.GetModifications(labelType);
                var explicitLabelType = labelType;
                if (labelMods == null && !labelType.IsLight)
                {
                    labelMods              = docNode.ExplicitMods.GetModifications(IsotopeLabelType.light);
                    explicitLabelType      = IsotopeLabelType.light;
                    includeStaticHeavyMods = true;
                }
                if (labelMods != null || staticBaseMods != null)
                {
                    IEnumerable <ExplicitMod> modsToAdd = (labelMods ?? Enumerable.Empty <ExplicitMod>())
                                                          .Concat(staticBaseMods ?? Enumerable.Empty <ExplicitMod>());
                    var monoMasses = docNode.ExplicitMods.GetModMasses(MassType.Monoisotopic, explicitLabelType);
                    var avgMasses  = docNode.ExplicitMods.GetModMasses(MassType.Average, explicitLabelType);
                    foreach (var mod in modsToAdd)
                    {
                        explicitMods.Add(new Modification(mod, monoMasses[mod.IndexAA], avgMasses[mod.IndexAA]));
                    }
                    includeStaticMods = docNode.ExplicitMods.IsVariableStaticMods && staticBaseMods == null;
                }
            }

            if (includeStaticMods || includeStaticHeavyMods)
            {
                var peptideModifications = settings.PeptideSettings.Modifications;
                for (int i = 0; i < unmodifiedSequence.Length; i++)
                {
                    IEnumerable <StaticMod> staticMods = peptideModifications.GetModifications(labelType);
                    if (!labelType.IsLight && includeStaticMods)
                    {
                        staticMods = peptideModifications.GetModifications(IsotopeLabelType.light).Concat(staticMods);
                    }
                    foreach (var staticMod in staticMods)
                    {
                        if (staticMod.IsExplicit || staticMod.IsVariable)
                        {
                            continue;
                        }
                        if (staticMod.Terminus.HasValue)
                        {
                            if (staticMod.Terminus == ModTerminus.N && i != 0)
                            {
                                continue;
                            }
                            if (staticMod.Terminus == ModTerminus.C && i != unmodifiedSequence.Length - 1)
                            {
                                continue;
                            }
                        }
                        if (!string.IsNullOrEmpty(staticMod.AAs) && !staticMod.AAs.Contains(unmodifiedSequence[i]))
                        {
                            continue;
                        }
                        var monoMass = staticMod.MonoisotopicMass ??
                                       SrmSettings.MonoisotopicMassCalc.GetAAModMass(unmodifiedSequence[i], i,
                                                                                     unmodifiedSequence.Length);
                        var avgMass = staticMod.AverageMass ??
                                      SrmSettings.AverageMassCalc.GetAAModMass(unmodifiedSequence[i], i,
                                                                               unmodifiedSequence.Length);
                        if (monoMass == 0 && avgMass == 0)
                        {
                            char aa = unmodifiedSequence[i];
                            if ((staticMod.LabelAtoms & LabelAtoms.LabelsAA) != LabelAtoms.None && AminoAcid.IsAA(aa))
                            {
                                string heavyFormula = SequenceMassCalc.GetHeavyFormula(aa, staticMod.LabelAtoms);
                                monoMass = SequenceMassCalc.FormulaMass(BioMassCalc.MONOISOTOPIC, heavyFormula,
                                                                        SequenceMassCalc.MassPrecision);
                                avgMass = SequenceMassCalc.FormulaMass(BioMassCalc.AVERAGE, heavyFormula,
                                                                       SequenceMassCalc.MassPrecision);
                            }
                        }
                        explicitMods.Add(new Modification(new ExplicitMod(i, staticMod), monoMass, avgMass));
                    }
                }
            }
            return(new ModifiedSequence(unmodifiedSequence, explicitMods, settings.TransitionSettings.Prediction.PrecursorMassType));
        }
コード例 #27
0
ファイル: PasteTest.cs プロジェクト: lgatto/proteowizard
        public void TestPaste()
        {
            ClearDefaultModifications();
            _yeastDoc = new SrmDocument(SrmSettingsList.GetDefault().ChangeTransitionInstrument(instrument => instrument.ChangeMaxMz(1600)));
            _yeastDoc = _yeastDoc.ChangeSettings(_yeastDoc.Settings.ChangeTransitionFilter(filter =>
                                                                                           filter.ChangeMeasuredIons(new MeasuredIon[0])));
            IdentityPath path;
            _yeastDocReadOnly = _yeastDoc = _yeastDoc.ImportFasta(new StringReader(ExampleText.TEXT_FASTA_YEAST_LIB),
                false, IdentityPath.ROOT, out path);

            _study7DocReadOnly = _study7Doc = CreateStudy7Doc();

            IdentityPath pathRoot = IdentityPath.ROOT;

            // Test pasting into document with same implicit modifications does not create any extra explicit modifications.
            var study7EmptyDoc = (SrmDocument) _study7Doc.ChangeChildren(new DocNode[0]);
            var study7PasteDoc = CopyPaste(_study7Doc, null, study7EmptyDoc, pathRoot);
            var arrayPeptides = _study7Doc.Peptides.ToArray();
            var arrayPastePeptides = study7PasteDoc.Peptides.ToArray();
            Assert.AreEqual(arrayPeptides.Length, arrayPastePeptides.Length);
            AssertEx.DocsEqual(_study7Doc, study7PasteDoc); // DocsEqual gives a more verbose failure message using XML output

            // Test implicit mods in source document become explicit mods in target document.
            ResetDocuments();
            _yeastDoc = (SrmDocument) _yeastDoc.ChangeChildren(new DocNode[0]);
            var settings = _yeastDoc.Settings;
            _yeastDoc = _yeastDoc.ChangeSettings(settings.ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(new StaticMod[0])));
            _yeastDoc = CopyPaste(_study7Doc, null, _yeastDoc, pathRoot);
            var pepMods = _yeastDoc.Settings.PeptideSettings.Modifications;
            Assert.IsTrue(pepMods.StaticModifications != null);
            Assert.IsTrue(pepMods.HasHeavyModifications);
            Assert.IsFalse(pepMods.StaticModifications.Contains(mod => !mod.IsExplicit));
            Assert.IsFalse(pepMods.HeavyModifications.Contains(mod => !mod.IsExplicit));

            // Test explicit mods are dropped if the target document has matching implicit modifications.
            study7PasteDoc = CopyPaste(_yeastDoc, null, study7EmptyDoc, pathRoot);
            Assert.AreEqual(_study7Doc, study7PasteDoc);

            // Add new label type to source document.
            ResetDocuments();
            const string labelTypeName13C = "heavy 13C";
            var labelType13C = new IsotopeLabelType(labelTypeName13C, IsotopeLabelType.light.SortOrder + 1);
            _yeastDoc = ChangePeptideModifications(_yeastDoc,
                 new[] {new TypedModifications(labelType13C, HEAVY_MODS_13_C)});
            Assert.IsTrue(_yeastDoc.PeptideTransitionGroups.Contains(nodeGroup =>
                Equals(nodeGroup.TransitionGroup.LabelType, labelType13C)));
               // Test pasting into the same document with new label type.
            _yeastDoc = CopyPaste(_yeastDoc, null, _yeastDoc, pathRoot);
            // Check all transition have correct label type references.
            Assert.IsFalse(_yeastDoc.PeptideTransitionGroups.Contains(nodeGroup =>
                {
                    IsotopeLabelType labelType = nodeGroup.TransitionGroup.LabelType;
                    return !ReferenceEquals(labelType,
                        _yeastDoc.Settings.PeptideSettings.Modifications.GetModificationsByName(labelType.Name).LabelType);
                }));

            // Check new document still serializes correctly.
            AssertEx.Serializable(_yeastDoc, AssertEx.DocumentCloned);

            // Test pasting into new document drops label types from source document that are not found in the target document.
            _yeastDoc = CopyPaste(_yeastDoc, null, new SrmDocument(SrmSettingsList.GetDefault()), pathRoot);
            Assert.IsNull(_yeastDoc.Settings.PeptideSettings.Modifications.GetModificationsByName(labelTypeName13C));

            // If only specific children are selected, test that only these children get copied.
            ResetDocuments();
            var arrayTrans = _study7Doc.PeptideTransitions.ToArray();
            IList<DocNode> selNodes = new List<DocNode>();
            for (int i = 0; i < arrayTrans.Length; i += 2)
            {
                selNodes.Add(arrayTrans[i]);
            }
            _study7Doc = CopyPaste(_study7Doc, selNodes, _study7Doc, pathRoot);
            Assert.AreEqual(arrayTrans.Length + selNodes.Count, _study7Doc.PeptideTransitionCount);

            // Test after pasting to a peptide list, all children have been updated to point to the correct parent.
            ResetDocuments();
            _study7Doc = CopyPaste(_yeastDoc, new[] { _yeastDoc.Peptides.ToArray()[0] }, _study7Doc,
                                  _study7Doc.GetPathTo((int) SrmDocument.Level.MoleculeGroups, 0));
            Assert.AreEqual(_yeastDoc.Peptides.ToArray()[0].Peptide, _study7Doc.Peptides.ToArray()[0].Peptide);
            Assert.AreEqual(_study7Doc.Peptides.ToArray()[0].Peptide,
                          _study7Doc.PeptideTransitionGroups.ToArray()[0].TransitionGroup.Peptide);
            Assert.AreEqual(_study7Doc.PeptideTransitionGroups.ToArray()[0].TransitionGroup,
                          _study7Doc.PeptideTransitions.ToArray()[0].Transition.Group);

            // If only specific transition are selected for a peptide, but all transition groups are included, test AutoManageChildren is true.
            ResetDocuments();
            selNodes = new List<DocNode>();
            foreach (TransitionGroupDocNode transGroup in _study7Doc.PeptideTransitionGroups)
            {
                selNodes.Add(transGroup.Children[0]);
            }
            // TODO: Fix this and make it pass
            //            var emptyDoc = (SrmDocument)_study7Doc.ChangeChildren(new List<DocNode>());
            //            _study7Doc = CopyPaste(_study7Doc, selNodes, emptyDoc, pathRoot);
            _study7Doc = (SrmDocument)_study7Doc.ChangeChildren(new List<DocNode>());
            _study7Doc = CopyPaste(_study7Doc, selNodes, _study7Doc, pathRoot);
            foreach (PeptideDocNode peptide in _study7Doc.Peptides)
                Assert.IsTrue(peptide.AutoManageChildren);

            // Test pasting in modifications with the same name as but different definition from existing modifications not allowed.
            ResetDocuments();
            _yeastDoc = ChangePeptideModifications(_yeastDoc,
                new[] { new TypedModifications(IsotopeLabelType.heavy, HEAVY_C_K_DIFDEF) });
            SetDefaultModifications(_study7Doc);
            AssertEx.ThrowsException<Exception>(() => _yeastDoc.Settings.UpdateDefaultModifications(false));

            // Test variable modifications kept if target document has matching variable modifications turned on.
            ResetDocuments();
            settings = _yeastDoc.Settings;
            var modsDefault = settings.PeptideSettings.Modifications;
            var listVariableMods = new List<StaticMod>(modsDefault.StaticModifications) { VAR_MET_OXIDIZED };
            _yeastDoc = _yeastDoc.ChangeSettings(settings.ChangePeptideModifications(mods =>
                mods.ChangeStaticModifications(listVariableMods.ToArray())));
            // Make sure there is an implicitly modified peptide in the yeast document
            Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.Peptide.Sequence.Contains("C")));
            Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasVariableMods));
            _yeastDoc = CopyPaste(_yeastDoc, null, _yeastDoc, pathRoot);
            Assert.IsFalse(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasExplicitMods && !nodePep.HasVariableMods));

            // Otherwise the variable modifications become only explicit modifications.
            var yeastDocVar = _yeastDoc;
            _yeastDoc = _yeastDoc.ChangeSettings(_yeastDoc.Settings.ChangePeptideModifications(mods => modsDefault));
            _yeastDoc = CopyPaste(yeastDocVar, null, _yeastDoc, pathRoot);
            Assert.IsFalse(_yeastDoc.Settings.PeptideSettings.Modifications.HasVariableModifications);
            Assert.IsTrue(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasExplicitMods));
            Assert.IsFalse(_yeastDoc.Peptides.Contains(nodePep => nodePep.HasVariableMods));
        }
コード例 #28
0
 public TransitionGroup(Peptide peptide, Adduct precursorAdduct, IsotopeLabelType labelType)
     : this(peptide, precursorAdduct, labelType, false, null)
 {
 }
コード例 #29
0
        /// <summary>
        /// Constructs a ModifiedSequence from SrmSettings and PeptideDocNode.
        /// </summary>
        public static ModifiedSequence GetModifiedSequence(SrmSettings settings, ISequenceContainer peptide, IsotopeLabelType labelType)
        {
            if (!peptide.Target.IsProteomic)
            {
                return(null);
            }
            var unmodifiedSequence = peptide.Target.Sequence;
            List <IsotopeLabelType> implicitLabelTypes = new List <IsotopeLabelType>();

            implicitLabelTypes.Add(IsotopeLabelType.light);
            if (!labelType.IsLight)
            {
                implicitLabelTypes.Add(labelType);
            }
            List <Modification> explicitMods = new List <Modification>();

            if (null != peptide.ExplicitMods)
            {
                var staticBaseMods = peptide.ExplicitMods.GetStaticBaseMods(labelType);
                if (staticBaseMods != null)
                {
                    implicitLabelTypes.Clear();
                }
                var labelMods = peptide.ExplicitMods.GetModifications(labelType);
                if (labelMods != null)
                {
                    if (!peptide.ExplicitMods.IsVariableStaticMods)
                    {
                        implicitLabelTypes.Remove(labelType);
                    }
                }
                else if (!labelType.IsLight)
                {
                    labelMods = peptide.ExplicitMods.GetModifications(IsotopeLabelType.light);
                    if (labelMods != null && !peptide.ExplicitMods.IsVariableStaticMods)
                    {
                        implicitLabelTypes.Remove(IsotopeLabelType.light);
                    }
                }
                if (labelMods != null || staticBaseMods != null)
                {
                    IEnumerable <ExplicitMod> modsToAdd = (labelMods ?? Enumerable.Empty <ExplicitMod>())
                                                          .Concat(staticBaseMods ?? Enumerable.Empty <ExplicitMod>());
                    foreach (var mod in modsToAdd)
                    {
                        explicitMods.Add(MakeModification(unmodifiedSequence, mod));
                    }
                }
            }

            List <StaticMod> implicitMods = new List <StaticMod>();
            var peptideModifications      = settings.PeptideSettings.Modifications;

            foreach (var implicitLabelType in implicitLabelTypes)
            {
                implicitMods.AddRange(peptideModifications.GetModifications(implicitLabelType));
            }

            for (int i = 0; i < unmodifiedSequence.Length; i++)
            {
                foreach (var staticMod in implicitMods)
                {
                    if (staticMod.IsExplicit || staticMod.IsVariable)
                    {
                        continue;
                    }
                    if (staticMod.Terminus.HasValue)
                    {
                        if (staticMod.Terminus == ModTerminus.N && i != 0)
                        {
                            continue;
                        }
                        if (staticMod.Terminus == ModTerminus.C && i != unmodifiedSequence.Length - 1)
                        {
                            continue;
                        }
                    }
                    if (!string.IsNullOrEmpty(staticMod.AAs) && !staticMod.AAs.Contains(unmodifiedSequence[i]))
                    {
                        continue;
                    }
                    explicitMods.Add(MakeModification(unmodifiedSequence, new ExplicitMod(i, staticMod)));
                }
            }
            return(new ModifiedSequence(unmodifiedSequence, explicitMods, settings.TransitionSettings.Prediction.PrecursorMassType));
        }
コード例 #30
0
 public bool Equals(IsotopeLabelType other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Name, Name) && other.SortOrder == SortOrder;
 }
コード例 #31
0
ファイル: PasteDlg.cs プロジェクト: lgatto/proteowizard
 public MoleculeInfo(string name, string formula, int charge, double mz, double monoMass, double averageMass,
     IsotopeLabelType isotopeLabelType,
     ExplicitRetentionTimeInfo explicitRetentionTime,
     ExplicitTransitionGroupValues explicitTransitionGroupValues,
     string note)
 {
     Name = name;
     Formula = formula;
     Charge = charge;
     Mz = mz;
     MonoMass = monoMass;
     AverageMass = averageMass;
     IsotopeLabelType = isotopeLabelType;
     ExplicitRetentionTime = explicitRetentionTime;
     ExplicitTransitionGroupValues = explicitTransitionGroupValues;
     Note = note;
 }
コード例 #32
0
        private void UpdateAxes(bool resetAxes, GraphValues.AggregateOp aggregateOp, AreaNormalizeToData normalizeData,
            AreaNormalizeToView areaView, IsotopeLabelType standardType)
        {
            if (resetAxes)
            {
                XAxis.Scale.MaxAuto = XAxis.Scale.MinAuto = true;
                YAxis.Scale.MaxAuto = true;
            }
            if (BarSettings.Type == BarType.PercentStack)
            {
                YAxis.Scale.Max = 100;
                YAxis.Scale.MaxAuto = false;
                YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Percentage);
                YAxis.Type = AxisType.Linear;
                YAxis.Scale.MinAuto = false;
                FixedYMin = YAxis.Scale.Min = 0;
            }
            else
            {
                if (normalizeData == AreaNormalizeToData.optimization)
                {
                    // If currently log scale or normalized to max, reset the y-axis max
                    if (YAxis.Type == AxisType.Log || YAxis.Scale.Max == 1)
                        YAxis.Scale.MaxAuto = true;

                    YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Percent_of_Regression_Peak_Area);
                    YAxis.Type = AxisType.Linear;
                    YAxis.Scale.MinAuto = false;
                    FixedYMin = YAxis.Scale.Min = 0;
                }
                else if (areaView == AreaNormalizeToView.area_maximum_view)
                {
                    YAxis.Scale.Max = 1;
                    if (IsDotProductVisible)
                        // Make YAxis Scale Max a little higher to accommodate for the dot products
                        YAxis.Scale.Max = 1.1;
                    YAxis.Scale.MaxAuto = false;
                    YAxis.Title.Text = aggregateOp.AnnotateTitle(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Normalized);
                    YAxis.Type = AxisType.Linear;
                    YAxis.Scale.MinAuto = false;
                    FixedYMin = YAxis.Scale.Min = 0;
                }
                else if (Settings.Default.AreaLogScale)
                {
                    // If currently not log scale, reset the y-axis max
                    if (YAxis.Type != AxisType.Log)
                        YAxis.Scale.MaxAuto = true;
                    if (Settings.Default.PeakAreaMaxArea != 0)
                    {
                        YAxis.Scale.MaxAuto = false;
                        YAxis.Scale.Max = Settings.Default.PeakAreaMaxArea;
                    }

                    YAxis.Type = AxisType.Log;
                    YAxis.Title.Text = GraphValues.AnnotateLogAxisTitle(aggregateOp.AnnotateTitle(
                        Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area));
                    YAxis.Scale.MinAuto = false;
                    FixedYMin = YAxis.Scale.Min = 1;
                }
                else
                {
                    // If currently log scale, reset the y-axis max
                    if (YAxis.Type == AxisType.Log)
                        YAxis.Scale.MaxAuto = true;
                    if (Settings.Default.PeakAreaMaxArea != 0)
                    {
                        YAxis.Scale.MaxAuto = false;
                        YAxis.Scale.Max = Settings.Default.PeakAreaMaxArea;
                    }
                    else if (!YAxis.Scale.MaxAuto)
                    {
                        YAxis.Scale.MaxAuto = true;
                    }
                    string yTitle = Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area;
                    switch (areaView)
                    {
                        case AreaNormalizeToView.area_ratio_view:
                            yTitle = string.Format(Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Ratio_To__0_,
                                                   standardType.Title);
                            break;
                        case AreaNormalizeToView.area_global_standard_view:
                            yTitle = Resources.AreaReplicateGraphPane_UpdateGraph_Peak_Area_Ratio_To_Global_Standards;
                            break;
                    }
                    YAxis.Title.Text = aggregateOp.AnnotateTitle(yTitle);
                    YAxis.Type = AxisType.Linear;
                    YAxis.Scale.MinAuto = false;
                    FixedYMin = YAxis.Scale.Min = 0;
                }
                // Handle a switch from percent stack
                if (!YAxis.Scale.MaxAuto && YAxis.Scale.Max == 100)
                    YAxis.Scale.MaxAuto = true;
            }
            Legend.IsVisible = Settings.Default.ShowPeakAreaLegend;
            AxisChange();

            // Reformat Y-Axis for labels and whiskers
            var maxY = GraphHelper.GetMaxY(CurveList,this);
            if (IsDotProductVisible)
            {
                var extraSpace = _lableHeight*(maxY/(Chart.Rect.Height - _lableHeight*2))*2;
                maxY += extraSpace;
            }

            GraphHelper.ReformatYAxis(this, maxY);
        }
コード例 #33
0
ファイル: EditPepModsDlg.cs プロジェクト: lgatto/proteowizard
        public void SelectModification(IsotopeLabelType labelType, int indexAA, string modName)
        {
            int row = indexAA + 1;
            string comboName = (labelType.IsLight ?
                GetStaticName(row) :
                GetHeavyName(row, labelType.SortOrder));

            foreach (var comboBox in _listComboStatic)
            {
                if (Equals(comboName, comboBox.Name))
                {
                    comboBox.SelectedItem = modName;
                    return;
                }
            }
            foreach (var listComboHeavy in _listListComboHeavy)
            {
                foreach (var comboBox in listComboHeavy)
                {
                    if (Equals(comboName, comboBox.Name))
                    {
                        comboBox.SelectedItem = modName;
                        return;
                    }
                }
            }
        }
コード例 #34
0
        public void TestModificationMatcher()
        {
            InitSeqs();

            var carbC = StaticModList.GetDefaultsOn()[0];

            // Test exception thrown if unable to match - mass.
            UpdateMatcherFail(STR_FAIL_MASS);
            UpdateMatcherFail(STR_FAIL_NOT_A_NUMBER);
            // Test exception thrown if unable to match - name.
            UpdateMatcherFail(STR_FAIL_NAME);
            // Can't match empty modifications.
            UpdateMatcherFail(STR_FAIL_EMPTY_MOD);
            UpdateMatcherFail(STR_FAIL_EMPTY_MOD2);
            // Can't match double modifications.
            UpdateMatcherFail(STR_FAIL_DOUBLE_MOD);
            // Test exception thrown if unimod not specified correctly
            UpdateMatcherFail(STR_FAIL_UNIMOD);
            UpdateMatcherFail(STR_UNKNOWN_UNIMOD);
            // Can't phosphorylate tryptophan
            UpdateMatcherFail(STR_FAIL_WRONG_AA_UNIMOD);
            // Can't put C-terminal modification in middle of peptide
            UpdateMatcherFail(STR_FAIL_UNIMOD_TERMINUS);

            // Test mods in UniMod match correctly.
            UpdateMatcher(StaticModList.GetDefaultsOn(), HeavyModList.GetDefaultsOn(), null, null);
            // A sequence with no modifications should not be explicitly modified.
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_NO_MODS).HasExplicitMods);
            var nodeCysOxi = MATCHER.GetModifiedNode(STR_CYS_AND_OXI);
            Assert.IsTrue(nodeCysOxi.HasExplicitMods);
            Assert.IsFalse(nodeCysOxi.ExplicitMods.HasHeavyModifications);
            // Modifications should match by name.
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_MOD_BY_NAME).ExplicitMods.StaticModifications.Contains(mod =>
                Equals(mod.Modification.Name,  "Phospho (ST)")));
            // Test can find terminal modification
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_TERM_ONLY).ExplicitMods.HeavyModifications.Contains(mod =>
                mod.Modification.EquivalentAll(UniMod.GetModification("Label:13C(6) (C-term R)", false))));
            // Test can find matches on terminus that are not terminal
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_MOD_BY_NAME).ExplicitMods.StaticModifications.Contains(mod =>
                mod.Modification.Terminus == null));
            // Test matching negative masses
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_AMMONIA_LOSS).ExplicitMods.StaticModifications.Contains(mod =>
                mod.Modification.EquivalentAll(UniMod.GetModification("Ammonia-loss (N-term C)", true))));

            // General and specific
            // If all AAs modified, try for most general modification.
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15)
                .ExplicitMods.HeavyModifications.Contains(mod => mod.Modification.Equivalent(LABEL15_N)));

            // Updating the settings.
            // Peptide settings should change to include new mods.
            var docNew = new SrmDocument(SrmSettingsList.GetDefault());
            IdentityPath firstAdded;
            IdentityPath nextAdded;
            docNew = docNew.AddPeptideGroups(new[] { new PeptideGroupDocNode(new PeptideGroup(), "PepGroup1", "",
                new[] {MATCHER.GetModifiedNode(STR_MOD_BY_NAME)})}, true, null, out firstAdded, out nextAdded);
            var pepSetNew = MATCHER.GetDocModifications(docNew);
            Assert.IsTrue(pepSetNew.StaticModifications.Contains(UniMod.GetModification("Phospho (ST)", true).ChangeExplicit(true)));
            // Update the document to the new settings.
            var pepSetNew1 = pepSetNew;
            var settingsNew2 = docNew.Settings.ChangePeptideModifications(mods => pepSetNew1);
            var lightGlobalMods = new MappedList<string, StaticMod>();
            lightGlobalMods.AddRange(settingsNew2.PeptideSettings.Modifications.StaticModifications);
            var heavyGlobalMods = new MappedList<string, StaticMod>();
            heavyGlobalMods.AddRange(settingsNew2.PeptideSettings.Modifications.HeavyModifications);
            // Match again. Test FoundMatches string should now be empty.
            MATCHER.CreateMatches(docNew.Settings.ChangePeptideModifications(mods => pepSetNew1),
                new List<string> { STR_MOD_BY_NAME }, lightGlobalMods, heavyGlobalMods);
            Assert.IsTrue(string.IsNullOrEmpty(MATCHER.FoundMatches));

            // Adding 15N to the settings.
            UpdateMatcher(new[] { carbC }, new[] { LABEL15_N }, null, null);
            // Test sequences with only explicit heavy mods should not have explicit light mods
            Assert.IsNull(MATCHER.GetModifiedNode(STR_HEAVY_ONLY).ExplicitMods.StaticModifications);

            // Test sequences with only explicit light mods should not have explicit heavy mods
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_LIGHT_ONLY).ExplicitMods.HasHeavyModifications);

            // Test global mods take precendence over UniMod
            UpdateMatcher(new[] { carbC }, null, new[] { OXIDATION_M_GLOBAL }, new[] { LABEL15_N });
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).ExplicitMods.StaticModifications
                .Contains(mod => Equals(mod.Modification, OXIDATION_M_GLOBAL)));

            // Test document mods take precendence over UniMod
            UpdateMatcher(new[] { carbC, METHIONINE_OXIDATION }, null, new[] { OXIDATION_M_GLOBAL }, new[] { LABEL15_N });
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).HasExplicitMods);

            // Test exception thrown if match doesn't make sense - wrong AA.
            UpdateMatcherFail(STR_FAIL_OX_ON_D);
            // Test exception thrown if match doesn't make sense - wrong terminus.
            _seqs.Add(STR_FAIL_OX_TERM);
            AssertEx.ThrowsException<FormatException>(() => UpdateMatcher(new[] {OXIDATION_M_C_TERM}, null, null, null));
            _seqs.Remove(STR_FAIL_OX_TERM);

            // Heavy 15N - All AAs.
            UpdateMatcher(new[] { carbC, METHIONINE_OXIDATION }, new[] {LABEL15_N}, null, null);
            // Node should be created from document settings if possible.
            Assert.IsNull(MATCHER.GetModifiedNode(STR_HEAVY_15).ExplicitMods);
            // Heavy 15N - specific AA.
            // If only a specific AA is modified, there must be an explicit mod.
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15_F).HasExplicitMods);

            // Test variable mods match correctly.
            // Put variable mod in global mod and not on doc - make sure don't get variable mod,
            // should get explicit mod in that case.
            var variableMetOx = METHIONINE_OXIDATION.ChangeVariable(true);
            UpdateMatcher(new[] { carbC }, null, new[] { variableMetOx }, null);
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).HasExplicitMods);
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_OXI_PHOS).ExplicitMods.IsVariableStaticMods);
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_OXI_PHOS_CAP).ExplicitMods.IsVariableStaticMods);
            // Add variable mod to doc
            UpdateMatcher(new[] { carbC, variableMetOx }, null, null, null);
            // Mod can be created by the settings.
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).HasExplicitMods);
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).ExplicitMods.IsVariableStaticMods);
            // Mod cannot be created by the settings.
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_OXI_PHOS).ExplicitMods.IsVariableStaticMods);
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_OXI_PHOS_CAP).ExplicitMods.IsVariableStaticMods);

            // Add Met Ox to global. Test: +16 finds it.
            UpdateMatcher(new[] {carbC}, null, new[] {MET_OX_ROUNDED}, null);
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).
                ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, MET_OX_ROUNDED)));
            // Test: +15.99 finds UniMod.
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_HEAVY_15).
                ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, MET_OX_ROUNDED)));
            // Add Methionine Oxidation before Met Ox. Test: +16 finds it.
            UpdateMatcher(new[] { carbC }, null, new[] { METHIONINE_OXIDATION, MET_OX_ROUNDED }, null);
            Assert.IsFalse(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).
                ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, MET_OX_ROUNDED)));
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_CYS_AND_OXI).
                ExplicitMods.StaticModifications.Contains(mod => Equals(mod.Modification, METHIONINE_OXIDATION)));
            // Test long masses rounded.
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_METOX_LONG_MASS).ExplicitMods.StaticModifications.Contains(mod =>
                Equals(mod.Modification, METHIONINE_OXIDATION)));
            // Test UniMod label types
            var node = MATCHER.GetModifiedNode(STR_UNIMOD_LABEL);
            Assert.IsNotNull(node);
            Assert.IsNull(node.ExplicitMods.StaticModifications);
            Assert.IsTrue(node.ExplicitMods.HeavyModifications.Contains(mod =>
                Equals(mod.Modification, N_TERM_LABEL)));
            UpdateMatcherWithNoSequences(new[] { carbC }, new[] { N_TERM_LABEL }, new[] { METHIONINE_OXIDATION, MET_OX_ROUNDED }, null);
            var nodeNew = MATCHER.GetModifiedNode(STR_UNIMOD_LABEL);
            Assert.IsNotNull(nodeNew);
            Assert.IsTrue(nodeNew.TransitionGroups.Any(group => Equals(group.TransitionGroup.LabelType, IsotopeLabelType.heavy)));
            UpdateMatcher(new[] { carbC }, null, new[] { METHIONINE_OXIDATION, MET_OX_ROUNDED }, null);

            // Test case where there are lots of unimod labels
            var nodeUniAll = MATCHER.GetModifiedNode(STR_UNIMOD_ALL);
            Assert.AreEqual(nodeUniAll.ExplicitMods.HeavyModifications.Count, 10);
            Assert.IsNull(nodeUniAll.ExplicitMods.StaticModifications);
            foreach (var mod in nodeUniAll.ExplicitMods.HeavyModifications)
            {
                Assert.AreEqual(mod.Modification.ShortName, "+01");
                Assert.AreEqual(mod.Modification.UnimodId, 994);
            }

            // Test unimod terminal label
            var nodeUniTerm = MATCHER.GetModifiedNode(STR_UNIMOD_TERMINUS);
            Assert.AreEqual(nodeUniTerm.ExplicitMods.HeavyModifications.Count, 1);
            Assert.IsNull(nodeUniTerm.ExplicitMods.StaticModifications);
            Assert.AreEqual(nodeUniTerm.ExplicitMods.HeavyModifications[0].Modification.Terminus, ModTerminus.C);
            Assert.AreEqual(nodeUniTerm.ExplicitMods.HeavyModifications[0].Modification.UnimodId, 298);

            // Basic multi-label test
            var heavyLabelType2 = new IsotopeLabelType("Heavy2", 1);
            var typedMod = new TypedModifications(heavyLabelType2, new List<StaticMod> { LABEL15_N });
            var peptideMods = new PeptideModifications(new List<StaticMod>(), new List<TypedModifications> { typedMod });
            var settingsMultiLabel = SrmSettingsList.GetDefault().ChangePeptideModifications(mods => peptideMods);
            var defSetSetLight = new MappedList<string, StaticMod>();
            defSetSetLight.AddRange(StaticModList.GetDefaultsOn());
            var defSetHeavy = new MappedList<string, StaticMod>();
            defSetHeavy.AddRange(HeavyModList.GetDefaultsOn());
            defSetHeavy.Add( LABEL15_N );
            MATCHER.CreateMatches(settingsMultiLabel, new List<string> { STR_HEAVY_15_F }, defSetSetLight, defSetHeavy);
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15_F).ExplicitMods.GetHeavyModifications().Contains(mod => Equals(mod.LabelType, heavyLabelType2)));
            // Peptide settings should not change.
            var docNew0 = new SrmDocument(settingsMultiLabel).AddPeptideGroups(new[] { new PeptideGroupDocNode(new PeptideGroup(),
                "PepGroup1", "", new[] {MATCHER.GetModifiedNode(STR_HEAVY_15_F)})}, true, null, out firstAdded, out nextAdded);
            var settingsNew = MATCHER.GetDocModifications(docNew0);
            Assert.AreEqual(settingsMultiLabel.PeptideSettings.Modifications, settingsNew);

            // Finding specific modifications.
            // If only specific AA modified, try for most specific modification.
            UpdateMatcher(null, null, null, null, new[] { STR_HEAVY_15_F});
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15_F)
                .ExplicitMods.HeavyModifications.Contains(mod =>
                    mod.Modification.AminoAcids.Contains(c => c == 'F')));
            // If only some AAs modified, try for most specific modifications.
            UpdateMatcher(null, null, null, null, new[] { STR_HEAVY_15_NOT_ALL });
            Assert.IsTrue(MATCHER.GetModifiedNode(STR_HEAVY_15_NOT_ALL)
                .ExplicitMods.HeavyModifications.Contains(mod =>
                mod.Modification.AminoAcids.Contains(c => c == 'I')));

            using (var testDir = new TestFilesDir(TestContext, ZIP_FILE))
            {
                var modMatchDocContainer = InitMatchDocContainer(testDir);
                var libkeyModMatcher = new LibKeyModificationMatcher();
                var anlLibSpec = new BiblioSpecLiteSpec("ANL_Combo", testDir.GetTestPath("ANL_Combined.blib"));
                var yeastLibSpec = new BiblioSpecLiteSpec("Yeast", testDir.GetTestPath("Yeast_atlas_small.blib"));
                modMatchDocContainer.ChangeLibSpecs(new[] { anlLibSpec, yeastLibSpec });
                var docLibraries = modMatchDocContainer.Document.Settings.PeptideSettings.Libraries.Libraries;
                int anlLibIndex = docLibraries.IndexOf(library => Equals(library.Name, anlLibSpec.Name));
                int yeastLibIndex = docLibraries.IndexOf(library => Equals(library.Name, yeastLibSpec.Name));

                libkeyModMatcher.CreateMatches(modMatchDocContainer.Document.Settings,
                    docLibraries[anlLibIndex].Keys, defSetSetLight, defSetHeavy);

                // Test can match 15N
                Assert.IsTrue(libkeyModMatcher.Matches.Values.Contains(match =>
                    match.HeavyMod != null && match.HeavyMod.Equivalent(LABEL15_N)));

                var uniModMetOx = UniMod.GetModification("Oxidation (M)", true);

                // Test can match Met Ox
                Assert.IsTrue(libkeyModMatcher.Matches.Values.Contains(match =>
                    match.StructuralMod != null && match.StructuralMod.Equivalent(uniModMetOx)));

                // Test can match 15N and Met ox!
                Assert.IsTrue(libkeyModMatcher.Matches.Contains(match => match.Key.Mass == 17
                    && match.Value.StructuralMod != null && match.Value.StructuralMod.Equivalent(uniModMetOx)
                    && match.Value.HeavyMod != null && match.Value.HeavyMod.Equivalent(LABEL15_N)));

                // Test can match Cysteine (Implicit) and Met Ox (variable)
                libkeyModMatcher.CreateMatches(modMatchDocContainer.Document.Settings,
                    docLibraries[yeastLibIndex].Keys, defSetSetLight, defSetHeavy);
                Assert.IsTrue(libkeyModMatcher.MatcherPepMods.StaticModifications.Contains(mod =>
                    mod.Formula.Equals(UniMod.GetModification(StaticModList.DEFAULT_NAME, true).Formula) && !mod.IsVariable));
                Assert.IsTrue(libkeyModMatcher.MatcherPepMods.StaticModifications.Contains(mod =>
                    mod.Formula.Equals("O") && mod.IsVariable));
            }
        }
コード例 #35
0
ファイル: EditPepModsDlg.cs プロジェクト: lgatto/proteowizard
 private static string GetIsotopeLabelText(IsotopeLabelType labelType)
 {
     return string.Format(Resources.EditPepModsDlg_GetIsotopeLabelText_Isotope__0__, labelType);
 }
コード例 #36
0
        /// <summary>
        /// For creating at the Molecule level (create molecule and first transition group) or modifying at the transition level
        /// Null values imply "don't ask user for this"
        /// </summary>
        public EditCustomMoleculeDlg(SkylineWindow parent, string title, Identity initialId, IEnumerable<Identity> existingIds, int minCharge, int maxCharge,
            SrmSettings settings, string defaultName, string defaultFormula, int? defaultCharge, ExplicitTransitionGroupValues explicitAttributes,
            ExplicitRetentionTimeInfo explicitRetentionTime,
            IsotopeLabelType defaultIsotopeLabelType, bool enableFormulaEditing = true)
        {
            Text = title;
            _parent = parent;
            _initialId = initialId;
            _existingIds = existingIds;
            _minCharge = minCharge;
            _maxCharge = maxCharge;
            _transitionSettings = settings != null ? settings.TransitionSettings : null;
            _peptideSettings = settings != null ? settings.PeptideSettings : null;

            InitializeComponent();

            NameText = defaultName;
            var needOptionalValuesBox = explicitRetentionTime != null || explicitAttributes != null;
            var heightDelta = 0;

            if (explicitAttributes == null)
            {
                ResultExplicitTransitionGroupValues = null;
                labelCollisionEnergy.Visible = false;
                textCollisionEnergy.Visible = false;
                labelSLens.Visible = false;
                textSLens.Visible = false;
                labelCompensationVoltage.Visible = false;
                textCompensationVoltage.Visible = false;
                labelConeVoltage.Visible = false;
                textConeVoltage.Visible = false;
                labelDriftTimeHighEnergyOffsetMsec.Visible = false;
                textDriftTimeHighEnergyOffsetMsec.Visible = false;
                labelDriftTimeMsec.Visible = false;
                textDriftTimeMsec.Visible = false;
                if (needOptionalValuesBox)
                {
                    // We blanked out everything but the retention time
                    var vmargin = labelRetentionTime.Location.Y;
                    var newHeight = textRetentionTime.Location.Y + textRetentionTime.Height +  vmargin;
                    heightDelta = groupBoxOptionalValues.Height - newHeight;
                    groupBoxOptionalValues.Height = newHeight;
                }
            }
            else
            {
                ResultExplicitTransitionGroupValues = new ExplicitTransitionGroupValues(explicitAttributes);
            }

            string labelAverage = defaultCharge.HasValue
                ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_m_z_
                : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_mass_;
            string labelMono = defaultCharge.HasValue
                ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_m_z_
                : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_mass_;

            _formulaBox =
                new FormulaBox(Resources.EditMeasuredIonDlg_EditMeasuredIonDlg_Ion__chemical_formula_,
                    labelAverage,
                    labelMono,
                    defaultCharge)
                {
                    Formula = defaultFormula,
                    Location = new Point(textName.Left, textName.Bottom + 12)
                };
            Controls.Add(_formulaBox);
            _formulaBox.TabIndex = 2;
            _formulaBox.Enabled = enableFormulaEditing;
            bool needCharge = defaultCharge.HasValue;
            textCharge.Visible = labelCharge.Visible = needCharge;
            Charge = defaultCharge ?? 0;
            if (needOptionalValuesBox && !needCharge)
            {
                heightDelta += groupBoxOptionalValues.Location.Y - labelCharge.Location.Y;
                groupBoxOptionalValues.Location = new Point(groupBoxOptionalValues.Location.X, labelCharge.Location.Y);
            }
            if (explicitRetentionTime == null)
            {
                // Don't ask user for retetention times
                RetentionTime = null;
                RetentionTimeWindow = null;
                labelRetentionTime.Visible = false;
                labelRetentionTimeWindow.Visible = false;
                textRetentionTime.Visible = false;
                textRetentionTimeWindow.Visible = false;
                if (needOptionalValuesBox)
                {
                    var rtHeight = labelCollisionEnergy.Location.Y - labelRetentionTimeWindow.Location.Y;
                    groupBoxOptionalValues.Height -= rtHeight;
                    heightDelta += rtHeight;
                }
            }
            else
            {
                RetentionTime = explicitRetentionTime.RetentionTime;
                RetentionTimeWindow = explicitRetentionTime.RetentionTimeWindow;
            }
            if (!needOptionalValuesBox)
            {
                groupBoxOptionalValues.Visible = false;
                heightDelta = groupBoxOptionalValues.Height;
            }
            // Initialize label
            if (settings != null && defaultIsotopeLabelType != null)
            {
                _driverLabelType = new PeptideSettingsUI.LabelTypeComboDriver(comboIsotopeLabelType,
                    settings.PeptideSettings.Modifications, null, null, null, null)
                {
                    SelectedName = defaultIsotopeLabelType.Name
                };
            }
            else
            {
                comboIsotopeLabelType.Visible = false;
                labelIsotopeLabelType.Visible = false;
            }
            Height -= heightDelta;
        }
コード例 #37
0
 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;
 }
コード例 #38
0
ファイル: SequenceUtil.cs プロジェクト: lgatto/proteowizard
 public TypedMassCalc(IsotopeLabelType labelType, SequenceMassCalc massCalc)
 {
     LabelType = labelType;
     MassCalc = massCalc;
 }
コード例 #39
0
ファイル: Peptide.cs プロジェクト: tomas-pluskal/pwiz
        public IEnumerable <TransitionGroup> GetTransitionGroups(SrmSettings settings, PeptideDocNode nodePep, ExplicitMods mods, bool useFilter)
        {
            if (IsCustomIon)
            {
                // We can't generate nodes as we do with peptides, so just filter what we do have on instrument mz range
                foreach (var group in nodePep.TransitionGroups.Where(tranGroup => tranGroup.TransitionGroup.IsCustomIon))
                {
                    if (!useFilter || settings.TransitionSettings.IsMeasurablePrecursor(group.PrecursorMz))
                    {
                        yield return(group.TransitionGroup);
                    }
                }
            }
            else
            {
                IList <int> precursorCharges = settings.TransitionSettings.Filter.PrecursorCharges;
                if (!useFilter)
                {
                    precursorCharges = new List <int>();
                    for (int i = TransitionGroup.MIN_PRECURSOR_CHARGE; i < TransitionGroup.MAX_PRECURSOR_CHARGE; i++)
                    {
                        precursorCharges.Add(i);
                    }
                }

                var modSettings = settings.PeptideSettings.Modifications;

                double precursorMassLight  = settings.GetPrecursorMass(IsotopeLabelType.light, Sequence, mods);
                var    listPrecursorMasses = new List <KeyValuePair <IsotopeLabelType, double> >
                {
                    new KeyValuePair <IsotopeLabelType, double>(IsotopeLabelType.light, precursorMassLight)
                };

                foreach (var typeMods in modSettings.GetHeavyModifications())
                {
                    IsotopeLabelType labelType     = typeMods.LabelType;
                    double           precursorMass = precursorMassLight;
                    if (settings.HasPrecursorCalc(labelType, mods))
                    {
                        precursorMass = settings.GetPrecursorMass(labelType, Sequence, mods);
                    }

                    listPrecursorMasses.Add(new KeyValuePair <IsotopeLabelType, double>(labelType, precursorMass));
                }

                foreach (int charge in precursorCharges)
                {
                    if (useFilter && !settings.Accept(settings, this, mods, charge))
                    {
                        continue;
                    }

                    for (int i = 0; i < listPrecursorMasses.Count; i++)
                    {
                        var pair = listPrecursorMasses[i];
                        IsotopeLabelType labelType     = pair.Key;
                        double           precursorMass = pair.Value;
                        // Only return a heavy group, if the precursor masses differ
                        // between the light and heavy calculators
                        if (i == 0 || precursorMass != precursorMassLight)
                        {
                            if (settings.TransitionSettings.IsMeasurablePrecursor(SequenceMassCalc.GetMZ(precursorMass, charge)))
                            {
                                yield return(new TransitionGroup(this, null, charge, labelType));
                            }
                        }
                    }
                }
            }
        }
コード例 #40
0
ファイル: GraphHelper.cs プロジェクト: lgatto/proteowizard
 public PaneKey(IsotopeLabelType isotopeLabelType)
     : this(null, isotopeLabelType, false)
 {
 }