Exemplo n.º 1
0
 private void WriteExplicitTransitionValuesAttributes(XmlWriter writer, ExplicitTransitionValues importedAttributes)
 {
     writer.WriteAttributeNullable(ATTR.explicit_collision_energy, importedAttributes.CollisionEnergy);
     writer.WriteAttributeNullable(ATTR.explicit_ion_mobility_high_energy_offset, importedAttributes.IonMobilityHighEnergyOffset);
     writer.WriteAttributeNullable(ATTR.explicit_s_lens, importedAttributes.SLens);
     writer.WriteAttributeNullable(ATTR.explicit_cone_voltage, importedAttributes.ConeVoltage);
     writer.WriteAttributeNullable(ATTR.explicit_declustering_potential, importedAttributes.DeclusteringPotential);
 }
Exemplo n.º 2
0
 public ExplicitValues(ExplicitRetentionTimeInfo resultRetentionTimeInfo,
                       ExplicitTransitionGroupValues resultExplicitTransitionGroupValues,
                       ExplicitTransitionValues resultExplicitTransitionValues)
 {
     ResultRetentionTimeInfo             = resultRetentionTimeInfo;
     ResultExplicitTransitionGroupValues = resultExplicitTransitionGroupValues;
     ResultExplicitTransitionValues      = resultExplicitTransitionValues;
 }
Exemplo n.º 3
0
 public TransitionDocNode MakeTransitionDocNode(SrmSettings settings, ExplicitMods explicitMods,
                                                IsotopeDistInfo isotopeDist,
                                                Annotations annotations,
                                                TransitionDocNode.TransitionQuantInfo transitionQuantInfo,
                                                ExplicitTransitionValues explicitTransitionValues,
                                                Results <TransitionChromInfo> results)
 {
     return(GetCrosslinkBuilder(settings, explicitMods).MakeTransitionDocNode(this, isotopeDist, annotations, transitionQuantInfo, explicitTransitionValues, results));
 }
Exemplo n.º 4
0
        public TransitionDocNode MakeTransitionDocNode(ComplexFragmentIon complexFragmentIon,
                                                       IsotopeDistInfo isotopeDist,
                                                       Annotations annotations,
                                                       TransitionDocNode.TransitionQuantInfo transitionQuantInfo,
                                                       ExplicitTransitionValues explicitTransitionValues,
                                                       Results <TransitionChromInfo> results)
        {
            var neutralFormula = GetNeutralFormula(complexFragmentIon);
            var productMass    = GetFragmentMassFromFormula(Settings, neutralFormula);

            if (complexFragmentIon.Children.Count > 0)
            {
                complexFragmentIon = complexFragmentIon.CloneTransition();
            }

            if (complexFragmentIon.IsMs1 && Settings.TransitionSettings.FullScan.IsHighResPrecursor)
            {
                isotopeDist         = isotopeDist ?? GetPrecursorIsotopeDistInfo(complexFragmentIon.Transition.Adduct, 0);
                productMass         = isotopeDist.GetMassI(complexFragmentIon.Transition.MassIndex, complexFragmentIon.Transition.DecoyMassShift);
                transitionQuantInfo = transitionQuantInfo.ChangeIsotopeDistInfo(new TransitionIsotopeDistInfo(
                                                                                    isotopeDist.GetRankI(complexFragmentIon.Transition.MassIndex), isotopeDist.GetProportionI(complexFragmentIon.Transition.MassIndex)));
            }
            return(new TransitionDocNode(complexFragmentIon, annotations, productMass, transitionQuantInfo, explicitTransitionValues, results));
        }
Exemplo n.º 5
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, UsageMode usageMode, string title, Identity initialId,
                                     IEnumerable <Identity> existingIds, int minCharge, int maxCharge,
                                     SrmSettings settings, CustomMolecule molecule, Adduct defaultCharge,
                                     ExplicitTransitionGroupValues explicitTransitionGroupAttributes,
                                     ExplicitTransitionValues explicitTransitionAttributes,
                                     ExplicitRetentionTimeInfo explicitRetentionTime,
                                     IsotopeLabelType defaultIsotopeLabelType)
        {
            Text                  = title;
            _parent               = parent;
            _initialId            = initialId;
            _existingIds          = existingIds;
            _minCharge            = minCharge;
            _maxCharge            = maxCharge;
            _transitionSettings   = settings != null ? settings.TransitionSettings : null;
            _peptideSettings      = settings != null ? settings.PeptideSettings : null;
            _resultAdduct         = Adduct.EMPTY;
            _resultCustomMolecule = molecule;
            _usageMode            = usageMode;

            var enableFormulaEditing = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.moleculeEdit ||
                                       usageMode == UsageMode.fragment;
            var enableAdductEditing = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.precursor ||
                                      usageMode == UsageMode.fragment;
            var suggestOnlyAdductsWithMass        = usageMode != UsageMode.fragment;
            var needExplicitTransitionValues      = usageMode == UsageMode.fragment;
            var needExplicitTransitionGroupValues = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.precursor;

            InitializeComponent();

            NameText         = molecule == null ? String.Empty : molecule.Name;
            textName.Enabled = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.moleculeEdit ||
                               usageMode == UsageMode.fragment; // Can user edit name?

            var needOptionalValuesBox = explicitRetentionTime != null || explicitTransitionGroupAttributes != null || explicitTransitionAttributes != null;

            if (!needExplicitTransitionValues)
            {
                labelCollisionEnergy.Visible             = false;
                textCollisionEnergy.Visible              = false;
                labelSLens.Visible                       = false;
                textSLens.Visible                        = false;
                labelConeVoltage.Visible                 = false;
                textConeVoltage.Visible                  = false;
                labelIonMobilityHighEnergyOffset.Visible = false;
                textIonMobilityHighEnergyOffset.Visible  = false;
                labelDeclusteringPotential.Visible       = false;
                textDeclusteringPotential.Visible        = false;
            }

            if (!needExplicitTransitionGroupValues)
            {
                labelCCS.Visible                 = false;
                textBoxCCS.Visible               = false;
                labelIonMobility.Visible         = false;
                textIonMobility.Visible          = false;
                labelIonMobilityUnits.Visible    = false;
                comboBoxIonMobilityUnits.Visible = false;
            }

            var heightDelta = 0;

            // Initialise the ion mobility units dropdown with L10N values
            foreach (eIonMobilityUnits t in Enum.GetValues(typeof(eIonMobilityUnits)))
            {
                comboBoxIonMobilityUnits.Items.Add(IonMobilityFilter.IonMobilityUnitsL10NString(t));
            }

            if (needOptionalValuesBox)
            {
                var newHeight = groupBoxOptionalValues.Height;
                var movers    = new List <Control>();
                int offset    = 0;
                if (!needExplicitTransitionGroupValues && !needExplicitTransitionValues)
                {
                    // We blanked out everything but the retention time
                    newHeight = labelCollisionEnergy.Location.Y;
                }
                else if (!needExplicitTransitionGroupValues)
                {
                    // We need to shift transition-level items up to where retention time was
                    movers.AddRange(new Control[] {
                        textCollisionEnergy, labelCollisionEnergy, textDeclusteringPotential, labelDeclusteringPotential, textSLens,
                        labelSLens, textConeVoltage, labelConeVoltage, textIonMobilityHighEnergyOffset, labelIonMobilityHighEnergyOffset
                    });
                    labelIonMobilityHighEnergyOffset.Location = labelIonMobility.Location;
                    textIonMobilityHighEnergyOffset.Location  = textIonMobility.Location;
                    offset    = labelCollisionEnergy.Location.Y - labelRetentionTime.Location.Y;
                    newHeight = textBoxCCS.Location.Y;
                }
                else if (!needExplicitTransitionValues)
                {
                    // We need to shift precursor-level items up to where retention time was
                    movers.AddRange(new Control[] { textBoxCCS, labelCCS, textIonMobility,
                                                    labelIonMobility, comboBoxIonMobilityUnits, labelIonMobilityUnits });
                    offset    = labelIonMobility.Location.Y - (explicitRetentionTime == null ? labelRetentionTime.Location.Y : labelCollisionEnergy.Location.Y);
                    newHeight = explicitRetentionTime == null ? textSLens.Location.Y : textIonMobility.Location.Y;
                }

                foreach (var mover in movers)
                {
                    mover.Anchor   = AnchorStyles.Left | AnchorStyles.Top;
                    mover.Location = new Point(mover.Location.X, mover.Location.Y - offset);
                }

                heightDelta = groupBoxOptionalValues.Height - newHeight;
                groupBoxOptionalValues.Height = newHeight;
            }

            ResultExplicitTransitionGroupValues = new ExplicitTransitionGroupValues(explicitTransitionGroupAttributes);
            ResultExplicitTransitionValues      = new ExplicitTransitionValues(explicitTransitionAttributes);

            string labelAverage = !defaultCharge.IsEmpty
                ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_m_z_
                : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_mass_;
            string labelMono = !defaultCharge.IsEmpty
                ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_m_z_
                : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_mass_;
            var defaultFormula = molecule == null ? string.Empty : molecule.Formula;
            var transition     = initialId as Transition;

            FormulaBox.EditMode editMode;
            if (enableAdductEditing && !enableFormulaEditing)
            {
                editMode = FormulaBox.EditMode.adduct_only;
            }
            else if (!enableAdductEditing && enableFormulaEditing)
            {
                editMode = FormulaBox.EditMode.formula_only;
            }
            else
            {
                editMode = FormulaBox.EditMode.formula_and_adduct;
            }
            string formulaBoxLabel;

            if (defaultCharge.IsEmpty)
            {
                formulaBoxLabel = Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_Chemi_cal_formula_;
            }
            else if (editMode == FormulaBox.EditMode.adduct_only)
            {
                var prompt = defaultFormula;
                if (string.IsNullOrEmpty(defaultFormula) && molecule != null)
                {
                    // Defined by mass only
                    prompt = molecule.ToString();
                }
                formulaBoxLabel = string.Format(Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_Addu_ct_for__0__,
                                                prompt);
            }
            else
            {
                formulaBoxLabel = Resources.EditMeasuredIonDlg_EditMeasuredIonDlg_Ion__chemical_formula_;
            }

            double?averageMass = null;
            double?monoMass    = null;

            if (transition != null && string.IsNullOrEmpty(defaultFormula) && transition.IsCustom())
            {
                averageMass = transition.CustomIon.AverageMass;
                monoMass    = transition.CustomIon.MonoisotopicMass;
            }
            else if (molecule != null)
            {
                averageMass = molecule.AverageMass;
                monoMass    = molecule.MonoisotopicMass;
            }

            _formulaBox =
                new FormulaBox(false, // Not proteomic, so offer Cl and Br in atoms popup
                               formulaBoxLabel,
                               labelAverage,
                               labelMono,
                               defaultCharge,
                               editMode,
                               suggestOnlyAdductsWithMass)
            {
                NeutralFormula = defaultFormula,
                AverageMass    = averageMass,
                MonoMass       = monoMass,
                Location       = new Point(textName.Left, textName.Bottom + 12)
            };
            _formulaBox.ChargeChange += (sender, args) =>
            {
                if (!_formulaBox.Adduct.IsEmpty)
                {
                    Adduct = _formulaBox.Adduct;
                    var revisedFormula = _formulaBox.NeutralFormula + Adduct.AdductFormula;
                    if (!Equals(revisedFormula, _formulaBox.Formula))
                    {
                        _formulaBox.Formula = revisedFormula;
                    }
                    if (string.IsNullOrEmpty(_formulaBox.NeutralFormula) && averageMass.HasValue)
                    {
                        _formulaBox.AverageMass = averageMass;
                        _formulaBox.MonoMass    = monoMass;
                    }
                }
            };
            Controls.Add(_formulaBox);
            _formulaBox.TabIndex = 2;
            _formulaBox.Enabled  = enableFormulaEditing || enableAdductEditing;
            Adduct = defaultCharge;
            var needCharge = !Adduct.IsEmpty;

            textCharge.Visible = labelCharge.Visible = needCharge;
            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;
            }
            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(PeptideSettingsUI.LabelTypeComboDriver.UsageType.InternalStandardPicker, comboIsotopeLabelType,
                                                                              settings.PeptideSettings.Modifications, null, null, null, null)
                {
                    SelectedName = defaultIsotopeLabelType.Name
                };
            }
            else
            {
                comboIsotopeLabelType.Visible = false;
                labelIsotopeLabelType.Visible = false;
            }
            Height -= heightDelta;
        }