Пример #1
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;
            }
        }
Пример #2
0
 public ChromatogramExporter(SrmDocument document)
 {
     Document = document;
     _settings = Document.Settings;
     _measuredResults = _settings.MeasuredResults;
     _matchTolerance = (float)_settings.TransitionSettings.Instrument.MzMatchTolerance;
     _chromatogramSets = _measuredResults.Chromatograms;
 }
Пример #3
0
 public static PeptideQuantifier GetPeptideQuantifier(SrmSettings srmSettings, PeptideGroupDocNode peptideGroup, PeptideDocNode peptide)
 {
     var mods = srmSettings.PeptideSettings.Modifications;
     // Quantify on all label types which are not internal standards.
     ICollection<IsotopeLabelType> labelTypes = ImmutableList.ValueOf(mods.GetModificationTypes()
         .Except(mods.InternalStandardTypes));
     return new PeptideQuantifier(peptideGroup, peptide, srmSettings.PeptideSettings.Quantification)
     {
         MeasuredLabelTypes = labelTypes
     };
 }
Пример #4
0
 public static Configuration GetConfiguration(String path, SrmSettings settings)
 {
     Configuration configuration = new Configuration()
         .SetProperty("dialect", typeof(NHibernate.Dialect.SQLiteDialect).AssemblyQualifiedName) // Not L10N
         .SetProperty("connection.connection_string", new SQLiteConnectionStringBuilder // Not L10N
         {
             DataSource = path
         }.ToString())
         .SetProperty("connection.driver_class", typeof(NHibernate.Driver.SQLite20Driver).AssemblyQualifiedName); // Not L10N
     Assembly assembly = typeof(SessionFactoryFactory).Assembly;
     configuration.SetProperty("connection.provider", typeof(NHibernate.Connection.DriverConnectionProvider).AssemblyQualifiedName); // Not L10N
     configuration.AddInputStream(assembly.GetManifestResourceStream(typeof(SessionFactoryFactory).Namespace + ".mapping.xml")); // Not L10N
     if (settings != null)
         AddRatioColumns(configuration, settings);
     AddAnnotations(configuration, settings, AnnotationDef.AnnotationTarget.protein, typeof(DbProtein));
     AddAnnotations(configuration, settings, AnnotationDef.AnnotationTarget.peptide, typeof(DbPeptide));
     AddAnnotations(configuration, settings, AnnotationDef.AnnotationTarget.precursor, typeof(DbPrecursor));
     AddAnnotations(configuration, settings, AnnotationDef.AnnotationTarget.transition, typeof(DbTransition));
     AddAnnotations(configuration, settings, AnnotationDef.AnnotationTarget.replicate, typeof(DbProteinResult));
     AddAnnotations(configuration, settings, AnnotationDef.AnnotationTarget.precursor_result, typeof(DbPrecursorResult));
     AddAnnotations(configuration, settings, AnnotationDef.AnnotationTarget.transition_result, typeof(DbTransitionResult));
     return configuration;
 }
 public bool Accept(SrmSettings settings, Peptide peptide, ExplicitMods explicitMods, out bool allowVariableMods)
 {
     return PeptideFilter.UNFILTERED.Accept(settings, peptide, explicitMods, out allowVariableMods);
 }
        internal void InitMatcherSettings(SrmSettings settings,
            MappedList<string, StaticMod> defSetStatic, MappedList<string, StaticMod> defSetHeavy)
        {
            DefSetStatic = defSetStatic;
            DefSetHeavy = defSetHeavy;

            Settings = settings;

            var modifications = settings.PeptideSettings.Modifications;

            UserDefinedTypedMods = new Dictionary<StaticMod, IsotopeLabelType>();
            // First add modifications found in document settings, then add modifications found in the global settings.
            foreach (var type in settings.PeptideSettings.Modifications.GetModificationTypes())
            {
                // Set the default heavy type to the first heavy type encountered.
                if (!ReferenceEquals(type, IsotopeLabelType.light) && DocDefHeavyLabelType == null)
                    DocDefHeavyLabelType = type;
                InitUserDefTypedModDict(modifications.GetModificationsByName(type.Name), false);
            }
            InitUserDefTypedModDict(new TypedModifications(IsotopeLabelType.light, DefSetStatic), true);
            InitUserDefTypedModDict(new TypedModifications(DocDefHeavyLabelType, DefSetHeavy), true);

            Matches = new Dictionary<AAModKey, AAModMatch>();
            UnmatchedSequences = new List<string>();
            _foundHeavyLabels = new List<StaticMod>();

            while (MoveNextSequence())
            {
                InitModMatches();
            }
            CleanUpMatches();

            Initialized = true;
        }
Пример #7
0
        public static TextSequence[] CreateTextSequences(PeptideDocNode nodePep,
            SrmSettings settings, string label, IDeviceContext g, ModFontHolder fonts)
        {
            // Store text and font information for all label types
            bool heavyMods = false;
            var listTypeSequences = new List<TextSequence> { CreateTypeTextSequence(nodePep, settings, IsotopeLabelType.light, fonts) };
            foreach (var labelType in settings.PeptideSettings.Modifications.GetHeavyModificationTypes())
            {
                // Only color for the label types actually measured in this peptide
                if (!nodePep.HasChildType(labelType))
                    continue;

                var textSequence = CreateTypeTextSequence(nodePep, settings, labelType, fonts);
                listTypeSequences.Add(textSequence);
                heavyMods = (heavyMods || textSequence != null);
            }

            // Calculate text sequence values for the peptide display string
            var listTextSequences = new List<TextSequence>();
            if (nodePep.Peptide.IsCustomIon)
                listTextSequences.Add(CreatePlainTextSequence(nodePep.CustomIon.DisplayName, fonts));
            // If no modifications, use a single plain text sequence
            else if (!heavyMods && !listTypeSequences[0].Text.Contains("[")) // Not L10N: For identifying modifications
                listTextSequences.Add(CreatePlainTextSequence(label, fonts));
            else
            {
                string pepSequence = nodePep.Peptide.Sequence;
                int startPep = label.IndexOf(pepSequence, StringComparison.Ordinal);
                int endPep = startPep + pepSequence.Length;

                // Add prefix plain-text if necessary
                if (startPep > 0)
                {
                    string prefix = label.Substring(0, startPep);
                    listTextSequences.Add(CreatePlainTextSequence(prefix, fonts));
                }

                // Enumerate amino acid characters coallescing their font information
                // into text sequences.
                var prevCharFont = new CharFont('.', fonts.Plain, Color.Black); // Not L10N: Amino acid format
                var indexes = new int[listTypeSequences.Count];

                CharFont charFont;
                var sb = new StringBuilder();
                while ((charFont = GetCharFont(indexes, listTypeSequences, fonts)) != null)
                {
                    if (!charFont.IsSameDisplay(prevCharFont) && sb.Length > 0)
                    {
                        listTextSequences.Add(CreateTextSequence(sb, prevCharFont));
                        sb.Remove(0, sb.Length);
                    }
                    sb.Append(charFont.Character);
                    prevCharFont = charFont;
                }
                // Add the last segment
                if (sb.Length > 0)
                    listTextSequences.Add(CreateTextSequence(sb, prevCharFont));

                // Add suffix plain-text if necessary
                if (endPep < label.Length)
                {
                    string suffix = label.Substring(endPep);
                    listTextSequences.Add(CreatePlainTextSequence(suffix, fonts));
                }
            }

            if (g != null)
            {
                // Calculate placement for each text sequence
                int textRectWidth = 0;
                foreach (var textSequence in listTextSequences)
                {
                    Size sizeMax = new Size(int.MaxValue, int.MaxValue);
                    textSequence.Position = textRectWidth;
                    textSequence.Width = TextRenderer.MeasureText(g, textSequence.Text,
                                                                  textSequence.Font, sizeMax, FORMAT_TEXT_SEQUENCE).
                        Width;
                    textRectWidth += textSequence.Width;
                }
            }

            return listTextSequences.ToArray();
        }
Пример #8
0
 public bool Equals(SrmSettings obj)
 {
     if (ReferenceEquals(null, obj)) return false;
     if (ReferenceEquals(this, obj)) return true;
     return base.Equals(obj) &&
         Equals(obj.PeptideSettings, PeptideSettings) &&
         Equals(obj.TransitionSettings, TransitionSettings) &&
         Equals(obj.DataSettings, DataSettings) &&
         Equals(obj.MeasuredResults, MeasuredResults) &&
         Equals(obj.DocumentRetentionTimes, DocumentRetentionTimes);
 }
Пример #9
0
 public bool Accept(SrmSettings settings, Peptide peptide, ExplicitMods explicitMods, out bool allowVariableMods)
 {
     return Accept(settings,
                   peptide,
                   explicitMods,
                   TransitionSettings.Filter.PrecursorCharges,
                   PeptideFilterType.fasta,
                   out allowVariableMods);
 }
Пример #10
0
 /// <summary>
 /// Calculates the differences between the settings for two document states.
 /// </summary>
 /// <param name="settingsOld">The previous document settings</param>
 /// <param name="settingsNew">New document settings to chage to</param>
 public SrmSettingsDiff(SrmSettings settingsOld, SrmSettings settingsNew)
     : this(settingsOld, settingsNew, false)
 {
 }
Пример #11
0
        private static void AddRatioColumns(Configuration configuration, SrmSettings settings)
        {
            var mappingPeptide = configuration.GetClassMapping(typeof(DbPeptideResult));
            var mappingPrec = configuration.GetClassMapping(typeof(DbPrecursorResult));
            var mappingTran = configuration.GetClassMapping(typeof(DbTransitionResult));

            var mods = settings.PeptideSettings.Modifications;
            var standardTypes = mods.RatioInternalStandardTypes;
            var labelTypes = mods.GetModificationTypes().ToArray();
            if (labelTypes.Length > 2)
            {
                foreach (var standardType in standardTypes)
                {
                    foreach (var labelType in labelTypes)
                    {
                        if (ReferenceEquals(labelType, standardType))
                            continue;

                        AddColumn(mappingPeptide,
                                  RatioPropertyAccessor.PeptideRatioProperty(labelType, standardType).ColumnName,
                                  typeof (RatioPropertyAccessor));
                        AddColumn(mappingPeptide,
                                  RatioPropertyAccessor.PeptideRdotpProperty(labelType, standardType).ColumnName,
                                  typeof (RatioPropertyAccessor));
                    }

                    // Only add TotalAreaRatioTo<label type> and AreaRatioTo<label type> columns
                    // when there is more than one internal standard label type, because that
                    // is the only time that data is added to these columns in the database.
                    if (standardTypes.Count > 1)
                    {
                        AddColumn(mappingPrec, RatioPropertyAccessor.PrecursorRatioProperty(standardType).ColumnName,
                                  typeof (RatioPropertyAccessor));
                        AddColumn(mappingPrec, RatioPropertyAccessor.PrecursorRdotpProperty(standardType).ColumnName,
                                  typeof (RatioPropertyAccessor));
                        AddColumn(mappingTran, RatioPropertyAccessor.TransitionRatioProperty(standardType).ColumnName,
                                  typeof (RatioPropertyAccessor));
                    }
                }
            }

            if (settings.HasGlobalStandardArea)
            {
                foreach (var labelType in labelTypes)
                {
                    AddColumn(mappingPeptide, RatioPropertyAccessor.PeptideRatioProperty(labelType, null).ColumnName, typeof(RatioPropertyAccessor));
                }
                AddColumn(mappingPrec, RatioPropertyAccessor.PrecursorRatioProperty(null).ColumnName, typeof(RatioPropertyAccessor));
                AddColumn(mappingTran, RatioPropertyAccessor.TransitionRatioProperty(null).ColumnName, typeof(RatioPropertyAccessor));
            }
        }
Пример #12
0
 public PickTransitionGroupTip(PeptideDocNode nodePep,
     TransitionGroupDocNode nodeGroup, SrmSettings settings)
 {
     _nodePep = nodePep;
     _nodeGroup = nodeGroup;
     _settings = settings;
 }
Пример #13
0
        private static IEnumerable<KeyValuePair<IsotopeLabelType, string>> GetTypedModifiedSequences(
            PeptideDocNode nodePep, SrmSettings settings)
        {
            foreach (var labelType in settings.PeptideSettings.Modifications.GetModificationTypes())
            {
                if (nodePep.Peptide.IsCustomIon)
                    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.Sequence, true); // Never have to worry about this being a custom ion, we already checked

                // Only return if the modified sequence contains modifications
                if (modSequence.Contains('[')) // Not L10N
                    yield return new KeyValuePair<IsotopeLabelType, string>(labelType, modSequence);
            }
        }
Пример #14
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)
                       };
        }
Пример #15
0
        public static Size RenderTip(PeptideDocNode nodePep,
            TransitionDocNode nodeTranSelected,
            SrmSettings settings,
            Graphics g,
            Size sizeMax,
            bool draw)
        {
            var table = new TableDesc();
            using (RenderTools rt = new RenderTools())
            {
                Peptide peptide = nodePep.Peptide;
                SizeF size;
                if (peptide.IsCustomIon)
                {
                    table.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Molecule, nodePep.CustomIon.Name, rt);
                    table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodePep.CustomIon.Formula, rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Neutral_Mass,
                        nodePep.CustomIon.GetMass(settings.TransitionSettings.Prediction.PrecursorMassType).ToString(LocalizationHelper.CurrentCulture), rt);
                    size = table.CalcDimensions(g);
                    table.Draw(g);
                    return new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2));
                }

                if (nodePep.Children.Count > 1)
                {
                    foreach (var typedModSequence in GetTypedModifiedSequences(nodePep, settings))
                        table.AddDetailRow(typedModSequence.Key.Title, typedModSequence.Value, rt);
                }

                if (peptide.Begin.HasValue)
                {
                    // Add a spacing row, if anything was added
                    if (table.Count > 0)
                        table.AddDetailRow(" ", " ", rt); // Not L10N
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Previous, peptide.PrevAA.ToString(CultureInfo.InvariantCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_First, peptide.Begin.Value.ToString(LocalizationHelper.CurrentCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Last, ((peptide.End ?? 1) - 1).ToString(LocalizationHelper.CurrentCulture), rt);
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Next, peptide.NextAA.ToString(CultureInfo.InvariantCulture), rt);
                }
                if (nodePep.Rank.HasValue)
                    table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Rank, nodePep.Rank.Value.ToString(LocalizationHelper.CurrentCulture), rt);

                size = table.CalcDimensions(g);
                if (draw)
                    table.Draw(g);

                // Render group tip, if there is only one, and this node is collapsed
                if (nodePep.Children.Count == 1)
                {
                    var nodeGroup = (TransitionGroupDocNode)nodePep.Children[0];
                    if (size.Height > 0)
                        size.Height += TableDesc.TABLE_SPACING;
                    if (draw)
                        g.TranslateTransform(0, size.Height);
                    Size sizeMaxGroup = new Size(sizeMax.Width, sizeMax.Height - (int)size.Height);
                    SizeF sizeGroup = TransitionGroupTreeNode.RenderTip(nodePep, nodeGroup,
                        nodeTranSelected, settings, g, sizeMaxGroup, draw);
                    if (draw)
                        g.TranslateTransform(0, -size.Height);

                    size.Width = Math.Max(size.Width, sizeGroup.Width);
                    size.Height += sizeGroup.Height;
                }

                return new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2));
            }
        }
Пример #16
0
 public static bool HasPeptideTip(PeptideDocNode nodePep, SrmSettings settings)
 {
     return nodePep.Peptide.Begin.HasValue ||
            nodePep.Rank.HasValue ||
            nodePep.Note != null ||
            // With one child, its tip detail will be appended
            nodePep.Children.Count == 1 ||
            // With multiple children, modification sequences may be shown
            GetTypedModifiedSequences(nodePep, settings).Any();
 }
Пример #17
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);
     }
 }
Пример #18
0
        private bool Accept(SrmSettings settings,
            Peptide peptide,
            ExplicitMods mods,
            IList<int> precursorCharges,
            PeptideFilterType filterType,
            out bool allowVariableMods)
        {
            // Assume variable modifications are not allowed until proven otherwise
            allowVariableMods = false;
            // Only filter user specified peptides based on the heuristic
            // filter when explicitly requested.
            bool useFilter = filterType == PeptideFilterType.full;
            if (filterType == PeptideFilterType.fasta)
                useFilter = peptide.Begin.HasValue;

            var libraries = PeptideSettings.Libraries;
            if (!libraries.HasLibraries || libraries.Pick == PeptidePick.filter)
            {
                if (!useFilter)
                {
                    allowVariableMods = true;
                    return true;
                }
                return PeptideSettings.Filter.Accept(settings, peptide, mods, out allowVariableMods);
            }

            // Check if the peptide is in the library for one of the
            // acceptable precursor charges.
            bool inLibrary = false;
            // If the libraries are not fully loaded, then act like nothing
            // could be found in the libraries.  This will be corrected when
            // the libraries are loaded.
            if (libraries.IsLoaded &&
                // Only check the library, if this is a custom ion or a peptide that already has
                // a variable modification, or the library contains some form of the peptide.
                // This is a performance improvement over checking every variable modification
                // of a peptide when it is not even in the library.
                (peptide.IsCustomIon || (mods != null && mods.IsVariableStaticMods) || LibrariesContainAny(peptide.Sequence)))
            {
                // Only allow variable modifications, if the peptide has no modifications
                // or already checking variable modifications, and there is reason to check
                // the library.  Failing to do this check profiled as a performance bottleneck.
                allowVariableMods = mods == null || mods.IsVariableStaticMods;

                inLibrary = LibrariesContainMeasurablePeptide(peptide, precursorCharges, mods);
            }

            switch (libraries.Pick)
            {
                case PeptidePick.library:
                    return inLibrary;
                case PeptidePick.both:
                    return inLibrary && (!useFilter || PeptideSettings.Filter.Accept(settings, peptide, mods, out allowVariableMods));
                default:
                    return inLibrary || (!useFilter || PeptideSettings.Filter.Accept(settings, peptide, mods, out allowVariableMods));
            }
        }
Пример #19
0
        /// <summary>
        /// Used for changes that involve only results changes.  Usually used to force recalculation of
        /// all results information.
        /// </summary>
        /// <param name="settingsCurrent">The current settings which are used as <see cref="SettingsOld"/></param>
        /// <param name="allResults">True if all results information should be recalculated</param>
        public SrmSettingsDiff(SrmSettings settingsCurrent, bool allResults)
        {
            SettingsOld = settingsCurrent;

            DiffResults = true;
            DiffResultsAll = allResults;
        }
Пример #20
0
        private static void AddAnnotations(Configuration configuration, SrmSettings settings, AnnotationDef.AnnotationTarget annotationTarget, Type persistentClass)
        {
            var mapping = configuration.GetClassMapping(persistentClass);
            foreach (var annotationDef in settings.DataSettings.AnnotationDefs)
            {
                if (!annotationDef.AnnotationTargets.Contains(annotationTarget))
                {
                    continue;
                }
                string columnName = AnnotationDef.GetColumnName(annotationDef.Name);
                Type accessorType;
                switch (annotationDef.Type)
                {
                    case AnnotationDef.AnnotationType.number:
                        accessorType = typeof (NumberAnnotationPropertyAccessor);
                        break;
                    case AnnotationDef.AnnotationType.true_false:
                        accessorType = typeof (BoolAnnotationPropertyAccessor);
                        break;
                    default:
                        accessorType = typeof (AnnotationPropertyAccessor);
                        break;
                }

                AddColumn(mapping, columnName, accessorType);
            }
        }
Пример #21
0
        /// <summary>
        /// Calculates the differences between the settings for two document states.
        /// </summary>
        /// <param name="settingsOld">The previous document settings</param>
        /// <param name="settingsNew">New document settings to chage to</param>
        /// <param name="isUnexplainedExplicitModificationAllowed">True if this settings change should not check
        /// explicit modifications against the global settings to make sure they are present</param>
        public SrmSettingsDiff(SrmSettings settingsOld, SrmSettings settingsNew,
            bool isUnexplainedExplicitModificationAllowed)
        {
            _isUnexplainedExplicitModificationAllowed = isUnexplainedExplicitModificationAllowed;

            SettingsOld = settingsOld;

            PeptideSettings newPep = settingsNew.PeptideSettings;
            PeptideSettings oldPep = settingsOld.PeptideSettings;
            TransitionSettings newTran = settingsNew.TransitionSettings;
            TransitionSettings oldTran = settingsOld.TransitionSettings;

            // Figure out whether precursor charges differ for determining
            // both peptide and transition group changes.
            bool precursorsDiff = !ArrayUtil.EqualsDeep(newTran.Filter.PrecursorCharges,
                                                        oldTran.Filter.PrecursorCharges) ||
                                  // Also changing auto-select could change precursors
                                  newTran.Filter.AutoSelect != oldTran.Filter.AutoSelect ||
                                  // And changing DIA isolation scheme could change precursors
                                  !Equals(newTran.FullScan.IsolationScheme, oldTran.FullScan.IsolationScheme);

            // Change peptides if enzyme, digestion or filter settings changed
            DiffPeptides = !newPep.Enzyme.Equals(oldPep.Enzyme) ||
                                  !newPep.DigestSettings.Equals(oldPep.DigestSettings) ||
                                  !newPep.Filter.Equals(oldPep.Filter) ||
                                  // If precursors differ, and peptide picks depend on the library
                                  (precursorsDiff && newPep.Libraries.HasLibraries && newPep.Libraries.Pick != PeptidePick.filter) ||
                                  // If variable modifications changed
                                  newPep.Modifications.MaxVariableMods != oldPep.Modifications.MaxVariableMods ||
                                  !ArrayUtil.EqualsDeep(newPep.Modifications.VariableModifications.ToArray(),
                                                        oldPep.Modifications.VariableModifications.ToArray());

            // Peptide standard types can change with iRT calculator
            DiffPeptideProps = !ReferenceEquals(newPep.Prediction.RetentionTime,
                                                oldPep.Prediction.RetentionTime);

            var oldLib = oldPep.Libraries;
            var newLib = newPep.Libraries;

            bool libraryChange = !ReferenceEquals(newLib, oldLib);
            bool diffLibraries = libraryChange && !EquivalentLibraries(newLib, oldLib);
            if (!DiffPeptides && libraryChange)
            {
                // If libraries have been removed, update peptides, if picking algorithm
                // allowed peptides outside the filter.
                if (!newLib.HasLibraries)
                {
                    DiffPeptides = oldLib.Pick == PeptidePick.library ||
                                   oldLib.Pick == PeptidePick.either;
                }
                // If the libraries are not loaded, wait until they are to make any changes
                else if (newLib.IsLoaded)
                {
                    // If no libraries were used before, or the picking algorithm has changed,
                    // or the peptide ranking ID has changed, or the peptide count limit has change,
                    // or the picking algorithm relies on the libraries, and the libraries have changed
                    DiffPeptides = (!oldLib.HasLibraries ||
                        newLib.Pick != oldLib.Pick ||
                        !Equals(newLib.RankId, oldLib.RankId) ||
                        !Equals(newLib.PeptideCount, oldLib.PeptideCount) ||
                        (newLib.Pick != PeptidePick.filter && diffLibraries));
                }
            }

            // Calculate changes in global implicit modifications
            var oldMods = oldPep.Modifications;
            var newMods = newPep.Modifications;
            bool diffStaticMods = !StaticMod.EquivalentImplicitMods(newMods.StaticModifications,
                                           oldMods.StaticModifications);
            bool diffHeavyMods = false;
            var enumNewHeavyMods = newMods.GetHeavyModifications().GetEnumerator();
            foreach (var oldTypedMods in oldMods.GetHeavyModifications())
            {
                if (!enumNewHeavyMods.MoveNext())   // synch with foreach
                {
                    // If fewer heavy label types
                    diffHeavyMods = true;
                    break;
                }
                var newTypedMods = enumNewHeavyMods.Current;
                if (newTypedMods == null || // ReSharper
                        !Equals(newTypedMods.LabelType, oldTypedMods.LabelType) ||
                        !StaticMod.EquivalentImplicitMods(newTypedMods.Modifications,
                                                          oldTypedMods.Modifications))
                {
                    // If label types or implicit modifications differ
                    diffHeavyMods = true;
                    break;
                }
            }
            // If not different yet, then make sure nothing was added
            if (!diffHeavyMods)
                diffHeavyMods = enumNewHeavyMods.MoveNext();

            // Set explicit differences, if no differences in the global implicit modifications,
            // but the modifications have changed.
            if (!diffStaticMods && !diffHeavyMods && !ReferenceEquals(oldPep.Modifications, newPep.Modifications))
                DiffExplicit = true;

            // Change transition groups if precursor charges or heavy group
            // existence changed, or if the IsolationScheme range changed
            var isolationRangesNew = newTran.FullScan.IsolationScheme == null ? null : newTran.FullScan.IsolationScheme.PrespecifiedIsolationWindows;
            var isolationRangesOld = oldTran.FullScan.IsolationScheme == null ? null : oldTran.FullScan.IsolationScheme.PrespecifiedIsolationWindows;
            bool diffInstrumentRange = newTran.Instrument.MinMz != oldTran.Instrument.MinMz ||
                                       newTran.Instrument.MaxMz != oldTran.Instrument.MaxMz ||
                                       !Equals(isolationRangesNew, isolationRangesOld);
            bool diffIsolationScheme = !Equals(newTran.FullScan.IsolationScheme, oldTran.FullScan.IsolationScheme);
            DiffTransitionGroups = precursorsDiff || diffHeavyMods || diffInstrumentRange || diffIsolationScheme;

            // If libraries changed, then transition groups should change whenever
            // peptides change also.
            if (!DiffTransitionGroups && libraryChange)
                DiffTransitionGroups = DiffPeptides;

            // Any change in modifications or precursor mass-type forces a recalc
            // of precursor m/z values, as
            bool enrichmentsChanged = !Equals(newTran.FullScan.IsotopeEnrichments, oldTran.FullScan.IsotopeEnrichments);
            DiffTransitionGroupProps = diffStaticMods || diffHeavyMods ||
                                 !newTran.Prediction.PrecursorMassType.Equals(oldTran.Prediction.PrecursorMassType) ||
                                 // Or changes to MS1 filtering that change the expected isotope distribution
                                 !newTran.FullScan.PrecursorMassAnalyzer.Equals(oldTran.FullScan.PrecursorMassAnalyzer) ||
                                 !Equals(newTran.FullScan.PrecursorRes, oldTran.FullScan.PrecursorRes) ||
                                 !Equals(newTran.FullScan.PrecursorResMz, oldTran.FullScan.PrecursorResMz) ||
                                 // Or isotope enrichments
                                 enrichmentsChanged
                                 ;

            if (!DiffTransitionGroupProps && libraryChange)
            {
                // Make sure transition group library properties are updated, as long as the
                // libraries are loaded and have changed.
                DiffTransitionGroupProps = !newLib.HasLibraries || (newLib.IsLoaded && diffLibraries);
            }

            // Change transitions if anything in the transition filter changes.
            DiffTransitions = !newTran.Filter.Equals(oldTran.Filter) ||
                              !newTran.Libraries.Equals(oldTran.Libraries) ||
                              // Or libraries changed, and picking based on libraries
                              (libraryChange && DiffTransitionGroupProps &&
                                    newTran.Libraries.Pick != TransitionLibraryPick.none) ||
                              // If instrument min or max m/z changed
                              diffInstrumentRange ||
                              newTran.Instrument.IsDynamicMin != oldTran.Instrument.IsDynamicMin ||
                              // If loss modifications changed
                              newPep.Modifications.MaxNeutralLosses != oldPep.Modifications.MaxNeutralLosses ||
                              !ArrayUtil.EqualsDeep(newPep.Modifications.NeutralLossModifications.ToArray(),
                                                    oldPep.Modifications.NeutralLossModifications.ToArray()) ||
                              // MS1 filtering changed select peaks
                              newTran.FullScan.PrecursorIsotopes != oldTran.FullScan.PrecursorIsotopes ||
                              newTran.FullScan.PrecursorIsotopeFilter != oldTran.FullScan.PrecursorIsotopeFilter ||
                              (newTran.FullScan.PrecursorIsotopes != FullScanPrecursorIsotopes.None && enrichmentsChanged)
                              ;

            // If the library loded state has changed, make sure the library properties are up to date,
            // but avoid changing the chosen transitions.
            // CONSIDER: The way library transition ranking is currently implemented makes this too slow
            //            if (!DiffTransitionGroupProps && libraryChange && newLib.IsLoaded && !oldLib.IsLoaded)
            //                DiffTransitionGroupProps = true;

            // Any change in modifications or fragment mass-type forces a recalc
            // of transition m/z values, as
            DiffTransitionProps = diffStaticMods || diffHeavyMods ||
                                 !newTran.Prediction.FragmentMassType.Equals(oldTran.Prediction.FragmentMassType) ||
                                 (libraryChange && DiffTransitionGroupProps) ||
                                 // Any change in transitions can change transition rankings
                                 // if a library is in use.
                                 (newLib.HasLibraries && DiffTransitions) ||
                                 // If using MS1 isotopes, an enrichment change can change transition masses
                                 (newTran.FullScan.PrecursorIsotopes != FullScanPrecursorIsotopes.None && enrichmentsChanged)
                                 ;

            // If the results changed, then update the results information which has changed
            DiffResults = !EqualExceptAnnotations(settingsNew.MeasuredResults, settingsOld.MeasuredResults);
            // If the integration strategy has changed, then force a full update of all results
            if (newTran.Integration.IsIntegrateAll != oldTran.Integration.IsIntegrateAll)
                DiffResults = DiffResultsAll = true;
            // If the match tolerance has changed, then force a full update of all results
            if (newTran.Instrument.MzMatchTolerance != oldTran.Instrument.MzMatchTolerance)
                DiffResults = DiffResultsAll = true;
            // If internal standard type or all types changed, update all results to recalculate ratios.
            if (!ArrayUtil.EqualsDeep(newMods.InternalStandardTypes, oldMods.InternalStandardTypes) ||
                !ArrayUtil.EqualsDeep(newMods.GetModificationTypes().ToArray(), oldMods.GetModificationTypes().ToArray()))
            {
                DiffResults = true;
            }
            // Results handler is temporary. Any time the document has one, it means the results
            // must be updated and reintegration applied.
            if (newPep.Integration.ResultsHandler != null)
                DiffResults = true;
            // Avoid updating results while in a bulk import operation without UI
            if (settingsNew.IsResultsJoiningDisabled)
                DiffResults = false;
            // Force update if the bulk import has just completed
            else if (settingsOld.HasResults && settingsOld.MeasuredResults.IsResultsUpdateRequired)
                DiffResults = true;
        }
Пример #22
0
        private void UpdateGraphUI(SrmSettings settingsOld, bool docIdChanged)
        {
            SrmSettings settingsNew = DocumentUI.Settings;
            if (ReferenceEquals(settingsNew, settingsOld))
            {
                // Just about any change could potentially change the list
                // or retention times or peak areas.
                if (settingsNew.HasResults)
                {
                    // UpdateGraphPanes can handle null values in the list, but
                    // only call it when at least one of the graphs is present.
                    if (_graphRetentionTime != null || _graphPeakArea != null)
                        UpdateGraphPanes(new List<IUpdatable> {_graphRetentionTime, _graphPeakArea});
                }
                return;
            }
            var listUpdateGraphs = new List<IUpdatable>();
            var filterNew = settingsNew.TransitionSettings.Filter;
            var filterOld = settingsOld.TransitionSettings.Filter;
            if (!ReferenceEquals(filterNew, filterOld))
            {
                // If ion types or charges changed, make sure the new
                // ones are on and the old ones are off by default.
                bool refresh = false;
                if (!ArrayUtil.EqualsDeep(filterNew.IonTypes, filterOld.IonTypes))
                {
                    // Only turn off old ion types, if new settings are not MS1-only full-scan
                    var fullScan = settingsNew.TransitionSettings.FullScan;
                    if (!fullScan.IsEnabled || fullScan.IsEnabledMsMs)
                        CheckIonTypes(filterOld.IonTypes, false);

                    CheckIonTypes(filterNew.IonTypes, true);
                    refresh = true;
                }
                if (!ArrayUtil.EqualsDeep(filterNew.ProductCharges, filterOld.ProductCharges))
                {
                    CheckIonCharges(filterOld.ProductCharges, false);
                    CheckIonCharges(filterNew.ProductCharges, true);
                    refresh = true;
                }
                if (refresh && _graphSpectrum != null)
                    listUpdateGraphs.Add(_graphSpectrum);
            }

            using (var layoutLock = new DockPanelLayoutLock(dockPanel))
            {
                bool deserialized = false;
                string layoutFile = GetViewFile(DocumentFilePath);
                if (docIdChanged && File.Exists(layoutFile))
                {
                    layoutLock.EnsureLocked();
                    try
                    {
                        using (var layoutReader = new StreamReader(layoutFile))
                        {
                            LoadLayout(layoutReader.BaseStream);
                        }
                        deserialized = true;
                    }
                    catch (Exception x)
                    {
                        var message = TextUtil.LineSeparate(string.Format(Resources.SkylineWindow_UpdateGraphUI_Failure_attempting_to_load_the_window_layout_file__0__, layoutFile),
                                                                            Resources.SkylineWindow_UpdateGraphUI_Rename_or_delete_this_file_to_restore_the_default_layout,
                                                                            Resources.SkylineWindow_UpdateGraphUI_Skyline_may_also_need_to_be_restarted);
                        throw new IOException(message, x);
                    }
                }

                bool enable = DocumentUI.Settings.PeptideSettings.Libraries.HasLibraries;
                if (graphsToolStripMenuItem.Enabled != enable)
                {
                    graphsToolStripMenuItem.Enabled = enable;
                    ionTypesMenuItem.Enabled = enable;
                    chargesMenuItem.Enabled = enable;
                    ranksMenuItem.Enabled = enable;

                    if (!deserialized)
                    {
                        layoutLock.EnsureLocked();
                        ShowGraphSpectrum(enable && Settings.Default.ShowSpectra);
                    }
                }
                enable = DocumentUI.Settings.HasResults;
                bool enableSchedule = enable || DocumentUI.Settings.PeptideSettings.Prediction.RetentionTime != null;
                if (retentionTimesMenuItem.Enabled != enableSchedule || replicateComparisonMenuItem.Enabled != enable)
                {
                    retentionTimesMenuItem.Enabled = enableSchedule;
                    replicateComparisonMenuItem.Enabled = enable;
                    timePeptideComparisonMenuItem.Enabled = enable;
                    linearRegressionMenuItem.Enabled = enable;
                    schedulingMenuItem.Enabled = enableSchedule;

                    if (!deserialized)
                    {
                        layoutLock.EnsureLocked();
                        ShowGraphRetentionTime(enable && Settings.Default.ShowRetentionTimeGraph);
                    }
                }
                if (resultsGridMenuItem.Enabled != enable)
                {
                    resultsGridMenuItem.Enabled = enable;
                    if (!deserialized)
                    {
                        layoutLock.EnsureLocked();
                        ShowResultsGrid(enable && Settings.Default.ShowResultsGrid);
                    }
                }
                if (peakAreasMenuItem.Enabled != enable)
                {
                    peakAreasMenuItem.Enabled = enable;
                    areaReplicateComparisonMenuItem.Enabled = enable;
                    areaPeptideComparisonMenuItem.Enabled = enable;

                    if (!deserialized)
                    {
                        layoutLock.EnsureLocked();
                        ShowGraphPeakArea(enable && Settings.Default.ShowPeakAreaGraph);
                    }
                }
                if (_graphFullScan != null && _graphFullScan.Visible && !enable)
                {
                    layoutLock.EnsureLocked();
                    DestroyGraphFullScan();
                }

                if (!ReferenceEquals(settingsNew.MeasuredResults, settingsOld.MeasuredResults))
                {
                    // First hide all graph windows for results that no longer exist in the document
                    foreach (var graphChromatogram in _listGraphChrom.ToArray())
                    {
                        string name = graphChromatogram.NameSet;
                        // Look for mathcing chromatogram sets across the documents
                        ChromatogramSet chromSetOld;
                        ChromatogramSet chromSetNew;
                        int index;
                        if (settingsOld.HasResults &&
                            settingsOld.MeasuredResults.TryGetChromatogramSet(name, out chromSetOld, out index) &&
                            settingsNew.HasResults &&
                            settingsNew.MeasuredResults.TryGetChromatogramSet(chromSetOld.Id.GlobalIndex, out chromSetNew, out index))
                        {
                            // If matching chromatogram found, but name has changed, then
                            // update the graph pane
                            if (!Equals(chromSetNew.Name, chromSetOld.Name))
                                name = graphChromatogram.NameSet = chromSetNew.Name;
                        }
                        var results = settingsNew.MeasuredResults;
                        if (results == null || !results.Chromatograms.Contains(chrom => Equals(chrom.Name, name)))
                        {
                            layoutLock.EnsureLocked();
                            ShowGraphChrom(graphChromatogram.NameSet, false);
                            // If changed to a new document, destroy unused panes
                            if (docIdChanged)
                            {
                                var graphChrom = GetGraphChrom(name);
                                _listGraphChrom.Remove(graphChrom);
                                if (graphChrom != null)
                                    DestroyGraphChrom(graphChrom);
                            }
                        }
                    }
                    // Next show any graph windows for results that were not previously part of
                    // the document.
                    if (settingsNew.MeasuredResults != null && !deserialized)
                    {
                        // Keep changes in graph panes from stealing the focus
                        var focusStart = User32.GetFocusedControl();

                        _inGraphUpdate = true;
                        try
                        {
                            string nameFirst = null;
                            string nameLast = SelectedGraphChromName;

                            foreach (var chromatogram in settingsNew.MeasuredResults.Chromatograms)
                            {
                                string name = chromatogram.Name;
                                var graphChrom = GetGraphChrom(name);
                                if (graphChrom == null)
                                {
                                    layoutLock.EnsureLocked();
                                    CreateGraphChrom(name, nameLast, false);

                                    nameFirst = nameFirst ?? name;
                                    nameLast = name;
                                }
                                    // If the pane is not showing a tab for this graph, than add one.
                                else if (graphChrom.Pane == null ||
                                         !graphChrom.Pane.DisplayingContents.Contains(graphChrom))
                                {
                                    layoutLock.EnsureLocked();
                                    ShowGraphChrom(name, true);

                                    nameFirst = nameFirst ?? name;
                                    nameLast = name;
                                }
                            }

                            // Put the first set on top, since it will get populated with data first
                            if (nameFirst != null)
                            {
                                layoutLock.EnsureLocked();
                                ShowGraphChrom(nameFirst, true);
                            }
                        }
                        finally
                        {
                            _inGraphUpdate = false;
                        }

                        if (focusStart != null)
                            focusStart.Focus();
                    }

                    // Update displayed graphs, which are no longer valid
                    var listGraphUpdate = from graph in _listGraphChrom
                                          where graph.Visible
                                          where !graph.IsCurrent(settingsOld, settingsNew)
                                          select graph;
                    listUpdateGraphs.AddRange(listGraphUpdate.ToArray());

                    // Make sure view menu is correctly enabled
                    bool enabled = settingsNew.HasResults;
                    chromatogramsMenuItem.Enabled = enabled;
                    transitionsMenuItem.Enabled = enabled;
                    transformChromMenuItem.Enabled = enabled;
                    autoZoomMenuItem.Enabled = enabled;
                    arrangeGraphsToolStripMenuItem.Enabled = enabled;

            //                    UpdateReplicateMenuItems(enabled);

                    // CONSIDER: Enable/disable submenus too?
                }
                else if (!ReferenceEquals(settingsNew.PeptideSettings.Prediction.RetentionTime,
                                          settingsOld.PeptideSettings.Prediction.RetentionTime))
                {
                    // If retention time regression changed, and retention prediction is showing
                    // update all displayed graphs
                    if (Settings.Default.ShowRetentionTimePred)
                        listUpdateGraphs.AddRange(_listGraphChrom.ToArray());
                }
            } // layoutLock.Dispose()

            // Do this after layout is unlocked, because it messes up the selected graph otherwise
            if (_sequenceTreeForm == null)
            {
                ShowSequenceTreeForm(true);
            }

            // Just about any change could potentially change these panes.
            if (settingsNew.HasResults)
            {
                if (_graphRetentionTime != null)
                    listUpdateGraphs.Add(_graphRetentionTime);
                if (_graphPeakArea != null)
                    listUpdateGraphs.Add(_graphPeakArea);
            }

            UpdateGraphPanes(listUpdateGraphs);
            FoldChangeForm.CloseInapplicableForms(this);
        }
Пример #23
0
 /// <summary>
 /// This version of Accept is used to select transition groups after the peptide
 /// itself has already been screened.  For this reason, it only applies library
 /// filtering.
 /// </summary>
 public bool Accept(SrmSettings settings, Peptide peptide, ExplicitMods mods, int charge)
 {
     bool allowVariableMods;
     return Accept(settings, peptide, mods, new[] { charge }, PeptideFilterType.library, out allowVariableMods);
 }
 public void CreateMatches(SrmSettings settings, IEnumerable<LibKey> libKeys,
     MappedList<string, StaticMod> defSetStatic, MappedList<string, StaticMod> defSetHeavy)
 {
     _dictAAMassPairs = new Dictionary<AATermKey, List<byte[]>>();
     _libKeys = libKeys.GetEnumerator();
     InitMatcherSettings(settings, defSetStatic, defSetHeavy);
     MatcherPepMods = CreateMatcherPeptideSettings();
 }
Пример #25
0
 public DataRow(SrmSettings settings, RetentionTimeSource target, RetentionTimeSource timesToAlign)
     : this()
 {
     DocumentRetentionTimes = settings.DocumentRetentionTimes;
     Target = target;
     Source = timesToAlign;
     Assume.IsNotNull(target, "target"); // Not L10N
     Assume.IsNotNull(DocumentRetentionTimes.FileAlignments, "DocumentRetentionTimes.FileAlignments"); // Not L10N
     var fileAlignment = DocumentRetentionTimes.FileAlignments.Find(target.Name);
     if (fileAlignment != null)
     {
         Assume.IsNotNull(fileAlignment.RetentionTimeAlignments, "fileAlignment.RetentionTimeAlignments"); // Not L10N
         Assume.IsNotNull(Source, "Source"); // Not L10N
         Alignment = fileAlignment.RetentionTimeAlignments.Find(Source.Name);
     }
     TargetTimes = GetFirstRetentionTimes(settings, target);
     SourceTimes = GetFirstRetentionTimes(settings, timesToAlign);
 }
Пример #26
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;
        }
Пример #27
0
        public EditPepModsDlg(SrmSettings settings, PeptideDocNode nodePeptide)
        {
            DocSettings = settings;
            NodePeptide = nodePeptide;
            ExplicitMods = nodePeptide.ExplicitMods;

            InitializeComponent();

            Icon = Resources.Skyline;

            SuspendLayout();
            ComboBox comboStaticLast = null;
            List<ComboBox> listComboHeavyLast = null;
            List<Label> listLabelHeavyLast = null;
            Label labelAALast = null;
            string seq = nodePeptide.Peptide.Sequence;
            var modsDoc = DocSettings.PeptideSettings.Modifications;

            _listLabelTypeHeavy.AddRange(from typedMods in modsDoc.GetHeavyModifications()
                                         select typedMods.LabelType);

            for (int i = 0; i < seq.Length; i++)
            {
                char aa = seq[i];
                int row = i + 1;

                if (comboStaticLast == null || listComboHeavyLast == null)  // ReSharper
                {
                    labelAALast = labelAA1;
                    comboStaticLast = comboStatic1;
                    foreach (var labelType in _listLabelTypeHeavy)
                    {
                        if (listComboHeavyLast == null)
                        {
                            listComboHeavyLast = new List<ComboBox> { comboHeavy1_1 };
                            listLabelHeavyLast = new List<Label> { labelHeavy1 };
                            labelHeavy1.Text = GetIsotopeLabelText(labelType);
                        }
                        else
                        {
                            var comboHeavyLast = listComboHeavyLast[listComboHeavyLast.Count - 1];
                            panelMain.Controls.Add(comboHeavyLast = new ComboBox
                            {
                                Name = GetHeavyName(row, labelType.SortOrder),
                                Left = comboHeavyLast.Right + HSPACE,
                                Top = comboHeavyLast.Top,
                                Size = comboHeavyLast.Size,
                                TabIndex = comboHeavyLast.TabIndex + 1
                            });
                            listComboHeavyLast.Add(comboHeavyLast);
                            var labelHeavyLast = listLabelHeavyLast[listLabelHeavyLast.Count - 1];
                            panelMain.Controls.Add(labelHeavyLast = new Label
                            {
                                Text = GetIsotopeLabelText(labelType),
                                Name = GetIsotopeLabelName(labelType.SortOrder),
                                Left = comboHeavyLast.Left,
                                Top = labelHeavyLast.Top,
                                TabIndex = labelHeavyLast.TabIndex + 1
                            });
                            listLabelHeavyLast.Add(labelHeavyLast);
                        }
                    }
                }
                else
                {
                    int controlsPerRow = 2 + listComboHeavyLast.Count;
                    int top = Top = comboStaticLast.Bottom + VSPACE;
                    panelMain.Controls.Add(labelAALast = new Label
                    {
                        Name = ("labelAA" + row), // Not L10N
                        AutoSize = true,
                        Font = labelAA1.Font,
                        Left = labelAA1.Left,
                        Top = top + (labelAALast.Top - comboStaticLast.Top),
                        Size = labelAA1.Size,
                        TabIndex = labelAALast.TabIndex + controlsPerRow
                    });
                    panelMain.Controls.Add(comboStaticLast = new ComboBox
                    {
                        Name = GetStaticName(row),
                        Left = comboStaticLast.Left,
                        Top = top,
                        Size = comboStaticLast.Size,
                        TabIndex = comboStaticLast.TabIndex + controlsPerRow
                    });
                    foreach (var labelType in _listLabelTypeHeavy)
                    {
                        int col = labelType.SortOrder - 1;
                        var comboHeavyLast = listComboHeavyLast[col];
                        panelMain.Controls.Add(comboHeavyLast = new ComboBox
                        {
                            Name = GetHeavyName(row, labelType.SortOrder),
                            Left = comboHeavyLast.Left,
                            Top = top,
                            Size = comboHeavyLast.Size,
                            TabIndex = comboHeavyLast.TabIndex + controlsPerRow
                        });
                        listComboHeavyLast[col] = comboHeavyLast;
                    }
                }
                // Store static modification combos and selected indexes
                _listSelectedIndexStatic.Add(-1);
                _listComboStatic.Add(InitModificationCombo(comboStaticLast, i, IsotopeLabelType.light));
                // Store heavy moficiation combos and selected indexes
                if (listComboHeavyLast != null)   // ReSharper
                {
                    for (int j = 0; j < _listLabelTypeHeavy.Count; j++)
                    {
                        while (_listListComboHeavy.Count <= j)
                        {
                            _listListSelectedIndexHeavy.Add(new List<int>());
                            _listListComboHeavy.Add(new List<ComboBox>());
                        }
                        var comboHeavyLast = listComboHeavyLast[j];
                        var labelType = _listLabelTypeHeavy[j];

                        _listListSelectedIndexHeavy[j].Add(-1);
                        _listListComboHeavy[j].Add(InitModificationCombo(comboHeavyLast, i, labelType));
                    }
                }
                // Store amino acid labels
                labelAALast.Text = aa.ToString(CultureInfo.InvariantCulture);
                _listLabelAA.Add(labelAALast);
            }
            for (int i = 0; i < _listLabelAA.Count; i++)
            {
                UpdateAminoAcidLabel(i);
            }
            if (comboStaticLast != null && comboStaticLast != comboStatic1)
            {
                // Increase width by the delta from the left edges of the first and last
                // heavy combo box columns
                int widthDiff = _listListComboHeavy[_listListComboHeavy.Count - 1][0].Left -
                    _listListComboHeavy[0][0].Left;
                Width += widthDiff;
                // Increase height by the delta from the bottom edges of the first and last
                // amino acid labels
                if (comboStatic1 != null)   // ReSharper
                {
                    int heightDiff = comboStaticLast.Bottom - comboStatic1.Bottom;
                    heightDiff += comboStatic1.Bottom - panelMain.Height;
                    Height += heightDiff;
                }
                if (listComboHeavyLast != null) // ReSharper
                    btnOk.TabIndex = listComboHeavyLast[listComboHeavyLast.Count - 1].TabIndex + 1;
                btnCancel.TabIndex = btnOk.TabIndex + 1;
            }
            ResumeLayout(true);
        }
Пример #28
0
 private static IDictionary<string, double> GetFirstRetentionTimes(
     SrmSettings settings, RetentionTimeSource retentionTimeSource)
 {
     var libraryRetentionTimes = settings.GetRetentionTimes(MsDataFileUri.Parse(retentionTimeSource.Name));
     if (null == libraryRetentionTimes)
     {
         return new Dictionary<string, double>();
     }
     return libraryRetentionTimes.GetFirstRetentionTimes();
 }
        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;
        }
Пример #30
0
        public void UpdateResultsUI(SrmSettings settingsNew, SrmSettings settingsOld)
        {
            if (_updateLockCountDoc > 0)
                return;

            var results = settingsNew.MeasuredResults;
            if (settingsOld == null || !ReferenceEquals(results, settingsOld.MeasuredResults))
            {
                if (results == null || results.Chromatograms.Count < 2)
                {
                    if (toolBarResults.Visible)
                        toolBarResults.Visible = false;

                    // Make sure the combo contains the results name, if one is
                    // available, because graph handling depends on this.
                    if (results != null && results.Chromatograms.Count > 0)
                    {
                        string resultsName = results.Chromatograms[0].Name;
                        if (ComboResults.Items.Count != 1 || !Equals(ComboResults.SelectedItem, resultsName))
                        {
                            ComboResults.Items.Clear();
                            ComboResults.Items.Add(resultsName);
                            ComboResults.SelectedIndex = 0;
                        }
                    }
                }
                else
                {
                    // Check to see if the list of files has changed.
                    var listNames = new List<string>();
                    foreach (var chromSet in results.Chromatograms)
                        listNames.Add(chromSet.Name);
                    var listExisting = new List<string>();
                    foreach (var item in ComboResults.Items)
                        listExisting.Add(item.ToString());
                    if (!ArrayUtil.EqualsDeep(listNames, listExisting))
                    {
                        // If it has, update the list, trying to maintain selection, if possible.
                        object selected = ComboResults.SelectedItem;
                        ComboResults.Items.Clear();
                        foreach (string name in listNames)
                            ComboResults.Items.Add(name);
                        if (selected == null || ComboResults.Items.IndexOf(selected) == -1)
                            ComboResults.SelectedIndex = 0;
                        else
                            ComboResults.SelectedItem = selected;
                        ComboHelper.AutoSizeDropDown(ComboResults);
                    }

                    // Show the toolbar after updating the files
                    if (!toolBarResults.Visible)
                    {
                        toolBarResults.Visible = true;
                        EnsureResultsComboSize();
                    }
                }
            }
        }