Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaDraw Bug Fix(es) and QOL Update #2420

Merged
merged 24 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8be2574
Updated to MzLib 1.0.548 and fixed custom ions in search tasks
nbollis May 21, 2024
a00af8a
reverted calibration task change
nbollis May 21, 2024
22c60ba
merged in master
nbollis May 30, 2024
f4695bb
merged in master bbbyy
nbollis Jun 10, 2024
d4f8b9d
Merge branch 'smith-chem-wisc:master' into master
nbollis Jun 19, 2024
1f0dc48
merged in master
nbollis Jun 21, 2024
5c0268b
idkman
nbollis Jul 3, 2024
b7e6a0f
merged in master
nbollis Jul 16, 2024
6446d89
Merge remote-tracking branch 'upstream/master'
nbollis Jul 24, 2024
322235d
Spectral Library from Command Line (#2386)
nbollis Jul 23, 2024
8b48c95
merged in master
nbollis Aug 6, 2024
2ef973f
Merge branch 'master' of https://github.com/nbollis/MetaMorpheus
nbollis Aug 6, 2024
0abcd9b
Merge branch 'master' of https://github.com/nbollis/MetaMorpheus
nbollis Aug 7, 2024
f9030f9
merged in master
nbollis Sep 4, 2024
046067e
merged in master
nbollis Sep 17, 2024
7f3d591
Adjusted MetaDrawSettings IO to default to default values instead of …
nbollis Sep 18, 2024
76c9435
Tested MetaDraw Settings loading under numerous conditions
nbollis Sep 18, 2024
f28770a
Fixed crash on MetaDraw tab switch while selecting ambiguous result
nbollis Sep 19, 2024
8c018c8
fixed crash on ambiguous selected on chimera tab to child scan
nbollis Sep 19, 2024
3ce88b3
general cleanup
nbollis Sep 19, 2024
5a03e38
Adjusted test data to expand code coverage
nbollis Sep 19, 2024
3df63d3
Added ability to select your own tolerance for MetaDraw fragmentation…
nbollis Sep 19, 2024
04e8fc0
Merge branch 'master' into MetaDrawBugFixes
trishorts Sep 24, 2024
b17cc03
Merge branch 'master' into MetaDrawBugFixes
nbollis Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 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 @@ -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;
}
}

/// <summary>
Expand Down Expand Up @@ -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))
Expand All @@ -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);
}
}
}

Expand All @@ -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;
Expand Down
56 changes: 34 additions & 22 deletions MetaMorpheus/GUI/Views/FragmentReanalysisControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,46 @@

<!-- All options in the header -->
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>

<Button Grid.Row="0" Grid.Column="0" x:Name="SearchButton" Grid.RowSpan="2" Content="Search" VerticalAlignment="Center" Margin="5 3"
VerticalContentAlignment="Center" Click="SearchWithNewIons_OnClick"/>
<CheckBox Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Content="Persist?" VerticalAlignment="Center"
IsChecked="{Binding Persist}"
Margin="5 3" ToolTip="Research each identification as they are selected"/>
<Button Grid.Row="0" Grid.Column="0" x:Name="SearchButton" Content="Search"
VerticalAlignment="Center" Margin="5 3"
VerticalContentAlignment="Center" Click="SearchWithNewIons_OnClick" />

<StackPanel Grid.Row="0" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="Set Dissociation Type: " VerticalAlignment="Center"/>
<ComboBox x:Name="DissociationTypeComboBox" ItemsSource="{Binding DissociationTypes}"
SelectedItem="{Binding SelectedDissociationType}"
Margin="5 3" VerticalContentAlignment="Center" Width="80" />
<CheckBox Grid.Row="0" Grid.Column="1" Content="Persist?" VerticalAlignment="Center"
IsChecked="{Binding Persist}"
Margin="5 3" ToolTip="Research each identification as they are selected" />

<StackPanel Grid.Row="0" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="Set Dissociation Type: " VerticalAlignment="Center" />
<ComboBox x:Name="DissociationTypeComboBox" ItemsSource="{Binding DissociationTypes}"
SelectedItem="{Binding SelectedDissociationType}"
Margin="5 3" VerticalContentAlignment="Center" Width="80"
HorizontalContentAlignment="Center"/>
</StackPanel>

<StackPanel Grid.Row="0" Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Text="Mass Tolerance (ppm): " VerticalAlignment="Center" />
<local:DoubleTextBoxControl Text="{Binding ProductIonMassTolerance, FallbackValue=20}"
HorizontalAlignment="Center" HorizontalContentAlignment="Center"
VerticalAlignment="Center" VerticalContentAlignment="Center"
BorderThickness="1" />
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center">
<CheckBox Content="Use internal ions of minimum length " IsChecked="{Binding UseInternalIons}"
HorizontalContentAlignment="Right" VerticalAlignment="Center" />
<local:IntegerTexBoxControl Text="{Binding MinInternalIonLength, FallbackValue=10}"
HorizontalAlignment="Center" HorizontalContentAlignment="Center" IsEnabled="{Binding UseInternalIons}"
VerticalAlignment="Center" VerticalContentAlignment="Center" BorderThickness="1" />

<StackPanel Grid.Row="0" Grid.Column="4" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
<CheckBox Content="Use internal ions of minimum length " IsChecked="{Binding UseInternalIons}"
HorizontalContentAlignment="Right" VerticalAlignment="Center" />
<local:IntegerTexBoxControl Text="{Binding MinInternalIonLength, FallbackValue=10}"
HorizontalAlignment="Center" HorizontalContentAlignment="Center"
IsEnabled="{Binding UseInternalIons}"
VerticalAlignment="Center" VerticalContentAlignment="Center"
BorderThickness="1" />
</StackPanel>
</Grid>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using EngineLayer;
using iText.StyledXmlParser.Jsoup;
using MassSpectrometry;
using MzLibUtil;
using Omics;
using Omics.Fragmentation;
using Proteomics.ProteolyticDigestion;
Expand All @@ -26,6 +27,7 @@
_isProtein = isProtein;
UseInternalIons = false;
MinInternalIonLength = 10;
ProductIonMassTolerance = 20;
if (isProtein)
{
DissociationTypes = new ObservableCollection<DissociationType>(Enum.GetValues<DissociationType>()
Expand Down Expand Up @@ -91,6 +93,14 @@
set { _useInternalIons = value; OnPropertyChanged(nameof(UseInternalIons)); }
}

private double _productIonMassTolerance;

public double ProductIonMassTolerance
{
get => _productIonMassTolerance;
set { _productIonMassTolerance = value; OnPropertyChanged(nameof(ProductIonMassTolerance)); }
}

private IEnumerable<FragmentViewModel> GetPossibleProducts(bool isProtein)
{
foreach (var product in Enum.GetValues<ProductType>())
Expand Down Expand Up @@ -177,7 +187,7 @@
Omics.Fragmentation.Peptide.DissociationTypeCollection.ProductsFromDissociationType[dissociationType].ToArray()
: Omics.Fragmentation.Oligo.DissociationTypeCollection.GetRnaProductTypesFromDissociationType(dissociationType).ToArray();
}
catch (Exception e)

Check warning on line 190 in MetaMorpheus/GuiFunctions/MetaDraw/FragmentResearching/FragmentationReanalysisViewModel.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

The variable 'e' is declared but never used

Check warning on line 190 in MetaMorpheus/GuiFunctions/MetaDraw/FragmentResearching/FragmentationReanalysisViewModel.cs

View workflow job for this annotation

GitHub Actions / windows-latest

The variable 'e' is declared but never used

Check warning on line 190 in MetaMorpheus/GuiFunctions/MetaDraw/FragmentResearching/FragmentationReanalysisViewModel.cs

View workflow job for this annotation

GitHub Actions / macos-latest

The variable 'e' is declared but never used
{
_selectedDissociationType = DissociationType.HCD;
dissociationTypeProducts = isProtein ?
Expand Down Expand Up @@ -211,13 +221,15 @@

// TODO: Adjust decon params for when RNA gets incorporated
var commonParams = new CommonParameters();
if (Math.Abs(commonParams.ProductMassTolerance.Value - ProductIonMassTolerance) > 0.00001)
commonParams.ProductMassTolerance = new PpmTolerance(ProductIonMassTolerance);

var specificMass = new Ms2ScanWithSpecificMass(ms2Scan, psmToRematch.PrecursorMz,
psmToRematch.PrecursorCharge, psmToRematch.FileNameWithoutExtension, commonParams);

return MetaMorpheusEngine.MatchFragmentIons(specificMass, allProducts, commonParams, false)
.Union(psmToRematch.MatchedIons.Where(p => _productsToUse.Contains(p.NeutralTheoreticalProduct.ProductType)))
.ToList();

}
}
}
2 changes: 1 addition & 1 deletion MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ public void FilterPsmsToChimerasOnly()
{
FilteredListOfPsms.Clear();

var filteredChimericPsms = ChimericPsms.Where(p => MetaDrawSettings.FilterAcceptsPsm(p));
var filteredChimericPsms = ChimericPsms.Where(MetaDrawSettings.FilterAcceptsPsm);
foreach (var psm in filteredChimericPsms)
{
if (filteredChimericPsms.Count(p => p.Ms2ScanNumber == psm.Ms2ScanNumber && p.FileNameWithoutExtension == psm.FileNameWithoutExtension) > 1)
Expand Down
30 changes: 27 additions & 3 deletions MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,9 @@
/// <summary>
/// Loads in settings based upon SettingsSnapshot parameter
/// </summary>
public static void LoadSettings(MetaDrawSettingsSnapshot settings)
public static void LoadSettings(MetaDrawSettingsSnapshot settings, out bool flaggedErrorOnRead)
{
flaggedErrorOnRead = false;
DisplayIonAnnotations = settings.DisplayIonAnnotations;
AnnotateMzValues = settings.AnnotateMzValues;
AnnotateCharges = settings.AnnotateCharges;
Expand Down Expand Up @@ -504,11 +505,15 @@

break;
}
default:
throw new MetaMorpheusException("Cannot parse Product Ion Color values");
}
}
catch (Exception e)

Check warning on line 512 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

The variable 'e' is declared but never used

Check warning on line 512 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / windows-latest

The variable 'e' is declared but never used

Check warning on line 512 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / macos-latest

The variable 'e' is declared but never used
{
Debugger.Break();
SetDefaultProductTypeColors();
flaggedErrorOnRead = true;
}

try // Beta Product Type Colors
Expand Down Expand Up @@ -537,11 +542,15 @@

break;
}
default:
throw new MetaMorpheusException("Cannot parse Beta Product Ion Color values");
}
}
catch (Exception e)

Check warning on line 549 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

The variable 'e' is declared but never used

Check warning on line 549 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / windows-latest

The variable 'e' is declared but never used

Check warning on line 549 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / macos-latest

The variable 'e' is declared but never used
{
Debugger.Break();
SetDefaultBetaProductTypeColors();
flaggedErrorOnRead = true;
}

try // Modification Type Colors
Expand Down Expand Up @@ -569,11 +578,15 @@

break;
}
default:
throw new MetaMorpheusException("Cannot parse Modification Color values");
}
}
catch (Exception e)

Check warning on line 585 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

The variable 'e' is declared but never used

Check warning on line 585 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / windows-latest

The variable 'e' is declared but never used

Check warning on line 585 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / macos-latest

The variable 'e' is declared but never used
{
Debugger.Break();
SetDefaultModificationColors();
flaggedErrorOnRead = true;
}

try // Coverage Type Colors
Expand All @@ -598,18 +611,25 @@
if (CoverageTypeToColor.ContainsKey(key))
CoverageTypeToColor[key] = DrawnSequence.ParseOxyColorFromName(savedProductType.Split(',')[1]);
}

break;
}
default:
throw new MetaMorpheusException("Cannot parse Sequence Coverage color values");

}
}
catch (Exception e)

Check warning on line 621 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

The variable 'e' is declared but never used

Check warning on line 621 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / windows-latest

The variable 'e' is declared but never used

Check warning on line 621 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / macos-latest

The variable 'e' is declared but never used
{
Debugger.Break();
Debugger.Break();
SetDefaultCoverageTypeColors();
flaggedErrorOnRead = true;
}

try // Spectrum Descriptors
{
if (!settings.SpectrumDescriptionValues.Any())
throw new MetaMorpheusException("Cannot parse Spectrum Descriptor values");

var firstSplit = settings.SpectrumDescriptionValues.First().Split(',');
switch (firstSplit.Length)
{
Expand All @@ -633,11 +653,15 @@

break;
}
default:
throw new MetaMorpheusException("Cannot parse Spectrum Descriptor values");
}
}
catch (Exception e)

Check warning on line 660 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

The variable 'e' is declared but never used

Check warning on line 660 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / windows-latest

The variable 'e' is declared but never used

Check warning on line 660 in MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs

View workflow job for this annotation

GitHub Actions / macos-latest

The variable 'e' is declared but never used
{
Debugger.Break();
SetDefaultProductTypeColors();
flaggedErrorOnRead = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ public void LoadSettings()
{
MetaDrawSettingsSnapshot settings = null;
settings = XmlReaderWriter.ReadFromXmlFile<MetaDrawSettingsSnapshot>(SettingsPath);
MetaDrawSettings.LoadSettings(settings);
MetaDrawSettings.LoadSettings(settings, out bool flaggedErrorOnRead);

if (flaggedErrorOnRead)
SaveAsDefault();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<string>true</string>
<string>true</string>
<string>true</string>
<string>gobbledygook</string>
</SpectrumDescriptionValues>
<ProductTypeToColorValues>
<string>Aqua</string>
Expand Down Expand Up @@ -3823,6 +3824,7 @@
<string>Hullabaloo</string>
<string>Aqua</string>
<string>Aqua</string>
<string>Claptrap</string>
</CoverageTypeToColorValues>
<UnannotatedPeakColor>LightGray</UnannotatedPeakColor>
<InternalIonColor>Purple</InternalIonColor>
Expand Down
Loading
Loading