Пример #1
0
        protected override void OnLoad(EventArgs e)
        {
            searchPathTextBox.Text = String.Join(";", Util.StringCollectionToStringArray(Properties.Settings.Default.SourcePaths));
            extensionsTextBox.Text = Properties.Settings.Default.SourceExtensions;
            embeddedChanges        = false;

            // TODO: set these from global defaults?
            _defaultIsobaricConfig = new Embedder.QuantitationConfiguration()
            {
                QuantitationMethod = QuantitationMethod.ITRAQ4plex
            };
            _defaultXicConfig = new Embedder.XICConfiguration();

            _isobaricConfigBySource = new Dictionary <int, Embedder.QuantitationConfiguration>();
            _xicConfigBySource      = new Dictionary <int, Embedder.XICConfiguration>();

            CancelRequested = false;
            EmbedInProgress = false;

            if (Owner != null && StartPosition == FormStartPosition.CenterParent)
            {
                Location = new Point(Owner.Location.X + Owner.Width / 2 - Width / 2,
                                     Owner.Location.Y + Owner.Height / 2 - Height / 2);
            }

            base.OnLoad(e);

            Refresh();
        }
Пример #2
0
        private void defaultXICSettingsButton_Click(object sender, EventArgs e)
        {
            var maxQValue        = 0.05;
            var mostRecentFilter = session.Query <PersistentDataFilter>().OrderByDescending(o => o.Id).FirstOrDefault();

            if (mostRecentFilter != null)
            {
                maxQValue = mostRecentFilter.MaximumQValue;
            }

            var quantitationSettingsForm = new QuantitationSettingsForm(_defaultXicConfig, _defaultIsobaricConfig, maxQValue);

            if (quantitationSettingsForm.ShowDialog() == DialogResult.OK)
            {
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    var method = QuantitationMethodForRow(row.Index);
                    if (IsLabelFree(method))
                    {
                        row.Cells[quantitationSettingsColumn.Index].Value = quantitationSettingsForm.XicConfig;
                    }
                    else if (IsIsobaric(method))
                    {
                        row.Cells[quantitationSettingsColumn.Index].Value = quantitationSettingsForm.IsobaricConfig;
                    }
                    else
                    {
                        row.Cells[quantitationSettingsColumn.Index].Value = "n/a";
                    }
                }
                _defaultIsobaricConfig = quantitationSettingsForm.IsobaricConfig;
                _defaultXicConfig      = quantitationSettingsForm.XicConfig;
            }
        }
Пример #3
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            var cloValue = (double)ChromatogramMzLowerOffsetValueBox.Value;
            var cloUnits = (MZTolerance.Units)ChromatogramMzLowerOffsetUnitsBox.SelectedIndex;
            var cuoValue = (double)ChromatogramMzUpperOffsetValueBox.Value;
            var cuoUnits = (MZTolerance.Units)ChromatogramMzUpperOffsetUnitsBox.SelectedIndex;
            var rtMax    = (int)Math.Round(RTTolUpperBox.Value);
            var rtMin    = (int)Math.Round(RTTolLowerBox.Value);
            var maMax    = (int)Math.Round(MonoisotopicAdjustmentMaxBox.Value);
            var maMin    = (int)Math.Round(MonoisotopicAdjustmentMinBox.Value);

            XicConfig = new Embedder.XICConfiguration {
                ChromatogramMzLowerOffset   = new MZTolerance(cloValue, cloUnits),
                ChromatogramMzUpperOffset   = new MZTolerance(cuoValue, cuoUnits),
                RetentionTimeLowerTolerance = rtMin,
                RetentionTimeUpperTolerance = rtMax,
                MonoisotopicAdjustmentMax   = maMax,
                MonoisotopicAdjustmentMin   = maMin,
                MaxQValue          = _maxQValue,
                AlignRetentionTime = RTAlignBox.Checked
            };

            IsobaricConfig = new Embedder.QuantitationConfiguration
            {
                QuantitationMethod     = IsobaricConfig.QuantitationMethod,
                ReporterIonMzTolerance = new MZTolerance((double)reporterIonToleranceUpDown.Value, (MZTolerance.Units)reporterIonToleranceUnits.SelectedIndex),
                NormalizeIntensities   = normalizeReporterIonsCheckBox.Checked
            };

            DialogResult = DialogResult.OK;
        }
Пример #4
0
 public QuantitationSettingsForm(Embedder.XICConfiguration oldXicConfig, Embedder.QuantitationConfiguration oldIsobaricConfig, double maxQValue)
 {
     XicConfig      = oldXicConfig;
     IsobaricConfig = oldIsobaricConfig;
     _maxQValue     = maxQValue;
     InitializeComponent();
 }
 public QuantitationSettingsForm(Embedder.XICConfiguration oldXicConfig, Embedder.QuantitationConfiguration oldIsobaricConfig, double maxQValue)
 {
     XicConfig = oldXicConfig;
     IsobaricConfig = oldIsobaricConfig;
     _maxQValue = maxQValue;
     InitializeComponent();
 }
Пример #6
0
        private void dataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var maxQValue        = 0.05;
            var mostRecentFilter = session.Query <PersistentDataFilter>().OrderByDescending(o => o.Id).FirstOrDefault();

            if (mostRecentFilter != null)
            {
                maxQValue = mostRecentFilter.MaximumQValue;
            }

            if (e.ColumnIndex == quantitationSettingsColumn.Index)
            {
                var row    = dataGridView.Rows[e.RowIndex];
                var method = QuantitationMethodForRow(e.RowIndex);
                if (method == QuantitationMethod.None)
                {
                    return;
                }

                var currentXicConfig          = new Embedder.XICConfiguration();
                var currentQuantitationConfig = new Embedder.QuantitationConfiguration();
                if (IsLabelFree(method))
                {
                    currentXicConfig = (row.Cells[quantitationSettingsColumn.Index].Value as Embedder.XICConfiguration) ?? currentXicConfig;

                    var quantSettingsForm = new QuantitationSettingsForm((row.Cells[quantitationSettingsColumn.Index].Value as Embedder.XICConfiguration), _defaultIsobaricConfig, maxQValue);
                    if (quantSettingsForm.ShowDialog() == DialogResult.OK)
                    {
                        row.Cells[quantitationSettingsColumn.Index].Value = quantSettingsForm.XicConfig;
                        _xicConfigBySource[e.RowIndex] = quantSettingsForm.XicConfig;
                    }
                }
                else if (IsIsobaric(method))
                {
                    currentQuantitationConfig = (row.Cells[quantitationSettingsColumn.Index].Value as Embedder.QuantitationConfiguration) ?? currentQuantitationConfig;

                    var quantSettingsForm = new QuantitationSettingsForm(_defaultXicConfig, (row.Cells[quantitationSettingsColumn.Index].Value as Embedder.QuantitationConfiguration), maxQValue);
                    if (quantSettingsForm.ShowDialog() == DialogResult.OK)
                    {
                        row.Cells[quantitationSettingsColumn.Index].Value = quantSettingsForm.IsobaricConfig;
                        _isobaricConfigBySource[e.RowIndex] = quantSettingsForm.IsobaricConfig;
                    }
                }
            }
        }
Пример #7
0
        private void embedAllButton_Click(object sender, EventArgs e)
        {
            var    searchPath = new StringBuilder(searchPathTextBox.Text);
            string extensions = extensionsTextBox.Text;

            Application.UseWaitCursor = true;
            deleteAllButton.Enabled   = embedAllButton.Enabled = false;
            embeddedChanges           = true;

            try
            {
                // add location of original idpDBs to the search path
                var mergedFilepaths = session.CreateSQLQuery("SELECT DISTINCT Filepath FROM MergedFiles").List <string>();
                foreach (var filepath in mergedFilepaths)
                {
                    searchPath.AppendFormat(";{0}", System.IO.Path.GetDirectoryName(filepath));
                }
            }
            catch
            {
                // ignore if MergedFiles does not exist
            }

            var quantitationMethodBySource = new Dictionary <int, Embedder.QuantitationConfiguration>();
            var xicConfigBySource          = new Dictionary <int, Embedder.XICConfiguration> {
                { 0, _defaultXicConfig }
            };

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                int id     = (int)row.Cells[idColumn.Index].Value;
                var method = QuantitationMethodForRow(row.Index);

                if (IsLabelFree(method))
                {
                    xicConfigBySource[id]          = (Embedder.XICConfiguration)row.Cells[quantitationSettingsColumn.Index].Value;
                    quantitationMethodBySource[id] = new Embedder.QuantitationConfiguration(QuantitationMethod.LabelFree, _defaultIsobaricConfig.ToString());
                }
                else if (IsIsobaric(method))
                {
                    quantitationMethodBySource[id] = (Embedder.QuantitationConfiguration)row.Cells[quantitationSettingsColumn.Index].Value;
                }
            }

            okButton.Text   = "Cancel";
            EmbedInProgress = true;

            new Thread(() =>
            {
                try
                {
                    var ilr = new IterationListenerRegistry();
                    ilr.addListener(new EmbedderIterationListener(this), 1);

                    var tempFolder      = string.Empty;
                    var splitSourceList = new List <List <string> >();
                    if (quantitationMethodBySource.Any(x => IsLabelFree(x.Value.QuantitationMethod)) && xicConfigBySource.Any(x => x.Value.AlignRetentionTime))
                    {
                        tempFolder      = getTempFolder();
                        splitSourceList = GetRTAlignGroups();
                    }

                    string idpDbFilepath = session.Connection.GetDataSource();
                    if (embedScanTimeOnlyBox.Checked)
                    {
                        Embedder.EmbedScanTime(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, ilr);
                    }
                    else
                    {
                        Embedder.Embed(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, ilr);
                    }

                    if (quantitationMethodBySource.Any(x => IsLabelFree(x.Value.QuantitationMethod)))
                    {
                        BeginInvoke(new MethodInvoker(() => ModeandDefaultPanel.Visible = false));
                        if (xicConfigBySource.Any(x => x.Value.AlignRetentionTime))
                        {
                            try
                            {
                                RTAlignPreparations(splitSourceList, tempFolder);
                                foreach (var kvp in xicConfigBySource)
                                {
                                    kvp.Value.RTFolder = tempFolder;
                                }
                            }
                            catch (Exception rtError)
                            {
                                MessageBox.Show("Error: Cannot prepare RT alignment. Skipping to next stage." +
                                                Environment.NewLine + rtError.Message);
                                foreach (var kvp in xicConfigBySource)
                                {
                                    kvp.Value.AlignRetentionTime = false;
                                }
                            }
                        }

                        Embedder.EmbedMS1Metrics(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, xicConfigBySource, ilr);
                        if (!string.IsNullOrEmpty(tempFolder) && Directory.Exists(tempFolder))
                        {
                            Directory.Delete(tempFolder, true);
                        }
                        BeginInvoke(new MethodInvoker(() => ModeandDefaultPanel.Visible = true));
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("QuantitationConfiguration"))
                    {
                        string message = ex.Message.Replace("[QuantitationConfiguration] ", "");
                        message        = Char.ToUpper(message[0]) + message.Substring(1);
                        MessageBox.Show(message);
                    }
                    else if (ex.Message.Contains("no filepath"))
                    {
                        bool multipleMissingFilepaths = ex.Message.Contains("\n");
                        string missingFilepaths       = ex.Message.Replace("\n", "\r\n");
                        missingFilepaths = missingFilepaths.Replace("[embed] no", "No");
                        missingFilepaths = missingFilepaths.Replace("[embedScanTime] no", "No");
                        MessageBox.Show(missingFilepaths + "\r\n\r\nCheck that " +
                                        (multipleMissingFilepaths ? "these source files" : "this source file") +
                                        " can be found in the search path with one of the specified extensions.");
                    }
                    else
                    {
                        Program.HandleException(ex);
                    }
                }
                BeginInvoke(new MethodInvoker(() => Refresh()));
            }).Start();
        }
Пример #8
0
        public override void Refresh()
        {
            Text = "Embed Subset Spectra";
            Application.UseWaitCursor = false;

            dataGridView.SuspendLayout();
            dataGridView.Rows.Clear();

            var rows = session.CreateSQLQuery(
                "SELECT ss.Id, Name, COUNT(s.Id), IFNULL((SELECT LENGTH(MsDataBytes) FROM SpectrumSourceMetadata WHERE Id=ss.Id), 0), MIN(IFNULL(s.ScanTimeInSeconds, 0)), QuantitationMethod, IFNULL(QuantitationSettings, '') " +
                "FROM SpectrumSource ss " +
                "JOIN UnfilteredSpectrum s ON ss.Id=Source " +
                "GROUP BY ss.Id")
                       .List <object[]>()
                       .Select(o => new
            {
                Id                      = Convert.ToInt32(o[0]),
                Name                    = (string)o[1],
                Spectra                 = Convert.ToInt32(o[2]),
                EmbeddedSize            = Convert.ToInt32(o[3]),
                MinScanTime             = Convert.ToDouble(o[4]),
                QuantitationMethodIndex = Convert.ToInt32(o[5]),
                QuantitationSettings    = (string)o[6]
            });

            hasEmbeddedSources = hasNonEmbeddedSources = false;

            _isobaricConfigBySource.Clear();
            _xicConfigBySource.Clear();

            foreach (var row in rows)
            {
                string status;
                if (row.EmbeddedSize > 0)
                {
                    status             = String.Format("{0} spectra embedded ({1} bytes)", row.Spectra, row.EmbeddedSize);
                    hasEmbeddedSources = true;
                }
                else if (row.QuantitationMethodIndex != 0)
                {
                    status                = String.Format("{0} spectra with quantitation", row.Spectra);
                    hasEmbeddedSources    = true;
                    hasNonEmbeddedSources = true;
                }
                else if (row.MinScanTime > 0)
                {
                    status                = String.Format("{0} spectra with scan times", row.Spectra);
                    hasEmbeddedSources    = true;
                    hasNonEmbeddedSources = true;
                }
                else
                {
                    status = "not embedded";
                    hasNonEmbeddedSources = true;
                }

                var quantitationMethod = (QuantitationMethod)row.QuantitationMethodIndex;

                if (IsLabelFree(quantitationMethod))
                {
                    var savedSettings = new Embedder.XICConfiguration(row.QuantitationSettings);
                    _xicConfigBySource[row.Id] = savedSettings;
                    dataGridView.Rows.Add(row.Id, row.Name, status, quantitationMethodColumn.Items[row.QuantitationMethodIndex], savedSettings);
                }
                else if (IsIsobaric(quantitationMethod))
                {
                    var savedSettings = new Embedder.QuantitationConfiguration(quantitationMethod, row.QuantitationSettings);
                    _isobaricConfigBySource[row.Id] = savedSettings;
                    dataGridView.Rows.Add(row.Id, row.Name, status, quantitationMethodColumn.Items[row.QuantitationMethodIndex], savedSettings);
                }
                else
                {
                    dataGridView.Rows.Add(row.Id, row.Name, status, quantitationMethodColumn.Items[row.QuantitationMethodIndex], "n/a");
                }
            }

            dataGridView.ResumeLayout();

            if (dataGridView.Rows.Cast <DataGridViewRow>().Any(x => x.Cells[quantitationMethodColumn.Index].Value.ToString() != "None"))
            {
                embedScanTimeOnlyBox.Text = "Embed scan times and quantitation only";
            }
            else
            {
                embedScanTimeOnlyBox.Text = "Embed scan times only";
            }

            deleteAllButton.Enabled = hasEmbeddedSources;
            embedAllButton.Enabled  = hasNonEmbeddedSources;
            okButton.Text           = "Close";
            okButton.Enabled        = true;

            CancelRequested = false;
            EmbedInProgress = false;

            if (TaskbarManager.IsPlatformSupported)
            {
                TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress);
            }

            base.Refresh();
        }
Пример #9
0
        protected override void OnLoad (EventArgs e)
        {
            searchPathTextBox.Text = String.Join(";", Util.StringCollectionToStringArray(Properties.Settings.Default.SourcePaths));
            extensionsTextBox.Text = Properties.Settings.Default.SourceExtensions;
            embeddedChanges = false;

            // TODO: set these from global defaults?
            _defaultIsobaricConfig = new Embedder.QuantitationConfiguration() { QuantitationMethod = QuantitationMethod.ITRAQ4plex };
            _defaultXicConfig = new Embedder.XICConfiguration();

            _isobaricConfigBySource = new Dictionary<int, Embedder.QuantitationConfiguration>();
            _xicConfigBySource = new Dictionary<int, Embedder.XICConfiguration>();

            CancelRequested = false;
            EmbedInProgress = false;

            if (Owner != null && StartPosition == FormStartPosition.CenterParent)
                Location = new Point(Owner.Location.X + Owner.Width / 2 - Width / 2,
                                     Owner.Location.Y + Owner.Height / 2 - Height / 2);

            base.OnLoad(e);

            Refresh();
        }
Пример #10
0
        private void dataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var maxQValue = 0.05;
            var mostRecentFilter = session.Query<PersistentDataFilter>().OrderByDescending(o => o.Id).FirstOrDefault();
            if (mostRecentFilter != null)
                maxQValue = mostRecentFilter.MaximumQValue;

            if (e.ColumnIndex == quantitationSettingsColumn.Index)
            {
                var row = dataGridView.Rows[e.RowIndex];
                var method = QuantitationMethodForRow(e.RowIndex);
                if (method == QuantitationMethod.None)
                    return;

                var currentXicConfig = new Embedder.XICConfiguration();
                var currentQuantitationConfig = new Embedder.QuantitationConfiguration();
                if (IsLabelFree(method))
                {
                    currentXicConfig = (row.Cells[quantitationSettingsColumn.Index].Value as Embedder.XICConfiguration) ?? currentXicConfig;

                    var quantSettingsForm = new QuantitationSettingsForm((row.Cells[quantitationSettingsColumn.Index].Value as Embedder.XICConfiguration), _defaultIsobaricConfig, maxQValue);
                    if (quantSettingsForm.ShowDialog() == DialogResult.OK)
                    {
                        row.Cells[quantitationSettingsColumn.Index].Value = quantSettingsForm.XicConfig;
                        _xicConfigBySource[e.RowIndex] = quantSettingsForm.XicConfig;
                    }
                }
                else if (IsIsobaric(method))
                {
                    currentQuantitationConfig = (row.Cells[quantitationSettingsColumn.Index].Value as Embedder.QuantitationConfiguration) ?? currentQuantitationConfig;

                    var quantSettingsForm = new QuantitationSettingsForm(_defaultXicConfig, (row.Cells[quantitationSettingsColumn.Index].Value as Embedder.QuantitationConfiguration), maxQValue);
                    if (quantSettingsForm.ShowDialog() == DialogResult.OK)
                    {
                        row.Cells[quantitationSettingsColumn.Index].Value = quantSettingsForm.IsobaricConfig;
                        _isobaricConfigBySource[e.RowIndex] = quantSettingsForm.IsobaricConfig;
                    }
                }
            }
        }
Пример #11
0
        private void defaultXICSettingsButton_Click(object sender, EventArgs e)
        {
            var maxQValue = 0.05;
            var mostRecentFilter = session.Query<PersistentDataFilter>().OrderByDescending(o => o.Id).FirstOrDefault();
            if (mostRecentFilter != null)
                maxQValue = mostRecentFilter.MaximumQValue;

            var quantitationSettingsForm = new QuantitationSettingsForm(_defaultXicConfig, _defaultIsobaricConfig, maxQValue);
            if (quantitationSettingsForm.ShowDialog() == DialogResult.OK)
            {
                foreach (DataGridViewRow row in dataGridView.Rows)
                {
                    var method = QuantitationMethodForRow(row.Index);
                    if (IsLabelFree(method))
                        row.Cells[quantitationSettingsColumn.Index].Value = quantitationSettingsForm.XicConfig;
                    else if (IsIsobaric(method))
                        row.Cells[quantitationSettingsColumn.Index].Value = quantitationSettingsForm.IsobaricConfig;
                    else
                        row.Cells[quantitationSettingsColumn.Index].Value = "n/a";
                }
                _defaultIsobaricConfig = quantitationSettingsForm.IsobaricConfig;
                _defaultXicConfig = quantitationSettingsForm.XicConfig;
            }
        }
Пример #12
0
        private void embedAllButton_Click (object sender, EventArgs e)
        {
            var searchPath = new StringBuilder(searchPathTextBox.Text);
            string extensions = extensionsTextBox.Text;
            Application.UseWaitCursor = true;
            deleteAllButton.Enabled = embedAllButton.Enabled = false;
            embeddedChanges = true;

            try
            {
                // add location of original idpDBs to the search path
                var mergedFilepaths = session.CreateSQLQuery("SELECT DISTINCT Filepath FROM MergedFiles").List<string>();
                foreach (var filepath in mergedFilepaths)
                    searchPath.AppendFormat(";{0}", System.IO.Path.GetDirectoryName(filepath));
            }
            catch
            {
                // ignore if MergedFiles does not exist
            }

            var quantitationMethodBySource = new Dictionary<int, Embedder.QuantitationConfiguration>();
            var xicConfigBySource = new Dictionary<int, Embedder.XICConfiguration>{{0, _defaultXicConfig}};

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                int id = (int) row.Cells[idColumn.Index].Value;
                var method = QuantitationMethodForRow(row.Index);

                if (IsLabelFree(method))
                {
                    xicConfigBySource[id] = (Embedder.XICConfiguration) row.Cells[quantitationSettingsColumn.Index].Value;
                    quantitationMethodBySource[id] = new Embedder.QuantitationConfiguration(QuantitationMethod.LabelFree, _defaultIsobaricConfig.ToString());
                }
                else if (IsIsobaric(method))
                    quantitationMethodBySource[id] = (Embedder.QuantitationConfiguration) row.Cells[quantitationSettingsColumn.Index].Value;
            }

            okButton.Text = "Cancel";
            EmbedInProgress = true;

            new Thread(() =>
            {
                try
                {
                    var ilr = new IterationListenerRegistry();
                    ilr.addListener(new EmbedderIterationListener(this), 1);

                    var tempFolder = string.Empty;
                    var splitSourceList = new List<List<string>>();
                    if (quantitationMethodBySource.Any(x => IsLabelFree(x.Value.QuantitationMethod)) && xicConfigBySource.Any(x => x.Value.AlignRetentionTime))
                    {
                        tempFolder = getTempFolder();
                        splitSourceList = GetRTAlignGroups();
                    }

                    string idpDbFilepath = session.Connection.GetDataSource();
                    if (embedScanTimeOnlyBox.Checked)
                        Embedder.EmbedScanTime(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, ilr);
                    else
                        Embedder.Embed(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, ilr);

                    if (quantitationMethodBySource.Any(x => IsLabelFree(x.Value.QuantitationMethod)))
                    {
                        BeginInvoke(new MethodInvoker(() => ModeandDefaultPanel.Visible = false));
                        if (xicConfigBySource.Any(x => x.Value.AlignRetentionTime))
                        {
                            try
                            {
                                RTAlignPreparations(splitSourceList, tempFolder);
                                foreach (var kvp in xicConfigBySource)
                                    kvp.Value.RTFolder = tempFolder;
                            }
                            catch (Exception rtError)
                            {
                                MessageBox.Show("Error: Cannot prepare RT alignment. Skipping to next stage." +
                                                Environment.NewLine + rtError.Message);
                                foreach (var kvp in xicConfigBySource)
                                    kvp.Value.AlignRetentionTime = false;
                            }
                        }

                        Embedder.EmbedMS1Metrics(idpDbFilepath, searchPath.ToString(), extensions, quantitationMethodBySource, xicConfigBySource, ilr);
                        if (!string.IsNullOrEmpty(tempFolder) && Directory.Exists(tempFolder))
                            Directory.Delete(tempFolder,true);
                        BeginInvoke(new MethodInvoker(() => ModeandDefaultPanel.Visible = true));
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("QuantitationConfiguration"))
                    {
                        string message = ex.Message.Replace("[QuantitationConfiguration] ", "");
                        message = Char.ToUpper(message[0]) + message.Substring(1);
                        MessageBox.Show(message);
                    }
                    else if (ex.Message.Contains("no filepath"))
                    {
                        bool multipleMissingFilepaths = ex.Message.Contains("\n");
                        string missingFilepaths = ex.Message.Replace("\n", "\r\n");
                        missingFilepaths = missingFilepaths.Replace("[embed] no", "No");
                        missingFilepaths = missingFilepaths.Replace("[embedScanTime] no", "No");
                        MessageBox.Show(missingFilepaths + "\r\n\r\nCheck that " +
                                        (multipleMissingFilepaths ? "these source files" : "this source file") +
                                        " can be found in the search path with one of the specified extensions.");
                    }
                    else
                        Program.HandleException(ex);
                }
                BeginInvoke(new MethodInvoker(() => Refresh()));
            }).Start();
        }
Пример #13
0
        public override void Refresh ()
        {
            Text = "Embed Subset Spectra";
            Application.UseWaitCursor = false;

            dataGridView.SuspendLayout();
            dataGridView.Rows.Clear();

            var rows = session.CreateSQLQuery(
                "SELECT ss.Id, Name, COUNT(s.Id), IFNULL((SELECT LENGTH(MsDataBytes) FROM SpectrumSourceMetadata WHERE Id=ss.Id), 0), MIN(IFNULL(s.ScanTimeInSeconds, 0)), QuantitationMethod, IFNULL(QuantitationSettings, '') " +
                "FROM SpectrumSource ss " +
                "JOIN UnfilteredSpectrum s ON ss.Id=Source " +
                "GROUP BY ss.Id")
                              .List<object[]>()
                              .Select(o => new
                                  {
                                      Id = Convert.ToInt32(o[0]),
                                      Name = (string) o[1],
                                      Spectra = Convert.ToInt32(o[2]),
                                      EmbeddedSize = Convert.ToInt32(o[3]),
                                      MinScanTime = Convert.ToDouble(o[4]),
                                      QuantitationMethodIndex = Convert.ToInt32(o[5]),
                                      QuantitationSettings = (string) o[6]
                                  });

            hasEmbeddedSources = hasNonEmbeddedSources = false;

            _isobaricConfigBySource.Clear();
            _xicConfigBySource.Clear();

            foreach (var row in rows)
            {
                string status;
                if (row.EmbeddedSize > 0)
                {
                    status = String.Format("{0} spectra embedded ({1} bytes)", row.Spectra, row.EmbeddedSize);
                    hasEmbeddedSources = true;
                }
                else if (row.QuantitationMethodIndex != 0)
                {
                    status = String.Format("{0} spectra with quantitation", row.Spectra);
                    hasEmbeddedSources = true;
                    hasNonEmbeddedSources = true;
                }
                else if (row.MinScanTime > 0)
                {
                    status = String.Format("{0} spectra with scan times", row.Spectra);
                    hasEmbeddedSources = true;
                    hasNonEmbeddedSources = true;
                }
                else
                {
                    status = "not embedded";
                    hasNonEmbeddedSources = true;
                }

                var quantitationMethod = (QuantitationMethod) row.QuantitationMethodIndex;

                if (IsLabelFree(quantitationMethod))
                {
                    var savedSettings = new Embedder.XICConfiguration(row.QuantitationSettings);
                    _xicConfigBySource[row.Id] = savedSettings;
                    dataGridView.Rows.Add(row.Id, row.Name, status, quantitationMethodColumn.Items[row.QuantitationMethodIndex], savedSettings);
                }
                else if (IsIsobaric(quantitationMethod))
                {
                    var savedSettings = new Embedder.QuantitationConfiguration(quantitationMethod, row.QuantitationSettings);
                    _isobaricConfigBySource[row.Id] = savedSettings;
                    dataGridView.Rows.Add(row.Id, row.Name, status, quantitationMethodColumn.Items[row.QuantitationMethodIndex], savedSettings);
                }
                else
                    dataGridView.Rows.Add(row.Id, row.Name, status, quantitationMethodColumn.Items[row.QuantitationMethodIndex], "n/a");
            }

            dataGridView.ResumeLayout();

            if (dataGridView.Rows.Cast<DataGridViewRow>().Any(x => x.Cells[quantitationMethodColumn.Index].Value.ToString() != "None"))
                embedScanTimeOnlyBox.Text = "Embed scan times and quantitation only";
            else
                embedScanTimeOnlyBox.Text = "Embed scan times only";

            deleteAllButton.Enabled = hasEmbeddedSources;
            embedAllButton.Enabled = hasNonEmbeddedSources;
            okButton.Text = "Close";
            okButton.Enabled = true;

            CancelRequested = false;
            EmbedInProgress = false;

            if (TaskbarManager.IsPlatformSupported)
                TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress);

            base.Refresh();
        }
        private void StartButton_Click(object sender, EventArgs e)
        {
            var cloValue = (double)ChromatogramMzLowerOffsetValueBox.Value;
            var cloUnits = (MZTolerance.Units)ChromatogramMzLowerOffsetUnitsBox.SelectedIndex;
            var cuoValue = (double)ChromatogramMzUpperOffsetValueBox.Value;
            var cuoUnits = (MZTolerance.Units)ChromatogramMzUpperOffsetUnitsBox.SelectedIndex;
            var rtMax = (int)Math.Round(RTTolUpperBox.Value);
            var rtMin = (int)Math.Round(RTTolLowerBox.Value);
            var maMax = (int)Math.Round(MonoisotopicAdjustmentMaxBox.Value);
            var maMin = (int)Math.Round(MonoisotopicAdjustmentMinBox.Value);
            XicConfig = new Embedder.XICConfiguration{
                ChromatogramMzLowerOffset = new MZTolerance(cloValue, cloUnits),
                ChromatogramMzUpperOffset = new MZTolerance(cuoValue, cuoUnits),
                RetentionTimeLowerTolerance = rtMin,
                RetentionTimeUpperTolerance = rtMax,
                MonoisotopicAdjustmentMax = maMax,
                MonoisotopicAdjustmentMin = maMin,
                MaxQValue = _maxQValue,
                AlignRetentionTime = RTAlignBox.Checked};

            IsobaricConfig = new Embedder.QuantitationConfiguration
            {
                QuantitationMethod = IsobaricConfig.QuantitationMethod,
                ReporterIonMzTolerance = new MZTolerance((double) reporterIonToleranceUpDown.Value, (MZTolerance.Units) reporterIonToleranceUnits.SelectedIndex),
                NormalizeIntensities = normalizeReporterIonsCheckBox.Checked
            };

            DialogResult = DialogResult.OK;
        }