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

[WIP] Enable saving of multiple settings for tasks #2319

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f8d02b1
Begin implementing GUI save preset settings
kscdnw Apr 17, 2023
4ebfdad
Change the Save button in the SaveSettingsWindow
kscdnw Apr 17, 2023
bc81a2f
Attached ViewModel to main task window
nbollis Apr 17, 2023
b8b97b8
Merge Conflict
nbollis Apr 17, 2023
0e49b6d
Added ability for view model to communicate selected item with gui an…
nbollis Apr 19, 2023
b24aafc
Default Settings updated.
kscdnw Apr 19, 2023
79a2a0f
Removed dead method
nbollis Apr 19, 2023
eea8177
Merge updated
kscdnw Apr 19, 2023
8d0c428
SaveAsDefautSettings and SaveSettings buttons updated.
kscdnw Apr 26, 2023
aa3ce6d
Some Gui bugs fixed.
kscdnw Apr 26, 2023
4d0e2cb
Developed ability to test with actions and methods
nbollis Apr 26, 2023
a60fb95
Merge branch 'FWSaveSettings' of https://github.com/kscdnw/MetaMorphe…
nbollis Apr 26, 2023
f421159
Added testing class for window operations
nbollis Apr 27, 2023
957185f
Got the other windows ready
nbollis Apr 27, 2023
87917e7
Merged Master into development branch
kscdnw Sep 12, 2023
ffacfc6
Replace added files with what's in the old hard drive.
kscdnw Sep 19, 2023
f7f8772
Add the TaskSettingViewModel to all task window except for Spectral A…
kscdnw Nov 28, 2023
c9c2a8c
Clean up codes and spaces that are not used. Reformatting the Guis th…
kscdnw Dec 5, 2023
798d5e3
Merge branch 'master' into FWSaveSettings
kscdnw Dec 5, 2023
a83a1b1
Binding SaveAsDefault button for all task windows and manually test t…
kscdnw Dec 5, 2023
43a7336
Change the columns of the labels in TaskWindows. Remove SaveAsDefault…
kscdnw Dec 12, 2023
fc5fc80
Merge branch 'master' into FWSaveSettings
kscdnw Dec 12, 2023
6af7af1
Merge branch 'master' into FWSaveSettings
nbollis Dec 13, 2023
419efe4
Merge branch 'master' into FWSaveSettings
nbollis Jan 29, 2024
3e7be9b
Merge branch 'master' into FWSaveSettings
nbollis Feb 6, 2024
8348513
removed extra solution file
nbollis Feb 6, 2024
8306c7a
Reverted changes to testscan management
nbollis Feb 6, 2024
1fb9361
Reverted changes to testscan management
nbollis Feb 6, 2024
d0dc6c0
merged
nbollis Feb 6, 2024
f930a39
reverted change to TestScanManagement
nbollis Feb 6, 2024
9c4ddce
Merge branch 'master' into FWSaveSettings
nbollis Feb 27, 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
6 changes: 3 additions & 3 deletions MetaMorpheus/GUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,15 @@

<!--Button to add spectra files-->
<Button Name="AddSpectraButton" Grid.Row="2" Content="+ADD SPECTRA" Click="AddSpectraFile_Click" HorizontalAlignment="Right"
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,10,0"/>
Style="{StaticResource ImportantButtonStyle}" Margin="0,0,10,0"/>

<Button Name="SetFileSpecificSettingsButton" Grid.Row="2" Content="SET FILE-SPECIFIC SETTINGS" Click="SetFileSpecificParameters_Click"
HorizontalAlignment="Right" Style="{StaticResource ImportantButtonStyle}"
Margin="0,0,211,0"/>
Margin="0,0,211,0"/>

<Button Name="SetExperimentalDesignButton" Grid.Row="2" Content="SET EXPERIMENTAL DESIGN" Click="SetExperimentalDesign_Click"
HorizontalAlignment="Right" Style="{StaticResource ImportantButtonStyle}"
Margin="0,0,412,0"/>
Margin="0,0,412,0"/>

<!--The list of spectra files-->
<DataGrid Name="dataGridSpectraFiles" ItemsSource="{Binding}" Grid.Row="3" Style="{StaticResource x:DataGridStyle}"
Expand Down
18 changes: 14 additions & 4 deletions MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<Grid DockPanel.Dock="Top" Margin="5,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Task Name" />
<TextBox x:Name="OutputFileNameTextBox" Width="150">
<TextBox x:Name="OutputFileNameTextBox" Width="150" Grid.Column="1">
<TextBox.Style>
<Style TargetType="TextBox" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style.Resources>
Expand All @@ -44,7 +49,11 @@
</Style>
</TextBox.Style>
</TextBox>
</StackPanel>
<!-- save settings -->
<local:SaveSettingsControl x:Name="TaskSettingsCtrl" Grid.Column="2" HorizontalAlignment="Right"
DataContext="{Binding TaskSettingViewModel}" />
</Grid>

<GroupBox Header="Search Parameters" DockPanel.Dock="Top">
<Expander x:Name="SearchModeExpander">
<StackPanel>
Expand Down Expand Up @@ -422,7 +431,8 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1" Margin="5">
<Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" />
<Button x:Name="SaveButton" Content="Save Calibrate Task" Click="SaveButton_Click" FontSize="24" />
<Button x:Name="SetDefaultbutton" Click="SaveAsDefault_Click" Width="100" >
<Button x:Name="setDefaultbutton"
Command="{Binding SaveAsDefaultSettingsCommand}" Width="100" >
<TextBlock Text="Save As Default" TextWrapping="Wrap" TextAlignment="Center"/>
<ToolTipService.ToolTip>
<ToolTip Content="Save these parameters as the default. MetaMorpheus can return to original defaults by deleting the folder 'DefaultParameters'" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500" />
Expand Down
33 changes: 21 additions & 12 deletions MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public partial class CalibrateTaskWindow : Window
private readonly ObservableCollection<ModTypeForLoc> LocalizeModTypeForTreeViewObservableCollection = new ObservableCollection<ModTypeForLoc>();
private bool AutomaticallyAskAndOrUpdateParametersBasedOnProtease = true;
private CustomFragmentationWindow CustomFragmentationWindow;
private TaskSettingViewModel TaskSettingViewModel;

public CalibrateTaskWindow(CalibrationTask myCalibrateTask)
{
Expand All @@ -36,8 +37,12 @@ public CalibrateTaskWindow(CalibrationTask myCalibrateTask)

AutomaticallyAskAndOrUpdateParametersBasedOnProtease = false;
PopulateChoices();
UpdateFieldsFromTask(TheTask);
var updateFieldsFromNewTaskAction = (MetaMorpheusTask task) => UpdateFieldsFromTask(task as CalibrationTask);
TaskSettingViewModel = new(TheTask, updateFieldsFromNewTaskAction, GetTaskFromGui);
TaskSettingsCtrl.DataContext = TaskSettingViewModel;
setDefaultbutton.DataContext = TaskSettingViewModel;
AutomaticallyAskAndOrUpdateParametersBasedOnProtease = true;


if (myCalibrateTask == null)
{
Expand Down Expand Up @@ -187,15 +192,25 @@ private void CancelButton_Click(object sender, RoutedEventArgs e)
}

private void SaveButton_Click(object sender, RoutedEventArgs e)
{
CalibrationTask task = GetTaskFromGui();
if (task == null)
return;

TheTask = task;
DialogResult = true;
}

private CalibrationTask GetTaskFromGui()
{
string fieldNotUsed = "1";

if (!GlobalGuiSettings.CheckTaskSettingsValidity(PrecursorMassToleranceTextBox.Text, ProductMassToleranceTextBox.Text, MissedCleavagesTextBox.Text,
MaxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, MaxThreadsTextBox.Text, MinScoreAllowed.Text,
fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, null, null, fieldNotUsed, MaxModsPerPeptideTextBox.Text, fieldNotUsed,
fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, fieldNotUsed, null, null, fieldNotUsed, MaxModsPerPeptideTextBox.Text, fieldNotUsed,
null, null, null))
{
return;
return null;
}

Protease protease = (Protease)ProteaseComboBox.SelectedItem;
Expand Down Expand Up @@ -226,7 +241,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)

if (!GlobalGuiSettings.VariableModCheck(listOfModsVariable))
{
return;
return null;
}

var listOfModsFixed = new List<(string, string)>();
Expand Down Expand Up @@ -296,7 +311,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
}

TheTask.CalibrationParameters.WriteIndexedMzml = writeIndexMzmlCheckbox.IsChecked.Value;
DialogResult = true;
return TheTask;
}

private void CheckIfNumber(object sender, TextCompositionEventArgs e)
Expand Down Expand Up @@ -357,13 +372,7 @@ private void OnClosing(object sender, CancelEventArgs e)
// remove event handler from timer
// keeping it will trigger an exception because the closed window stops existing

CustomFragmentationWindow.Close();
}

private void SaveAsDefault_Click(object sender, RoutedEventArgs e)
{
SaveButton_Click(sender, e);
Toml.WriteFile(TheTask, Path.Combine(GlobalVariables.DataDir, "DefaultParameters", @"CalibrationTaskDefault.toml"), MetaMorpheusTask.tomlConfig);
CustomFragmentationWindow?.Close();
}

private void ProteaseSpecificUpdate(object sender, SelectionChangedEventArgs e)
Expand Down
27 changes: 20 additions & 7 deletions MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<Label Content="Task Name" />
<TextBox x:Name="OutputFileNameTextBox" Width="150">
<Grid DockPanel.Dock="Top" Margin="5,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Task Name" Grid.Column="0"/>
<TextBox x:Name="OutputFileNameTextBox" Width="150" Grid.Column="1">
<TextBox.Style>
<Style TargetType="TextBox" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style TargetType="TextBox">
<Style.Resources>
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center"
Stretch="None">
<VisualBrush.Visual>
<Label Content="GPTMDTask" Foreground="Gray" />
</VisualBrush.Visual>
Expand All @@ -44,7 +50,13 @@
</Style>
</TextBox.Style>
</TextBox>
</StackPanel>
<!-- save settings -->
<local:SaveSettingsControl x:Name="TaskSettingsCtrl" Grid.Column="2" HorizontalAlignment="Right"
DataContext="{Binding TaskSettingViewModel}" />

</Grid>


<GroupBox Header="File Loading Parameters" DockPanel.Dock="Top">
<Expander x:Name="FileLoadExpander" >
<StackPanel>
Expand Down Expand Up @@ -499,7 +511,8 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1" Margin="5">
<Button x:Name="cancelButton" Content="Cancel" Click="CancelButton_Click" />
<Button x:Name="saveButton" Content="Save GPTMD task" Click="SaveButton_Click" FontSize="24" />
<Button x:Name="setDefaultbutton" Click="SaveAsDefault_Click" Width="100" >
<Button x:Name="setDefaultbutton"
Command="{Binding SaveAsDefaultSettingsCommand}" Width="100" >
<TextBlock Text="Save As Default" TextWrapping="Wrap" TextAlignment="Center"/>
<ToolTipService.ToolTip>
<ToolTip Content="Save these parameters as the default. MetaMorpheus can return to original defaults by deleting the folder 'DefaultParameters'" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500" />
Expand Down
40 changes: 24 additions & 16 deletions MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public partial class GptmdTaskWindow : Window
private readonly ObservableCollection<ModTypeForTreeViewModel> GptmdModTypeForTreeViewObservableCollection = new ObservableCollection<ModTypeForTreeViewModel>();
private bool AutomaticallyAskAndOrUpdateParametersBasedOnProtease = true;
private CustomFragmentationWindow CustomFragmentationWindow;
private TaskSettingViewModel TaskSettingViewModel;

public GptmdTaskWindow(GptmdTask myGPTMDtask)
{
Expand All @@ -37,8 +38,12 @@ public GptmdTaskWindow(GptmdTask myGPTMDtask)

AutomaticallyAskAndOrUpdateParametersBasedOnProtease = false;
PopulateChoices();
UpdateFieldsFromTask(TheTask);
var updateFieldsFromNewTaskAction = (MetaMorpheusTask task) => UpdateFieldsFromTask(task as GptmdTask);
TaskSettingViewModel = new(TheTask, updateFieldsFromNewTaskAction, GetTaskFromGui);
TaskSettingsCtrl.DataContext = TaskSettingViewModel;
setDefaultbutton.DataContext = TaskSettingViewModel;
AutomaticallyAskAndOrUpdateParametersBasedOnProtease = true;
PopulateChoices();

if (myGPTMDtask == null)
{
Expand Down Expand Up @@ -349,15 +354,25 @@ private void ProteaseSpecificUpdate(object sender, TextChangedEventArgs e)
}

private void SaveButton_Click(object sender, RoutedEventArgs e)
{
GptmdTask task = GetTaskFromGui();
if (task is null)
return;

TheTask = task;
DialogResult = true;
}

public GptmdTask GetTaskFromGui()
{
string fieldNotUsed = "1";

if (!GlobalGuiSettings.CheckTaskSettingsValidity(PrecursorMassToleranceTextBox.Text, ProductMassToleranceTextBox.Text, MissedCleavagesTextBox.Text,
MaxModificationIsoformsTextBox.Text, MinPeptideLengthTextBox.Text, MaxPeptideLengthTextBox.Text, MaxThreadsTextBox.Text, MinScoreAllowed.Text,
fieldNotUsed, fieldNotUsed, DeconvolutionMaxAssumedChargeStateTextBox.Text, NumberOfPeaksToKeepPerWindowTextBox.Text, MinimumAllowedIntensityRatioToBasePeakTexBox.Text,
fieldNotUsed, fieldNotUsed, DeconvolutionMaxAssumedChargeStateTextBox.Text, NumberOfPeaksToKeepPerWindowTextBox.Text, MinimumAllowedIntensityRatioToBasePeakTexBox.Text,
null, null, fieldNotUsed, fieldNotUsed, fieldNotUsed, null, null, null))
{
return;
return null;
}

Protease protease = (Protease)ProteaseComboBox.SelectedItem;
Expand Down Expand Up @@ -400,7 +415,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)

if (!GlobalGuiSettings.VariableModCheck(listOfModsVariable))
{
return;
return null;
}

bool TrimMs1Peaks = TrimMs1.IsChecked.Value;
Expand All @@ -416,7 +431,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
else
{
MessageBox.Show("The value that you entered for number of peaks to keep is not acceptable. Try again.");
return;
return null;
}
}

Expand All @@ -430,7 +445,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
else
{
MessageBox.Show("The value that you entered for minimum allowed intensity ratio to keep is not acceptable. Try again.");
return;
return null;
}
}

Expand Down Expand Up @@ -458,7 +473,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
dissociationType: dissociationType,
scoreCutoff: double.Parse(MinScoreAllowed.Text, CultureInfo.InvariantCulture),
precursorMassTolerance: precursorMassTolerance,
productMassTolerance: productMassTolerance,
productMassTolerance: productMassTolerance,
trimMs1Peaks: TrimMs1Peaks,
trimMsMsPeaks: TrimMsMsPeaks,
numberOfPeaksToKeepPerWindow: numPeaksToKeep,
Expand All @@ -477,8 +492,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
}

TheTask.CommonParameters = commonParamsToSave;

DialogResult = true;
return TheTask;
}

private void CheckIfNumber(object sender, TextCompositionEventArgs e)
Expand Down Expand Up @@ -551,13 +565,7 @@ private void OnClosing(object sender, CancelEventArgs e)
// remove event handler from timer
// keeping it will trigger an exception because the closed window stops existing

CustomFragmentationWindow.Close();
}

private void SaveAsDefault_Click(object sender, RoutedEventArgs e)
{
SaveButton_Click(sender, e);
Toml.WriteFile(TheTask, Path.Combine(GlobalVariables.DataDir, "DefaultParameters", @"GptmdTaskDefault.toml"), MetaMorpheusTask.tomlConfig);
CustomFragmentationWindow?.Close();
}
}
}
34 changes: 27 additions & 7 deletions MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MetaMorpheusGUI"
xmlns:guiFunctions="clr-namespace:GuiFunctions;assembly=GuiFunctions"
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d"
KeyDown="KeyPressed"
Title="Glyco Search Task" Height="750" Width="750" WindowStartupLocation="CenterScreen">
Expand Down Expand Up @@ -42,13 +43,19 @@
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.ColumnSpan="2">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<Label Content="Task Name" />
<TextBox x:Name="OutputFileNameTextBox" Width="150">
<Grid DockPanel.Dock="Top" Margin="5,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Task Name" Grid.Column="0"/>
<TextBox x:Name="OutputFileNameTextBox" Width="150" Grid.Column="1">
<TextBox.Style>
<Style TargetType="TextBox" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style TargetType="TextBox">
<Style.Resources>
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center"
Stretch="None">
<VisualBrush.Visual>
<Label Content="SearchTask" Foreground="Gray" />
</VisualBrush.Visual>
Expand All @@ -68,7 +75,13 @@
</Style>
</TextBox.Style>
</TextBox>
</StackPanel>

<!-- save settings -->
<local:SaveSettingsControl x:Name="TaskSettingsCtrl" Grid.Column="2" HorizontalAlignment="Right"
DataContext="{Binding TaskSettingViewModel}" />

</Grid>

<StackPanel DockPanel.Dock="Top">
<Grid>

Expand Down Expand Up @@ -500,9 +513,16 @@

</DockPanel>
</ScrollViewer>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1" Margin="188.333,5,261,5" Grid.Column="1">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1" Margin="5" Grid.Column="1">
<Button x:Name="cancelButton" Content="Cancel" Click="CancelButton_Click" />
<Button x:Name="saveButton" Content="Save GlycoSearch Task" Click="SaveButton_Click" FontSize="24" />
<Button x:Name="setDefaultbutton"
Command="{Binding SaveAsDefaultSettingsCommand}" Width="100" >
<TextBlock Text="Save As Default" TextWrapping="Wrap" TextAlignment="Center"/>
<ToolTipService.ToolTip>
<ToolTip Content="Save these parameters as the default. MetaMorpheus can return to original defaults by deleting the folder 'DefaultParameters'" ToolTipService.ShowDuration="999999" ToolTipService.InitialShowDelay="500" />
</ToolTipService.ToolTip>
</Button>
</StackPanel>
</Grid>
</Window>
Loading