Add cofactor-EC coverage as a second, independent cognate-ligand source - #11
Draft
m-crown wants to merge 2 commits into
Draft
Add cofactor-EC coverage as a second, independent cognate-ligand source#11m-crown wants to merge 2 commits into
m-crown wants to merge 2 commits into
Conversation
Combines CoFactor DB 2010 + BRENDA (vendored from RelLig's cofactor_ec.csv and cofactors_details.json) with UniProt's structured COFACTOR annotations into cofactor_ligands_df.pkl (preprocess_cofactors.py, mirrors preprocess_rhea.py's pattern), then concats it into get_ec_information.py's cognate_ligands_df alongside the existing reaction-derived sources, tagged via a new ligand_source column. Partial ECs are handled per the plan doc's broadcast rule: subsubclass-level wildcards (N.N.N.-) are expanded to matching terminal ECs, class/subclass-level wildcards are dropped rather than broadcast (verified unsafe - would match every terminal EC in that class). See docs/cofactor_coverage_plan.md for the full design and the coverage numbers behind it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ssing Found while running preprocess_rhea.py end-to-end for the first time against real reference data (unrelated to the cofactor-coverage work, but this script is a prerequisite for it). None of these are cofactor- specific: - rdfreader's .metadata property fixed-column-parses a mol block's whole header, including the program/timestamp line - Rhea's CDK-written molfiles don't conform to that fixed-width format (e.g. " CDK 2/12/10,15:27" instead of MDL's fixed MMDDYY field), which broke metadata parsing on ~97% of real Rhea rd/ files. Read the molecule name directly from the mol block's raw first line instead, since that's all this script actually needed from .metadata. - Assigning int -1 into a pandas StringDtype column raises under modern pandas (silently allowed under older/object-dtype behavior). Assign the string "-1" instead - the column gets cast to int on the next line regardless. - ChEBI's names.tsv.gz moved to lowercase columns upstream (already documented in download_reference_data.py's derive_chebi_results docstring, but never applied here) - rename after reading. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
docs/cofactor_coverage_plan.md: cognate ligands were previously derived only from reaction equations, which structurally misses catalytic/prosthetic cofactors that never appear as a reactant/product (e.g. NAD, FAD, PLP, metal centers).cofactor_ec.csv/cofactors_details.json) combined with UniProt's structuredCOFACTORannotations, built intocofactor_ligands_df.pklby newnextflow/bin/preprocess_cofactors.py(mirrorspreprocess_rhea.py's pattern).get_ec_information.pyconcats this alongside the existing reaction-derived sources intocognate_ligands_df, tagged via a newligand_sourcecolumn (reaction/cofactor, unioned when both apply). Strict addition - existing reaction-derived rows are unaffected (verified by test).N.N.N.-) are expanded to matching terminal ECs; class/subclass-level wildcards are dropped rather than broadcast (confirmed during planning that broadcasting those produces nonsense - e.g. a class-level wildcard matching literally every terminal EC in that class).get_chem_comp_descriptorsmoved fromprocess_all_pdb_contacts.pyintoutils.pyso both scripts can share the CCD→SMILES resolution logic.reference_data_manifest.yamlupdated: removed the stale RelLig bulk-TSV entries from an earlier version of the plan (checked against the real files - no EC column in either), added the three sources actually used, all optional and URL-verified.Test plan
nextflow/bin/tests/test_preprocess_cofactors.py- 21 tests covering UniProt parsing, the EC-completeness/broadcast safety rule (including a regression test for the class-level-wildcard bug caught during planning), CoFactor DB table loading, ChEBI resolution, and end-to-endbuild_cofactor_ligands_df.nextflow/bin/tests/test_utils_ec_broadcast.py- 10 tests forclassify_ec_completeness,broadcast_subsubclass_ec, and the movedget_chem_comp_descriptors.nextflow/bin/tests/test_get_ec_information_cofactor_merge.py- 4 tests replicating thecognate_ligands_dfconcat/groupby block to verifyligand_sourceplumbing and the strict-addition invariant.data_dirsetup).Known, explicitly out-of-scope gap: chlorophyll and other free-text-only UniProt
COFACTORannotations (~0.7% of the bulk pull) aren't mechanically resolvable by this path - deferred to a separate LLM-extraction follow-on per the plan doc.🤖 Generated with Claude Code