Major Refactoring of Current Koina Models#1029
Merged
Alexander-Sol merged 22 commits intoMar 6, 2026
Merged
Conversation
…ther models are unbuildable. just gotta clean up and test.
…ent timeout would set to 0). Now only create client and get requests if there are valid inputs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1029 +/- ##
==========================================
- Coverage 81.46% 81.43% -0.03%
==========================================
Files 315 315
Lines 42765 42993 +228
Branches 4814 4846 +32
==========================================
+ Hits 34839 35012 +173
- Misses 7051 7089 +38
- Partials 875 892 +17
🚀 New features to boost your workflow:
|
nbollis
previously approved these changes
Feb 26, 2026
Alexander-Sol
previously approved these changes
Feb 26, 2026
…s' parameter validation.
…ub.com/pcruzparri/mzLib into FixFlyabilityClientBatchingAndTimeouts
a5c0a2e
nbollis
previously approved these changes
Mar 3, 2026
…original input sequence or validated sequence) to record predictions for. Updated LibrarySpectrum generation to take into account fragment ion MZ choice. This will better map the MZs we will typically want when creating/comparing spectral libraries.
…he side of prediction validity.
nbollis
approved these changes
Mar 5, 2026
Alexander-Sol
approved these changes
Mar 6, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SUMMARY:
Copilot Summary:
🔧 Key Changes
• Introduced Generic Type Parameters: All abstract model classes now use generic type parameters <TModelInput, TModelOutput> for type-safe prediction workflows
• New Interface: Created IPredictor<TModelInput, TModelOutput> interface defining the standard prediction contract
• Input/Output Records: Added strongly-typed input records for each model type:
• DetectabilityPredictionInput
• FragmentIntensityPredictionInput
• RetentionTimePredictionInput
• Unified API: Standardized prediction method signature: List Predict(List inputs) across all models
• New Enum: Added IncompatibleModHandlingMode with 4 strategies:
• RemoveIncompatibleMods: Strip unsupported modifications and predict with remaining mods
• UsePrimarySequence: Ignore all modifications and use only base sequence
• ThrowException(): Fail fast if incompatible modifications present
• ReturnNull: Skip prediction for peptides with incompatible modifications
• Configurable per Model: Each model can specify its preferred modification handling strategy via ModHandlingMode property
• Warning System: Predictions now include WarningException? field to communicate modification handling to users
• Dynamic Timeout Calculation: Timeouts now scale based on batch count using benchmarked timing data (BenchmarkedTimeForOneMaxBatchSizeInMilliseconds)
• Configurable Batching: Added MaxNumberOfBatchesPerRequest and ThrottlingDelayInMilliseconds properties to control request parallelism
• Better Throttling: Implements chunked batch processing with configurable delays to prevent server overload
• Edge Case Fix: Fixed bug where client timeout would be set to 0 when no valid inputs exist (commit 4244575)
• ValidInputsMask: Added boolean mask to track which inputs passed validation
• Pre-Validation: Input cleaning and validation now happens upfront before API calls
• Better Alignment: Predictions are correctly aligned back to original input order, with null predictions for invalid inputs
• Renamed Property: CanonicalAminoAcidPattern → AllowedAminoAcidPattern for clarity
• Concrete model classes (e.g., Prosit2020IntensityHCD, Prosit2019iRT, PFly2024FineTuned) significantly simplified
• Removed constructor complexity and moved validation logic to base classes
• Reduced code duplication across model implementations
📊 Files Changed
Core Abstract Classes:
• KoinaModelBase.cs (+72/-39)
• DetectabilityModel.cs (+153/-55)
• FragmentIntensityModel.cs (+241/-74)
• RetentionTimeModel.cs (+158/-45)
New Files:
• IPredictor.cs (new interface, +22 lines)
• IncompatibleModHandlingMode.cs (new enum, +13 lines)
Concrete Model Implementations:
• PFly2024FineTuned.cs (+30/-71)
• Prosit2020IntensityHCD.cs (+70/-154)
• Prosit2019iRT.cs (+85/-49)
• Prosit2020iRTTMT.cs (+71/-44)
Test Files: (All significantly refactored to test new functionality)
• PFly2024FineTunedTests.cs (+289/-191)
• Prosit2020IntensityHCDTests.cs (+292/-301)
• Prosit2019iRTTests.cs (+246/-249)
• Prosit2020iRTTMTTests.cs (+313/-555)
✅ Testing
• All existing tests updated to work with new API
• Tests now verify modification handling behavior for different modes
• Boundary condition tests enhanced
• Benchmark tests completed on 4M+ peptides/predictions for all four model types
🐛 Bug Fixes
• Fixed client timeout being set to 0 when no valid inputs exist
• Improved handling of edge cases with empty or all-invalid input lists
• Better error messaging and warning propagation
💡 Benefits
🔄 Breaking Changes
• Constructor signatures changed for all model classes
• PeptideSequences property removed in favor of input/output parameters
• Prediction method changed from RunInferenceAsync() to Predict(List)
• Some properties renamed (e.g., CanonicalAminoAcidPattern → AllowedAminoAcidPattern)