Skip to content

Boltzina affinity - #54

Merged
hlasimpk merged 48 commits into
mainfrom
boltzina-affinity
Jul 17, 2026
Merged

Boltzina affinity#54
hlasimpk merged 48 commits into
mainfrom
boltzina-affinity

Conversation

@hlasimpk

@hlasimpk hlasimpk commented Jul 10, 2026

Copy link
Copy Markdown
  • Added module to run Boltz affinity scoring via boltzina
  • Updated documentation to describe how to run with Boltz affinity scores
  • Added reactifpTM as a dependency and updated the output with the scores
  • Updated the output pages so that only certain columns are shown in the output depending on how abcfold is run
  • Updated the output pages so that ipsae/reactifpTM scores are minimised if making a large multimer
  • Added ccp4cloud flag to omit PAE-viewer and open_output.py as ccp4 cloud can't deal with local servers
  • Added dry run flag to install software without running everything (important for CCP4 cloud)
  • Added template support to Boltz and OpenFold 3 (including custom template)
  • Updated OpenFold3 version
  • Changed kalign2 to kalign for Chai-1
  • Added custom template support to Chai-1, fixes Change template insertion into Chai-1 #37
  • Added force option for Boltz w/ templates
  • Added max_msa_seq option

Comment thread abcfold/affinity/boltzina_utils.py Outdated
def resolve_cache_path(cache_dir: Optional[Path] = None) -> Path:
"""Return the Boltz cache directory (holds ``ccd.pkl`` and ``mols/``).

``boltz.main.get_cache_path`` has moved/disappeared across Boltz versions,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd remove working notes from the doc strings. It has the ability to snowball with too may changes and changes should be tracked in git

Comment thread abcfold/affinity/boltzina_utils.py Outdated
def ensure_boltz_cache(cache_dir: Path) -> None:
"""Make sure the Boltz molecule/CCD cache is downloaded.

The ``boltz predict`` CLI downloads ``ccd.pkl`` / ``mols/`` / weights into

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here. this much information isn't need in the docstring

Comment thread abcfold/affinity/boltzina_utils.py Outdated
if mol_dir.exists() and any(mol_dir.iterdir()):
return

from boltz import main as bm

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason this is here and not at the top of the file?

Comment thread abcfold/affinity/boltzina_utils.py Outdated
matching how Boltzina prepares ligand mols.
"""
from rdkit import Chem
from rdkit.Chem import AllChem

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same with these, why not at the top of the file. I'm surprised the pre-commit doesn't catch these

Comment thread abcfold/affinity/boltzina_utils.py Outdated

Boltz expects one ``{record_id}.pkl`` per record, each a
``{ligand_name: rdkit_mol}`` dict, located in the processed ``mols`` dir.
"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't mind the helper functions to not have the right style doc strings but this should. Also a type hint for mol

Comment thread abcfold/affinity/boltzina_utils.py Outdated
Boltz expects one ``{record_id}.pkl`` per record, each a
``{ligand_name: rdkit_mol}`` dict, located in the processed ``mols`` dir.
"""
from rdkit import Chem

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Imported multiple times across multiple functions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The doc strings need to be revisited for consistency, the imports should be moved to the top of the file and some arguments didn't have type hints

Comment thread abcfold/affinity/run_affinity.py Outdated
logger.warning("No affinity results were produced at %s", results_csv)
return {}

import pandas as pd

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Move to the top of the file

@hllelli2 hllelli2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall, the code seems fine but AI does code very well. If using Claude, I'd recommend setting up some skills which help ensure consistency in coding style such as " /code_audit ". The big things to address are the docstrings, The style has gone from google to whatever is there now on new functions. This should be refactored for consistency. There's also may imports which are in functions ad sometimes in the middle of functions. These should be moved to the top of files. Another thing I noticed was there is a lot of new additions regarding boltzina but I dont see any new tests. Make sure these are written so that functionality can be maintained and assessed.

# --------------------------------------------------------------------------- #
# Ligand -> RDKit mol
# --------------------------------------------------------------------------- #
def write_ligand_pdb(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Still not google style

mol,
record_ids: List[str],
base_extra_mols_dir: Path,
ligand_name: str = "LIG",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"

Comment thread abcfold/affinity/boltzina_utils.py Outdated
record_ids: List[str],
out_manifest: Path,
) -> Path:
"""Clone the base record into one record per ``record_ids`` entry."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"

# Results
# --------------------------------------------------------------------------- #
def extract_affinity_results(
predictions_dir: Path,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"

@hllelli2 hllelli2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Commenting until boltzina tests add ons

@hlasimpk

Copy link
Copy Markdown
Author

Added tests for boltzina_utils, chai templates, and run_affinity.

Boltzina utils is run within the Boltz environment which has some libraries that aren't accessible in the CI env. That's why the imports were within the functions, so I've had to revert it. I have, however, tidied up the rdkit import mechanism so that it's not imported repeatedly.



def limit_msa_depth(a3m: str, max_seqs: Optional[int]) -> str:
"""Return an a3m MSA truncated to its first ``max_seqs`` sequences.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Flag

@hlasimpk
hlasimpk merged commit f4f0e56 into main Jul 17, 2026
6 checks passed
@hlasimpk
hlasimpk deleted the boltzina-affinity branch July 17, 2026 12:19
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.

Change template insertion into Chai-1

2 participants