From 6dd10e0aaee5321c9f724925ff87450381e9c470 Mon Sep 17 00:00:00 2001 From: Nic Bollis Date: Wed, 25 Sep 2024 11:55:18 -0500 Subject: [PATCH] MetaDraw Bug Fix(es) and QOL Update (#2420) * Updated to MzLib 1.0.548 and fixed custom ions in search tasks * reverted calibration task change * merged in master bbbyy * Spectral Library from Command Line (#2386) * Updated to MzLib 1.0.548 and fixed custom ions in search tasks * reverted calibration task change * merged in master bbbyy * Enabled Library Loading from command line * Adjusted MetaDrawSettings IO to default to default values instead of a uniform default * Tested MetaDraw Settings loading under numerous conditions * Fixed crash on MetaDraw tab switch while selecting ambiguous result * fixed crash on ambiguous selected on chimera tab to child scan * general cleanup * Adjusted test data to expand code coverage * Added ability to select your own tolerance for MetaDraw fragmentation reanalysis --------- Co-authored-by: trishorts --- MetaMorpheus/GUI/MetaDraw/MetaDraw.xaml.cs | 53 +++++++++--- .../GUI/Views/FragmentReanalysisControl.xaml | 56 ++++++++----- .../FragmentationReanalysisViewModel.cs | 14 +++- .../GuiFunctions/MetaDraw/MetaDrawLogic.cs | 2 +- .../GuiFunctions/MetaDraw/MetaDrawSettings.cs | 30 ++++++- .../ViewModels/MetaDrawSettingsViewModel.cs | 5 +- ...ingsSavedEditedForTestCoverageFailures.xml | 2 + .../Test/MetaDraw/FragmentReanalysis.cs | 20 ++++- .../MetaDraw/MetaDrawSettingsAndViewsTest.cs | 84 ++++++++++++++++++- 9 files changed, 220 insertions(+), 46 deletions(-) diff --git a/MetaMorpheus/GUI/MetaDraw/MetaDraw.xaml.cs b/MetaMorpheus/GUI/MetaDraw/MetaDraw.xaml.cs index c23820447..4a524c6d3 100644 --- a/MetaMorpheus/GUI/MetaDraw/MetaDraw.xaml.cs +++ b/MetaMorpheus/GUI/MetaDraw/MetaDraw.xaml.cs @@ -191,14 +191,16 @@ private void dataGridScanNums_SelectedCellsChanged(object sender, SelectedCellsC // Chimera plotter if (MetaDrawTabControl.SelectedContent is Grid { Name: "chimeraPlotGrid" }) { + ClearPresentationArea(); + chimeraPlot.Visibility = Visibility.Visible; List chimericPsms = MetaDrawLogic.FilteredListOfPsms .Where(p => p.Ms2ScanNumber == psm.Ms2ScanNumber && p.FileNameWithoutExtension == psm.FileNameWithoutExtension).ToList(); MetaDrawLogic.DisplayChimeraSpectra(chimeraPlot, chimericPsms, out List error); if (error != null && error.Count > 0) Debugger.Break(); - ClearPresentationArea(); wholeSequenceCoverageHorizontalScroll.Visibility = Visibility.Collapsed; - + AmbiguousWarningTextBlocks.Visibility = Visibility.Collapsed; + AmbiguousSequenceOptionBox.Visibility = Visibility.Collapsed; if (MetaDrawSettings.ShowLegend) { @@ -217,7 +219,27 @@ private void dataGridScanNums_SelectedCellsChanged(object sender, SelectedCellsC // Clicking the research button on an ambiguous psm => research with new ions if (psm.FullSequence.Contains('|') && (sender.ToString() == "System.Object" || sender is FragmentationReanalysisViewModel)) { - psm = (PsmFromTsv)AmbiguousSequenceOptionBox.SelectedItem; + // From chimeric scan view to child scan view with ambiguous selected + if (AmbiguousSequenceOptionBox.SelectedItem == null) + { + // set to first and break the loop if casted successfully + foreach (var ambiguousResult in AmbiguousSequenceOptionBox.Items) + { + psm = ambiguousResult as PsmFromTsv; + if (psm != null) + break; + } + + AmbiguousWarningTextBlocks.Visibility = Visibility.Collapsed; + AmbiguousSequenceOptionBox.Visibility = Visibility.Visible; + AmbiguousSequenceOptionBox.SelectedItem = psm; + } + // selecting a different ambiguous result from the combobox in child scan view + else + { + psm = (PsmFromTsv)AmbiguousSequenceOptionBox.SelectedItem; + } + if (FragmentationReanalysisViewModel.Persist || sender is FragmentationReanalysisViewModel) { oldMatchedIons = psm.MatchedIons; @@ -918,8 +940,15 @@ private void AmbiguousSequenceOptionBox_SelectionChanged(object sender, Selectio SetSequenceDrawingPositionSettings(true); object obj = new object(); if (AmbiguousSequenceOptionBox.Items.Count > 0) + { dataGridScanNums_SelectedCellsChanged(obj, null); - MetaDrawLogic.DisplaySequences(stationarySequenceCanvas, scrollableSequenceCanvas, sequenceAnnotationCanvas, psm); + MetaDrawLogic.DisplaySequences(stationarySequenceCanvas, scrollableSequenceCanvas, + sequenceAnnotationCanvas, psm); + } + else + { + AmbiguousSequenceOptionBox.Visibility = Visibility.Hidden; + } } /// @@ -1033,6 +1062,7 @@ private void MetaDrawTabControl_OnSelectionChanged(object sender, SelectionChang if (e.RemovedItems.Count > 0 && ((TabItem)e.RemovedItems[0]).Name == "ChimeraScanPlot") { MetaDrawLogic.FilterPsms(); + ClearPresentationArea(); // reselect what was selected if (selectedPsm != null && MetaDrawLogic.FilteredListOfPsms.Contains(selectedPsm)) @@ -1047,12 +1077,15 @@ private void MetaDrawTabControl_OnSelectionChanged(object sender, SelectionChang if (e.AddedItems.Count > 0 && ((TabItem)e.AddedItems[0]).Name == "ChimeraScanPlot") { MetaDrawLogic.FilterPsmsToChimerasOnly(); + ClearPresentationArea(); - // reselect what was selected - if (selectedPsm == null || !MetaDrawLogic.FilteredListOfPsms.Contains(selectedPsm)) return; - int psmIndex = MetaDrawLogic.FilteredListOfPsms.IndexOf(selectedPsm); - dataGridScanNums.SelectedIndex = psmIndex; - dataGridScanNums_SelectedCellsChanged(new object(), null); + // reselect what was selected if possible + if (selectedPsm != null && MetaDrawLogic.FilteredListOfPsms.Contains(selectedPsm)) + { + int psmIndex = MetaDrawLogic.FilteredListOfPsms.IndexOf(selectedPsm); + dataGridScanNums.SelectedIndex = psmIndex; + dataGridScanNums_SelectedCellsChanged(new object(), null); + } } } @@ -1066,11 +1099,11 @@ private void ClearPresentationArea() DrawnSequence.ClearCanvas(map); DrawnSequence.ClearCanvas(sequenceText); DrawnSequence.ClearCanvas(sequenceAnnotationCanvas); - plotView.Visibility = Visibility.Hidden; GrayBox.Opacity = 0; wholeSequenceCoverageHorizontalScroll.Visibility = Visibility.Collapsed; AmbiguousSequenceOptionBox.Items.Clear(); plotView.Visibility = Visibility.Hidden; + chimeraPlot.Visibility = Visibility.Hidden; if (ChimeraLegend != null) ChimeraLegend.Visibility = false; diff --git a/MetaMorpheus/GUI/Views/FragmentReanalysisControl.xaml b/MetaMorpheus/GUI/Views/FragmentReanalysisControl.xaml index 71de1ed97..e0e555126 100644 --- a/MetaMorpheus/GUI/Views/FragmentReanalysisControl.xaml +++ b/MetaMorpheus/GUI/Views/FragmentReanalysisControl.xaml @@ -18,34 +18,46 @@ - - - - - - + + + + -