-
Notifications
You must be signed in to change notification settings - Fork 46
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
Added custom protease window in GUI #2352
base: master
Are you sure you want to change the base?
Changes from all commits
56092b7
1c09290
b2fd696
1a949b0
c4e3c37
5163f7b
50f5923
279f3b0
7380a72
e50e20b
ef0f153
f979921
0819a66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<Window x:Class="MetaMorpheusGUI.Views.CustomProteaseWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:MetaMorpheusGUI.Views" | ||
mc:Ignorable="d" | ||
Title="CustomProteaseWindow" Height="330" Width="380" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> | ||
<Grid> | ||
<StackPanel Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,5,0,0" Height="300"> | ||
<!--protease name--> | ||
<StackPanel Orientation="Horizontal" Height="40"> | ||
<Label Content="Name" Width="135" Margin=" 10,5,5,5" FontSize="13"></Label> | ||
<Label Content="*" Foreground="Red" FontWeight="Bold" /> | ||
<TextBox x:Name="ProteaseNameTextBox" Width="155" Height="25"> | ||
</TextBox> | ||
</StackPanel> | ||
<!--Cleavage specificity--> | ||
<StackPanel Orientation="Horizontal" Height="40"> | ||
<Label Content="Cleavage Specificity" Width="135" Margin=" 10,5,5,5" Height="33" FontSize="13"></Label> | ||
<Label Content="*" Foreground="Red" FontWeight="Bold" /> | ||
<ComboBox Name ="CleavageSpecComboBox" SelectionChanged ="CleavageSpecComboBox_SelectionChanged" Width="155" Height="25"> | ||
|
||
</ComboBox> | ||
</StackPanel> | ||
<!--Psi-MS Acession Number--> | ||
<StackPanel Orientation="Horizontal" Height="40"> | ||
<Label Content="Psi-MS Number" Width="145" Margin=" 10,5,10,10" Height="28" FontSize="13"></Label> | ||
<TextBox Name="PsiMsAccessionNumTextBox" Width="155" Height="25"> | ||
</TextBox> | ||
</StackPanel> | ||
<!--Psi-MS Name--> | ||
<StackPanel Orientation="Horizontal" Height="40"> | ||
<Label Content="Psi-MS Name" Width="145" Margin=" 10,5,10,10" FontSize="13"></Label> | ||
<TextBox Name="PsiNameTextBox" Width="155" Height="25"> | ||
</TextBox> | ||
</StackPanel> | ||
<!--Digestion motif--> | ||
<StackPanel Orientation="Horizontal" Height="40"> | ||
<Label Content="Digestion Motif" Width="135" Margin=" 10,5,5,5" Height="31" FontSize="13"></Label> | ||
<Label Content="*" Foreground="Red" FontWeight="Bold" /> | ||
<TextBox Name="DigestionMotifTextBox" Width="155" Height="25"> | ||
<ToolTipService.ToolTip> | ||
<ToolTip Content="Amino acid sequences or motifs recognized and cleaved by the protease"/> | ||
</ToolTipService.ToolTip> | ||
<TextBox.Style> | ||
<Style TargetType="TextBox" xmlns:sys="clr-namespace:System;assembly=mscorlib"> | ||
<Style.Resources> | ||
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None"> | ||
<VisualBrush.Visual> | ||
<Label Content="ex: 'A|', '|R', 'F[P]|'" Foreground="Gray" /> | ||
</VisualBrush.Visual> | ||
</VisualBrush> | ||
</Style.Resources> | ||
<Style.Triggers> | ||
<Trigger Property="Text" Value="{x:Static sys:String.Empty}"> | ||
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" /> | ||
</Trigger> | ||
<Trigger Property="Text" Value="{x:Null}"> | ||
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" /> | ||
</Trigger> | ||
<Trigger Property="IsKeyboardFocused" Value="True"> | ||
<Setter Property="Background" Value="White" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</TextBox.Style> | ||
</TextBox> | ||
</StackPanel> | ||
<!--Cleavage Mod--> | ||
<StackPanel Orientation="Horizontal" Height="40"> | ||
<Label Content="Cleavage Mod" Width="145" Margin=" 10,5,10,10" Height="36" FontSize="13"></Label> | ||
<TextBox Name="CleavageModTextBox" Width="155" Height="25"> | ||
</TextBox> | ||
</StackPanel> | ||
<!--Save and cancel buttons--> | ||
<StackPanel Orientation="Horizontal" Height="40" HorizontalAlignment="Center" Margin="8"> | ||
<Button Name="SaveProtease" Content="Save protease" FontSize="13" Margin="5" Width="100" Click="SaveProteaseButton_Click" /> | ||
<Button Name="CancelProtease" Content="Cancel" FontSize="13" Margin="5" Width="100" Click="CancelProteaseButton_Click" /> | ||
</StackPanel> | ||
|
||
</StackPanel> | ||
</Grid> | ||
</Window> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
using Proteomics.ProteolyticDigestion; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.IO; | ||
using EngineLayer; | ||
using Omics.Digestion; | ||
using Proteomics.AminoAcidPolymer; | ||
|
||
namespace MetaMorpheusGUI.Views | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CustomProteaseWindow.xaml | ||
/// </summary> | ||
public partial class CustomProteaseWindow : Window | ||
{ | ||
public CustomProteaseWindow() | ||
{ | ||
InitializeComponent(); | ||
|
||
foreach (CleavageSpecificity c in Enum.GetValues(typeof(CleavageSpecificity))) | ||
{ | ||
CleavageSpecComboBox.Items.Add(c); | ||
} | ||
} | ||
|
||
private void SaveProteaseButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
if (ProteaseNameTextBox.Text.Length == 0) | ||
{ | ||
MessageBox.Show("Please specify the name of the protease"); | ||
return; | ||
} | ||
if (CleavageSpecComboBox.Text.Length == 0) | ||
{ | ||
MessageBox.Show("Please specify the cleavage specificity of the protease"); | ||
return; | ||
} | ||
if (DigestionMotifTextBox.Text.Length == 0) | ||
{ | ||
MessageBox.Show("Please specify the digestion motif(s) of the protease"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check to see if the digestion motiff is a valid amino acid? |
||
return; | ||
} | ||
string proteaseName = ProteaseNameTextBox.Text; | ||
string psiMsAccessionNum = PsiMsAccessionNumTextBox.Text; | ||
string psiMsName = PsiNameTextBox.Text; | ||
string motifString = DigestionMotifTextBox.Text; | ||
|
||
CleavageSpecificity cleavageSpecificity; | ||
if (Enum.TryParse(CleavageSpecComboBox.Text, out CleavageSpecificity _cleaveageSpec)) | ||
{ | ||
cleavageSpecificity = _cleaveageSpec; | ||
} | ||
else | ||
{ | ||
MessageBox.Show("Please specify the digestion motif(s) of the protease"); | ||
return; | ||
} | ||
|
||
List<DigestionMotif> digestionMotifs; | ||
var aminoAcidsInMotifString = motifString.Where(char.IsLetter).ToList(); | ||
foreach(var aa in aminoAcidsInMotifString) | ||
{ | ||
if (!Residue.ResiduesDictionary.ContainsKey(aa.ToString())) | ||
{ | ||
MessageBox.Show("Motif(s) contains invalid amino acids."); | ||
return; | ||
} | ||
} | ||
try | ||
{ | ||
digestionMotifs = DigestionMotif.ParseDigestionMotifsFromString(motifString); | ||
} | ||
catch | ||
{ | ||
MessageBox.Show("The motif(s) could not be parsed."); | ||
return; | ||
} | ||
|
||
//create a new Protease and add to ProteaseDictionary | ||
Protease proteaseToAdd = new Protease(proteaseName, cleavageSpecificity, psiMsAccessionNum, psiMsName, digestionMotifs); | ||
|
||
if (ProteaseDictionary.Dictionary.ContainsKey(proteaseName)) | ||
{ | ||
MessageBox.Show("This protease already exists"); | ||
} | ||
else | ||
{ | ||
if (ProteaseDictionary.Dictionary.TryAdd(proteaseName, proteaseToAdd)) | ||
{ | ||
MessageBox.Show("Success! Protease '" + proteaseName + "' has been added to the dictionary."); | ||
} | ||
else | ||
{ | ||
MessageBox.Show("Failed to add Protease '" + proteaseName + "' to the dictionary."); | ||
} | ||
} | ||
|
||
//customProtease file path | ||
string ProtDirectory = Path.Combine(GlobalVariables.DataDir, @"ProteolyticDigestion"); | ||
string customProteasePath = Path.Combine(ProtDirectory, @"CustomProtease.tsv"); | ||
|
||
//check if the customProtease file exists, create it if not | ||
if (!File.Exists(customProteasePath)) | ||
{ | ||
File.Create(customProteasePath); | ||
} | ||
|
||
string lineToAdd = "\n" + proteaseName + "\t" + motifString + "\t\t\t" + CleavageSpecComboBox.Text + "\t" + psiMsAccessionNum + "\t" + psiMsName + "\t\t\t\t\t"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what pieces of information are being skipped over with all of the \t\t\t\t and is that information important here? |
||
var lines = new List<string> { lineToAdd }; | ||
File.AppendAllLines(customProteasePath, lines); | ||
DialogResult = true; | ||
} | ||
|
||
private void CancelProteaseButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
DialogResult = false; | ||
} | ||
|
||
private void CleavageSpecComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused method can be removed |
||
{ | ||
|
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Proteomics.ProteolyticDigestion; | ||
using System.IO; | ||
using NUnit.Framework; | ||
using EngineLayer; | ||
using Omics.Digestion; | ||
using MzLibUtil; | ||
|
||
|
||
namespace Test | ||
{ | ||
public static class CustomProteaseTest | ||
{ | ||
[Test] | ||
public static void TestAddCustomProtease () | ||
{ | ||
string ProtDirectory = Path.Combine(GlobalVariables.DataDir, @"ProteolyticDigestion"); | ||
string customProteasePath = Path.Combine(ProtDirectory, @"CustomProtease.tsv"); | ||
|
||
string[] pString = new string[] { "p\tA|\t\t\tfull\tcusPsiNum\tcusPsiName\t\t\t\t\t" }; | ||
File.WriteAllLines(customProteasePath, pString); | ||
|
||
GlobalVariables.LoadCustomProtease(); | ||
var dictionary = ProteaseDictionary.Dictionary; | ||
Assert.That(ProteaseDictionary.Dictionary.ContainsKey("p")); | ||
Assert.That(ProteaseDictionary.Dictionary["p"].PsiMsName == "cusPsiName"); | ||
|
||
File.Delete(customProteasePath); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most likely need to start at i == 1 because the first row is the header