-
Notifications
You must be signed in to change notification settings - Fork 41
Real OpenMS FLASHDeconv using exe from provided installation path #1045
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
Open
trishorts
wants to merge
20
commits into
smith-chem-wisc:master
Choose a base branch
from
trishorts:realFlashDecon
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d343ff5
read flashdeconv using exe requires external installation of openms a…
trishorts 93cb498
Merge branch 'master' into realFlashDecon
trishorts c454acf
Merge branch 'master' into realFlashDecon
trishorts 27b2b2d
fix(decon): address PR #1045 review findings on RealFLASHDeconvolution
trishorts 477fd63
Merge remote-tracking branch 'upstream/master' into realFlashDecon
trishorts ebac8ef
Merge branch 'master' into realFlashDecon
trishorts abd4e67
Merge branch 'master' into realFlashDecon
trishorts 6329f72
Merge branch 'master' into realFlashDecon
trishorts 8792de9
implement ToDecoyParameters on RealFLASHDeconvolutionParameters
trishorts b4c6f05
cover RealFLASHDeconvolution parser/file-guard error paths
trishorts 2404580
cover DeconvoluteWithDecoys null-decoy guard
trishorts 47cbfc0
refactor(decon): make RealFLASHDeconvolutionAlgorithm unit-testable
trishorts d194d06
tighten RealFLASHDeconvolution test assertions and fill parser gaps
trishorts d639fdf
cache validated FLASHDeconv exe paths to skip per-scan syscalls
trishorts 9975a5e
refactor(decon): move FLASHDeconv exe discovery out of the algorithm
trishorts 26b0ad8
test(decon): add registry cache + explicit-path Resolve coverage
trishorts 2341760
fix(decon): tighten FlashDeconvExePathRegistry.Register validation
trishorts 97e1324
Merge branch 'master' into realFlashDecon
trishorts 16b1c96
top down snip added to deconvolution development
trishorts 41c1c60
Merge branch 'master' into realFlashDecon
nbollis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
mzLib/MassSpectrometry/Deconvolution/Algorithms/FlashDeconvExePathRegistry.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| using System; | ||
| using System.Collections.Concurrent; | ||
| using System.IO; | ||
|
|
||
| namespace MassSpectrometry | ||
| { | ||
| /// <summary> | ||
| /// Static registry of validated FLASHDeconv executable paths. | ||
| /// | ||
| /// Each <see cref="Deconvoluter.Deconvolute(MzSpectrum, DeconvolutionParameters, MzLibUtil.MzRange)"/> | ||
| /// call constructs a fresh <see cref="RealFLASHDeconvolutionAlgorithm"/>, and | ||
| /// resolving the FLASHDeconv exe path costs File.Exists syscalls (the explicit | ||
| /// path, plus a walk of well-known paths and the PATH env var on misses). | ||
| /// On a per-scan hot path that's a few-hundred-ms stack of redundant syscalls | ||
| /// per minute. The exe doesn't move between calls, so first-call validation | ||
| /// is enough -- this registry caches the resolved path so subsequent calls | ||
| /// skip the filesystem. | ||
| /// | ||
| /// Production callers that know the path up front (typically MetaMorpheus via | ||
| /// <c>GlobalSettings.FLASHDeconvExecutablePath</c>) should call | ||
| /// <see cref="Register"/> once at startup. Ad-hoc callers don't have to do | ||
| /// anything: the algorithm caches lazily on first resolution either way. | ||
| /// </summary> | ||
| public static class FlashDeconvExePathRegistry | ||
| { | ||
| // Sentinel key for "no explicit path was supplied; this is the result of | ||
| // walking the well-known list + PATH". A real path string can never collide | ||
| // with this because the inner '<' / '>' aren't legal in filesystem paths. | ||
| internal const string DefaultSearchSentinel = "<default-search>"; | ||
|
|
||
| private static readonly ConcurrentDictionary<string, string> _validated | ||
| = new ConcurrentDictionary<string, string>(); | ||
|
|
||
| /// <summary> | ||
| /// Validate the given exe path once and cache it so subsequent | ||
| /// deconvolution calls skip the filesystem check. | ||
| /// </summary> | ||
| /// <exception cref="ArgumentException">path is null/whitespace.</exception> | ||
| /// <exception cref="FileNotFoundException">path does not exist on disk.</exception> | ||
| public static void Register(string path) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(path)) | ||
| throw new ArgumentException("Path must be a non-empty string.", nameof(path)); | ||
| if (!File.Exists(path)) | ||
| throw new FileNotFoundException( | ||
| $"FLASHDeconv not found at: {path}", path); | ||
| _validated[path] = path; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Number of entries currently cached. Useful for tests that want to | ||
| /// assert registration happened without depending on internal state. | ||
| /// </summary> | ||
| public static int Count => _validated.Count; | ||
|
|
||
| /// <summary> | ||
| /// Forget every cached path. Test-only -- production code has no reason | ||
| /// to clear because validation is permissive (a stale cached entry just | ||
| /// pushes the actual existence check to Process.Start, which surfaces | ||
| /// the same failure with a clear error). | ||
| /// </summary> | ||
| internal static void Clear() => _validated.Clear(); | ||
|
|
||
| /// <summary> | ||
| /// Look up a previously-validated resolution. Key is the explicit path | ||
| /// string, or the default-search sentinel when <paramref name="explicitPath"/> | ||
| /// is null/whitespace (i.e. the caller wants the algorithm to search | ||
| /// well-known paths + PATH itself). | ||
| /// </summary> | ||
| internal static bool TryGet(string? explicitPath, out string resolved) | ||
| { | ||
| string key = string.IsNullOrWhiteSpace(explicitPath) | ||
| ? DefaultSearchSentinel | ||
| : explicitPath!; | ||
| return _validated.TryGetValue(key, out resolved!); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Cache a resolution that has already been validated (typically by the | ||
| /// algorithm's own resolve pass). Keyed identically to | ||
| /// <see cref="TryGet"/>: explicit path or default-search sentinel. | ||
| /// </summary> | ||
| internal static void CacheValidated(string? explicitPath, string resolved) | ||
| { | ||
| string key = string.IsNullOrWhiteSpace(explicitPath) | ||
| ? DefaultSearchSentinel | ||
| : explicitPath!; | ||
| _validated[key] = resolved; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.