Beispiel #1
0
        public static int ComparePeptides(Peptide pep1, Peptide pep2)
        {
            if (pep1.FastaSequence == null || pep2.FastaSequence == null)
            {
                throw new InvalidOperationException(Resources.FastaSequence_ComparePeptides_Peptides_without_FASTA_sequence_information_may_not_be_compared);
            }
            if (!ReferenceEquals(pep1.FastaSequence, pep2.FastaSequence))
            {
                throw new InvalidOperationException(Resources.FastaSequence_ComparePeptides_Peptides_in_different_FASTA_sequences_may_not_be_compared);
            }

            return(Comparer <int> .Default.Compare(pep1.Order, pep2.Order));
        }
        public PeptideDocNode CreateDocNodeFromSettings(Target target, Peptide peptide, SrmSettingsDiff diff,
                                                        out TransitionGroupDocNode nodeGroupMatched)
        {
            if (!target.IsProteomic)
            {
                nodeGroupMatched = null;
                return(null);
            }

            var seq = target.Sequence;

            seq = Transition.StripChargeIndicators(seq, TransitionGroup.MIN_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE);
            if (peptide == null)
            {
                string seqUnmod = FastaSequence.StripModifications(seq);
                try
                {
                    peptide = new Peptide(null, seqUnmod, null, null,
                                          Settings.PeptideSettings.Enzyme.CountCleavagePoints(seqUnmod));
                }
                catch (InvalidDataException)
                {
                    nodeGroupMatched = null;
                    return(null);
                }
            }

            // Use the number of modifications as the maximum, if it is less than the current
            // settings to keep from over enumerating, which can be slow.
            int seqModCount  = seq.Count(c => c == '[' || c == '(');
            var filterMaxMod = new MaxModFilter(Math.Min(seqModCount,
                                                         Settings.PeptideSettings.Modifications.MaxVariableMods));
            var filterMod = new VariableModLocationFilter(seq);
            var newTarget = new Target(seq);

            foreach (var nodePep in peptide.CreateDocNodes(Settings, filterMaxMod, filterMod))
            {
                var nodePepMod = CreateDocNodeFromSettings(newTarget, nodePep, diff, out nodeGroupMatched);
                if (nodePepMod != null)
                {
                    return(nodePepMod);
                }
            }
            nodeGroupMatched = null;
            return(null);
        }
Beispiel #3
0
        public bool Equals(Peptide obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            var equal = Equals(obj._fastaSequence, _fastaSequence) &&
                        Equals(obj.Target, Target) &&
                        obj.Begin.Equals(Begin) &&
                        obj.End.Equals(End) &&
                        obj.MissedCleavages == MissedCleavages &&
                        obj.IsDecoy == IsDecoy;

            return(equal); // For debugging convenience
        }
Beispiel #4
0
        public Transition(TransitionGroup group, IonType type, int?offset, int?massIndex, Adduct adduct,
                          int?decoyMassShift, CustomMolecule customMolecule = null)
        {
            _group = group;

            IonType        = type;
            CleavageOffset = offset ?? 0;
            MassIndex      = massIndex ?? 0;
            Adduct         = adduct;
            DecoyMassShift = decoyMassShift;
            // Small molecule precursor transition should have same custom molecule as parent
            if (IsPrecursor(type) && group.IsCustomIon)
            {
                CustomIon = new CustomIon(group.CustomMolecule, adduct);
            }
            else if (customMolecule is CustomIon)
            {
                // As with reporter ions
                CustomIon = (CustomIon)customMolecule;
                Assume.IsTrue(Equals(adduct.AdductCharge, CustomIon.Adduct.AdductCharge));
                Adduct = CustomIon.Adduct; // Ion mass is part of formula, so use charge only adduct
            }
            else if (customMolecule != null)
            {
                CustomIon = new CustomIon(customMolecule, adduct);
            }
            // Derived values
            if (!IsCustom(type, group))
            {
                Peptide peptide = group.Peptide;
                Ordinal = OffsetToOrdinal(type, (int)offset, peptide.Length);
                AA      = (IsNTerminal()
                    ? peptide.Sequence[(int)offset]
                    : peptide.Sequence[(int)offset + 1]);
            }
            else
            {
                // caller may have passed in offset = group.Peptide.Length - 1, which for custom ions gives -1
                CleavageOffset = 0;
            }
            Validate();
        }
        public PeptideDocNode CreateDocNodeFromSettings(LibKey key, Peptide peptide, SrmSettingsDiff diff, out TransitionGroupDocNode nodeGroupMatched)
        {
            if (!key.Target.IsProteomic)
            {
                // Scan the spectral lib entry for top N ranked (for now, that's just by intensity with high mz as tie breaker) fragments,
                // add those as mass-only fragments, or with more detail if peak annotations are present.
                foreach (var nodePep in peptide.CreateDocNodes(Settings, new MaxModFilter(0)))
                {
                    SpectrumHeaderInfo libInfo;
                    if (nodePep != null && Settings.PeptideSettings.Libraries.TryGetLibInfo(key, out libInfo))
                    {
                        var isotopeLabelType = key.Adduct.HasIsotopeLabels ? IsotopeLabelType.heavy : IsotopeLabelType.light;
                        var group            = new TransitionGroup(peptide, key.Adduct, isotopeLabelType);
                        nodeGroupMatched = new TransitionGroupDocNode(group, Annotations.EMPTY, Settings, null, libInfo, ExplicitTransitionGroupValues.EMPTY, null, null, false);
                        SpectrumPeaksInfo spectrum;
                        if (Settings.PeptideSettings.Libraries.TryLoadSpectrum(key, out spectrum))
                        {
                            // Add fragment and precursor transitions as needed
                            var transitionDocNodes =
                                Settings.TransitionSettings.Filter.SmallMoleculeIonTypes.Contains(IonType.precursor)
                                    ? nodeGroupMatched.GetPrecursorChoices(Settings, null, true) // Gives list of precursors
                                    : new List <DocNode>();

                            if (Settings.TransitionSettings.Filter.SmallMoleculeIonTypes.Contains(IonType.custom))
                            {
                                GetSmallMoleculeFragments(key, nodeGroupMatched, spectrum, transitionDocNodes);
                            }
                            nodeGroupMatched = (TransitionGroupDocNode)nodeGroupMatched.ChangeChildren(transitionDocNodes);
                            return((PeptideDocNode)nodePep.ChangeChildren(new List <DocNode>()
                            {
                                nodeGroupMatched
                            }));
                        }
                    }
                }
                nodeGroupMatched = null;
                return(null);
            }
            return(CreateDocNodeFromSettings(key.Target, peptide, diff, out nodeGroupMatched));
        }
Beispiel #6
0
        public PeptideDocNode CreateFullPeptideDocNode(SrmSettings settings, String peptideSequence)
        {
            peptideSequence = StripModifications(peptideSequence);
            foreach (var peptideDocNode in CreateFullPeptideDocNodes(settings, false, peptideSequence))
            {
                if (peptideSequence == peptideDocNode.Peptide.Sequence)
                {
                    return(peptideDocNode);
                }
            }

            int begin = Sequence.IndexOf(peptideSequence, StringComparison.Ordinal);

            if (begin < 0)
            {
                return(null);
            }

            var peptide = new Peptide(this, peptideSequence, begin, begin + peptideSequence.Length,
                                      settings.PeptideSettings.Enzyme.CountCleavagePoints(peptideSequence));

            return(new PeptideDocNode(peptide)
                   .ChangeSettings(settings, SrmSettingsDiff.ALL));
        }
Beispiel #7
0
 public PeptideModKey(Peptide peptide, ExplicitMods modifications)
 {
     Peptide       = peptide;
     Modifications = modifications;
 }
Beispiel #8
0
 public static IEnumerable <PeptideDocNode> CreateAllDocNodes(SrmSettings settings, Peptide peptide)
 {
     return(peptide.CreateDocNodes(settings, PeptideFilter.UNFILTERED));
 }
        public PeptideDocNode GetModifiedNode(LibKey key, string seqUnmod, SrmSettings settings, SrmSettingsDiff diff)
        {
            if (string.IsNullOrEmpty(seqUnmod))
            {
                return(null);
            }

            var peptide = new Peptide(null, seqUnmod, null, null,
                                      settings.PeptideSettings.Enzyme.CountCleavagePoints(seqUnmod));

            // First try and create the match from the settings created to match the library explorer.
            Settings = HasMatches
                ? settings.ChangePeptideModifications(mods => MatcherPepMods)
                : settings;
            TransitionGroupDocNode nodeGroup;
            var nodePep = CreateDocNodeFromSettings(key.Sequence, peptide, diff, out nodeGroup);

            if (nodePep != null)
            {
                if (diff == null)
                {
                    nodePep = (PeptideDocNode)nodePep.ChangeAutoManageChildren(false);
                }
                else
                {
                    // Keep only the matching transition group, so that modifications
                    // will be highlighted differently for light and heavy forms.
                    // Only performed when getting peptides for display in the explorer.
                    nodePep = (PeptideDocNode)nodePep.ChangeChildrenChecked(
                        new DocNode[] { nodeGroup });
                }
                return(nodePep);
            }
            else if (Matches == null)
            {
                return(null);
            }
            bool hasHeavy;

            // Create explicit mods from the found matches.
            nodePep = CreateDocNodeFromMatches(new PeptideDocNode(peptide),
                                               EnumerateSequenceInfos(key.Key, true), false, out hasHeavy);

            if (nodePep == null)
            {
                return(null);
            }

            // Call change settings with the matched modification settings to enumerate the children.
            nodePep = nodePep.ChangeSettings(settings.ChangePeptideModifications(mods =>
                                                                                 !HasMatches ? settings.PeptideSettings.Modifications : MatcherPepMods), diff ?? SrmSettingsDiff.ALL);
            if (nodePep.Children.Count == 0)
            {
                return(null);
            }
            // Select the correct child, only for use with the library explorer.
            if (diff != null && nodePep.Children.Count > 1)
            {
                nodePep =
                    (PeptideDocNode)
                    nodePep.ChangeChildrenChecked(new List <DocNode> {
                    nodePep.Children[hasHeavy ? 1 : 0]
                });
            }
            if (diff == null)
            {
                nodePep = (PeptideDocNode)nodePep.ChangeAutoManageChildren(false);
            }
            return(nodePep);
        }
 public bool Accept(SrmSettings settings, Peptide peptide, ExplicitMods explicitMods, out bool allowVariableMods)
 {
     return(PeptideFilter.UNFILTERED.Accept(settings, peptide, explicitMods, out allowVariableMods));
 }
Beispiel #11
0
 public TransitionGroup(Peptide peptide, int precursorCharge, IsotopeLabelType labelType, bool unlimitedCharge, int?decoyMassShift)
     : this(peptide, null, precursorCharge, labelType, unlimitedCharge, decoyMassShift)
 {
 }
Beispiel #12
0
 public TransitionGroup(Peptide peptide, DocNodeCustomIon customIon, int precursorCharge, IsotopeLabelType labelType)
     : this(peptide, customIon, precursorCharge, labelType, false, null)
 {
 }
Beispiel #13
0
 public TransitionGroup(Peptide peptide, Adduct precursorAdduct, IsotopeLabelType labelType)
     : this(peptide, precursorAdduct, labelType, false, null)
 {
 }