feat: public parse_fold_chains() for pure-syntactic spec parsing#3
Merged
Conversation
Adds `parse_fold_chains(spec, protein_delimiter="+") -> List[(name, copies, regions)]`, exported from `alphapulldown_input_parser`. Pure: no filesystem access, no FeatureIndex lookup — returns chain composition and copy numbers *before* features exist on disk. Delegates to the existing internal helpers `_extract_copy_and_regions` + `_parse_regions`, so all parsing rules stay in one place. Use case: downstream tooling (e.g. AlphaPulldownSnakemake) needs to know the chain composition of a fold spec at workflow-parse time to size SLURM resources or to filter folds by total length — both run before `create_features` produces the on-disk feature index that `expand_fold_specification` / `parse_fold` require. The chain name is returned verbatim (no path/extension stripping); the caller can normalise if needed. Region tokens are parsed into `RegionSelection`, honouring the same `name[:copies][:region...]` AlphaPulldown convention. Version: 0.4.0 -> 0.5.0. README updated. 26 tests pass (6 new). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
DimaMolod
added a commit
to KosinskiLab/AlphaPulldownSnakemake
that referenced
this pull request
May 26, 2026
Removes the local `parse_fold_chains` duplicate from common.smk and imports the canonical pure-syntactic parser from `alphapulldown_input_parser` (KosinskiLab/alphapulldown-input-parser#3, exposed in v0.5.0). A small adapter still drops the `regions` part of the (name, copies, regions) triples since the memory/length-filter logic here counts regions conservatively at full chain length. - workflow/rules/common.smk: import + thin (name, copies) shim. - workflow/envs/alphapulldown.yaml: bump alphapulldown-input-parser>=0.5.0. - .github/workflows/ci.yml: pip install the parser (PyPI 0.5.0 once released, with a fallback to the parser PR branch until then). - test/test_memory_resources.py: drop the local parse_fold_chains test — it tested the duplicate; the parser package owns those tests now. 20 tests pass. Co-Authored-By: Claude Opus 4.7 <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
Adds
parse_fold_chains(spec, protein_delimiter="+") -> List[(name, copies, regions)]— a pure-syntactic parse of a single fold spec into per-chain triples, with no filesystem access and noFeatureIndexlookup.Why
Downstream tooling (e.g. AlphaPulldownSnakemake length-aware SLURM sizing, KosinskiLab/AlphaPulldownSnakemake#44) needs to know the chain composition of a fold spec at workflow-parse time — before
create_featureshas produced the on-disk feature index thatexpand_fold_specification/parse_foldrequire. APS was duplicating the same parse logic; this PR lifts it into the canonical parser package.What it adds
parse_fold_chainsinalphapulldown_input_parser.parser, re-exported from the package's__init__._extract_copy_and_regions+_parse_regions, so thename[:copies][:region...]rules stay in one place.Other
0.4.0 -> 0.5.0.parse_fold_chains).🤖 Generated with Claude Code