Exemple #1
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);
        }
Exemple #2
0
 public override float GetRankValue(PeptideRankId rankId)
 {
     if (ReferenceEquals(rankId, ChromatogramLibrarySpec.PEPTIDE_RANK_PEAK_AREA))
     {
         return((float)PeakArea);
     }
     return(base.GetRankValue(rankId));
 }
Exemple #3
0
 public override float GetRankValue(PeptideRankId rankId)
 {
     if (ReferenceEquals(rankId, LibrarySpec.PEP_RANK_COPIES))
     {
         return(SpectrumCount);
     }
     return(base.GetRankValue(rankId));
 }
Exemple #4
0
 public override float GetRankValue(PeptideRankId rankId)
 {
     if (ReferenceEquals(rankId, XHunterLibSpec.PEP_RANK_EXPECT))
     {
         return(-Expect);
     }
     if (ReferenceEquals(rankId, XHunterLibSpec.PEP_RANK_PROCESSED_INTENSITY))
     {
         return(ProcessedIntensity);
     }
     return(base.GetRankValue(rankId));
 }
Exemple #5
0
        private static bool IsUpdateNeeded(PeptideRankId rankId, IList <DocNode> listPeptides)
        {
            if (rankId != null)
            {
                return(true);
            }

            foreach (PeptideDocNode nodePep in listPeptides)
            {
                if (nodePep.Rank.HasValue)
                {
                    return(true);
                }
            }
            return(false);
        }
        public override IEnumerable <DocNode> GetChoices(bool useFilter)
        {
            SrmSettings settings = DocSettings;

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

            foreach (var nodePep in DocNode.GetPeptideNodes(settings, useFilter))
            {
                listPeptides.Add(nodePep.ChangeSettings(settings, SrmSettingsDiff.ALL));
            }

            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);
        }
 private static bool IsValidRankId(PeptideRankId rankId, IEnumerable<LibrarySpec> chosen)
 {
     foreach (LibrarySpec spec in chosen)
     {
         if (!spec.PeptideRankIds.Contains(rankId))
             return false;
     }
     return true;
 }
Exemple #8
0
        public static IList <DocNode> RankPeptides(IList <DocNode> listPeptides, SrmSettings settings, bool useLimit)
        {
            // If no rank ID is set, just return the input list
            PeptideRankId rankId = settings.PeptideSettings.Libraries.RankId;

            if (!IsUpdateNeeded(rankId, listPeptides))
            {
                return(listPeptides);
            }

            // Transfer input list to a typed array
            var listRanks = new List <KeyValuePair <PeptideDocNode, float> >();

            foreach (PeptideDocNode nodePep in listPeptides)
            {
                var nodePepAdd = nodePep;
                // Remove any old rank information, if peptides are no longer ranked.
                if (rankId == null && nodePepAdd.Rank.HasValue)
                {
                    nodePepAdd = nodePepAdd.ChangeRank(null);
                }
                listRanks.Add(new KeyValuePair <PeptideDocNode, float>(nodePepAdd, nodePepAdd.GetRankValue(rankId)));
            }

            if (rankId == null)
            {
                return(listRanks.ConvertAll(p => p.Key).ToArray());
            }

            // Sort desc by rank ID value
            listRanks.Sort((p1, p2) => Comparer.Default.Compare(p2.Value, p1.Value));

            int rank = 1;

            for (int i = 0; i < listRanks.Count; i++)
            {
                var peptideRank = listRanks[i];
                var peptide     = peptideRank.Key;
                if (peptideRank.Value == float.MinValue)
                {
                    if (peptide.Rank.HasValue)
                    {
                        peptide = peptide.ChangeRank(null);
                    }
                }
                else if (!peptide.Rank.HasValue || peptide.Rank.Value != rank)
                {
                    peptide = peptide.ChangeRank(rank);
                }
                listRanks[i] = new KeyValuePair <PeptideDocNode, float>(peptide, peptideRank.Value);

                rank++;
            }

            // Reduce array length to desired limit, if necessary
            int?peptideCount = settings.PeptideSettings.Libraries.PeptideCount;
            int numPeptides  = useLimit && peptideCount.HasValue && peptideCount.Value < listPeptides.Count
                              ? peptideCount.Value
                              : listPeptides.Count;
            var peptidesNew = new List <PeptideDocNode>();

            for (int i = 0; i < numPeptides; i++)
            {
                // TODO: Remove any peptide groups without the correct rank value
                if (useLimit && listRanks[i].Value == float.MinValue)
                {
                    break;
                }
                peptidesNew.Add(listRanks[i].Key);
            }

            // Re-sort by order in FASTA sequence
            peptidesNew.Sort(FastaSequence.ComparePeptides);

            return(peptidesNew.ToArray());
        }
 public float GetRankValue(PeptideRankId rankId)
 {
     float value = Single.MinValue;
     foreach (TransitionGroupDocNode nodeGroup in Children)
         value = Math.Max(value, nodeGroup.GetRankValue(rankId));
     return value;
 }
 public override float GetRankValue(PeptideRankId rankId)
 {
     if (rankId == ChromatogramLibrarySpec.PEPTIDE_RANK_PEAK_AREA)
     {
         return (float) PeakArea;
     }
     return base.GetRankValue(rankId);
 }
Exemple #11
0
 public override float GetRankValue(PeptideRankId rankId)
 {
     if (ReferenceEquals(rankId, LibrarySpec.PEP_RANK_COPIES))
         return SpectrumCount;
     return base.GetRankValue(rankId);
 }
        private void comboMatching_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboMatching.SelectedIndex)
            {
                case (int)PeptidePick.library:
                case (int)PeptidePick.both:
                    UpdateRanks(null);
                    if (IsValidRankId(_lastRankId, _driverLibrary.Chosen))
                        comboRank.SelectedItem = _lastRankId;
                    comboRank.Enabled = true;
                    break;

                case (int)PeptidePick.filter:
                case (int)PeptidePick.either:
                    if (comboRank.SelectedIndex != -1)
                        _lastRankId = (PeptideRankId)comboRank.SelectedItem;
                    comboRank.SelectedIndex = -1;
                    comboRank.Enabled = false;
                    break;
            }
        }
Exemple #13
0
 private static IList<DocNode> FilterHighestRank(IList<DocNode> childrenNew, PeptideRankId rankId)
 {
     if (childrenNew.Count < 2)
         return childrenNew;
     int maxCharge = 0;
     float maxValue = Single.MinValue;
     foreach (TransitionGroupDocNode nodeGroup in childrenNew)
     {
         float rankValue = nodeGroup.GetRankValue(rankId);
         if (rankValue > maxValue)
         {
             maxCharge = nodeGroup.TransitionGroup.PrecursorCharge;
             maxValue = rankValue;
         }
     }
     var listHighestRankChildren = new List<DocNode>();
     foreach (TransitionGroupDocNode nodeGroup in childrenNew)
     {
         if (nodeGroup.TransitionGroup.PrecursorCharge == maxCharge)
             listHighestRankChildren.Add(nodeGroup);
     }
     return listHighestRankChildren;
 }
        private void UpdateRanks(ItemCheckEventArgs e)
        {
            // Store selection, if there is one.
            if (comboRank.SelectedIndex != -1)
                _lastRankId = (PeptideRankId) comboRank.SelectedItem;

            PeptideRankId rankId = _lastRankId;

            _eventChosenLibraries = _driverLibrary.GetChosen(e);
            try
            {
                // Recalculate possible ranks from selected libraries
                comboRank.Items.Clear();
                comboRank.Items.Add(PeptideRankId.PEPTIDE_RANK_NONE);

                HashSet<PeptideRankId> rankIdSet = new HashSet<PeptideRankId>();
                foreach (LibrarySpec spec in _eventChosenLibraries)
                {
                    // If not all libraries contain the most recently selected
                    // rank ID, then leave the default of no rank ID.
                    if (rankId != null && !spec.PeptideRankIds.Contains(rankId))
                        rankId = null;

                    rankIdSet.UnionWith(spec.PeptideRankIds);
                }
                PeptideRankId[] rankIds = rankIdSet.ToArray();
                Array.Sort(rankIds, (id1, id2) => Comparer<string>.Default.Compare(id1.Label, id2.Label));
                comboRank.Items.AddRange(rankIds.Cast<object>().ToArray());

                // Restore selection
                if (rankId != null)
                    comboRank.SelectedItem = rankId;
                comboRank_SelectedIndexChanged(this, new EventArgs());
            }
            finally
            {
                _eventChosenLibraries = null;
            }
        }
 public PeptideLibraries ChangeRankId(PeptideRankId prop)
 {
     return ChangeProp(ImClone(this), im =>
                                          {
                                              im.RankId = prop;
                                              if (prop == null)
                                                  im.PeptideCount = null;
                                          });
 }
        public PeptideLibraries(PeptidePick pick, PeptideRankId rankId, int? peptideCount,
            bool hasDocLib, IList<LibrarySpec> librarySpecs, IList<Library> libraries)
        {
            Pick = pick;
            RankId = rankId;
            PeptideCount = peptideCount;
            HasDocumentLibrary = hasDocLib;
            LibrarySpecs = librarySpecs;
            Libraries = libraries;

            DoValidate();
        }
        private void EnsureRankId()
        {
            string idName = (RankId != null ? RankId.Value : _rankIdName);
            if (idName == null)
                return;

            if (HasDocumentLibrary && !LibrarySpecs.Any(spec => spec != null && spec.IsDocumentLibrary))
            {
                // Not possible to reconcile until Document Library is loaded.
                return;
            }

            // Look for the rank ID in the specified LibrarySpecs.
            // They should all have it, or this is not a valid ranking.
            PeptideRankId idFound = null;
            foreach (LibrarySpec spec in LibrarySpecs)
            {
                // Not possible to reconcile until all library specs are loaded
                if (spec == null)
                    return;

                // Find the rank ID in each library.
                idFound = null;

                foreach (PeptideRankId id in spec.PeptideRankIds)
                {
                    if (Equals(idName, id.Value))
                    {
                        idFound = id;
                        break;
                    }
                }

                // Not found in one of the libraries.
                if (idFound == null)
                    break;
            }

            if (idFound == null)
                throw new InvalidDataException(string.Format(Resources.PeptideLibraries_EnsureRankId_Specified_libraries_do_not_support_the___0___peptide_ranking, idName));

            // No longer necessary
            _rankIdName = null;

            RankId = idFound;
        }
        public PeptideSettingsUI(SkylineWindow parent, LibraryManager libraryManager)
        {
            InitializeComponent();

            btnUpdateIonMobilityLibraries.Visible = false; // TODO: ion mobility libraries are more complex than initially thought - put this off until after summer 2014 release

            _parent = parent;
            _libraryManager = libraryManager;
            _peptideSettings = parent.DocumentUI.Settings.PeptideSettings;

            // Initialize digestion settings
            _driverEnzyme = new SettingsListComboDriver<Enzyme>(comboEnzyme, Settings.Default.EnzymeList);
            _driverEnzyme.LoadList(_peptideSettings.Enzyme.GetKey());
            for (int i = DigestSettings.MIN_MISSED_CLEAVAGES; i <= DigestSettings.MAX_MISSED_CLEAVAGES; i++)
                comboMissedCleavages.Items.Add(i.ToString(CultureInfo.InvariantCulture));
            comboMissedCleavages.SelectedItem = Digest.MaxMissedCleavages.ToString(LocalizationHelper.CurrentCulture);
            if (comboMissedCleavages.SelectedIndex < 0)
                comboMissedCleavages.SelectedIndex = 0;
            cbRaggedEnds.Checked = Digest.ExcludeRaggedEnds;

            // Initialize prediction settings
            _driverRT = new SettingsListComboDriver<RetentionTimeRegression>(comboRetentionTime, Settings.Default.RetentionTimeList);
            string sel = (Prediction.RetentionTime == null ? null : Prediction.RetentionTime.Name);
            _driverRT.LoadList(sel);
            cbUseMeasuredRT.Checked = textMeasureRTWindow.Enabled = Prediction.UseMeasuredRTs;
            if (Prediction.MeasuredRTWindow.HasValue)
                textMeasureRTWindow.Text = Prediction.MeasuredRTWindow.Value.ToString(LocalizationHelper.CurrentCulture);

            _driverDT = new SettingsListComboDriver<DriftTimePredictor>(comboDriftTimePredictor, Settings.Default.DriftTimePredictorList);
            string selDT = (Prediction.DriftTimePredictor == null ? null : Prediction.DriftTimePredictor.Name);
            _driverDT.LoadList(selDT);
            cbUseSpectralLibraryDriftTimes.Checked = textSpectralLibraryDriftTimesResolvingPower.Enabled = Prediction.UseLibraryDriftTimes;
            if (Prediction.LibraryDriftTimesResolvingPower.HasValue)
                textSpectralLibraryDriftTimesResolvingPower.Text = Prediction.LibraryDriftTimesResolvingPower.Value.ToString(LocalizationHelper.CurrentCulture);

            // Initialize filter settings
            _driverExclusion = new SettingsListBoxDriver<PeptideExcludeRegex>(listboxExclusions, Settings.Default.PeptideExcludeList);
            _driverExclusion.LoadList(null, Filter.Exclusions);

            textExcludeAAs.Text = Filter.ExcludeNTermAAs.ToString(LocalizationHelper.CurrentCulture);
            textMaxLength.Text = Filter.MaxPeptideLength.ToString(LocalizationHelper.CurrentCulture);
            textMinLength.Text = Filter.MinPeptideLength.ToString(LocalizationHelper.CurrentCulture);
            cbAutoSelect.Checked = Filter.AutoSelect;

            // Initialize spectral library settings
            _driverLibrary = new SettingsListBoxDriver<LibrarySpec>(listLibraries, Settings.Default.SpectralLibraryList);
            IList<LibrarySpec> listLibrarySpecs = Libraries.LibrarySpecs;

            _driverLibrary.LoadList(null, listLibrarySpecs);
            _driverBackgroundProteome = new SettingsListComboDriver<BackgroundProteomeSpec>(comboBackgroundProteome, Settings.Default.BackgroundProteomeList);
            _driverBackgroundProteome.LoadList(_peptideSettings.BackgroundProteome.Name);

            panelPick.Visible = listLibrarySpecs.Count > 0;
            btnExplore.Enabled = listLibraries.Items.Count > 0;

            comboMatching.SelectedIndex = (int) Libraries.Pick;

            _lastRankId = Libraries.RankId;
            _lastPeptideCount = Libraries.PeptideCount.HasValue
                                    ? Libraries.PeptideCount.Value.ToString(LocalizationHelper.CurrentCulture)
                                    : null;

            UpdateRanks(null);

            // Initialize modification settings
            _driverStaticMod = new SettingsListBoxDriver<StaticMod>(listStaticMods, Settings.Default.StaticModList);
            _driverStaticMod.LoadList(null, Modifications.StaticModifications);
            _driverHeavyMod = new SettingsListBoxDriver<StaticMod>(listHeavyMods, Settings.Default.HeavyModList);
            _driverLabelType = new LabelTypeComboDriver(comboLabelType, Modifications, _driverHeavyMod,
                labelStandardType, comboStandardType, listStandardTypes);
            textMaxVariableMods.Text = Modifications.MaxVariableMods.ToString(LocalizationHelper.CurrentCulture);
            textMaxNeutralLosses.Text = Modifications.MaxNeutralLosses.ToString(LocalizationHelper.CurrentCulture);

            // Initialize peak scoring settings.
            _driverPeakScoringModel = new SettingsListComboDriver<PeakScoringModelSpec>(comboPeakScoringModel, Settings.Default.PeakScoringModelList);
            var peakScoringModel = _peptideSettings.Integration.PeakScoringModel;
            _driverPeakScoringModel.LoadList(peakScoringModel != null ? peakScoringModel.Name : null);

            IsShowLibraryExplorer = false;
            tabControl1.TabPages.Remove(tabIntegration);
            comboNormalizationMethod.Items.AddRange(
                NormalizationMethod.ListNormalizationMethods(parent.DocumentUI).ToArray());
            comboNormalizationMethod.SelectedItem = _peptideSettings.Quantification.NormalizationMethod;
            comboWeighting.Items.AddRange(RegressionWeighting.All.Cast<object>().ToArray());
            comboWeighting.SelectedItem = _peptideSettings.Quantification.RegressionWeighting;
            comboRegressionFit.Items.AddRange(RegressionFit.All.Cast<object>().ToArray());
            comboRegressionFit.SelectedItem = _peptideSettings.Quantification.RegressionFit;
            comboQuantMsLevel.SelectedIndex = Math.Max(0, _quantMsLevels.IndexOf(_peptideSettings.Quantification.MsLevel));
            tbxQuantUnits.Text = _peptideSettings.Quantification.Units;
        }
Exemple #19
0
        private static bool IsUpdateNeeded(PeptideRankId rankId, IList<DocNode> listPeptides)
        {
            if (rankId != null)
                return true;

            foreach (PeptideDocNode nodePep in listPeptides)
            {
                if (nodePep.Rank.HasValue)
                    return true;
            }
            return false;
        }