protected bool Equals(ExplicitTransitionGroupValues other) { return(Equals(IonMobility, other.IonMobility) && Equals(CollisionEnergy, other.CollisionEnergy) && Equals(IonMobilityUnits, other.IonMobilityUnits) && Equals(CollisionalCrossSectionSqA, other.CollisionalCrossSectionSqA)); }
public ExplicitTransitionGroupValues(ExplicitTransitionGroupValues other) : this( (other == null) ? null : other.IonMobility, (other == null) ? eIonMobilityUnits.none : other.IonMobilityUnits, (other == null) ? null : other.CollisionalCrossSectionSqA) { }
public ExplicitTransitionGroupValues(ExplicitTransitionGroupValues other) : this((other == null) ? null : other.CollisionEnergy, (other == null) ? null : other.DriftTimeMsec, (other == null) ? null : other.DriftTimeHighEnergyOffsetMsec, (other == null) ? null : other.SLens, (other == null) ? null : other.ConeVoltage, (other == null) ? null : other.DeclusteringPotential, (other == null) ? null : other.CompensationVoltage) { }
protected bool Equals(ExplicitTransitionGroupValues other) { return(Equals(CollisionEnergy, other.CollisionEnergy) && Equals(DriftTimeMsec, other.DriftTimeMsec) && Equals(DriftTimeHighEnergyOffsetMsec, other.DriftTimeHighEnergyOffsetMsec) && Equals(SLens, other.SLens) && Equals(ConeVoltage, other.ConeVoltage) && CompensationVoltage.Equals(other.CompensationVoltage) && DeclusteringPotential.Equals(other.DeclusteringPotential)); }
public ExplicitTransitionGroupValues(ExplicitTransitionGroupValues other) : this( (other == null) ? null : other.CollisionEnergy, (other == null) ? null : other.DriftTimeMsec, (other == null) ? null : other.DriftTimeHighEnergyOffsetMsec, (other == null) ? null : other.SLens, (other == null) ? null : other.ConeVoltage, (other == null) ? null : other.DeclusteringPotential, (other == null) ? null : other.CompensationVoltage) { }
protected bool Equals(ExplicitTransitionGroupValues other) { return(Equals(CollisionEnergy, other.CollisionEnergy) && Equals(IonMobility, other.IonMobility) && Equals(IonMobilityHighEnergyOffset, other.IonMobilityHighEnergyOffset) && Equals(IonMobilityUnits, other.IonMobilityUnits) && Equals(CollisionalCrossSectionSqA, other.CollisionalCrossSectionSqA) && Equals(SLens, other.SLens) && Equals(ConeVoltage, other.ConeVoltage) && CompensationVoltage.Equals(other.CompensationVoltage) && DeclusteringPotential.Equals(other.DeclusteringPotential)); }
public ExplicitTransitionGroupValues(ExplicitTransitionGroupValues other) : this( (other == null) ? null : other.CollisionEnergy, (other == null) ? null : other.IonMobility, (other == null) ? null : other.IonMobility, (other == null) ? MsDataFileImpl.eIonMobilityUnits.none : other.IonMobilityUnits, (other == null) ? null : other.CollisionalCrossSectionSqA, (other == null) ? null : other.SLens, (other == null) ? null : other.ConeVoltage, (other == null) ? null : other.DeclusteringPotential, (other == null) ? null : other.CompensationVoltage) { }
protected bool Equals(ExplicitTransitionGroupValues other) { return Equals(CollisionEnergy, other.CollisionEnergy) && Equals(DriftTimeMsec, other.DriftTimeMsec) && Equals(DriftTimeHighEnergyOffsetMsec, other.DriftTimeHighEnergyOffsetMsec) && Equals(SLens, other.SLens) && Equals(ConeVoltage, other.ConeVoltage) && CompensationVoltage.Equals(other.CompensationVoltage) && DeclusteringPotential.Equals(other.DeclusteringPotential); }
public MoleculeInfo(string name, string formula, int charge, double mz, double monoMass, double averageMass, IsotopeLabelType isotopeLabelType, ExplicitRetentionTimeInfo explicitRetentionTime, ExplicitTransitionGroupValues explicitTransitionGroupValues, string note) { Name = name; Formula = formula; Charge = charge; Mz = mz; MonoMass = monoMass; AverageMass = averageMass; IsotopeLabelType = isotopeLabelType; ExplicitRetentionTime = explicitRetentionTime; ExplicitTransitionGroupValues = explicitTransitionGroupValues; Note = note; }
// We need some combination of: // Formula and mz // Formula and charge // mz and charge private MoleculeInfo ReadPrecursorOrProductColumns(SrmDocument document, DataGridViewRow row, bool getPrecursorColumns) { int indexName = getPrecursorColumns ? INDEX_MOLECULE_NAME : INDEX_PRODUCT_NAME; int indexFormula = getPrecursorColumns ? INDEX_MOLECULE_FORMULA : INDEX_PRODUCT_FORMULA; int indexMz = getPrecursorColumns ? INDEX_MOLECULE_MZ : INDEX_PRODUCT_MZ; int indexCharge = getPrecursorColumns ? INDEX_MOLECULE_CHARGE : INDEX_PRODUCT_CHARGE; var name = NullForEmpty(Convert.ToString(row.Cells[indexName].Value)); var formula = NullForEmpty(Convert.ToString(row.Cells[indexFormula].Value)); var note = NullForEmpty(Convert.ToString(row.Cells[INDEX_NOTE].Value)); IsotopeLabelType isotopeLabelType = null; double mz; bool badMz = false; if (!double.TryParse(Convert.ToString(row.Cells[indexMz].Value), out mz)) { if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[indexMz].Value))) { badMz = true; } mz = 0; } if ((mz < 0) || badMz) { ShowTransitionError(new PasteError { Column = indexMz, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_m_z_value__0_, Convert.ToString(row.Cells[indexMz].Value)) }); return null; } int? charge = null; int trycharge; if (int.TryParse(Convert.ToString(row.Cells[indexCharge].Value), out trycharge)) charge = trycharge; else if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[indexCharge].Value))) { ShowTransitionError(new PasteError { Column = indexCharge, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_charge_value__0_, Convert.ToString(row.Cells[indexCharge].Value)) }); return null; } double dtmp; double? collisionEnergy = null; double? slens = null; double? coneVoltage = null; double? retentionTime = null; double? retentionTimeWindow = null; double? declusteringPotential = null; double? compensationVoltage = null; if (getPrecursorColumns) { var label = NullForEmpty(Convert.ToString(row.Cells[INDEX_LABEL_TYPE].Value)); if (label != null) { var typedMods = DocumentUiContainer.Document.Settings.PeptideSettings.Modifications.GetModificationsByName(label); if (typedMods == null) { ShowTransitionError(new PasteError { Column = INDEX_LABEL_TYPE, Line = row.Index, Message = string.Format(Resources.SrmDocument_ReadLabelType_The_isotope_modification_type__0__does_not_exist_in_the_document_settings, label) }); return null; } isotopeLabelType = typedMods.LabelType; } if (double.TryParse(Convert.ToString(row.Cells[INDEX_COLLISION_ENERGY].Value), out dtmp)) collisionEnergy = dtmp; else if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_COLLISION_ENERGY].Value))) { ShowTransitionError(new PasteError { Column = INDEX_COLLISION_ENERGY, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_collision_energy_value__0_, Convert.ToString(row.Cells[INDEX_COLLISION_ENERGY].Value)) }); return null; } if (double.TryParse(Convert.ToString(row.Cells[INDEX_SLENS].Value), out dtmp)) slens = dtmp; else if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_SLENS].Value))) { ShowTransitionError(new PasteError { Column = INDEX_SLENS, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_S_Lens_value__0_, Convert.ToString(row.Cells[INDEX_SLENS].Value)) }); return null; } if (double.TryParse(Convert.ToString(row.Cells[INDEX_CONE_VOLTAGE].Value), out dtmp)) coneVoltage = dtmp; else if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_CONE_VOLTAGE].Value))) { ShowTransitionError(new PasteError { Column = INDEX_CONE_VOLTAGE, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_cone_voltage_value__0_, Convert.ToString(row.Cells[INDEX_CONE_VOLTAGE].Value)) }); return null; } if (double.TryParse(Convert.ToString(row.Cells[INDEX_DECLUSTERING_POTENTIAL].Value), out dtmp)) declusteringPotential = dtmp; else if (!string.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_DECLUSTERING_POTENTIAL].Value))) { ShowTransitionError(new PasteError { Column = INDEX_DECLUSTERING_POTENTIAL, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_declustering_potential__0_, Convert.ToString(row.Cells[INDEX_DECLUSTERING_POTENTIAL].Value)) }); return null; } if (double.TryParse(Convert.ToString(row.Cells[INDEX_COMPENSATION_VOLTAGE].Value), out dtmp)) compensationVoltage = dtmp; else if (!string.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_COMPENSATION_VOLTAGE].Value))) { ShowTransitionError(new PasteError { Column = INDEX_COMPENSATION_VOLTAGE, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_compensation_voltage__0_, Convert.ToString(row.Cells[INDEX_COMPENSATION_VOLTAGE].Value)) }); return null; } if (double.TryParse(Convert.ToString(row.Cells[INDEX_RETENTION_TIME].Value), out dtmp)) retentionTime = dtmp; else if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_RETENTION_TIME].Value))) { ShowTransitionError(new PasteError { Column = INDEX_RETENTION_TIME, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_retention_time_value__0_, Convert.ToString(row.Cells[INDEX_RETENTION_TIME].Value)) }); return null; } if (double.TryParse(Convert.ToString(row.Cells[INDEX_RETENTION_TIME_WINDOW].Value), out dtmp)) { retentionTimeWindow = dtmp; if (!retentionTime.HasValue) { ShowTransitionError(new PasteError { Column = INDEX_RETENTION_TIME_WINDOW, Line = row.Index, Message = Resources.Peptide_ExplicitRetentionTimeWindow_Explicit_retention_time_window_requires_an_explicit_retention_time_value_ }); return null; } } else if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_RETENTION_TIME_WINDOW].Value))) { ShowTransitionError(new PasteError { Column = INDEX_RETENTION_TIME_WINDOW, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_retention_time_window_value__0_, Convert.ToString(row.Cells[INDEX_RETENTION_TIME_WINDOW].Value)) }); return null; } } double? driftTimePrecursorMsec = null; if (double.TryParse(Convert.ToString(row.Cells[INDEX_MOLECULE_DRIFT_TIME_MSEC].Value), out dtmp)) driftTimePrecursorMsec = dtmp; else if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_MOLECULE_DRIFT_TIME_MSEC].Value))) { ShowTransitionError(new PasteError { Column = INDEX_MOLECULE_DRIFT_TIME_MSEC, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_drift_time_value__0_, Convert.ToString(row.Cells[INDEX_MOLECULE_DRIFT_TIME_MSEC].Value)) }); return null; } double? driftTimeHighEnergyOffsetMsec = null; if (double.TryParse(Convert.ToString(row.Cells[INDEX_HIGH_ENERGY_DRIFT_TIME_OFFSET_MSEC].Value), out dtmp)) driftTimeHighEnergyOffsetMsec = dtmp; else if (!String.IsNullOrEmpty(Convert.ToString(row.Cells[INDEX_HIGH_ENERGY_DRIFT_TIME_OFFSET_MSEC].Value))) { ShowTransitionError(new PasteError { Column = INDEX_HIGH_ENERGY_DRIFT_TIME_OFFSET_MSEC, Line = row.Index, Message = String.Format(Resources.PasteDlg_ReadPrecursorOrProductColumns_Invalid_drift_time_high_energy_offset_value__0_, Convert.ToString(row.Cells[INDEX_HIGH_ENERGY_DRIFT_TIME_OFFSET_MSEC].Value)) }); return null; } string errMessage = String.Format(getPrecursorColumns ? Resources.PasteDlg_ValidateEntry_Error_on_line__0___Precursor_needs_values_for_any_two_of__Formula__m_z_or_Charge_ : Resources.PasteDlg_ValidateEntry_Error_on_line__0___Product_needs_values_for_any_two_of__Formula__m_z_or_Charge_, row.Index+1); int errColumn = indexFormula; int countValues = 0; if (charge.HasValue && charge.Value != 0) countValues++; if (mz > 0) countValues++; if (NullForEmpty(formula) != null) countValues++; if (countValues >= 2) // Do we have at least 2 of charge, mz, formula? { double monoMass; double averageMmass; if (driftTimePrecursorMsec.HasValue) { if (!driftTimeHighEnergyOffsetMsec.HasValue) { driftTimeHighEnergyOffsetMsec = 0; } } else { driftTimeHighEnergyOffsetMsec = null; // Offset without a base value isn't useful } var retentionTimeInfo = retentionTime.HasValue ? new ExplicitRetentionTimeInfo(retentionTime.Value, retentionTimeWindow) : null; var explicitTransitionGroupValues = new ExplicitTransitionGroupValues(collisionEnergy, driftTimePrecursorMsec, driftTimeHighEnergyOffsetMsec, slens, coneVoltage, declusteringPotential, compensationVoltage); var massOk = true; var massTooLow = false; string massErrMsg = null; var absCharge = Math.Abs(charge ?? 0); if (getPrecursorColumns && absCharge != 0 && (absCharge < TransitionGroup.MIN_PRECURSOR_CHARGE || absCharge > TransitionGroup.MAX_PRECURSOR_CHARGE)) { errMessage = String.Format(Resources.Transition_Validate_Precursor_charge__0__must_be_non_zero_and_between__1__and__2__, charge, -TransitionGroup.MAX_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE); errColumn = indexCharge; } else if (!getPrecursorColumns && absCharge != 0 && (absCharge < Transition.MIN_PRODUCT_CHARGE || absCharge > Transition.MAX_PRODUCT_CHARGE)) { errMessage = String.Format(Resources.Transition_Validate_Product_ion_charge__0__must_be_non_zero_and_between__1__and__2__, charge, -Transition.MAX_PRODUCT_CHARGE, Transition.MAX_PRODUCT_CHARGE); errColumn = indexCharge; } else if (NullForEmpty(formula) != null) { // We have a formula try { if (mz > 0) { // Is the ion's formula the old style where user expected us to add a hydrogen? double? mzCalc; charge = ValidateFormulaWithMz(document, ref formula, mz, charge, out monoMass, out averageMmass, out mzCalc); row.Cells[indexFormula].Value = formula; massOk = monoMass < CustomIon.MAX_MASS && averageMmass < CustomIon.MAX_MASS && !(massTooLow = charge.HasValue && (monoMass < CustomIon.MIN_MASS || averageMmass < CustomIon.MIN_MASS)); // Null charge => masses are 0 but meaningless if (massOk) { if (charge.HasValue) { row.Cells[indexCharge].Value = charge.Value; return new MoleculeInfo(name, formula, charge.Value, mz, monoMass, averageMmass, isotopeLabelType, retentionTimeInfo, explicitTransitionGroupValues, note); } else if (mzCalc.HasValue) { // There was an initial charge value, but it didn't make sense with formula and proposed mz errMessage = String.Format(getPrecursorColumns ? Resources.PasteDlg_ReadPrecursorOrProductColumns_Error_on_line__0___Precursor_m_z__1__does_not_agree_with_value__2__as_calculated_from_ion_formula_and_charge_state__delta____3___Transition_Settings___Instrument___Method_match_tolerance_m_z____4_____Correct_the_m_z_value_in_the_table__or_leave_it_blank_and_Skyline_will_calculate_it_for_you_ : Resources.PasteDlg_ReadPrecursorOrProductColumns_Error_on_line__0___Product_m_z__1__does_not_agree_with_value__2__as_calculated_from_ion_formula_and_charge_state__delta____3___Transition_Settings___Instrument___Method_match_tolerance_m_z____4_____Correct_the_m_z_value_in_the_table__or_leave_it_blank_and_Skyline_will_calculate_it_for_you_, row.Index + 1, (float)mz, (float)mzCalc.Value, (float)(mzCalc.Value - mz), (float)document.Settings.TransitionSettings.Instrument.MzMatchTolerance); errColumn = indexMz; } else { // No charge state given, and mz makes no sense with formula errMessage = String.Format(getPrecursorColumns ? Resources.PasteDlg_ValidateEntry_Error_on_line__0___Precursor_formula_and_m_z_value_do_not_agree_for_any_charge_state_ : Resources.PasteDlg_ValidateEntry_Error_on_line__0___Product_formula_and_m_z_value_do_not_agree_for_any_charge_state_, row.Index+1); errColumn = indexMz; } } } else if (charge.HasValue) { // Get the mass from the formula, and mz from that and charge mz = ValidateFormulaWithCharge(document, formula, charge.Value, out monoMass, out averageMmass); massOk = !((monoMass >= CustomIon.MAX_MASS || averageMmass >= CustomIon.MAX_MASS)) && !(massTooLow = (monoMass < CustomIon.MIN_MASS || averageMmass < CustomIon.MIN_MASS)); row.Cells[indexMz].Value = mz; if (massOk) return new MoleculeInfo(name, formula, charge.Value, mz, monoMass, averageMmass, isotopeLabelType, retentionTimeInfo, explicitTransitionGroupValues, note); } } catch (InvalidDataException x) { massOk = false; massErrMsg = x.Message; } } else if (mz != 0 && charge.HasValue) { // No formula, just use charge and m/z monoMass = averageMmass = BioMassCalc.CalculateIonMassFromMz(mz, charge.Value); massOk = monoMass < CustomIon.MAX_MASS && averageMmass < CustomIon.MAX_MASS && !(massTooLow = (monoMass < CustomIon.MIN_MASS || averageMmass < CustomIon.MIN_MASS)); errColumn = indexMz; if (massOk) return new MoleculeInfo(name, formula, charge.Value, mz, monoMass, averageMmass, isotopeLabelType, retentionTimeInfo, explicitTransitionGroupValues, note); } if (massTooLow) { errMessage = massErrMsg ?? string.Format( Resources .EditCustomMoleculeDlg_OkDialog_Custom_molecules_must_have_a_mass_greater_than_or_equal_to__0__, CustomIon.MIN_MASS); } else if (!massOk) { errMessage = massErrMsg ?? string.Format( Resources .EditCustomMoleculeDlg_OkDialog_Custom_molecules_must_have_a_mass_less_than_or_equal_to__0__, CustomIon.MAX_MASS); } } ShowTransitionError(new PasteError { Column = errColumn, Line = row.Index, Message = errMessage }); return null; }
/// <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; }