Enabling automatic param/top generation for ligands embedded in a larger system and multiple ligands - #1646
Open
amjjbonvin wants to merge 13 commits into
Open
Enabling automatic param/top generation for ligands embedded in a larger system and multiple ligands#1646amjjbonvin wants to merge 13 commits into
amjjbonvin wants to merge 13 commits into
Conversation
When an unknown ligand is embedded in a larger system (e.g. a protein/ligand complex or a membrane with many lipid copies), the whole PDB was passed to PRODRG, which only handles a single small molecule and failed to generate topology/parameter files. - extract_ligand(): strip everything except the ligand residues, keeping only the first copy of each residue name (copies share one topology). - run_prodrg(): accept ligand_resnames and run PRODRG once per distinct ligand, concatenating the resulting .top and .param files. Factored the single-molecule execution into _run_prodrg_single(). - topoaa: pass the detected unknown residue names to run_prodrg(). - Tests for extraction, single-copy, complex success, multi-ligand concatenation, and resname de-duplication. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Set autotoppar=true for the topoaa step run by haddock3-score so that a complex containing an unknown ligand has its topology and parameters generated on-the-fly with PRODRG, instead of failing topology generation. When ligand_top_fname/ligand_param_fname are supplied they still take precedence, and standard systems are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Apply ruff format and fix E721 (use `is` for the bool type comparison). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A missing comma had merged "-k" "--keep-all" into a single option string "-k--keep-all", so the -k short flag was never registered. Split into two separate option strings so -k works as documented. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PRODRG encodes its CNSSEP character as the second character of every atom type name it generates. When several distinct ligands are auto-generated, each is now run with a unique CNSSEP character so their atom types do not overlap once the topologies/parameters are concatenated. The characters are drawn from a pool of uppercase letters and digits that excludes the separators already used by the built-in cofactors.top topology (computed at runtime), so auto-generated ligand atom types can no longer clash with the cofactor ones. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Single auto-generated ligands are now also assigned a CNSSEP character from the cofactor-safe pool, so their prodrg atom types cannot clash with the built-in cofactors.top topology either. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Switch the new run_prodrg/extract_ligand complex tests to the 1AZS_l_u.pdb protein-ligand complex (unknown ligand GSP) and add it to the golden data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
haddock3-score now runs topoaa with autotoppar=true, and alascan scores via cli_score.main. A protein-ligand complex scored without user-provided topo/param therefore now keeps the ligand (topology generated by PRODRG) instead of dropping it, so the test asserts the ligand is retained. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CNS can write a ligand atom's element as a two-letter metal: a phosphate beta-phosphorus named PB ends up with element Pb (lead), which PRODRG rejects. When extracting a ligand, atoms whose element is an unsupported two-letter metal symbol (read from ion.top, excluding the PRODRG-supported halides Cl/Br) are collapsed back to their real single-letter element and their name re-justified. Isolated ions never reach PRODRG, so such a metal element on a ligand atom is always a mislabelling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace magic PDB column slices in _demetalise_atom and extract_ligand with the named slc_* constants from libpdb (matching gear/preprocessing), and collapse the first-copy insert-then-compare into a single setdefault. No behavior change. Co-Authored-By: Claude Opus 4.8 <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.
What does this PR do and why?
topoaa's autotoppar path calls libligand.run_prodrg(model, ...) on the entire PDB. When an unknown ligand is embedded in a larger system (protein/ligand complex, or e.g. a protein in a membrane with many lipid copies), PRODRG received the whole system and failed to generate topology/parameter files.
src/haddock/libs/libligand.pywas modified to deal with this cases.- Extracted the single-molecule PRODRG execution into a _run_prodrg_single() helper.
- When multiple distinct ligands are present (e.g. DPP + DPC), PRODRG runs once per ligand and the resulting .top files are concatenated into one, and the .param files into one.
- De-duplicates resnames so a repeated ligand triggers a single run.
- With ligand_resnames=None, behavior is unchanged (whole file → PRODRG).
cofactors.top. This uses the CNSSEP option of PRODRGVerification
How was this tested?
Tested using examples of proteins contain a ligand (e.g. 1AZS_l_u.pdb from the BM5 benchmark).
AI assistance
Claude was used to modify the ligand handling machinery and add tests.
Checklist
CHANGELOG.mdupdated for user-facing changesRelated issues
#1645
Notes for reviewers
You can test it using for example haddock3-score