Skip to content

Commit 2fc4f6e

Browse files
nbollisavcarr2
andauthored
Averaging task in MetaMorpheus (#2281)
* Implemented AveragingTask in MM * Fixed runtime notification boxes and added Option to the small add task button on the Run Page * Updated default loading in with preset settings * Expanded View Model Test Coverage * Added tool tips to preset parameters * Added tests to expand coverage of SpectralAveragingParametersViewModel * Expanded test coverage * Expanded test coverage and added links to wiki * Fixed broken Tests * Fixed bug with null coalescing operator that was okay in compile time, but caused an issue in runtime. * Test comment to force build in github --------- Co-authored-by: avcarr2 <[email protected]> Co-authored-by: avcarr2 <[email protected]>
1 parent 2729265 commit 2fc4f6e

19 files changed

+1929
-36
lines changed

MetaMorpheus/GUI/App.xaml

+21
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,26 @@
3636
<Style x:Key="DataGridCenteredCellStyle" TargetType="TextBlock">
3737
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
3838
</Style>
39+
40+
<!-- GroupBoxStyle -->
41+
<Style TargetType="{x:Type GroupBox}" x:Key="GroupBoxStyle">
42+
<Setter Property="BorderBrush" Value="{StaticResource ForegroundDarkBrush}"></Setter>
43+
<Setter Property="BorderThickness" Value="2"></Setter>
44+
<Setter Property="Margin" Value="5"></Setter>
45+
</Style>
46+
47+
<!-- ValueEnteringStackPanel -->
48+
<Style TargetType="{x:Type StackPanel}" x:Key="ValueEnteringStackPanel">
49+
<Setter Property="Orientation" Value="Horizontal"></Setter>
50+
<Setter Property="Margin" Value="5"></Setter>
51+
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
52+
</Style>
53+
54+
<!-- TextBoxStyle -->
55+
<Style TargetType="{x:Type TextBox}" x:Key="TextBoxStyle">
56+
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
57+
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
58+
<Setter Property="Width" Value="40"></Setter>
59+
</Style>
3960
</Application.Resources>
4061
</Application>

MetaMorpheus/GUI/MainWindow.xaml

+34-19
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
xmlns:local="clr-namespace:MetaMorpheusGUI"
77
mc:Ignorable="d"
88
Drop="Window_Drop" AllowDrop="true" Background="{StaticResource BackgroundColor}" WindowStartupLocation="CenterScreen" MinHeight="400"
9-
MinWidth="800" Height="550" Width="950"
9+
MinWidth="800" Height="550" Width="1000"
1010
Loaded="MyWindow_Loaded">
1111

1212
<Window.Resources>
@@ -122,6 +122,7 @@
122122
<!--Defines the context menu when "add task" button is clicked-->
123123
<ContextMenu x:Key="AddTaskMenu" Style="{StaticResource ContextMenuStyle}">
124124
<MenuItem Header="Add new calibration task" Click="AddCalibrateTaskButton_Click" />
125+
<MenuItem Header="Add new averaging task" Click="AddAveragingTaskButton_OnClick" />
125126
<MenuItem Header="Add new GPTMD task" Click="AddGPTMDTaskButton_Click" />
126127
<MenuItem Header="Add new search task" Click="AddSearchTaskButton_Click" />
127128
<MenuItem Header="Add new crosslink task" Click="AddCrosslinkTask_Click" />
@@ -298,9 +299,20 @@
298299

299300
task performs mass calibration;
300301

302+
<!-- TODO: Change link to averaging paper once published -->
301303
<LineBreak />
304+
305+
● The
306+
307+
<Hyperlink NavigateUri="https://github.com/smith-chem-wisc/MetaMorpheus/wiki/Averaging-Task" RequestNavigate="Hyperlink_RequestNavigate">
308+
averaging
309+
</Hyperlink>
302310

303-
● the
311+
task averages spectra to refine isotopic distributions
312+
313+
<LineBreak />
314+
315+
● The
304316
<Hyperlink NavigateUri="https://pubs.acs.org/doi/10.1021/acs.jproteome.6b00034" RequestNavigate="Hyperlink_RequestNavigate">
305317
GPTMD
306318
</Hyperlink>
@@ -309,7 +321,7 @@
309321

310322
<LineBreak />
311323

312-
the search task performs a proteomics database search, with
324+
The search task performs a proteomics database search, with
313325

314326
<Hyperlink NavigateUri="https://pubs.acs.org/doi/10.1021/acs.jproteome.7b00608" RequestNavigate="Hyperlink_RequestNavigate">
315327
quantification
@@ -328,7 +340,7 @@
328340

329341
<LineBreak />
330342

331-
the
343+
The
332344

333345
<Hyperlink NavigateUri="https://pubs.acs.org/doi/10.1021/acs.jproteome.8b00141" RequestNavigate="Hyperlink_RequestNavigate">
334346
XL search
@@ -338,7 +350,7 @@
338350

339351
<LineBreak />
340352

341-
the
353+
The
342354

343355
<Hyperlink NavigateUri="https://www.biorxiv.org/content/10.1101/2020.05.18.102327v1.abstract" RequestNavigate="Hyperlink_RequestNavigate">
344356
glycopeptide
@@ -501,23 +513,26 @@
501513
<!--Button to add tasks-->
502514
<Grid Grid.Row="2" Background="{StaticResource BackgroundColor}" Margin="0,0,10,0" HorizontalAlignment="Right">
503515
<Grid.ColumnDefinitions>
504-
<ColumnDefinition Width="150"/>
505-
<ColumnDefinition Width="150"/>
506-
<ColumnDefinition Width="150"/>
507-
<ColumnDefinition Width="150"/>
508-
<ColumnDefinition Width="150"/>
516+
<ColumnDefinition Width="140"/>
517+
<ColumnDefinition Width="140"/>
518+
<ColumnDefinition Width="140"/>
519+
<ColumnDefinition Width="140"/>
520+
<ColumnDefinition Width="140"/>
521+
<ColumnDefinition Width="140"/>
509522
</Grid.ColumnDefinitions>
510523

511524
<Button Name="AddCalibTaskButton" Grid.Column="0" Content="+ADD CALIBRATION" HorizontalAlignment="Right" Click="AddCalibrateTaskButton_Click"
512-
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,1,0" Width="150"/>
513-
<Button Name="AddGptmdTaskButton" Grid.Column="1" Content="+ADD PTM DISCOVERY" HorizontalAlignment="Right" Click="AddGPTMDTaskButton_Click"
514-
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,1,0" Width="150"/>
515-
<Button Name="AddSearchTaskButton" Grid.Column="2" Content="+ADD SEARCH" HorizontalAlignment="Right" Click="AddSearchTaskButton_Click"
516-
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,1,0" Width="150"/>
517-
<Button Name="AddXlTaskButton" Grid.Column="3" Content="+ADD XL SEARCH" HorizontalAlignment="Right" Click="AddCrosslinkTask_Click"
518-
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,1,0" Width="150"/>
519-
<Button Name="AddGlycoTaskButton" Grid.Column="4" Content="+ADD GLYCO SEARCH" HorizontalAlignment="Right" Click="AddGlycoSearchTask_Click"
520-
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,0,0" Width="150"/>
525+
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,1,0" Width="140"/>
526+
<Button Name="AddAveragingTaskButton" Grid.Column="1" Content="+AVERAGE SPECTRA" HorizontalAlignment="Right" Click="AddAveragingTaskButton_OnClick"
527+
Style="{StaticResource ImportantButtonStyle}" Margin="0, 0, 1, 0" Width="140" FontSize="11" />
528+
<Button Name="AddGptmdTaskButton" Grid.Column="2" Content="+ADD PTM DISCOVERY" HorizontalAlignment="Right" Click="AddGPTMDTaskButton_Click"
529+
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,1,0" Width="140"/>
530+
<Button Name="AddSearchTaskButton" Grid.Column="3" Content="+ADD SEARCH" HorizontalAlignment="Right" Click="AddSearchTaskButton_Click"
531+
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,1,0" Width="140"/>
532+
<Button Name="AddXlTaskButton" Grid.Column="4" Content="+ADD XL SEARCH" HorizontalAlignment="Right" Click="AddCrosslinkTask_Click"
533+
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,1,0" Width="140"/>
534+
<Button Name="AddGlycoTaskButton" Grid.Column="5" Content="+ADD GLYCO SEARCH" HorizontalAlignment="Right" Click="AddGlycoSearchTask_Click"
535+
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,0,0" Width="140"/>
521536
</Grid>
522537

523538
<!--List of tasks-->

MetaMorpheus/GUI/MainWindow.xaml.cs

+22-6
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,13 @@ private void AddGlycoSearchTask_Click(object sender, RoutedEventArgs e)
710710
{
711711
OpenNewTaskWindow(MyTask.GlycoSearch);
712712
}
713+
private void AddAveragingTaskButton_OnClick(object sender, RoutedEventArgs e)
714+
{
715+
OpenNewTaskWindow(MyTask.Average);
716+
}
713717

714718
/// <summary>
715-
/// Event fires when the "Add Task" button is clicked.
719+
/// Event fires when the "Add Task" button is clicked on the RunPage
716720
/// </summary>
717721
private void AddTask_Click(object sender, RoutedEventArgs e)
718722
{
@@ -905,10 +909,9 @@ private void RunAllTasks_Click(object sender, RoutedEventArgs e)
905909
NotificationHandler(null, new StringEventArgs("You need to add at least one spectra file!", null));
906910
return;
907911
}
908-
if (!ProteinDatabases.Any())
912+
if (!ProteinDatabases.Any() && PreRunTasks.Any(p => p.metaMorpheusTask.TaskType != MyTask.Average)) // will not throw this if averaging is the only task
909913
{
910914
NotificationHandler(null, new StringEventArgs("You need to add at least one protein database!", null));
911-
return;
912915
}
913916

914917
// check that experimental design is defined if normalization is enabled
@@ -1658,6 +1661,11 @@ private void AddPreRunFile(string filePath)
16581661
var glyco = Toml.ReadFile<GlycoSearchTask>(filePath, MetaMorpheusTask.tomlConfig);
16591662
AddTaskToCollection(glyco);
16601663
break;
1664+
1665+
case "Average":
1666+
var average = Toml.ReadFile<SpectralAveragingTask>(filePath, MetaMorpheusTask.tomlConfig);
1667+
AddTaskToCollection(average);
1668+
break;
16611669
}
16621670
}
16631671
catch (Exception e)
@@ -1706,6 +1714,7 @@ private void OpenNewTaskWindow(MyTask taskType)
17061714
case MyTask.Gptmd: defaultTomlName = "GptmdTaskDefault.toml"; break;
17071715
case MyTask.XLSearch: defaultTomlName = "XLSearchTaskDefault.toml"; break;
17081716
case MyTask.GlycoSearch: defaultTomlName = "GlycoSearchTaskDefault.toml"; break;
1717+
case MyTask.Average: defaultTomlName = "SpectralAverageTaskDefault.toml"; break;
17091718
}
17101719

17111720
string defaultTomlFilePath = Path.Combine(GlobalVariables.DataDir, "DefaultParameters", defaultTomlName);
@@ -1721,6 +1730,7 @@ private void OpenNewTaskWindow(MyTask taskType)
17211730
case MyTask.Gptmd: task = Toml.ReadFile<GptmdTask>(defaultTomlFilePath, MetaMorpheusTask.tomlConfig); break;
17221731
case MyTask.XLSearch: task = Toml.ReadFile<XLSearchTask>(defaultTomlFilePath, MetaMorpheusTask.tomlConfig); break;
17231732
case MyTask.GlycoSearch: task = Toml.ReadFile<GlycoSearchTask>(defaultTomlFilePath, MetaMorpheusTask.tomlConfig); break;
1733+
case MyTask.Average: task = Toml.ReadFile<SpectralAveragingTask>(defaultTomlFilePath, MetaMorpheusTask.tomlConfig); break;
17241734
}
17251735
}
17261736
catch (Exception)
@@ -1737,6 +1747,7 @@ private void OpenNewTaskWindow(MyTask taskType)
17371747
case MyTask.Gptmd: dialog = new GptmdTaskWindow((GptmdTask)task); break;
17381748
case MyTask.XLSearch: dialog = new XLSearchTaskWindow((XLSearchTask)task); break;
17391749
case MyTask.GlycoSearch: dialog = new GlycoSearchTaskWindow((GlycoSearchTask)task); break;
1750+
case MyTask.Average: dialog = new SpectralAveragingTaskWindow((SpectralAveragingTask)task); break;
17401751
}
17411752

17421753
// save the task to the task collection
@@ -1748,7 +1759,8 @@ private void OpenNewTaskWindow(MyTask taskType)
17481759
case MyTask.Calibrate: AddTaskToCollection(((CalibrateTaskWindow)dialog).TheTask); break;
17491760
case MyTask.Gptmd: AddTaskToCollection(((GptmdTaskWindow)dialog).TheTask); break;
17501761
case MyTask.XLSearch: AddTaskToCollection(((XLSearchTaskWindow)dialog).TheTask); break;
1751-
case MyTask.GlycoSearch: AddTaskToCollection(((GlycoSearchTaskWindow)dialog).TheTask); break;
1762+
case MyTask.GlycoSearch: AddTaskToCollection(((GlycoSearchTaskWindow)dialog).TheTask); break;
1763+
case MyTask.Average: AddTaskToCollection(((SpectralAveragingTaskWindow)dialog).TheTask); break;
17521764
}
17531765

17541766
UpdateGuiOnPreRunChange();
@@ -1866,6 +1878,12 @@ private void OpenPreRunTaskForEditing(PreRunTask preRunTask)
18661878
var GlycoSearchdialog = new GlycoSearchTaskWindow(preRunTask.metaMorpheusTask as GlycoSearchTask);
18671879
GlycoSearchdialog.ShowDialog();
18681880
break;
1881+
1882+
case MyTask.Average:
1883+
var averagingDialog =
1884+
new SpectralAveragingTaskWindow(preRunTask.metaMorpheusTask as SpectralAveragingTask);
1885+
averagingDialog.ShowDialog();
1886+
break;
18691887
}
18701888

18711889
UpdateGuiOnPreRunChange();
@@ -1950,7 +1968,5 @@ private void OpenProteomesFolder_Click(object sender, RoutedEventArgs e)
19501968
{
19511969
OpenFolder(Path.Combine(GlobalVariables.DataDir, @"Proteomes"));
19521970
}
1953-
1954-
19551971
}
19561972
}

0 commit comments

Comments
 (0)