Example #1
0
 public void Add()
 {
     using (var dlg = new AddPeakCompareDlg(Document, _peakBoundaryList))
     {
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             _peakBoundaryList.Add(dlg.BoundaryComparer);
             UpdateCheckedList();
             UpdateAll();
         }
     }
 }
Example #2
0
        public ComparePeakBoundaries EditItem(Control owner, ComparePeakBoundaries item,
                                              IEnumerable <ComparePeakBoundaries> existing, object tag)
        {
            var document = tag as SrmDocument;

            using (var dlg = new AddPeakCompareDlg(document, item, existing))
            {
                return(dlg.ShowDialog(owner) == DialogResult.OK ?
                       dlg.BoundaryComparer :
                       default(ComparePeakBoundaries));
            }
        }
        private void TestErrors(AddPeakCompareDlg addPeakCompareDlg, string peakBoundariesFile)
        {
            // 1. Blank name gives error
            RunUI(() => addPeakCompareDlg.IsModel = false);
            MessageDlgError(addPeakCompareDlg.OkDialog, Resources.AddPeakCompareDlg_OkDialog_Comparison_name_cannot_be_empty_);
            // 2. Blank file path gives error
            RunUI(() => addPeakCompareDlg.FileName = "OpenSwathNew");
            MessageDlgError(addPeakCompareDlg.OkDialog, Resources.AddPeakCompareDlg_OkDialog_File_path_cannot_be_empty_);
            // 3. Non-existent file gives error
            RunUI(() => addPeakCompareDlg.FilePath = "bad_file_path");
            MessageDlgError(addPeakCompareDlg.OkDialog, Resources.AddPeakCompareDlg_OkDialog_File_path_field_must_contain_a_path_to_a_valid_file_);
            // 4. Same name as existing gives error
            RunUI(() => addPeakCompareDlg.FileName = "OpenSwath");
            RunUI(() => addPeakCompareDlg.FilePath = peakBoundariesFile);
            MessageDlgError(addPeakCompareDlg.OkDialog, Resources.AddPeakCompareDlg_OkDialog_There_is_already_an_imported_file_with_the_current_name___Please_choose_another_name);
            // 5. Attempt to re-load same model gives error
            RunUI(() => addPeakCompareDlg.IsModel = true);
            RunUI(() => addPeakCompareDlg.PeakScoringModelSelected = "full model");
            MessageDlgError(addPeakCompareDlg.OkDialog, Resources.AddPeakCompareDlg_OkDialog_The_selected_model_is_already_included_in_the_list_of_comparisons__Please_choose_another_model_);
            // 6. Selecting an untrained model leads to error
            RunUI(() => addPeakCompareDlg.PeakScoringModelSelected = "untrained");
            MessageDlgError(addPeakCompareDlg.OkDialog, Resources.AddPeakCompareDlg_OkDialog_Model_must_be_trained_before_it_can_be_used_for_peak_boundary_comparison_);
            // 7. File with unreadable q value produces error
            var peakBoundariesBadQ = GetLocalizedFile("OpenSwathPeaksBadQ.csv");
            RunUI(() => addPeakCompareDlg.IsModel = false);
            RunUI(() => addPeakCompareDlg.FileName = "OpenSwathBad");
            RunUI(() => addPeakCompareDlg.FilePath = peakBoundariesBadQ);
            MessageDlgError(addPeakCompareDlg.OkDialog, string.Format(Resources.AddPeakCompareDlg_OkDialog_Error_applying_imported_peak_boundaries___0_,
                                                                      string.Format(Resources.PeakBoundsMatch_QValue_Unable_to_read_q_value_annotation_for_peptide__0__of_file__1_,
                                                                                    "APIPTALDTDSSK",
                                                                                    "napedro_L120420_007_SW")));
            // 8. File with unreadable score produces error
            var peakBoundariesBadScore = GetLocalizedFile("OpenSwathPeaksBadScore.csv");
            RunUI(() => addPeakCompareDlg.IsModel = false);
            RunUI(() => addPeakCompareDlg.FileName = "OpenSwathBad");
            RunUI(() => addPeakCompareDlg.FilePath = peakBoundariesBadScore);
            MessageDlgError(addPeakCompareDlg.OkDialog, string.Format(Resources.AddPeakCompareDlg_OkDialog_Error_applying_imported_peak_boundaries___0_,
                                                                      string.Format(Resources.PeakBoundsMatch_QValue_Unable_to_read_q_value_annotation_for_peptide__0__of_file__1_,
                                                                                    "APIPTALDTDSSK",
                                                                                    "napedro_L120420_007_SW")));
            // 9. File with missing q value column and score column produces error
            var peakBoundariesMissing = GetLocalizedFile("OpenSwathPeaksMissingQScores.csv");
            RunUI(() => addPeakCompareDlg.IsModel = false);
            RunUI(() => addPeakCompareDlg.FileName = "OpenSwathMissing");
            RunUI(() => addPeakCompareDlg.FilePath = peakBoundariesMissing);

            MessageDlgError(addPeakCompareDlg.OkDialog, string.Format(Resources.AddPeakCompareDlg_OkDialog_Error_applying_imported_peak_boundaries___0_,
                                                                      Resources.AddPeakCompareDlg_OkDialog_The_current_file_or_model_has_no_q_values_or_scores_to_analyze___Either_q_values_or_scores_are_necessary_to_compare_peak_picking_tools_));
            // 10. Empty file leads to error
            var peakBoundariesEmpty = GetLocalizedFile("OpenSwathPeaksEmpty.csv");
            RunUI(() => addPeakCompareDlg.IsModel = false);
            RunUI(() => addPeakCompareDlg.FileName = "OpenSwathEmpty");
            RunUI(() => addPeakCompareDlg.FilePath = peakBoundariesEmpty);
            MessageDlgError(addPeakCompareDlg.OkDialog, string.Format(Resources.AddPeakCompareDlg_OkDialog_Error_applying_imported_peak_boundaries___0_,
                                                                      Resources.AddPeakCompareDlg_OkDialog_The_selected_file_or_model_does_not_assign_peak_boundaries_to_any_chromatograms_in_the_document___Please_select_a_different_model_or_file_));

            // 11. Apex-based file with bad apex entry leads to error
            var peakBoundariesApex = GetLocalizedFile("OpenSwathPeaksBadApex.csv");
            RunUI(() => addPeakCompareDlg.IsModel = false);
            RunUI(() => addPeakCompareDlg.FileName = "OpenSwathBadApex");
            RunUI(() => addPeakCompareDlg.FilePath = peakBoundariesApex);
            MessageDlgError(addPeakCompareDlg.OkDialog, string.Format(Resources.AddPeakCompareDlg_OkDialog_Error_applying_imported_peak_boundaries___0_,
                                                                      string.Format(Resources.PeakBoundsMatch_PeakBoundsMatch_Unable_to_read_apex_retention_time_value_for_peptide__0__of_file__1__,
                                                                                    "DITAFDETLFR",
                                                                                    "napedro_L120420_007_SW")));
        }