-
Notifications
You must be signed in to change notification settings - Fork 99
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
Alphapeptdeep Integration #3123
base: master
Are you sure you want to change the base?
Changes from all commits
c4e7c59
dc612f9
d77d35e
9d6cab0
888627c
d06c394
3b12574
1e5eb21
f2d97e9
7812cb5
5c487ab
eade5f9
e0a85e1
15930d7
dab7240
494b457
622c47a
668f811
2043f45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using log4net.Util; | ||
using pwiz.Common.Collections; | ||
using pwiz.Common.SystemUtil; | ||
using pwiz.Skyline.Model.DocSettings; | ||
|
@@ -211,7 +212,19 @@ private string FormatSelf(Func<IEnumerable<Modification>, string> modFormatter) | |
return result.ToString(); | ||
} | ||
|
||
// TODO: | ||
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. This seems like old code that was aimed at a generalized solution for a specific case that requires very few modifications. This code should be reverted. |
||
// 1. create mapper in AlphapeptdeepLibraryBuilder to map from unimode to hardcoded text | ||
// 2. do the formatting in AlphapeptdeepLibraryBuilder instead of here | ||
public string FormatFullNamesByPattern(string pattern) | ||
{ | ||
return Format(mods => string.Concat(Enumerable.Select(mods, mod => Bracket(FormatFullNameByPattern(mod, pattern))))); | ||
} | ||
|
||
private string FormatFullNameByPattern(Modification mod, string pattern) | ||
{ | ||
Assume.IsTrue(!string.IsNullOrEmpty(mod.Name), @"The full modification name [mod.Name] is required but does not exist."); | ||
return mod.Name; // TODO(xgwang): modify | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,4 +244,124 @@ | |
<data name="ToolMacros_listArguments_This_tool_requires_an_Active_Replicate_Name_to_run" xml:space="preserve"> | ||
<value>This tool requires an Active Replicate Name to run</value> | ||
</data> | ||
<data name="PythonInstaller_GetPackages_Installing_Packages" xml:space="preserve"> | ||
<value>Installing Packages</value> | ||
</data> | ||
<data name="PythonInstaller_GetPip_Installing_Pip" xml:space="preserve"> | ||
<value>Installing Pip</value> | ||
</data> | ||
<data name="PythonInstaller_GetPython_Installing_Python" xml:space="preserve"> | ||
<value>Installing Python</value> | ||
</data> | ||
<data name="PythonInstaller_InstallPackages_Install" xml:space="preserve"> | ||
<value>Install</value> | ||
</data> | ||
<data name="PythonInstaller_Download_failed__Check_your_network_connection_or_contact_Skyline_team_for_help_" xml:space="preserve"> | ||
<value>Download failed. Check your network connection or contact Skyline team for help.</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Downloading_Python_embeddable_package" xml:space="preserve"> | ||
<value>Downloading Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Failed_to_download_Python_embeddable_package" xml:space="preserve"> | ||
<value>Failed to download Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Unzipping_Python_embeddable_package" xml:space="preserve"> | ||
<value>Unzipping Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Failed_to_unzip_Python_embeddable_package" xml:space="preserve"> | ||
<value>Failed to unzip Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Enabling_search_path_in_Python_embeddable_package" xml:space="preserve"> | ||
<value>Enabling search path in Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Failed_to_enable_search_path_in_Python_embeddable_package" xml:space="preserve"> | ||
<value>Failed to enable search path in Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Downloading_the_get_pip_py_script" xml:space="preserve"> | ||
<value>Downloading the get pip py script</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Failed_to_download_the_get_pip_py_script" xml:space="preserve"> | ||
<value>Failed to download the get pip py script</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Failed_to_run_the_get_pip_py_script" xml:space="preserve"> | ||
<value>Failed to run the get pip py script</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Failed_to_create_virtual_environment__0_" xml:space="preserve"> | ||
<value>Failed to create virtual environment {0}</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Installing_Python_packages_in_virtual_environment__0_" xml:space="preserve"> | ||
<value>Installing Python packages in virtual environment {0}</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonVirtualEnvironmentTask_Failed_to_install_Python_packages_in_virtual_environment__0_" xml:space="preserve"> | ||
<value>Failed to install Python packages in virtual environment {0}</value> | ||
</data> | ||
<data name="PythonInstaller_Failed_to_execute_command____0__" xml:space="preserve"> | ||
<value>Failed to execute command: [{0}]</value> | ||
</data> | ||
<data name="PythonInstaller__0__Running_command____1____2__" xml:space="preserve"> | ||
<value>{0} Running command: [{1}] {2} </value> | ||
</data> | ||
<data name="PythonInstaller_PipInstall__0__This_sometimes_could_take_3_5_minutes__Please_be_patient___1__" xml:space="preserve"> | ||
<value>{0} This sometimes could take 3-5 minutes. Please be patient. {1} </value> | ||
</data> | ||
<data name="PythonInstallerUnsupportedTaskException_Task_with_action_type__0__is_not_supported_by_PythonInstaller_yet" xml:space="preserve"> | ||
<value>Task with action type {0} is not supported by PythonInstaller yet</value> | ||
</data> | ||
<data name="PythonInstallerUnsupportedTaskNameException_Task_with_task_name__0__is_not_supported_by_PythonInstaller_yet" xml:space="preserve"> | ||
<value>Task with task name {0} is not supported by PythonInstaller yet</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Downloading_Python_embeddable_package" xml:space="preserve"> | ||
<value>Downloading Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Failed_to_download_Python_embeddable_package" xml:space="preserve"> | ||
<value>Failed to download Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Unzipping_Python_embeddable_package" xml:space="preserve"> | ||
<value>Unzipping Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Failed_to_unzip_Python_embeddable_package" xml:space="preserve"> | ||
<value>Failed to unzip Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Enabling_search_path_in_Python_embeddable_package" xml:space="preserve"> | ||
<value>Enabling search path in Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Failed_to_enable_search_path_in_Python_embeddable_package" xml:space="preserve"> | ||
<value>Failed to enable search path in Python embeddable package</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Downloading_the_get_pip_py_script" xml:space="preserve"> | ||
<value>Downloading the get pip py script</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Failed_to_download_the_get_pip_py_script" xml:space="preserve"> | ||
<value>Failed to download the get pip py script</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Running_the_get_pip_py_script" xml:space="preserve"> | ||
<value>Running the get pip py script</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Failed_to_run_the_get_pip_py_script" xml:space="preserve"> | ||
<value>Failed to run the get pip py script</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Running_pip_install__0_" xml:space="preserve"> | ||
<value>Running pip install {0}</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Failed_to_run_pip_install__0_" xml:space="preserve"> | ||
<value>Failed to run pip install {0}</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Creating_virtual_environment__0_" xml:space="preserve"> | ||
<value>Creating virtual environment {0}</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Failed_to_create_virtual_environment__0_" xml:space="preserve"> | ||
<value>Failed to create virtual environment {0}</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Installing_Python_packages_in_virtual_environment__0_" xml:space="preserve"> | ||
<value>Installing Python packages in virtual environment {0}</value> | ||
</data> | ||
<data name="PythonInstaller_GetPythonTask_Failed_to_install_Python_packages_in_virtual_environment__0_" xml:space="preserve"> | ||
<value>Failed to install Python packages in virtual environment {0}</value> | ||
</data> | ||
<data name="PythonInstaller_EnableSearchPathInPythonEmbeddablePackage_Found_0_or_more_than_one_files_with__pth_extension__this_is_unexpected" xml:space="preserve"> | ||
<value>Found 0 or more than one files with _pth extension, this is unexpected</value> | ||
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. Maybe make the second clause, "expecting one and only one." to clarify. It took me a second to get this. |
||
</data> | ||
<data name="PythonInstallerTaskValidator_ValidatePipInstallPackages_Failed_to_parse_package_name_and_version_from_entry___0__" xml:space="preserve"> | ||
<value>Failed to parse package name and version from entry [{0}]</value> | ||
</data> | ||
</root> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
@@ -28,14 +29,17 @@ | |
using pwiz.Skyline.Controls; | ||
using pwiz.Skyline.FileUI.PeptideSearch; | ||
using pwiz.Skyline.Model; | ||
using pwiz.Skyline.Model.AlphaPeptDeep; | ||
using pwiz.Skyline.Model.DocSettings; | ||
using pwiz.Skyline.Model.Find; | ||
using pwiz.Skyline.Model.Irt; | ||
using pwiz.Skyline.Model.Lib; | ||
using pwiz.Skyline.Model.Koina; | ||
using pwiz.Skyline.Properties; | ||
using pwiz.Skyline.ToolsUI; | ||
using pwiz.Skyline.Util; | ||
using pwiz.Skyline.Util.Extensions; | ||
using pwiz.Skyline.Model.Tools; | ||
|
||
namespace pwiz.Skyline.SettingsUI | ||
{ | ||
|
@@ -84,13 +88,20 @@ public class PropertiesPage : IFormView { } | |
public class FilesPage : IFormView { } | ||
public class LearningPage : IFormView { } | ||
|
||
private const string PYTHON = @"Python"; | ||
private const string ALPHAPEPTDEEP_PYTHON_VERSION = @"3.12.4"; | ||
private const string ALPHAPEPTDEEP = @"alphapeptdeep"; | ||
|
||
|
||
private static readonly IFormView[] TAB_PAGES = | ||
{ | ||
new PropertiesPage(), new FilesPage(), new LearningPage(), | ||
}; | ||
|
||
private bool IsAlphaEnabled => false; // TODO: Implement and enable | ||
private bool IsAlphaEnabled => true; | ||
private bool IsCarafeEnabled => false; // TODO: Implement and enable | ||
private string AlphapeptdeepPythonVirtualEnvironmentDir => | ||
PythonInstallerUtil.GetPythonVirtualEnvironmentScriptsDir(ALPHAPEPTDEEP_PYTHON_VERSION, ALPHAPEPTDEEP); | ||
|
||
public enum DataSourcePages { files, alpha, carafe, koina } | ||
public enum LearningOptions { none, libraries, document } | ||
|
@@ -258,9 +269,9 @@ private bool ValidateBuilder(bool validateInputFiles) | |
} | ||
else if (radioAlphaSource.Checked) | ||
{ | ||
// TODO: Replace with working AlphaPeptDeep implementation | ||
if (!CreateKoinaBuilder(name, outputPath)) | ||
if (!SetupPythonEnvironmentForAlpha()) | ||
return false; | ||
Builder = new AlphapeptdeepLibraryBuilder(name, outputPath, AlphapeptdeepPythonVirtualEnvironmentDir, _documentUiContainer.DocumentUI); | ||
} | ||
else if (radioCarafeSource.Checked) | ||
{ | ||
|
@@ -286,7 +297,7 @@ private bool ValidateBuilder(bool validateInputFiles) | |
// TODO: Probably need to validate that all the libraries can be loaded into memory with progress UI | ||
} | ||
|
||
// TODO: Create CarafeLibraryBuilder class with everything necessary to build a library | ||
// TODO: Create AlphapeptdeepLibraryBuilder class with everything necessary to build a library | ||
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. Seems like the original text is still appropriate. |
||
if (!CreateKoinaBuilder(name, outputPath)) | ||
return false; | ||
} | ||
|
@@ -374,6 +385,32 @@ private bool CreateKoinaBuilder(string name, string outputPath, int nce = 27) | |
return true; | ||
} | ||
|
||
private bool SetupPythonEnvironmentForAlpha() | ||
{ | ||
var programPathContainer = new ProgramPathContainer(PYTHON, ALPHAPEPTDEEP_PYTHON_VERSION); | ||
var packages = new List<PythonPackage>() | ||
{ | ||
new PythonPackage {Name = @"peptdeep", Version = null }, | ||
// We manually set numpy to the latest version before 2.0 because of a backward incompatibility issue | ||
// See details for tracking issue in AlphaPeptDeep repo: https://github.com/MannLabs/alphapeptdeep/issues/190 | ||
// TODO: delete the following line after the issue above is resolved | ||
new PythonPackage {Name = @"numpy", Version = @"1.26.4" } | ||
}; | ||
var pythonInstaller = new PythonInstaller(programPathContainer, packages, new TextBoxStreamWriterHelper(), | ||
new PythonInstallerTaskValidator(), ALPHAPEPTDEEP); | ||
if (pythonInstaller.IsPythonVirtualEnvironmentReady()) | ||
{ | ||
return true; | ||
} | ||
|
||
using var dlg = new PythonInstallerDlg(pythonInstaller); | ||
if (dlg.ShowDialog(this) == DialogResult.Cancel) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
private void textName_TextChanged(object sender, EventArgs e) | ||
{ | ||
string name = textName.Text; | ||
|
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.
Why log4net?