Esempio n. 1
0
        public void SettingsChangeMassCalcProps()
        {
            SrmDocument docFasta = CreateMixedDoc();
            SrmSettings settings = docFasta.Settings;

            // Use average precursor masses
            SrmDocument docFasta2 = docFasta.ChangeSettings(settings.ChangeTransitionPrediction(
                                                                p => p.ChangePrecursorMassType(MassType.Average)));

            // Average masses should be heavier that monoisotipic, and transitions should be unchanged
            CheckMasses(docFasta, docFasta2, (before, after) => Assert.IsTrue(before < after), Assert.AreEqual);

            // Use average fragment masses
            settings = docFasta2.Settings.ChangeTransitionInstrument(instrument => instrument.ChangeMaxMz(1501)); // Keep all the new heavy transitions
            SrmDocument docFasta3 = docFasta2.ChangeSettings(settings.ChangeTransitionPrediction(
                                                                 p => p.ChangeFragmentMassType(MassType.Average)));

            // Precursor masses should not have changed, and transitions should be heavier
            CheckMasses(docFasta2, docFasta3, Assert.AreEqual, (before, after) => Assert.IsTrue(before < after));

            // Change both back to all monoisotopic
            settings = docFasta3.Settings;
            SrmDocument docFasta4 = docFasta3.ChangeSettings(settings.ChangeTransitionPrediction(
                                                                 p => p.ChangePrecursorMassType(MassType.Monoisotopic).ChangeFragmentMassType(MassType.Monoisotopic)));

            // This should return the masses to their original values
            CheckMasses(docFasta, docFasta4, Assert.AreEqual, Assert.AreEqual);

            // TODO: Static modifications
        }
Esempio n. 2
0
        public void LibraryNoIonsTest()
        {
            var streamManager = new MemoryStreamManager();
            var loader        = new LibraryLoadTest.TestLibraryLoader {
                StreamManager = streamManager
            };

            // Create X! Hunter library with 20 lowest intensity peaks in NIST library
            LibraryLoadTest.CreateHunterFile(streamManager, loader, LibraryLoadTest.TEXT_LIB_YEAST_NIST, true);

            var hunterSpec = new XHunterLibSpec("Yeast (X!)", LibraryLoadTest.PATH_HUNTER_LIB);

            // For serialization, add the library spec to the settings
            TestLibraryList = new SpectralLibraryList {
                hunterSpec
            };

            var libraryManager = new LibraryManager {
                StreamManager = streamManager
            };
            var docContainer = new TestDocumentContainer();

            SrmSettings settings = SrmSettingsList.GetDefault();

            settings = settings.ChangePeptideLibraries(l => l.ChangeLibrarySpecs(new LibrarySpec[] { hunterSpec }));

            int         startRev;
            SrmDocument docLoaded = CreateLibraryDocument(settings, ExampleText.TEXT_FASTA_YEAST_LIB, false,
                                                          docContainer, libraryManager, out startRev);

            // Peptides should have been chosen, but no transitions, since the spectra are garbage
            AssertEx.IsDocumentState(docLoaded, startRev, 2, 4, 0);
        }
Esempio n. 3
0
        public void SettingsChangeTranGroups()
        {
            SrmDocument docFasta = CreateMixedDoc();
            SrmSettings settings = docFasta.Settings;

            // Add heavy mod
            SrmDocument docFasta2 = docFasta.ChangeSettings(settings.ChangePeptideModifications(
                                                                m => m.ChangeModifications(IsotopeLabelType.heavy, new[] { new StaticMod("N-Terminal K", "K", ModTerminus.C, "H7", LabelAtoms.None, null, null) })));

            CheckNTerminalKGroups(docFasta2);
            Assert.AreEqual(docFasta.PeptideCount, docFasta2.PeptideCount);

            // Add multiple charges with heavy mod
            var newCharges = Adduct.ProtonatedFromCharges(2, 3, 4);

            settings = docFasta2.Settings;
            SrmDocument docFasta3 = docFasta2.ChangeSettings(settings.ChangeTransitionFilter(
                                                                 f => f.ChangePeptidePrecursorCharges(newCharges)));

            CheckNTerminalKGroups(docFasta3);
            Assert.AreEqual(docFasta.PeptideCount, docFasta3.PeptideCount);

            // Use charge that will cause filtering on instrument maximum m/z
            docFasta2 = docFasta.ChangeSettings(settings.ChangeTransitionFilter(
                                                    f => f.ChangePeptidePrecursorCharges(Adduct.ProtonatedFromCharges(1))));
            Assert.IsTrue(docFasta.PeptideTransitionGroupCount < docFasta2.PeptideTransitionGroupCount);
            Assert.AreEqual(docFasta.PeptideCount, docFasta2.PeptideCount);
        }
Esempio n. 4
0
        public void SettingsChangeTrans()
        {
            SrmDocument docFasta    = CreateMixedDoc();
            SrmSettings settings    = docFasta.Settings;
            SrmDocument docFastaNoP = docFasta.ChangeSettings(settings.ChangeTransitionFilter(
                                                                  f => f.ChangeMeasuredIons(new MeasuredIon[0])));

            // Fixed start and end positions
            SrmDocument docFasta2 = CheckTranstions(docFastaNoP, "ion 1", "last ion", 1);

            CheckTranstions(docFasta2, "ion 2", "last ion - 1", 3);
            docFasta2 = CheckTranstions(docFastaNoP, "ion 3", "last ion - 2", 5);
            CheckTranstions(docFasta2, "ion 4", "last ion - 3", 7);

            // Check ion types including precursor
            var docPrec = docFasta2.ChangeSettings(docFasta2.Settings.ChangeTransitionFilter(f =>
                                                                                             f.ChangePeptideIonTypes(new[] { IonType.y, IonType.precursor })));

            Assert.AreEqual(docFasta2.PeptideTransitionCount + docFasta2.PeptideTransitionGroupCount, docPrec.PeptideTransitionCount);
            docPrec = docFasta2.ChangeSettings(docFasta2.Settings.ChangeTransitionFilter(f =>
                                                                                         f.ChangePeptideIonTypes(new[] { IonType.precursor })));
            Assert.AreEqual(docFasta2.PeptideTransitionGroupCount, docPrec.PeptideTransitionCount);
            AssertEx.Serializable(docPrec, AssertEx.DocumentCloned);

            // TODO: Finish this test
        }
Esempio n. 5
0
        private TransitionDocNode GetMatchingTransition(SrmSettings settings,
                                                        TransitionGroupDocNode nodeGroupMatching,
                                                        TransitionDocNode nodeTran,
                                                        IFragmentMassCalc calc)
        {
            var transition     = nodeTran.Transition;
            var losses         = nodeTran.Losses;
            var libInfo        = nodeTran.LibInfo;
            int?decoyMassShift = transition.IsPrecursor() ? DecoyMassShift : transition.DecoyMassShift;
            var tranNew        = new Transition(this,
                                                transition.IonType,
                                                transition.CleavageOffset,
                                                transition.MassIndex,
                                                transition.Charge,
                                                decoyMassShift,
                                                transition.CustomIon ?? CustomIon); // Handle reporter ions as well as small molecules
            var    isotopeDist = nodeGroupMatching.IsotopeDist;
            double massH;

            if (tranNew.IsCustom())
            {
                massH = tranNew.CustomIon.GetMass(settings.TransitionSettings.Prediction.FragmentMassType);
            }
            else
            {
                massH = calc.GetFragmentMass(tranNew, isotopeDist);
            }
            var isotopeDistInfo  = TransitionDocNode.GetIsotopeDistInfo(tranNew, losses, isotopeDist);
            var nodeTranMatching = new TransitionDocNode(tranNew, losses, massH, isotopeDistInfo, libInfo);

            return(nodeTranMatching);
        }
Esempio n. 6
0
 private bool OtherLabelTypesAllowed(SrmSettings settings, double minMz, double maxMz, int start, int end, double startMz, bool accept,
                                     TransitionGroupDocNode nodeGroupMatching,
                                     TransitionDocNode nodeTran,
                                     IEnumerable <Tuple <TransitionGroupDocNode, IFragmentMassCalc> > listOtherTypes)
 {
     foreach (var otherType in listOtherTypes)
     {
         var nodeGroupOther   = otherType.Item1;
         var tranGroupOther   = nodeGroupOther.TransitionGroup;
         var nodeTranMatching = tranGroupOther.GetMatchingTransition(settings,
                                                                     nodeGroupMatching, nodeTran, otherType.Item2);
         if (minMz > nodeTranMatching.Mz || nodeTranMatching.Mz > maxMz)
         {
             return(false);
         }
         if (accept && !settings.TransitionSettings.Accept(Peptide.Sequence,
                                                           nodeGroupOther.PrecursorMz,
                                                           nodeTranMatching.Transition.IonType,
                                                           nodeTranMatching.Transition.CleavageOffset,
                                                           nodeTranMatching.Mz,
                                                           start,
                                                           end,
                                                           startMz))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 7
0
        public void EnableGraphSpectrum(Action ensureLayoutLocked, SrmSettings settings, bool deserialized)
        {
            bool hasLibraries = settings.PeptideSettings.Libraries.HasLibraries;
            bool enable       = hasLibraries || PrositHelpers.PrositSettingsValid;

            if (enable)
            {
                UpdateIonTypesMenuItemsVisibility();
            }

            bool enableChanging = libraryMatchToolStripMenuItem.Enabled != enable;

            if (enableChanging)
            {
                libraryMatchToolStripMenuItem.Enabled = enable;
                ionTypesMenuItem.Enabled = enable;
                chargesMenuItem.Enabled  = enable;
                ranksMenuItem.Enabled    = enable;
            }

            // Make sure we don't keep a spectrum graph around because it was
            // persisted when Prosit settings were on and they no longer are
            if ((enableChanging && !deserialized) || (deserialized && !hasLibraries && !enable))
            {
                ensureLayoutLocked();
                SkylineWindow.ShowGraphSpectrum(enable && Settings.Default.ShowSpectra);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Makes prediction for a single precursor. The result is cached and
        /// if the same prediction is requested, the cached result is returned. This
        /// is useful since predictions are made from a ui updating function, which might be
        /// called repeatedly per update.
        /// </summary>
        /// <param name="predictionClient">Client to use for prediction</param>
        /// <param name="settings">Settings to use for creating inputs and outputs</param>
        /// <param name="input">Precursor and other information</param>
        /// <param name="token">Token for cancelling prediction</param>
        /// <returns>Prediction from Prosit</returns>
        public TSkylineOutput PredictSingle(PredictionService.PredictionServiceClient predictionClient,
                                            SrmSettings settings, TSkylineInputRow input, CancellationToken token)
        {
            lock (_cacheLock)
            {
                if (PrositConstants.CACHE_PREV_PREDICTION && _cachedInput != null && _cachedOutput != null &&
                    _cachedInput.Equals(input) && ReferenceEquals(_cachedClient, predictionClient) &&
                    ReferenceEquals(settings, _cachedSettings))
                {
                    return(_cachedOutput);
                }
            }

            var prositInputRow = CreatePrositInputRow(settings, input, out var exception);

            if (prositInputRow == null)
            {
                throw exception;
            }

            var prositIn   = CreatePrositInput(new[] { prositInputRow });
            var prediction = Predict(predictionClient, prositIn, token);
            var output     = CreateSkylineOutput(settings, new[] { input }, prediction);

            lock (_cacheLock)
            {
                _cachedClient   = predictionClient;
                _cachedSettings = settings;
                _cachedInput    = input;
                _cachedOutput   = output;
            }

            return(output);
        }
Esempio n. 9
0
        /// <summary>
        /// Returns candidates for grouping by annotation by the annotation target. (usually replicates)
        /// </summary>
        public static string[] FindGroupsByTarget(SrmSettings settings, AnnotationDef.AnnotationTarget target)
        {
            var replicateAnnotations = settings.DataSettings.AnnotationDefs
                                       .Where(annotationDef => annotationDef.AnnotationTargets.Contains(target));

            return(replicateAnnotations.Select(a => a.Name).ToArray());
        }
Esempio n. 10
0
        /// <summary>
        /// Gets possible values for an annotation.
        /// </summary>
        public static string[] GetPossibleAnnotations(SrmSettings settings, string group, AnnotationDef.AnnotationTarget target)
        {
            var annotation = settings.DataSettings.AnnotationDefs.FirstOrDefault(annotationDef => annotationDef.AnnotationTargets.Contains(target) && annotationDef.Name == group);

            if (annotation == null)
            {
                return(new string[0]);
            }

            switch (annotation.Type)
            {
            case AnnotationDef.AnnotationType.text:
            case AnnotationDef.AnnotationType.number:
                return(settings.MeasuredResults == null ? new string[0] : settings.MeasuredResults.Chromatograms
                       .Select(c => c.Annotations.GetAnnotation(group)).Distinct().Where(s => s != null).ToArray());

            case AnnotationDef.AnnotationType.value_list:
                return(annotation.Items.ToArray());

            case AnnotationDef.AnnotationType.true_false:
                return(new[] { Resources.AnnotationHelper_GetReplicateIndicices_True, Resources.AnnotationHelper_GetReplicateIndicices_False });

            default:
                return(new string[0]);      // Should never happen
            }
        }
Esempio n. 11
0
        private TransitionDocNode GetMatchingTransition(SrmSettings settings,
                                                        TransitionGroupDocNode nodeGroupMatching,
                                                        TransitionDocNode nodeTran,
                                                        IFragmentMassCalc calc)
        {
            var transition     = nodeTran.Transition;
            var losses         = nodeTran.Losses;
            var libInfo        = nodeTran.LibInfo;
            int?decoyMassShift = transition.IsPrecursor() ? DecoyMassShift : transition.DecoyMassShift;
            var tranNew        = new Transition(this,
                                                transition.IonType,
                                                transition.CleavageOffset,
                                                transition.MassIndex,
                                                transition.Adduct,
                                                decoyMassShift,
                                                transition.CustomIon ?? CustomMolecule); // Handle reporter ions as well as small molecules
            var       isotopeDist = nodeGroupMatching.IsotopeDist;
            TypedMass massH;
            var       massType = calc.MassType;

            if (tranNew.IsCustom())
            {
                massH = tranNew.CustomIon.GetMass(massType);
            }
            else
            {
                massH = calc.GetFragmentMass(tranNew, isotopeDist);
            }
            var isotopeDistInfo  = TransitionDocNode.GetIsotopeDistInfo(tranNew, losses, isotopeDist);
            var nodeTranMatching = new TransitionDocNode(tranNew, losses, massH, new TransitionDocNode.TransitionQuantInfo(isotopeDistInfo, libInfo, nodeTran.IsQuantitative(settings)), nodeTran.ExplicitValues);

            return(nodeTranMatching);
        }
Esempio n. 12
0
        public DocNode EnsureChildren(TransitionGroupDocNode parent, SrmSettings settings)
        {
            // Make sure node points to correct parent.
            if (ReferenceEquals(parent.TransitionGroup, Transition.Group))
            {
                return(this);
            }

            var transition = Transition.IsCustom()
                ? new Transition(parent.TransitionGroup,
                                 Transition.Adduct,
                                 Transition.MassIndex,
                                 Transition.CustomIon,
                                 Transition.IonType)
                : new Transition(parent.TransitionGroup,
                                 Transition.IonType,
                                 Transition.CleavageOffset,
                                 Transition.MassIndex,
                                 Transition.Adduct);

            return(new TransitionDocNode(transition,
                                         Annotations,
                                         Losses,
                                         TypedMass.ZERO_MONO_MASSH,
                                         QuantInfo,
                                         ExplicitValues,
                                         null)
            {
                Mz = Mz, MzMassType = MzMassType
            });
        }
Esempio n. 13
0
 public CrosslinkBuilder(SrmSettings settings, Peptide peptide, ExplicitMods explicitMods, IsotopeLabelType labelType)
 {
     Settings     = settings;
     Peptide      = peptide;
     ExplicitMods = explicitMods;
     LabelType    = labelType;
 }
        public PeptideGroupDocNode EnsureChildren(SrmSettings settings, bool peptideList)
        {
            var result = this;
            // Check if children will change as a result of ChangeSettings.
            var changed = result.ChangeSettings(settings, SrmSettingsDiff.ALL);

            if (result.AutoManageChildren && !AreEquivalentChildren(result.Children, changed.Children))
            {
                changed = result = (PeptideGroupDocNode)result.ChangeAutoManageChildren(false);
                changed = changed.ChangeSettings(settings, SrmSettingsDiff.ALL);
            }
            // Match children resulting from ChangeSettings to current children.
            var dictIndexToChild = Children.ToDictionary(child => child.Id.GlobalIndex);
            var listChildren     = new List <DocNode>();

            foreach (PeptideDocNode nodePep in changed.Children)
            {
                DocNode child;
                if (dictIndexToChild.TryGetValue(nodePep.Id.GlobalIndex, out child))
                {
                    listChildren.Add(((PeptideDocNode)child).EnsureChildren(settings, peptideList));
                }
            }
            return((PeptideGroupDocNode)result.ChangeChildrenChecked(listChildren));
        }
Esempio n. 15
0
        public RefineDlg(SrmDocument document)
        {
            _document = document;
            _settings = document.Settings;

            InitializeComponent();

            Icon = Resources.Skyline;

            // Fill label type combo box
            comboRefineLabelType.Items.Add(string.Empty);
            comboRefineLabelType.Items.Add(IsotopeLabelType.LIGHT_NAME);
            foreach (var typedMods in _settings.PeptideSettings.Modifications.GetHeavyModifications())
            {
                comboRefineLabelType.Items.Add(typedMods.LabelType.Name);
            }
            comboRefineLabelType.SelectedIndex = 0;
            comboReplicateUse.SelectedIndex    = 0;

            var settings = document.Settings;

            if (!settings.HasResults)
            {
                tabControl1.TabPages.Remove(tabResults);
            }

            if (settings.PeptideSettings.Libraries.HasLibraries)
            {
                labelMinDotProduct.Enabled = textMinDotProduct.Enabled = groupLibCorr.Enabled = true;
            }
            if (settings.TransitionSettings.FullScan.IsHighResPrecursor)
            {
                labelMinIdotProduct.Enabled = textMinIdotProduct.Enabled = groupLibCorr.Enabled = true;
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Returns all possible variably modified <see cref="PeptideDocNode"/> objects
        /// for a peptide sequence under specific settings.
        /// </summary>
        public static IEnumerable <PeptideDocNode> CreateAllDocNodes(SrmSettings settings, string sequence)
        {
            var peptide = new Peptide(null, sequence, null, null,
                                      settings.PeptideSettings.Enzyme.CountCleavagePoints(sequence));

            return(CreateAllDocNodes(settings, peptide));
        }
Esempio n. 17
0
        private static IEnumerable <KeyValuePair <IsotopeLabelType, string> > GetTypedModifiedSequences(
            PeptideDocNode nodePep, SrmSettings settings)
        {
            foreach (var labelType in settings.PeptideSettings.Modifications.GetModificationTypes())
            {
                if (nodePep.Peptide.IsCustomMolecule)
                {
                    continue;
                }
                // Only return the modified sequence, if the peptide actually as a child
                // of this type.
                if (!nodePep.HasChildType(labelType))
                {
                    continue;
                }
                var calc = settings.TryGetPrecursorCalc(labelType, nodePep.ExplicitMods);
                if (calc == null)
                {
                    continue;
                }

                string modSequence = calc.GetModifiedSequence(nodePep.Peptide.Target, true).Sequence; // Never have to worry about this being a custom molecule, we already checked

                // Only return if the modified sequence contains modifications
                if (modSequence.Contains('['))
                {
                    yield return(new KeyValuePair <IsotopeLabelType, string>(labelType, modSequence));
                }
            }
        }
Esempio n. 18
0
        public void Validate(SrmSettings settings)
        {
            var chromatogramSets = settings.MeasuredResults.Chromatograms;

            if (chromatogramSets.Count != Count)
            {
                throw new InvalidDataException(
                          string.Format(Resources.Results_Validate_DocNode_results_count__0__does_not_match_document_results_count__1__,
                                        Count, chromatogramSets.Count));
            }

            for (int i = 0; i < chromatogramSets.Count; i++)
            {
                var chromList = this[i];
                if (chromList == null)
                {
                    continue;
                }

                var chromatogramSet = chromatogramSets[i];
                if (chromList.Any(chromInfo => chromatogramSet.IndexOfId(chromInfo.FileId) == -1))
                {
                    throw new InvalidDataException(
                              string.Format(Resources.Results_Validate_DocNode_peak_info_found_for_file_with_no_match_in_document_results));
                }
            }
        }
Esempio n. 19
0
        public static void DrawPeptideText(PeptideDocNode nodePep,
                                           SrmSettings settings,
                                           IEnumerable <TextSequence> textSequences,
                                           Graphics g,
                                           Rectangle bounds,
                                           ModFontHolder fonts,
                                           Color foreColor,
                                           Color backColor)
        {
            if (textSequences == null)
            {
                textSequences = CreateTextSequences(nodePep, settings, GetLabel(nodePep, string.Empty), g, fonts);
            }
            Rectangle rectDraw = new Rectangle(0, bounds.Y, 0, bounds.Height);

            foreach (var textSequence in textSequences)
            {
                rectDraw.X     = textSequence.Position + bounds.X + TreeViewMS.PADDING;
                rectDraw.Width = textSequence.Width;
                // Use selection highlight color, if the background is highlight.
                if (backColor != SystemColors.Highlight)
                {
                    foreColor = textSequence.Color;
                }
                TextRenderer.DrawText(g, textSequence.Text, textSequence.Font, rectDraw,
                                      foreColor, backColor, FORMAT_TEXT_SEQUENCE);
            }
        }
Esempio n. 20
0
 public PickTransitionGroupTip(PeptideDocNode nodePep,
                               TransitionGroupDocNode nodeGroup, SrmSettings settings)
 {
     _nodePep   = nodePep;
     _nodeGroup = nodeGroup;
     _settings  = settings;
 }
Esempio n. 21
0
        public double GetIsotopologArea(SrmSettings settings, int replicateIndex, IsotopeLabelType labelType)
        {
            double totalArea           = 0;
            var    normalizationMethod = NormalizationMethod;

            if (normalizationMethod is NormalizationMethod.RatioToLabel)
            {
                normalizationMethod = NormalizationMethod.NONE;
            }
            foreach (var precursor in PeptideDocNode.TransitionGroups)
            {
                if (!Equals(labelType, precursor.LabelType))
                {
                    continue;
                }
                foreach (var transition in precursor.Transitions)
                {
                    if (SkipTransition(settings, transition))
                    {
                        continue;
                    }
                    var quantity = GetTransitionQuantity(settings, null, normalizationMethod, replicateIndex, precursor,
                                                         transition, false);
                    if (quantity != null)
                    {
                        totalArea += quantity.Intensity / quantity.Denominator;
                    }
                }
            }
            return(totalArea);
        }
Esempio n. 22
0
        public double?GetQualitativeIonRatio(SrmSettings settings, TransitionGroupDocNode precursor, int replicateIndex)
        {
            double numerator        = 0;
            int    numeratorCount   = 0;
            double denominator      = 0;
            int    denominatorCount = 0;

            foreach (var transition in precursor.Transitions)
            {
                var quantity = GetTransitionQuantity(settings, null, NormalizationMethod.NONE, replicateIndex,
                                                     precursor, transition, false);
                if (quantity != null)
                {
                    double value = quantity.Intensity / quantity.Denominator;
                    if (transition.ExplicitQuantitative)
                    {
                        denominator += value;
                        denominatorCount++;
                    }
                    else
                    {
                        numerator += value;
                        numeratorCount++;
                    }
                }
            }

            if (numeratorCount == 0 || denominatorCount == 0)
            {
                return(null);
            }

            return(numerator / denominator);
        }
Esempio n. 23
0
        public override IEnumerable <DocNode> GetChoices(bool useFilter)
        {
            SrmSettings settings = DocSettings;

            List <DocNode> listPeptides = new List <DocNode>();

            foreach (var nodePep in DocNode.GetPeptideNodes(settings, useFilter))
            {
                var nodePepMaterialized = nodePep.ChangeSettings(settings, SrmSettingsDiff.ALL);
                if (!useFilter || settings.TransitionSettings.Libraries.MinIonCount == 0 || nodePepMaterialized.Children.Count != 0)
                {
                    listPeptides.Add(nodePepMaterialized);
                }
            }

            PeptideRankId rankId = DocSettings.PeptideSettings.Libraries.RankId;

            if (rankId != null && !DocNode.IsPeptideList)
            {
                listPeptides = PeptideGroup.RankPeptides(listPeptides, settings, useFilter).ToList();
            }

            MergeChosen(listPeptides, useFilter, node => ((PeptideDocNode)node).Key);

            return(listPeptides);
        }
Esempio n. 24
0
        public IDictionary <IdentityPath, Quantity> GetTransitionIntensities(SrmSettings srmSettings, int replicateIndex, bool treatMissingAsZero)
        {
            var quantities = new Dictionary <IdentityPath, Quantity>();
            var transitionsToNormalizeAgainst = GetTransitionsToNormalizeAgainst(srmSettings, PeptideDocNode, replicateIndex);

            foreach (var precursor in PeptideDocNode.TransitionGroups)
            {
                if (SkipTransitionGroup(precursor))
                {
                    continue;
                }
                foreach (var transition in precursor.Transitions)
                {
                    if (SkipTransition(srmSettings, transition))
                    {
                        continue;
                    }
                    var quantity = GetTransitionQuantity(srmSettings, transitionsToNormalizeAgainst, NormalizationMethod, replicateIndex, precursor,
                                                         transition, treatMissingAsZero);
                    if (null != quantity)
                    {
                        IdentityPath transitionIdentityPath = new IdentityPath(PeptideGroupDocNode.PeptideGroup,
                                                                               PeptideDocNode.Peptide, precursor.TransitionGroup, transition.Transition);
                        quantities.Add(transitionIdentityPath, quantity);
                    }
                }
            }
            return(quantities);
        }
Esempio n. 25
0
        public PeptideDocNode CreateFullPeptideDocNode(SrmSettings settings, Target peptideSequence)
        {
            peptideSequence = StripModifications(peptideSequence);
            foreach (var peptideDocNode in CreateFullPeptideDocNodes(settings, false, peptideSequence))
            {
                if (peptideSequence == peptideDocNode.Peptide.Target)
                {
                    return(peptideDocNode);
                }
            }

            if (!peptideSequence.IsProteomic) // Can't (yet?) predict small mol fragments
            {
                return(null);
            }

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

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

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

            return(new PeptideDocNode(peptide)
                   .ChangeSettings(settings, SrmSettingsDiff.ALL));
        }
Esempio n. 26
0
        public DocNode EnsureChildren(TransitionGroupDocNode parent, SrmSettings settings)
        {
            // Make sure node points to correct parent.
            if (ReferenceEquals(parent.TransitionGroup, Transition.Group))
            {
                return(this);
            }

            var transition = Transition.IsCustom()
                ? new Transition(parent.TransitionGroup,
                                 Transition.Charge,
                                 Transition.MassIndex,
                                 Transition.CustomIon,
                                 Transition.IonType)
                : new Transition(parent.TransitionGroup,
                                 Transition.IonType,
                                 Transition.CleavageOffset,
                                 Transition.MassIndex,
                                 Transition.Charge);

            return(new TransitionDocNode(transition,
                                         Annotations,
                                         Losses,
                                         0.0,
                                         IsotopeDistInfo,
                                         LibInfo,
                                         null)
            {
                Mz = Mz
            });
        }
Esempio n. 27
0
        public IEnumerable <PeptideDocNode> CreatePeptideDocNodes(SrmSettings settings, bool useFilter, Target peptideSequence)
        {
            PeptideSettings pepSettings = settings.PeptideSettings;
            DigestSettings  digest = pepSettings.DigestSettings;
            IPeptideFilter  filter = (useFilter ? settings : PeptideFilter.UNFILTERED);
            int?            maxLen = null, minLen = null;
            var             pick = pepSettings.Libraries.Pick;

            if (useFilter && pick != PeptidePick.library && pick != PeptidePick.either)
            {
                // CONSIDER(brendanx): It should be possible to get min and max length from libraries
                maxLen = pepSettings.Filter.MaxPeptideLength;
                minLen = pepSettings.Filter.MinPeptideLength;
            }
            foreach (var peptide in pepSettings.Enzyme.Digest(this, digest, maxLen, minLen))
            {
                if (null != peptideSequence && !Equals(peptideSequence, peptide.Target))
                {
                    continue;
                }
                foreach (var nodePep in peptide.CreateDocNodes(settings, filter))
                {
                    yield return(nodePep);
                }
            }
        }
Esempio n. 28
0
        public IEnumerable <ComplexFragmentIon> ListComplexFragmentIons(SrmSettings settings, int maxFragmentEventCount, bool useFilter)
        {
            IEnumerable <ComplexFragmentIon> result = ListSimpleFragmentIons(settings, useFilter);

            result = PermuteComplexFragmentIons(ExplicitMods, settings, maxFragmentEventCount, useFilter, result);
            return(result);
        }
Esempio n. 29
0
        public TransitionGroupDocNode GetTransitionGroupDocNode(SrmSettings settings, IsotopeLabelType labelType, Adduct adduct)
        {
            var transitionGroup        = GetTransitionGroup(labelType, adduct);
            var transitionGroupDocNode = new TransitionGroupDocNode(transitionGroup, Annotations.EMPTY, settings, ExplicitMods, null, ExplicitTransitionGroupValues.EMPTY, null, null, false);

            return(transitionGroupDocNode);
        }
Esempio n. 30
0
        public ComplexFragmentIon MakeComplexFragmentIon(SrmSettings settings, IsotopeLabelType labelType, ComplexFragmentIonName complexFragmentIonName)
        {
            var        transitionGroup = GetTransitionGroup(labelType, Adduct.SINGLY_PROTONATED);
            Transition transition;

            if (complexFragmentIonName.IonType == IonType.precursor || complexFragmentIonName.IonType == IonType.custom)
            {
                transition = new Transition(transitionGroup, IonType.precursor, Peptide.Length - 1, 0, Adduct.SINGLY_PROTONATED);
            }
            else
            {
                transition = new Transition(transitionGroup, complexFragmentIonName.IonType,
                                            Transition.OrdinalToOffset(complexFragmentIonName.IonType, complexFragmentIonName.Ordinal, Peptide.Length),
                                            0, Adduct.SINGLY_PROTONATED);
            }

            var result = new ComplexFragmentIon(transition, null, CrosslinkStructure, complexFragmentIonName.IsOrphan);

            if (ExplicitMods != null)
            {
                foreach (var child in complexFragmentIonName.Children)
                {
                    LinkedPeptide linkedPeptide;
                    if (!ExplicitMods.Crosslinks.TryGetValue(child.Item1, out linkedPeptide))
                    {
                        throw new InvalidOperationException(@"No crosslink at " + child.Item1);
                    }
                    result = result.AddChild(child.Item1,
                                             linkedPeptide.MakeComplexFragmentIon(settings, labelType, child.Item2));
                }
            }

            return(result);
        }
 public CalibrationCurveFitter(PeptideQuantifier peptideQuantifier, SrmSettings srmSettings)
 {
     PeptideQuantifier = peptideQuantifier;
     SrmSettings = srmSettings;
 }
 public static CalibrationCurveFitter GetCalibrationCurveFitter(SrmSettings srmSettings,
     PeptideGroupDocNode peptideGroup, PeptideDocNode peptide)
 {
     return new CalibrationCurveFitter(PeptideQuantifier.GetPeptideQuantifier(srmSettings, peptideGroup, peptide), srmSettings);
 }