Skip to content

Refactor binding-affinity prediction and update README & docs - #20

Merged
5h4ng merged 15 commits into
mainfrom
dev
Jul 17, 2026
Merged

5h4ng merged 15 commits into
mainfrom
dev

Conversation

@5h4ng

@5h4ng 5h4ng commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Refactor the NetMHCpan, NetMHCIIpan, and MHCflurry feature generators and fix custom executable-path handling.
  • Add a retained binding-affinity intermediate controlled by keepIntermediate (default: true).
  • Save the best prediction per peptide and configured predictor to <outputDir>/<experimentName>/intermediate/BA.parquet.
  • Fix whitespace parsing for PWM files and clarify allele and peptide-preprocessing behavior.
  • Refresh the README and documentation, add updated project assets, and remove obsolete bundled example configurations and large example inputs.

BA.parquet

The Parquet table is indexed by peptide. Depending on the configured predictors, it contains:

  • NetMHCpan: netmhcpan_allele, netmhcpan_affinity, netmhcpan_ba_rank
  • NetMHCIIpan: netmhciipan_allele, netmhciipan_affinity, netmhciipan_ba_rank
  • MHCflurry: mhcflurry_allele, mhcflurry_affinity, mhcflurry_el_rank

NetMHCpan and NetMHCIIpan retain the allele with the lowest valid percentile rank for each peptide. MHCflurry contributes its best-allele prediction.

User impact

  • Binding-prediction implementations and documented feature names are aligned.
  • Custom NetMHCpan and NetMHCIIpan executable paths work through the configured generator parameters.
  • Binding summaries can be retained independently from the PIN feature matrix and mokapot result tables.
  • The removed example files are replaced by documentation using explicit user-provided paths.

Validation

  • uv run mkdocs build --strict
  • uv run ruff check .
  • git diff --check
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run pytest tests/test_utils.py tests/parser — 11 passed

The complete pytest suite was not collected successfully because importing optimhc.core eagerly loads the TensorFlow-backed feature stack and deadlocks during the native TensorFlow import in this environment. This behavior predates the documentation-only final review changes.

Follow-up work

  • Add dedicated BA.parquet schema and round-trip regression tests.
  • Declare the supported Parquet engine directly instead of relying on a transitive dependency.
  • Address output-directory simplification and future overlap.parquet support in separate changes.

5h4ng added 12 commits May 24, 2026 21:08
generate_features() now returns a dict of raw predictions keyed by
generator name. When keepIntermediate is true (default), the pipeline
assembles them into BA.parquet under <output_dir>/intermediate/.

- Add _build_ba_parquet() to feature_generation.py to handle
  per-tool normalization (NetMHCpan/II rank-based best-allele,
  MHCflurry presentation percentile) and outer-join merge
- Fix generator memory release: del before gc.collect() so the
  object is freed immediately rather than at next iteration
- Add keepIntermediate: True to DEFAULT_CONFIG
- Broaden .gitignore to cover data/, examples/, and playground/
* standardize netmhcpan and netmhciipan on BA mode
* align feature names with mhcflurry (remove _best_)
* clean up dead code
- Updated README to clarify the use of allele names for MHC binding and PWM features.
- Expanded examples in tutorial documentation to include allele naming conventions for Class I and Class II.
- Added details on PWM matrix requirements and how allele names map to PWM directory formats.
Standardize feature generator docstrings for flanking amino acid and modification removal options, and align DeepLC/SpectralSimilarity docs with their actual parameters.
@5h4ng 5h4ng changed the title Refactor binding-affinity prediction and add BA.parquet output Refactor binding-affinity prediction and update README & docs Jul 16, 2026
@5h4ng
5h4ng marked this pull request as ready for review July 16, 2026 20:30
@5h4ng

5h4ng commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 786d1ed6a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread optimhc/feature/netmhcpan.py
Comment thread optimhc/core/feature_generation.py Outdated
@5h4ng
5h4ng merged commit bc1447a into main Jul 17, 2026
4 checks passed
@5h4ng
5h4ng deleted the dev branch July 17, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant