Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the lipidomics MS/MS characterization code to improve annotation methods for several lipid classes. The changes primarily focus on correcting boolean logic, renaming parameters for clarity, adjusting fragment matching criteria, and adding support for additional adduct types.
- Fixed multiple boolean logic errors in validation conditions across various ceramide characterization methods
- Renamed parameters from "Omegaacyl/ExtAcyl" to "Acyl" for consistency and clarity
- Modified fragment matching thresholds and queries for several lipid classes (DGDG, Cer_EOS, Cer_EODS, HexCer_EOS, Cer_EBDS)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 18 comments.
| File | Description |
|---|---|
| tests/Common/CommonStandardTests/Lipidomics/MsmsCharacterizationTests.cs | Added two new test methods for CerEODS and HexCerEOS lipid characterization |
| src/Common/CommonStandard/Resources/LbmQueries.txt | Added support for DGDG with [M+Na]+ adduct and Cer_NP with positive ion mode adducts |
| src/Common/CommonStandard/Lipidomics/MsmsCharacterization.cs | Extensive refactoring of characterization logic including boolean condition fixes, parameter renaming, threshold adjustments, and algorithm modifications across multiple lipid classes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var isClassIonFound = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz, threshold); | ||
| var isClassIon2Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz2, threshold2); | ||
| if (isClassIonFound == !true || isClassIon2Found == !true) return null; | ||
| if (isClassIonFound == false && isClassIon2Found == false) return null; |
There was a problem hiding this comment.
The original condition had incorrect syntax "isClassIonFound == !true || isClassIon2Found == !true". The fix corrects it but changes from OR to AND. If the original intent was to require both ions (OR logic with negation), it should be "isClassIonFound == false || isClassIon2Found == false". Verify correct behavior for Ceramide NP.
| var isClassIon1Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz1, threshold1); | ||
| var isClassIon2Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz2, threshold2); | ||
| if (isClassIon1Found != true || isClassIon2Found != true) return null; | ||
| if (isClassIon1Found == false && isClassIon2Found == false) return null; |
There was a problem hiding this comment.
The logic change from OR to AND with negation may alter the intended behavior. The original condition returned null if either ion was NOT found. The new condition returns null only if BOTH ions are NOT found. This means the function will now proceed when at least one ion is found, whereas previously it required both ions to be present. This is a significant behavioral change that should be verified as intentional.
| var isClassIonFound = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz, threshold); | ||
| var isClassIon2Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz2, threshold2); | ||
| if (isClassIonFound == !true || isClassIon2Found == !true) return null; | ||
| if (isClassIonFound == false && isClassIon2Found == false) return null; |
There was a problem hiding this comment.
Same issue as line 10598. The original condition had incorrect syntax "isClassIonFound == !true || isClassIon2Found == !true". While the fix corrects the syntax error, it changes the logic from OR to AND. If the original intent was to require both ions (return null when either is missing), it should be "isClassIonFound == false || isClassIon2Found == false". Verify the correct behavior for Ceramide ABP.
| var isClassIon1Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz1, threshold1); | ||
| var isClassIon2Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz2, threshold2); | ||
| if (isClassIon1Found != true && isClassIon2Found != true) return null; | ||
| if (isClassIon1Found == false || isClassIon2Found == false) return null; |
There was a problem hiding this comment.
The logic has been inverted. The original "isClassIon1Found != true && isClassIon2Found != true" returned null only if BOTH ions were missing. The new "isClassIon1Found == false || isClassIon2Found == false" returns null if EITHER ion is missing. This changes from requiring at least one ion to requiring both ions. Verify this is the intended behavior for Ceramide AS.
| var PRECURSORTYPE = "[M-H]-"; | ||
| var target = new MSScanProperty | ||
| { | ||
| PrecursorMz = 736.6824, |
There was a problem hiding this comment.
The PrecursorMz value in the test target (736.6824) does not match the expected precursor mass for HexCer 34:1;O3(FA 12:0). The molMsRef correctly uses 896.7196, which should also be used in the target MSScanProperty to ensure the test is validating the correct scenario.
| PrecursorMz = 736.6824, | |
| PrecursorMz = 896.7196, |
| var isClassIonFound = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz, threshold); | ||
| var isClassIon2Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz2, threshold2); | ||
| if (isClassIonFound == !true || isClassIon2Found == !true) return null; | ||
| if (isClassIonFound == false && isClassIon2Found == false) return null; |
There was a problem hiding this comment.
Same issue as lines 10598 and 10767. The original condition had incorrect syntax "isClassIonFound == !true || isClassIon2Found == !true". The fix corrects the syntax but changes the logic from OR to AND. Verify the correct behavior for Hexceramide AP - should it require both ions or at least one ion?
| var isClassIon1Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz1, threshold1); | ||
| var isClassIon2Found = LipidMsmsCharacterizationUtility.isDiagnosticFragmentExist(spectrum, ms2Tolerance, diagnosticMz2, threshold2); | ||
| if (isClassIon1Found != true && isClassIon2Found != true) return null; | ||
| if (isClassIon1Found == false || isClassIon2Found == false) return null; |
There was a problem hiding this comment.
Same logic inversion as line 11585. The original required at least one ion to be present. The new condition requires both ions to be present. Verify this is intentional for Ceramide ADS.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nto Clean_up_MsmsCharacterization
In lipidomics analysis, annotation methods for several lipid classes were modified.