Skip to content

Commit

Permalink
fixed crash on ambiguous selected on chimera tab to child scan
Browse files Browse the repository at this point in the history
  • Loading branch information
nbollis committed Sep 19, 2024
1 parent f28770a commit 8c018c8
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions MetaMorpheus/GUI/MetaDraw/MetaDraw.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PsmFromTsv> chimericPsms = MetaDrawLogic.FilteredListOfPsms
.Where(p => p.Ms2ScanNumber == psm.Ms2ScanNumber && p.FileNameWithoutExtension == psm.FileNameWithoutExtension).ToList();
MetaDrawLogic.DisplayChimeraSpectra(chimeraPlot, chimericPsms, out List<string> 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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -1041,6 +1063,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))
Expand All @@ -1055,12 +1078,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);
}
}
}

Expand All @@ -1074,11 +1100,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;
Expand Down

0 comments on commit 8c018c8

Please sign in to comment.