Exemplo n.º 1
0
        public void OkDialog()
        {
            var peptide = NodePeptide.Peptide;
            var explicitModsCurrent = NodePeptide.ExplicitMods;
            var modsDoc = DocSettings.PeptideSettings.Modifications;
            var implicitMods = new ExplicitMods(NodePeptide,
                modsDoc.StaticModifications, Settings.Default.StaticModList,
                modsDoc.GetHeavyModifications(), Settings.Default.HeavyModList);

            // Get static modifications from the dialog, and check for equality with
            // the document implicit modifications.
            TypedExplicitModifications staticTypedMods = null;
            bool isVariableStaticMods = false;
            var staticMods = GetExplicitMods(_listComboStatic, Settings.Default.StaticModList);
            if (ArrayUtil.EqualsDeep(staticMods, implicitMods.StaticModifications))
            {
                if (!NodePeptide.HasVariableMods)
                    staticMods = null;  // Use implicit modifications
                else
                {
                    staticMods = explicitModsCurrent.StaticModifications;
                    isVariableStaticMods = true;
                }
            }
            else if (explicitModsCurrent != null &&
                        ArrayUtil.EqualsDeep(staticMods, explicitModsCurrent.StaticModifications))
            {
                staticMods = explicitModsCurrent.StaticModifications;
            }
            if (staticMods != null)
            {
                staticTypedMods = new TypedExplicitModifications(peptide,
                    IsotopeLabelType.light, staticMods);
            }

            var listHeavyTypedMods = new List<TypedExplicitModifications>();
            for (int i = 0; i < _listLabelTypeHeavy.Count; i++)
            {
                var labelType = _listLabelTypeHeavy[i];
                var heavyMods = GetExplicitMods(_listListComboHeavy[i], Settings.Default.HeavyModList);

                if (ArrayUtil.EqualsDeep(heavyMods, implicitMods.GetModifications(labelType)))
                    continue;

                var heavyTypedMods = new TypedExplicitModifications(peptide, labelType, heavyMods);
                listHeavyTypedMods.Add(heavyTypedMods.AddModMasses(staticTypedMods));
            }

            ExplicitMods explicitMods = null;
            if (staticMods != null || listHeavyTypedMods.Count > 0)
                explicitMods = new ExplicitMods(peptide, staticMods, listHeavyTypedMods, isVariableStaticMods);
            Helpers.AssignIfEquals(ref explicitMods, explicitModsCurrent);
            ExplicitMods = explicitMods;

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 2
0
 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
         };
 }
Exemplo n.º 3
0
        public RelativeRT GetRelativeRT(IsotopeLabelType labelType, string seq, ExplicitMods mods)
        {
            if (labelType.IsLight)
                return RelativeRT.Matching;
            // Default is matching
            RelativeRT relativeRT = RelativeRT.Matching;
            // One unkown modification makes everything unknown
            // One preceding modification with no unknowns make relative RT preceding
            // Overlapping overrides matching
            if (mods != null && mods.IsModified(labelType))
            {
                foreach (var mod in mods.GetModifications(labelType))
                {
                    if (mod.Modification.RelativeRT == RelativeRT.Unknown)
                        return RelativeRT.Unknown;

                    if (mod.Modification.RelativeRT == RelativeRT.Preceding)
                        relativeRT = RelativeRT.Preceding;
                    else if (mod.Modification.RelativeRT == RelativeRT.Overlapping &&
                             relativeRT == RelativeRT.Matching)
                        relativeRT = RelativeRT.Overlapping;
                }
            }
            else
            {
                foreach (var mod in PeptideSettings.Modifications.GetModifications(labelType))
                {
                    if (!mod.IsMod(seq))
                        continue;
                    if (mod.RelativeRT == RelativeRT.Unknown)
                        return RelativeRT.Unknown;

                    if (mod.RelativeRT == RelativeRT.Preceding)
                        relativeRT = RelativeRT.Preceding;
                    else if (mod.RelativeRT == RelativeRT.Overlapping &&
                             relativeRT == RelativeRT.Matching)
                        relativeRT = RelativeRT.Overlapping;
                }
            }
            return relativeRT;
        }
Exemplo n.º 4
0
        public PeptideDocNode EnsureMods(PeptideModifications source, PeptideModifications target,
            MappedList<string, StaticMod> defSetStat, MappedList<string, StaticMod> defSetHeavy)
        {
            // Create explicit mods matching the implicit mods on this peptide for each document.
            var sourceImplicitMods = new ExplicitMods(this, source.StaticModifications, defSetStat, source.GetHeavyModifications(), defSetHeavy);
            var targetImplicitMods = new ExplicitMods(this, target.StaticModifications, defSetStat, target.GetHeavyModifications(), defSetHeavy);

            // If modifications match, no need to create explicit modifications for the peptide.
            if (sourceImplicitMods.Equals(targetImplicitMods))
                return this;

            // Add explicit mods if static mods not implicit in the target document.
            IList<ExplicitMod> newExplicitStaticMods = null;
            bool preserveVariable = HasVariableMods;
            // Preserve non-variable explicit modifications
            if (!preserveVariable && HasExplicitMods && ExplicitMods.StaticModifications != null)
            {
                // If they are not the same as the implicit modifications in the new document
                if (!ArrayUtil.EqualsDeep(ExplicitMods.StaticModifications, targetImplicitMods.StaticModifications))
                    newExplicitStaticMods = ExplicitMods.StaticModifications;
            }
            else if (!ArrayUtil.EqualsDeep(sourceImplicitMods.StaticModifications, targetImplicitMods.StaticModifications))
            {
                preserveVariable = false;
                newExplicitStaticMods = sourceImplicitMods.StaticModifications;
            }
            else if (preserveVariable)
            {
                newExplicitStaticMods = ExplicitMods.StaticModifications;
            }

            // Drop explicit mods if matching implicit mods are found in the target document.
            IList<TypedExplicitModifications> newExplicitHeavyMods = new List<TypedExplicitModifications>();
            // For each heavy label type, add explicit mods if static mods not found in the target document.
            var newTypedStaticMods = newExplicitStaticMods != null
                ? new TypedExplicitModifications(Peptide, IsotopeLabelType.light, newExplicitStaticMods)
                : null;
            foreach (TypedExplicitModifications targetDocMod in targetImplicitMods.GetHeavyModifications())
            {
                // Use explicit modifications when available.  Otherwise, compare against new implicit modifications
                IList<ExplicitMod> heavyMods = (HasExplicitMods ? ExplicitMods.GetModifications(targetDocMod.LabelType) : null) ??
                    sourceImplicitMods.GetModifications(targetDocMod.LabelType);
                if (heavyMods != null && !ArrayUtil.EqualsDeep(heavyMods, targetDocMod.Modifications) && heavyMods.Count > 0)
                {
                    var newTypedHeavyMods = new TypedExplicitModifications(Peptide, targetDocMod.LabelType, heavyMods);
                    newTypedHeavyMods = newTypedHeavyMods.AddModMasses(newTypedStaticMods);
                    newExplicitHeavyMods.Add(newTypedHeavyMods);
                }
            }

            if (newExplicitStaticMods != null || newExplicitHeavyMods.Count > 0)
                return ChangeExplicitMods(new ExplicitMods(Peptide, newExplicitStaticMods, newExplicitHeavyMods, preserveVariable));
            return ChangeExplicitMods(null);
        }