From: <jmc...@us...> - 2011-07-26 21:23:02
|
Revision: 2885 http://proteowizard.svn.sourceforge.net/proteowizard/?rev=2885&view=rev Author: jmchilton Date: 2011-07-26 21:22:54 +0000 (Tue, 26 Jul 2011) Log Message: ----------- Skyline: Added real-time display of number of methods to export Modified Paths: -------------- trunk/pwiz/pwiz_tools/Skyline/Controls/ControlUtil.cs trunk/pwiz/pwiz_tools/Skyline/FileUI/ExportMethodDlg.Designer.cs trunk/pwiz/pwiz_tools/Skyline/FileUI/ExportMethodDlg.cs trunk/pwiz/pwiz_tools/Skyline/Model/Export.cs trunk/pwiz/pwiz_tools/Skyline/TestTutorial/MethodRefinementTutorialTest.cs trunk/pwiz/pwiz_tools/Skyline/Util/UtilUI.cs Modified: trunk/pwiz/pwiz_tools/Skyline/Controls/ControlUtil.cs =================================================================== --- trunk/pwiz/pwiz_tools/Skyline/Controls/ControlUtil.cs 2011-07-26 19:12:32 UTC (rev 2884) +++ trunk/pwiz/pwiz_tools/Skyline/Controls/ControlUtil.cs 2011-07-26 21:22:54 UTC (rev 2885) @@ -39,6 +39,8 @@ _showMessages = showMessages; } + public bool ShowMessages { get { return _showMessages; } } + public bool ValidateNameTextBox(CancelEventArgs e, Control control, out string val) { bool valid = false; @@ -104,7 +106,7 @@ /// <summary> /// Validates a TextBox that should containe an integer value. /// </summary> - /// <param name="e">CancelEvenArgs to cancel validation, if the integer is invalid</param> + /// <param name="e">CancelEventArgs to cancel validation, if the integer is invalid</param> /// <param name="control">The TextBox control to validate</param> /// <param name="min">Minimum allowed value</param> /// <param name="max">Maximum allowed value</param> @@ -251,7 +253,7 @@ /// <param name="x">An <see cref="Exception"/> thrown during XML parsing</param> public static void ShowXmlParsingError(IWin32Window parent, string firstLine, string path, Exception x) { - if(_showMessages) + if(!_showMessages) return; string messageException = XmlUtil.GetInvalidDataMessage(path, x); MessageBox.Show(parent, firstLine + "\n" + messageException, Program.Name); Modified: trunk/pwiz/pwiz_tools/Skyline/FileUI/ExportMethodDlg.Designer.cs =================================================================== --- trunk/pwiz/pwiz_tools/Skyline/FileUI/ExportMethodDlg.Designer.cs 2011-07-26 19:12:32 UTC (rev 2884) +++ trunk/pwiz/pwiz_tools/Skyline/FileUI/ExportMethodDlg.Designer.cs 2011-07-26 21:22:54 UTC (rev 2885) @@ -53,6 +53,8 @@ this.comboOptimizing = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); this.cbFullScan = new System.Windows.Forms.CheckBox(); + this.labelMethods = new System.Windows.Forms.Label(); + this.labelMethodNum = new System.Windows.Forms.Label(); this.SuspendLayout(); // // radioSingle @@ -104,6 +106,7 @@ this.textMaxTransitions.TabIndex = 7; this.helpTip.SetToolTip(this.textMaxTransitions, "Each file created will have at most this number of transitions, but may have fewe" + "r,\r\nif peptide or protein boundaries do not allow the maximum."); + this.textMaxTransitions.TextChanged += new System.EventHandler(this.textMaxTransitions_TextChanged); // // labelMaxTransitions // @@ -139,7 +142,7 @@ // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(13, 292); + this.label2.Location = new System.Drawing.Point(13, 303); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(69, 13); this.label2.TabIndex = 10; @@ -152,7 +155,7 @@ this.comboTargetType.Items.AddRange(new object[] { "Standard", "Scheduled"}); - this.comboTargetType.Location = new System.Drawing.Point(16, 308); + this.comboTargetType.Location = new System.Drawing.Point(16, 319); this.comboTargetType.Name = "comboTargetType"; this.comboTargetType.Size = new System.Drawing.Size(124, 21); this.comboTargetType.TabIndex = 11; @@ -160,7 +163,7 @@ // // textRunLength // - this.textRunLength.Location = new System.Drawing.Point(164, 308); + this.textRunLength.Location = new System.Drawing.Point(164, 319); this.textRunLength.Name = "textRunLength"; this.textRunLength.Size = new System.Drawing.Size(100, 20); this.textRunLength.TabIndex = 10; @@ -168,7 +171,7 @@ // // textDwellTime // - this.textDwellTime.Location = new System.Drawing.Point(164, 308); + this.textDwellTime.Location = new System.Drawing.Point(164, 319); this.textDwellTime.Name = "textDwellTime"; this.textDwellTime.Size = new System.Drawing.Size(100, 20); this.textDwellTime.TabIndex = 13; @@ -177,7 +180,7 @@ // labelDwellTime // this.labelDwellTime.AutoSize = true; - this.labelDwellTime.Location = new System.Drawing.Point(164, 289); + this.labelDwellTime.Location = new System.Drawing.Point(164, 300); this.labelDwellTime.Name = "labelDwellTime"; this.labelDwellTime.Size = new System.Drawing.Size(80, 13); this.labelDwellTime.TabIndex = 12; @@ -212,7 +215,7 @@ // labelTemplateFile // this.labelTemplateFile.AutoSize = true; - this.labelTemplateFile.Location = new System.Drawing.Point(13, 359); + this.labelTemplateFile.Location = new System.Drawing.Point(13, 370); this.labelTemplateFile.Name = "labelTemplateFile"; this.labelTemplateFile.Size = new System.Drawing.Size(70, 13); this.labelTemplateFile.TabIndex = 15; @@ -220,14 +223,14 @@ // // textTemplateFile // - this.textTemplateFile.Location = new System.Drawing.Point(16, 377); + this.textTemplateFile.Location = new System.Drawing.Point(16, 388); this.textTemplateFile.Name = "textTemplateFile"; this.textTemplateFile.Size = new System.Drawing.Size(175, 20); this.textTemplateFile.TabIndex = 16; // // btnBrowseTemplate // - this.btnBrowseTemplate.Location = new System.Drawing.Point(197, 375); + this.btnBrowseTemplate.Location = new System.Drawing.Point(197, 386); this.btnBrowseTemplate.Name = "btnBrowseTemplate"; this.btnBrowseTemplate.Size = new System.Drawing.Size(75, 23); this.btnBrowseTemplate.TabIndex = 17; @@ -256,7 +259,7 @@ // cbEnergyRamp // this.cbEnergyRamp.AutoSize = true; - this.cbEnergyRamp.Location = new System.Drawing.Point(164, 334); + this.cbEnergyRamp.Location = new System.Drawing.Point(164, 345); this.cbEnergyRamp.Name = "cbEnergyRamp"; this.cbEnergyRamp.Size = new System.Drawing.Size(106, 17); this.cbEnergyRamp.TabIndex = 14; @@ -268,15 +271,16 @@ // this.comboOptimizing.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboOptimizing.FormattingEnabled = true; - this.comboOptimizing.Location = new System.Drawing.Point(16, 239); + this.comboOptimizing.Location = new System.Drawing.Point(16, 250); this.comboOptimizing.Name = "comboOptimizing"; this.comboOptimizing.Size = new System.Drawing.Size(121, 21); this.comboOptimizing.TabIndex = 9; + this.comboOptimizing.SelectedIndexChanged += new System.EventHandler(this.comboOptimizing_SelectedIndexChanged); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 225); + this.label1.Location = new System.Drawing.Point(13, 236); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(58, 13); this.label1.TabIndex = 8; @@ -293,13 +297,33 @@ this.cbFullScan.UseVisualStyleBackColor = true; this.cbFullScan.Visible = false; // + // labelMethods + // + this.labelMethods.AutoSize = true; + this.labelMethods.Location = new System.Drawing.Point(13, 201); + this.labelMethods.Name = "labelMethods"; + this.labelMethods.Size = new System.Drawing.Size(51, 13); + this.labelMethods.TabIndex = 21; + this.labelMethods.Text = "Methods:"; + // + // labelMethodNum + // + this.labelMethodNum.AutoSize = true; + this.labelMethodNum.Location = new System.Drawing.Point(70, 201); + this.labelMethodNum.Name = "labelMethodNum"; + this.labelMethodNum.Size = new System.Drawing.Size(21, 13); + this.labelMethodNum.TabIndex = 22; + this.labelMethodNum.Text = "##"; + // // ExportMethodDlg // this.AcceptButton = this.btnOk; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(287, 409); + this.ClientSize = new System.Drawing.Size(287, 422); + this.Controls.Add(this.labelMethodNum); + this.Controls.Add(this.labelMethods); this.Controls.Add(this.cbFullScan); this.Controls.Add(this.label1); this.Controls.Add(this.comboOptimizing); @@ -360,5 +384,7 @@ private System.Windows.Forms.ComboBox comboOptimizing; private System.Windows.Forms.Label label1; private System.Windows.Forms.CheckBox cbFullScan; + private System.Windows.Forms.Label labelMethods; + private System.Windows.Forms.Label labelMethodNum; } } \ No newline at end of file Modified: trunk/pwiz/pwiz_tools/Skyline/FileUI/ExportMethodDlg.cs =================================================================== --- trunk/pwiz/pwiz_tools/Skyline/FileUI/ExportMethodDlg.cs 2011-07-26 19:12:32 UTC (rev 2884) +++ trunk/pwiz/pwiz_tools/Skyline/FileUI/ExportMethodDlg.cs 2011-07-26 21:22:54 UTC (rev 2885) @@ -126,6 +126,8 @@ if (document.Settings.TransitionSettings.Prediction.DeclusteringPotential != null) comboOptimizing.Items.Add(ExportOptimize.DP); comboOptimizing.SelectedIndex = 0; + + CalcMethodCount(); } public string InstrumentType @@ -192,13 +194,11 @@ private ExportSchedulingAlgorithm SchedulingAlgorithm { - get { return _exportProperties.SchedulingAlgorithm; } set { _exportProperties.SchedulingAlgorithm = value; } } private int? SchedulingReplicateNum { - get { return _exportProperties.SchedulingReplicateNum; } set { _exportProperties.SchedulingReplicateNum = value ?? 0; } } @@ -372,7 +372,7 @@ { // TODO: Remove this var e = new CancelEventArgs(); - var helper = new MessageBoxHelper(this); + var helper = new MessageBoxHelper(this, true); _instrumentType = comboInstrument.SelectedItem.ToString(); @@ -451,93 +451,12 @@ } } - // ReSharper disable ConvertIfStatementToConditionalTernaryExpression - if (radioSingle.Checked) - _exportProperties.ExportStrategy = ExportStrategy.Single; - else if (radioProtein.Checked) - _exportProperties.ExportStrategy = ExportStrategy.Protein; - else - _exportProperties.ExportStrategy = ExportStrategy.Buckets; - // ReSharper restore ConvertIfStatementToConditionalTernaryExpression - - _exportProperties.IgnoreProteins = cbIgnoreProteins.Checked; - _exportProperties.FullScans = cbFullScan.Checked; - _exportProperties.AddEnergyRamp = cbEnergyRamp.Visible && cbEnergyRamp.Checked; - - _exportProperties.OptimizeType = comboOptimizing.SelectedItem.ToString(); - var prediction = _document.Settings.TransitionSettings.Prediction; - if (Equals(_exportProperties.OptimizeType, ExportOptimize.NONE)) - _exportProperties.OptimizeType = null; - else if (Equals(_exportProperties.OptimizeType, ExportOptimize.CE)) + //This will populate _exportProperties + if(!ValidateSettings(e, helper)) { - var regression = prediction.CollisionEnergy; - _exportProperties.OptimizeStepSize = regression.StepSize; - _exportProperties.OptimizeStepCount = regression.StepCount; + return; } - else if (Equals(_exportProperties.OptimizeType, ExportOptimize.DP)) - { - var regression = prediction.DeclusteringPotential; - _exportProperties.OptimizeStepSize = regression.StepSize; - _exportProperties.OptimizeStepCount = regression.StepCount; - } - string maxTran = textMaxTransitions.Text; - if (string.IsNullOrEmpty(maxTran)) - { - if (_exportProperties.ExportStrategy == ExportStrategy.Buckets) - { - helper.ShowTextBoxError(textMaxTransitions, "{0} must contain a value."); - return; - } - _exportProperties.MaxTransitions = null; - } - else - { - int maxVal; - // CONSIDER: Better error message when instrument limitation encountered? - int maxInstrumentTrans = documentExport.Settings.TransitionSettings.Instrument.MaxTransitions ?? - TransitionInstrument.MAX_TRANSITION_MAX; - int minTrans = IsFullScanInstrument ? MassListExporter.MAX_TRANS_PER_INJ_MIN : MethodExporter.MAX_TRANS_PER_INJ_MIN_TLTQ; - if (!helper.ValidateNumberTextBox(e, textMaxTransitions, minTrans, maxInstrumentTrans, out maxVal)) - return; - // Make sure all the precursors can fit into a single document - if (!ValidatePrecursorFit(documentExport, maxVal)) - return; - _exportProperties.MaxTransitions = maxVal; - } - - _exportProperties.MethodType = (ExportMethodType)Enum.Parse(typeof(ExportMethodType), - comboTargetType.SelectedItem.ToString()); - - if (textDwellTime.Visible) - { - int dwellTime; - if (!helper.ValidateNumberTextBox(e, textDwellTime, MassListExporter.DWELL_TIME_MIN, MassListExporter.DWELL_TIME_MAX, out dwellTime)) - return; - - _exportProperties.DwellTime = dwellTime; - } - if (textRunLength.Visible) - { - double runLength; - if (!helper.ValidateDecimalTextBox(e, textRunLength, MassListExporter.RUN_LENGTH_MIN, MassListExporter.RUN_LENGTH_MAX, out runLength)) - return; - - _exportProperties.RunLength = runLength; - } - - // If export method type is scheduled, and allows multiple scheduling options - // ask the user which to use. - if (_exportProperties.MethodType == ExportMethodType.Scheduled && HasMultipleSchedulingOptions(documentExport)) - { - SchedulingOptionsDlg schedulingOptionsDlg = new SchedulingOptionsDlg(documentExport); - if (schedulingOptionsDlg.ShowDialog(this) != DialogResult.OK) - return; - - SchedulingAlgorithm = schedulingOptionsDlg.Algorithm; - SchedulingReplicateNum = schedulingOptionsDlg.ReplicateNum; - } - if (outputPath == null) { SaveFileDialog dlg = new SaveFileDialog @@ -575,6 +494,7 @@ } Settings.Default.ExportDirectory = Path.GetDirectoryName(outputPath); + try { _exportProperties.ExportFile(_instrumentType, _fileType, outputPath, documentExport, templateName); @@ -614,6 +534,129 @@ Close(); } + + /// <summary> + /// This function will validate all the settings required for exporting a method, + /// placing the values on the ExportDlgProperties _exportProperties. It returns + /// boolean whether or not it succeeded. It can show MessageBoxes or not based + /// on a parameter. + /// </summary> + /// <param name="e"></param> + /// <param name="helper"></param> + /// <returns></returns> + public bool ValidateSettings(CancelEventArgs e, MessageBoxHelper helper) + { + // ReSharper disable ConvertIfStatementToConditionalTernaryExpression + if (radioSingle.Checked) + _exportProperties.ExportStrategy = ExportStrategy.Single; + else if (radioProtein.Checked) + _exportProperties.ExportStrategy = ExportStrategy.Protein; + else + _exportProperties.ExportStrategy = ExportStrategy.Buckets; + // ReSharper restore ConvertIfStatementToConditionalTernaryExpression + + _exportProperties.IgnoreProteins = cbIgnoreProteins.Checked; + _exportProperties.FullScans = cbFullScan.Checked; + _exportProperties.AddEnergyRamp = cbEnergyRamp.Visible && cbEnergyRamp.Checked; + + _exportProperties.OptimizeType = comboOptimizing.SelectedItem == null ? ExportOptimize.NONE : comboOptimizing.SelectedItem.ToString(); + var prediction = _document.Settings.TransitionSettings.Prediction; + if (Equals(_exportProperties.OptimizeType, ExportOptimize.CE)) + { + var regression = prediction.CollisionEnergy; + _exportProperties.OptimizeStepSize = regression.StepSize; + _exportProperties.OptimizeStepCount = regression.StepCount; + } + else if (Equals(_exportProperties.OptimizeType, ExportOptimize.DP)) + { + var regression = prediction.DeclusteringPotential; + _exportProperties.OptimizeStepSize = regression.StepSize; + _exportProperties.OptimizeStepCount = regression.StepCount; + } + else + { + _exportProperties.OptimizeType = null; + _exportProperties.OptimizeStepSize = _exportProperties.OptimizeStepCount = 0; + } + + string maxTran = textMaxTransitions.Text; + if (string.IsNullOrEmpty(maxTran)) + { + if (_exportProperties.ExportStrategy == ExportStrategy.Buckets) + { + helper.ShowTextBoxError(textMaxTransitions, "{0} must contain a value."); + return false; + } + _exportProperties.MaxTransitions = null; + } + else + { + int maxVal; + // CONSIDER: Better error message when instrument limitation encountered? + int maxInstrumentTrans = _document.Settings.TransitionSettings.Instrument.MaxTransitions ?? + TransitionInstrument.MAX_TRANSITION_MAX; + int minTrans = IsFullScanInstrument ? MassListExporter.MAX_TRANS_PER_INJ_MIN : MethodExporter.MAX_TRANS_PER_INJ_MIN_TLTQ; + if (!helper.ValidateNumberTextBox(e, textMaxTransitions, minTrans, maxInstrumentTrans, out maxVal)) + return false; + // Make sure all the transitions of all precursors can fit into a single document, + // but not if this is a full-scan instrument, because then the maximum is refering + // to precursors and not transitions. + if (!IsFullScanInstrument && !ValidatePrecursorFit(_document, maxVal, helper.ShowMessages)) + return false; + _exportProperties.MaxTransitions = maxVal; + } + + _exportProperties.MethodType = (ExportMethodType)Enum.Parse(typeof(ExportMethodType), + comboTargetType.SelectedItem.ToString()); + + if (textDwellTime.Visible) + { + int dwellTime; + if (!helper.ValidateNumberTextBox(e, textDwellTime, MassListExporter.DWELL_TIME_MIN, MassListExporter.DWELL_TIME_MAX, out dwellTime)) + return false; + + _exportProperties.DwellTime = dwellTime; + } + if (textRunLength.Visible) + { + double runLength; + if (!helper.ValidateDecimalTextBox(e, textRunLength, MassListExporter.RUN_LENGTH_MIN, MassListExporter.RUN_LENGTH_MAX, out runLength)) + return false; + + _exportProperties.RunLength = runLength; + } + + // If export method type is scheduled, and allows multiple scheduling options + // ask the user which to use. + if (_exportProperties.MethodType == ExportMethodType.Scheduled && HasMultipleSchedulingOptions(_document)) + { + if (!helper.ShowMessages) + { + // CONSIDER: Kind of a hack, but pick some reasonable defaults. The user + // may decide otherwise later, but this is the best we can do + // without asking. + if (!_document.Settings.HasResults || Settings.Default.ScheduleAvergeRT) + SchedulingAlgorithm = ExportSchedulingAlgorithm.Average; + else + { + SchedulingAlgorithm = ExportSchedulingAlgorithm.Single; + SchedulingReplicateNum = _document.Settings.MeasuredResults.Chromatograms.Count - 1; + } + } + else + { + SchedulingOptionsDlg schedulingOptionsDlg = new SchedulingOptionsDlg(_document); + if (schedulingOptionsDlg.ShowDialog(this) != DialogResult.OK) + return false; + + SchedulingAlgorithm = schedulingOptionsDlg.Algorithm; + SchedulingReplicateNum = schedulingOptionsDlg.ReplicateNum; + } + } + + return true; + } + private static bool HasMultipleSchedulingOptions(SrmDocument document) { // No scheduling from data, if no data is present @@ -631,7 +674,7 @@ return (sched == 0 && chromatagrams.Count > 1); } - private bool ValidatePrecursorFit(SrmDocument document, int maxTransitions) + private bool ValidatePrecursorFit(SrmDocument document, int maxTransitions, bool showMessages) { string messageFormat = (OptimizeType == null ? "The precursor {0} for the peptide {1} has {2} transitions, which exceeds the current maximum {3}." : @@ -643,11 +686,14 @@ tranRequired *= OptimizeStepCount * 2 + 1; if (tranRequired > maxTransitions) { - MessageDlg.Show(this, string.Format(messageFormat, - SequenceMassCalc.PersistentMZ(nodeGroup.PrecursorMz) + Transition.GetChargeIndicator(nodeGroup.TransitionGroup.PrecursorCharge), - nodeGroup.TransitionGroup.Peptide.Sequence, - tranRequired, - maxTransitions)); + if (showMessages) + { + MessageDlg.Show(this, string.Format(messageFormat, + SequenceMassCalc.PersistentMZ(nodeGroup.PrecursorMz) + Transition.GetChargeIndicator(nodeGroup.TransitionGroup.PrecursorCharge), + nodeGroup.TransitionGroup.Peptide.Sequence, + tranRequired, + maxTransitions)); + } return false; } } @@ -695,21 +741,6 @@ OkDialog(null); } - public TExp InitExporter<TExp>(TExp exporter) - where TExp : MassListExporter - { - exporter.Strategy = ExportStrategy; - exporter.IgnoreProteins = IgnoreProteins; - exporter.MaxTransitions = MaxTransitions; - exporter.MethodType = MethodType; - exporter.OptimizeType = OptimizeType; - exporter.OptimizeStepSize = OptimizeStepSize; - exporter.OptimizeStepCount = OptimizeStepCount; - exporter.SchedulingReplicateIndex = SchedulingReplicateNum; - exporter.SchedulingAlgorithm = SchedulingAlgorithm; - return exporter; - } - private void radioSingle_CheckedChanged(object sender, EventArgs e) { StrategyCheckChanged(); @@ -731,6 +762,15 @@ cbIgnoreProteins.Enabled = radioBuckets.Checked; if (!radioBuckets.Checked) cbIgnoreProteins.Checked = false; + + if (radioSingle.Checked) + { + labelMethodNum.Text = "1"; + } + else + { + CalcMethodCount(); + } } private void comboInstrument_SelectedIndexChanged(object sender, EventArgs e) @@ -758,6 +798,8 @@ textTemplateFile.Text = templateFile.FilePath; else textTemplateFile.Text = ""; + + CalcMethodCount(); } private void comboTargetType_SelectedIndexChanged(object sender, EventArgs e) @@ -788,6 +830,8 @@ UpdateDwellControls(standard); UpdateEnergyRamp(standard); UpdateMaxLabel(standard); + + CalcMethodCount(); } private void UpdateMaxLabel(bool standard) @@ -807,7 +851,31 @@ labelMaxTransitions.Text = "Ma&x concurrent transitions:"; } } + + private void CalcMethodCount() + { + var e = new CancelEventArgs(); + var helper = new MessageBoxHelper(this, false); + if (!ValidateSettings(e, helper) || comboInstrument.SelectedItem == null) + { + labelMethodNum.Text = ""; + return; + } + + string instrument = comboInstrument.SelectedItem.ToString(); + MassListExporter exporter = null; + try + { + exporter = _exportProperties.ExportFile(instrument, _fileType, null, _document, null); + } + catch (IOException) + { + } + + labelMethodNum.Text = exporter != null ? exporter.MemoryOutput.Count.ToString() : ""; + } + private void UpdateDwellControls(bool standard) { bool showDwell = false; @@ -904,6 +972,23 @@ textTemplateFile.Text = openFileDialog.FileName; } } + + private void textMaxTransitions_TextChanged(object sender, EventArgs e) + { + int maxTrans; + if(!int.TryParse(textMaxTransitions.Text, out maxTrans) || maxTrans < 1) + { + labelMethodNum.Text = ""; + return; + } + + CalcMethodCount(); + } + + private void comboOptimizing_SelectedIndexChanged(object sender, EventArgs e) + { + CalcMethodCount(); + } } public class ExportDlgProperties : ExportProperties @@ -915,8 +1000,16 @@ _dialog = dialog; } + public bool ShowMessages { get; set; } + public override void PerformLongExport(Action<IProgressMonitor> performExport) { + if (!ShowMessages) + { + performExport(new SilentProgressMonitor()); + return; + } + var longWait = new LongWaitDlg { Text = "Exporting Methods" }; try { @@ -929,5 +1022,11 @@ MessageBox.Show(_dialog, string.Format("An error occurred attempting to export.\n{0}", x.Message), Program.Name); } } + + private class SilentProgressMonitor : IProgressMonitor + { + public bool IsCanceled { get { return false; } } + public void UpdateProgress(ProgressStatus status) { } + } } } Modified: trunk/pwiz/pwiz_tools/Skyline/Model/Export.cs =================================================================== --- trunk/pwiz/pwiz_tools/Skyline/Model/Export.cs 2011-07-26 19:12:32 UTC (rev 2884) +++ trunk/pwiz/pwiz_tools/Skyline/Model/Export.cs 2011-07-26 21:22:54 UTC (rev 2885) @@ -168,124 +168,136 @@ return exporter; } - public void ExportFile(string instrumentType, ExportFileType type, string path, SrmDocument doc, string template) + public MassListExporter ExportFile(string instrumentType, ExportFileType type, string path, SrmDocument doc, string template) { switch (instrumentType) { case ExportInstrumentType.ABI: case ExportInstrumentType.ABI_QTRAP: if (type == ExportFileType.List) - ExportAbiCsv(doc, path); + return ExportAbiCsv(doc, path); else - ExportAbiQtrapMethod(doc, path, template); - break; + return ExportAbiQtrapMethod(doc, path, template); case ExportInstrumentType.Agilent: case ExportInstrumentType.Agilent6400: if (type == ExportFileType.List) - ExportAgilentCsv(doc, path); + return ExportAgilentCsv(doc, path); else - ExportAgilentMethod(doc, path, template); - break; + return ExportAgilentMethod(doc, path, template); case ExportInstrumentType.Thermo: case ExportInstrumentType.Thermo_TSQ: if (type == ExportFileType.List) - ExportThermoCsv(doc, path); + return ExportThermoCsv(doc, path); else - ExportThermoMethod(doc, path, template); - break; + return ExportThermoMethod(doc, path, template); case ExportInstrumentType.Thermo_LTQ: OptimizeType = null; - ExportThermoLtqMethod(doc, path, template); - break; + return ExportThermoLtqMethod(doc, path, template); case ExportInstrumentType.Waters: case ExportInstrumentType.Waters_Xevo: if (type == ExportFileType.List) - ExportWatersCsv(doc, path); + return ExportWatersCsv(doc, path); else - ExportWatersMethod(doc, path, template); - break; + return ExportWatersMethod(doc, path, template); case ExportInstrumentType.Waters_Quattro_Premier: - ExportWatersQMethod(doc, path, template); - break; + return ExportWatersQMethod(doc, path, template); default: - break; + return null; } } - public void ExportAbiCsv(SrmDocument document, string fileName) + public MassListExporter ExportAbiCsv(SrmDocument document, string fileName) { var exporter = InitExporter(new AbiMassListExporter(document)); if (MethodType == ExportMethodType.Standard) exporter.DwellTime = DwellTime; exporter.Export(fileName); + + return exporter; } - public void ExportAbiQtrapMethod(SrmDocument document, string fileName, string templateName) + public MassListExporter ExportAbiQtrapMethod(SrmDocument document, string fileName, string templateName) { var exporter = InitExporter(new AbiQtrapMethodExporter(document)); if (MethodType == ExportMethodType.Standard) exporter.DwellTime = DwellTime; PerformLongExport(m => exporter.ExportMethod(fileName, templateName, m)); + + return exporter; } - public void ExportAgilentCsv(SrmDocument document, string fileName) + public MassListExporter ExportAgilentCsv(SrmDocument document, string fileName) { var exporter = InitExporter(new AgilentMassListExporter(document)); if (MethodType == ExportMethodType.Standard) exporter.DwellTime = DwellTime; exporter.Export(fileName); + + return exporter; } - public void ExportAgilentMethod(SrmDocument document, string fileName, string templateName) + public MassListExporter ExportAgilentMethod(SrmDocument document, string fileName, string templateName) { var exporter = InitExporter(new AgilentMethodExporter(document)); if (MethodType == ExportMethodType.Standard) exporter.DwellTime = DwellTime; PerformLongExport(m => exporter.ExportMethod(fileName, templateName, m)); + + return exporter; } - public void ExportThermoCsv(SrmDocument document, string fileName) + public MassListExporter ExportThermoCsv(SrmDocument document, string fileName) { var exporter = InitExporter(new ThermoMassListExporter(document)); exporter.AddEnergyRamp = AddEnergyRamp; exporter.Export(fileName); + + return exporter; } - public void ExportThermoMethod(SrmDocument document, string fileName, string templateName) + public MassListExporter ExportThermoMethod(SrmDocument document, string fileName, string templateName) { var exporter = InitExporter(new ThermoMethodExporter(document)); if (MethodType == ExportMethodType.Standard) exporter.RunLength = RunLength; PerformLongExport(m => exporter.ExportMethod(fileName, templateName, m)); + + return exporter; } - public void ExportThermoLtqMethod(SrmDocument document, string fileName, string templateName) + public MassListExporter ExportThermoLtqMethod(SrmDocument document, string fileName, string templateName) { var exporter = InitExporter(new ThermoLtqMethodExporter(document)); exporter.FullScans = FullScans; PerformLongExport(m => exporter.ExportMethod(fileName, templateName, m)); + + return exporter; } - public void ExportWatersCsv(SrmDocument document, string fileName) + public MassListExporter ExportWatersCsv(SrmDocument document, string fileName) { var exporter = InitExporter(new WatersMassListExporter(document)); if (MethodType == ExportMethodType.Standard) exporter.RunLength = RunLength; exporter.Export(fileName); + + return exporter; } - public void ExportWatersMethod(SrmDocument document, string fileName, string templateName) + public MassListExporter ExportWatersMethod(SrmDocument document, string fileName, string templateName) { var exporter = InitExporter(new WatersMethodExporter(document)); if (MethodType == ExportMethodType.Standard) exporter.RunLength = RunLength; PerformLongExport(m => exporter.ExportMethod(fileName, templateName, m)); + + return exporter; } - public void ExportWatersQMethod(SrmDocument document, string fileName, string templateName) + public MassListExporter ExportWatersQMethod(SrmDocument document, string fileName, string templateName) { var exporter = InitExporter(new WatersMethodExporter(document) { @@ -295,6 +307,8 @@ exporter.RunLength = RunLength; PerformLongExport(m => exporter.ExportMethod(fileName, templateName, m)); + + return exporter; } public abstract void PerformLongExport(Action<IProgressMonitor> performExport); @@ -373,6 +387,27 @@ public Dictionary<string, StringBuilder> MemoryOutput { get; private set; } /// <summary> + /// + /// </summary> + protected bool InitExport(string fileName, IProgressMonitor progressMonitor) + { + if (progressMonitor.IsCanceled) + return false; + + // First export transition lists to map in memory + Export(null); + + // If filename is null, then no more work needs to be done. + if (fileName == null) + { + progressMonitor.UpdateProgress(new ProgressStatus("").Complete()); + return false; + } + + return true; + } + + /// <summary> /// Export to a transition list to a file or to memory. /// </summary> /// <param name="fileName">A file on disk to export to, or null to export to memory.</param> @@ -1335,8 +1370,8 @@ public void ExportMethod(string fileName, string templateName, IProgressMonitor progressMonitor) { - // First export transition lists to map in memory - Export(null); + if (!InitExport(fileName, progressMonitor)) + return; MethodExporter.ExportMethod(EXE_BUILD_TSQ_METHOD, new List<string>(), fileName, templateName, MemoryOutput, progressMonitor); @@ -1360,8 +1395,8 @@ public void ExportMethod(string fileName, string templateName, IProgressMonitor progressMonitor) { - // First export transition lists to map in memory - Export(null); + if (!InitExport(fileName, progressMonitor)) + return; var argv = new List<string>(); if (FullScans) @@ -1450,13 +1485,12 @@ public void ExportMethod(string fileName, string templateName, IProgressMonitor progressMonitor) { - EnsureAnalyst(progressMonitor); - if (progressMonitor.IsCanceled) + if(fileName != null) + EnsureAnalyst(progressMonitor); + + if (!InitExport(fileName, progressMonitor)) return; - // First export transition lists to map in memory - Export(null); - var argv = new List<string>(); if (RTWindow.HasValue) { @@ -1666,8 +1700,8 @@ public void ExportMethod(string fileName, string templateName, IProgressMonitor progressMonitor) { - // First export transition lists to map in memory - Export(null); + if (!InitExport(fileName, progressMonitor)) + return; MethodExporter.ExportMethod(EXE_BUILD_AGILENT_METHOD, new List<string>(), fileName, templateName, MemoryOutput, progressMonitor); @@ -1821,10 +1855,11 @@ public void ExportMethod(string fileName, string templateName, IProgressMonitor progressMonitor) { - EnsureLibraries(); + if(fileName != null) + EnsureLibraries(); - // First export transition lists to map in memory - Export(null); + if (!InitExport(fileName, progressMonitor)) + return; var argv = new List<string>(); if (Equals(MethodInstrumentType, ExportInstrumentType.Waters_Quattro_Premier)) Modified: trunk/pwiz/pwiz_tools/Skyline/TestTutorial/MethodRefinementTutorialTest.cs =================================================================== --- trunk/pwiz/pwiz_tools/Skyline/TestTutorial/MethodRefinementTutorialTest.cs 2011-07-26 19:12:32 UTC (rev 2884) +++ trunk/pwiz/pwiz_tools/Skyline/TestTutorial/MethodRefinementTutorialTest.cs 2011-07-26 21:22:54 UTC (rev 2885) @@ -66,6 +66,8 @@ { SkylineWindow.OpenFile(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\WormUnrefined.sky")); SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; + + Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode.Text, "YLGAYLLATLGGNASPSAQDVLK"); }); // Unrefined Methods, p. 3 @@ -78,13 +80,28 @@ exportDlg.OkDialog(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm")); }); + for (int i = 1; i < 10; i++) + { + Assert.IsTrue(File.Exists(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm_000" + i + ".csv"))); + } + for (int i = 10; i < 40; i++) + { + Assert.IsTrue(File.Exists(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm_00" + i + ".csv"))); + } + // Importing Multiple Injection Data, p. 4 + + Assert.IsTrue(SkylineWindow.Document.Settings.HasResults); RunDlg<ManageResultsDlg>(SkylineWindow.ManageResults, manageResultsDlg => { manageResultsDlg.Remove(); + Assert.AreEqual(manageResultsDlg.Chromatograms.ToArray().Length, 0); manageResultsDlg.OkDialog(); }); + RunUI(() => SkylineWindow.SaveDocument()); + Assert.IsFalse(SkylineWindow.Document.Settings.HasResults); + const string replicateName = "Unrefined"; RunDlg<ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg => { @@ -95,6 +112,10 @@ importResultsDlg.OkDialog(); }); WaitForCondition(300*1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 5 minutes + + Assert.IsTrue(SkylineWindow.Document.Settings.HasResults); + Assert.AreEqual(15, SkylineWindow.Document.Settings.MeasuredResults.CachedFilePaths.ToArray().Length); + RunDlg<ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg => { importResultsDlg.RadioAddExistingChecked = true; @@ -104,8 +125,14 @@ importResultsDlg.OkDialog(); }); WaitForCondition(300*1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 5 minutes + + Assert.AreEqual(39, SkylineWindow.Document.Settings.MeasuredResults.CachedFilePaths.ToArray().Length); - // Simple Manual Refinement, p. 6 + // Simple Manual Refinement, p. 6 + int startingNodeCount = SkylineWindow.SequenceTree.Nodes[0].GetNodeCount(false); + + Assert.AreEqual("YLGAYLLATLGGNASPSAQDVLK", SkylineWindow.SequenceTree.Nodes[0].Nodes[0].Text); + RunUI(() => { SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; @@ -114,12 +141,16 @@ SkylineWindow.EditDelete(); SkylineWindow.ShowRTLinearRegressionGraph(); }); + Assert.AreEqual(SkylineWindow.SequenceTree.Nodes[0].GetNodeCount(false), startingNodeCount - 1); + Assert.AreEqual("VLEAGGLDCDMENANSVVDALK", SkylineWindow.SequenceTree.Nodes[0].Nodes[0].Text); + RunDlg<ShowRTThresholdDlg>(SkylineWindow.ShowRTThresholdDlg, rtThresholdDlg => { rtThresholdDlg.Threshold = 0.95; rtThresholdDlg.OkDialog(); }); WaitForConditionUI(() => SkylineWindow.RTGraphController.RegressionRefined != null); + RunDlg<EditRTDlg>(SkylineWindow.CreateRegression, editRTDlg => editRTDlg.OkDialog()); // Missing Data, p. 10 @@ -152,12 +183,15 @@ // Picking Measurable Peptides and Transitions, p. 12 SkylineWindow.ExpandPeptides(); + SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; Assert.IsTrue(SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Text.Contains((0.78).ToString())); SkylineWindow.EditDelete(); + SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0]; Assert.IsTrue(SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Text.Contains((0.63).ToString())); SkylineWindow.EditDelete(); + PeptideTreeNode nodePep; for (int i = 0; i < 2; i++) { @@ -230,6 +264,7 @@ refineDlg.DotProductThreshold = 0.90; refineDlg.OkDialog(); }); + WaitForCondition(() => SkylineWindow.Document.PeptideCount < 120); RunUI(() => { @@ -238,11 +273,21 @@ // Scheduling for Efficient Acquisition, p. 17 SkylineWindow.Undo(); }); - RunDlg<ManageResultsDlg>(SkylineWindow.ManageResults, manageResultsDlg => + + RunDlg<ManageResultsDlg>(SkylineWindow.ManageResults, mResults => { - manageResultsDlg.Remove(); - manageResultsDlg.OkDialog(); + Assert.AreEqual(1, mResults.Chromatograms.Count()); + + mResults.SelectedChromatograms = + SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Where( + set => Equals("Unrefined", set.Name)); + + mResults.Remove(); + + Assert.AreEqual(0, mResults.Chromatograms.Count()); + mResults.OkDialog(); }); + var importResultsDlg0 = ShowDialog<ImportResultsDlg>(SkylineWindow.ImportResults); RunUI(() => { @@ -253,6 +298,7 @@ var importResultsNameDlg = ShowDialog<ImportResultsNameDlg>(importResultsDlg0.OkDialog); RunUI(importResultsNameDlg.NoDialog); WaitForCondition(300*1000, () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); + var docCurrent = SkylineWindow.Document; RunUI(SkylineWindow.RemoveMissingResults); WaitForDocumentChange(docCurrent); @@ -265,6 +311,7 @@ exportMethodDlg.MaxTransitions = 130; exportMethodDlg.OkDialog(TestFilesDirs[1].FullPath + "\\unscheduled"); }); + /////////////////////// // Reviewing Retention Time Runs, p. 18 RunUI(() => Modified: trunk/pwiz/pwiz_tools/Skyline/Util/UtilUI.cs =================================================================== --- trunk/pwiz/pwiz_tools/Skyline/Util/UtilUI.cs 2011-07-26 19:12:32 UTC (rev 2884) +++ trunk/pwiz/pwiz_tools/Skyline/Util/UtilUI.cs 2011-07-26 21:22:54 UTC (rev 2885) @@ -120,6 +120,7 @@ public ProgressWaitBroker(Action<IProgressMonitor> performWork) { _performWork = performWork; + Status = new ProgressStatus(""); } public void PerformWork(ILongWaitBroker broker) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |