From 56092b71e0ef2a4efac748631f55f80a7c593c99 Mon Sep 17 00:00:00 2001 From: Zhuoxin Shi Date: Thu, 22 Feb 2024 16:10:10 -0600 Subject: [PATCH 1/7] Added custom protease window in GUI --- MetaMorpheus/EngineLayer/GlobalVariables.cs | 29 +++++ MetaMorpheus/GUI/MainWindow.xaml | 11 +- MetaMorpheus/GUI/MainWindow.xaml.cs | 6 + .../GUI/Views/CustomProteaseWindow.xaml | 84 +++++++++++++ .../GUI/Views/CustomProteaseWindow.xaml.cs | 117 ++++++++++++++++++ MetaMorpheus/Test/CustomProteaseTest.cs | 41 ++++++ 6 files changed, 284 insertions(+), 4 deletions(-) create mode 100644 MetaMorpheus/GUI/Views/CustomProteaseWindow.xaml create mode 100644 MetaMorpheus/GUI/Views/CustomProteaseWindow.xaml.cs create mode 100644 MetaMorpheus/Test/CustomProteaseTest.cs diff --git a/MetaMorpheus/EngineLayer/GlobalVariables.cs b/MetaMorpheus/EngineLayer/GlobalVariables.cs index 5d27c34f1..570593f93 100644 --- a/MetaMorpheus/EngineLayer/GlobalVariables.cs +++ b/MetaMorpheus/EngineLayer/GlobalVariables.cs @@ -1,5 +1,6 @@ using Chemistry; using MassSpectrometry; +using MzLibUtil; using Nett; using Proteomics; using Proteomics.AminoAcidPolymer; @@ -78,6 +79,7 @@ public static void SetUpGlobalVariables() SetUpGlobalSettings(); LoadDissociationTypes(); LoadAvailableProteomes(); + LoadCustomProtease(); } public static void AddMods(IEnumerable modifications, bool modsAreFromTheTopOfProteinXml) @@ -201,6 +203,33 @@ public static void LoadCustomAminoAcids() } } + public static void LoadCustomProtease() + { + string ProtDirectory = Path.Combine(GlobalVariables.DataDir, @"ProteolyticDigestion"); + string customProteasePath = Path.Combine(ProtDirectory, @"CustomProtease.tsv"); + + //load proteases from customProtease file or the original file to Protease dictionary + if (File.Exists(customProteasePath)) + { + string[] proteaseLines = File.ReadAllLines(customProteasePath); + ProteaseDictionary.Dictionary = ProteaseDictionary.LoadProteaseDictionary(customProteasePath); + foreach (var protease in ProteaseDictionary.Dictionary) + { + if (ProteaseDictionary.Dictionary.TryAdd(protease.Key, protease.Value)) + { + throw new MzLibException(protease + "is not added to the dictionary"); + } + } + } + //else + //{ + // string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); + // string path = ((!string.IsNullOrWhiteSpace(folderPath) && AppDomain.CurrentDomain.BaseDirectory.Contains(folderPath) && !AppDomain.CurrentDomain.BaseDirectory.Contains("Jenkins")) ? System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MetaMorpheus") : AppDomain.CurrentDomain.BaseDirectory); + // string path2 = System.IO.Path.Combine(path, "ProteolyticDigestion", "proteases.tsv"); + // ProteaseDictionary.Dictionary = ProteaseDictionary.LoadProteaseDictionary(path2); + //} + } + public static void WriteAminoAcidsFile() { string directory = Path.Combine(DataDir, @"CustomAminoAcids"); diff --git a/MetaMorpheus/GUI/MainWindow.xaml b/MetaMorpheus/GUI/MainWindow.xaml index 7c33fd33b..eaa62dcfc 100644 --- a/MetaMorpheus/GUI/MainWindow.xaml +++ b/MetaMorpheus/GUI/MainWindow.xaml @@ -732,16 +732,19 @@