Free Energy

molcube.free_energy.FreeEnergyProject

class FreeEnergyProject(client, calculate_program=Program.AMBER, calculate_application=Application.RELATIVE_BINDING, update_format='tqdm')

Bases: BaseProject

A class for creating and manipulating AFES projects.

Parameters:
  • calculate_program (Program)

  • calculate_application (Application)

  • update_format ('iter' | 'tqdm')

add_boresh_restraint(lig_ff, ligand_name, receptor_info, ligand_atom_name)

Add one Boresch restraint atom pair for ABFE setup.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • ligand_name (str) – Ligand name.

  • receptor_info (dict) – Receptor atom info.

  • ligand_atom_name (str) – Ligand atom name.

Returns:

None

add_core_indices(lig_ff, ligand_name, indices, set_num=1, group_index=0, visualize=True)

Add core atom indices for a ligand in selected set/group.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • ligand_name (str) – Ligand name.

  • indices – Index or list of indices to add.

  • set_num (int) – Morph set number (1-based).

  • group_index (int) – Ligand group index for BLaDE.

  • visualize (bool) – show the core indices as pngs or return the svg(s)

Returns:

None | svg | (svg, svg)

add_ligand_group(lig_ff, ligand_names)

Create a new hybrid ligand group from ligand names.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • ligand_names (list[str]) – Ligand names for new group.

Returns:

None

add_ligand_to_group(lig_ff, group_index, ligand_name)

Add one ligand to an existing hybrid ligand group.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • group_index (int) – Group index (0-based).

  • ligand_name (str) – Ligand name to add.

Returns:

None

add_morph_set(lig_ff, morph_set)

Add a morph connection to generated morph sets.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • morph_set (dict[str, Any]) – Morph edge info with start and end.

Returns:

None

apply_force_constant(distance, angle, dihedral)

Set force constants used in ABFE restraints.

Parameters:
  • distance (float) – Distance restraint constant.

  • angle (float) – Angle restraint constant.

  • dihedral (float) – Dihedral restraint constant.

Returns:

None

check_ligand_2d_structure(file_name_1, file_name_2, visualize=True)

Display two ligand 2D structures side by side for comparison.

Parameters:
  • file_name_1 (str) – First ligand file name.

  • file_name_2 (str) – Second ligand file name.

  • visualize (bool) – covert svgs to pngs and display them or return the svgs

Returns:

None | (svg, svg)

check_reference_ligands()

Check available reference ligands in the linked reference project.

Parameters:

None

Returns:

List of ligand dictionaries with chain/residue info.

Return type:

list[dict]

Note

Uses the free-energy module’s own search/target-ligands endpoint, which is what the web client calls. It resolves the PDB Reader project from this AFES project’s pdb_project_pk first and only then falls back to reference_project_id, so it serves both the quick-build path and the classic Builder-reference path. The high-throughput module’s same-named endpoint has no pdb_project_pk branch for Free Energy projects and fails with “reference_project_id not found in Free Energy project options” on a quick-built project.

create_project(title, reference_project_id='', ff=ForceField.AMBER, calculate_program=Program.AMBER, calculate_application=Application.RELATIVE_BINDING, amber_options={'lipid': Lipid.LIPID21, 'protein': Protein.FF19SB, 'water': Water.OPC}, pdb_project_id='', builder_type=None, box_margin=None, lipids=None)

Create a new alchemical free-energy project.

Two mutually exclusive ways to provide the reference system:

  1. reference_project_id – an already-built Solution/Membrane/… Builder project (the original, still-default workflow).

  2. pdb_project_id + builder_type – build the reference system on the fly from a raw PDB Reader project, mirroring the web UI’s Step 1 “Selection = PDB Reader” quick-build path. No separate Builder project is created; the PDB Reader system is wired directly into this AFES project (and billed as part of it).

Parameters:
  • title (str) – Project title.

  • reference_project_id (str) – Solution/Membrane Builder project ID. Mutually exclusive with pdb_project_id.

  • ff (ForceField) – Protein force field type.

  • calculate_program (Program) – FE backend program.

  • calculate_application (Application) – FE application type.

  • amber_options (dict[str, StrEnum]) – AMBER options (protein, water, lipid). lipid is required by the backend whenever ff is AMBER, even for non-membrane (Solution Builder) reference projects.

  • pdb_project_id (str) – PDB Reader project ID to build the reference system from directly. Mutually exclusive with reference_project_id. Requires builder_type. Not available for Application.MUTATION_FE.

  • builder_type (BuilderType) – SOLUTION or MEMBRANE. Only used when pdb_project_id is set. With MEMBRANE the PDB Reader project’s force field must equal ff; with SOLUTION a mismatch only prints a warning.

  • box_margin (float) – Water box margin (A) for the quick-built system. builder_type=MEMBRANE only.

  • lipids (list[dict]) – Lipid composition entries, one dict per lipid, e.g. {"lipid": "POPC", "upRatio": 1, "lowRatio": 1}. Required when builder_type=MEMBRANE. area is looked up from the backend’s lipid library when omitted (see get_available_lipids()) and type defaults to "standard"; pass either explicitly to override.

Returns:

True if project creation was successful, False otherwise.

Return type:

bool

Example

afes.create_project(title=’my_afes_project’, reference_project_id=sbuilder.projectId)

# Build directly from a raw PDB Reader project (Solution) afes.create_project(

title=’my_afes_project’, pdb_project_id=pdbreader.projectId, builder_type=BuilderType.SOLUTION,

)

delete_boresh_restraint(lig_ff, ligand_name, delete_indices)

Delete one or more Boresch restraints by index.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • ligand_name (str) – Ligand name.

  • delete_indices – Indices to remove.

Returns:

None

delete_core_indices(lig_ff, ligand_name, indices, set_num=1, group_index=0, visualize=True)

Delete core atom indices for a ligand in selected set/group.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • ligand_name (str) – Ligand name.

  • indices – Index or list of indices to delete.

  • set_num (int) – Morph set number (1-based).

  • group_index (int) – Ligand group index for BLaDE.

  • visualize (bool) – show the core indices as pngs or return the svg(s)

Returns:

None | svg | (svg, svg)

delete_ligand_from_group(lig_ff, group_index, ligand_name)

Remove one ligand from an existing hybrid ligand group.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • group_index (int) – Group index (0-based).

  • ligand_name (str) – Ligand name to remove.

Returns:

None

delete_ligand_group(lig_ff, group_index)

Delete a hybrid ligand group by index.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • group_index (int) – Group index (0-based).

Returns:

None

delete_morph_set(lig_ff, morph_set)

Delete a morph connection from generated morph sets.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • morph_set (dict[str, Any]) – Morph edge info with start and end.

Returns:

None

delete_mutation(delete_index)

Delete a configured mutation by list index.

Parameters:

delete_index (int) – Zero-based mutation index.

Returns:

None

download_project(filename='afes.tar.gz')

Download AFES project archive.

Parameters:

filename (str) – Output archive file path.

Returns:

None

generate_ligand_group(ligand_ff, ligand_modeler_project_id='', selected_ligands=None, reference_ligand=None)

Generate pre-ligand group suggestions for BLaDE relative binding.

Parameters:
  • reference_ligand (dict) – Receptor ligand marking the binding site, e.g. {"chainIndex": "HETE_C", "residueName": "53U"} – pick one from check_reference_ligands(). Optional: when omitted the SDK falls back to the reference ligand stored on the LRM project. See set_reference_ligand().

  • ligand_ff (list[LigandForceField]) – Ligand force fields to use.

  • ligand_modeler_project_id (str) – LRM project ID.

  • selected_ligands (dict[LigandForceField, list[str]]) – Ligand subset by FF.

Returns:

None

generate_morph_set(ligand_ff, ligand_modeler_project_id='', selected_ligands=None, generate_morphset_type=GenerateMorphsetType.CLOSED, reference_ligand=None)

Generate perturbation-path morph sets from selected ligands.

Parameters:
  • reference_ligand (dict) – Receptor ligand marking the binding site, e.g. {"chainIndex": "HETE_C", "residueName": "53U"} – pick one from check_reference_ligands(). Optional: when omitted the SDK falls back to the reference ligand stored on the LRM project. See set_reference_ligand().

  • ligand_ff (list[LigandForceField]) – Ligand force fields to use.

  • ligand_modeler_project_id (str) – LRM project ID.

  • selected_ligands (dict[LigandForceField, list[str]]) – Ligand subset by FF.

  • generate_morphset_type (GenerateMorphsetType) – Morph generation type.

Returns:

None

Example

afes.generate_morph_set(reference_ligand=reference_ligand, ligand_ff=[LigandForceField.GAFF_FAST])

generate_system(ion_type='kcl', ion_conc=0.15, use_hmr=False, temperature=310.15, margin=10, ion_neutralize=False)

Generate final FE simulation system from prepared workflow state.

Parameters:
  • ion_type (str) – Ion type.

  • ion_conc (float) – Ion concentration. Ignored by the backend when ion_neutralize is True.

  • use_hmr (bool) – Whether to use hydrogen mass repartitioning.

  • temperature (float) – System temperature in Kelvin.

  • margin (float) – Water box margin.

  • ion_neutralize (bool) – If True, add only the counter ions required to neutralize the system instead of ions up to ion_conc. Mirrors the web UI’s “Neutralize Only” checkbox.

Returns:

True if generation task succeeded, False otherwise.

Return type:

bool

Example

afes.generate_system(ion_type=’kcl’, ion_conc=0.15) afes.generate_system(ion_type=’kcl’, ion_neutralize=True)

get_available_lipids(ff=ForceField.AMBER, amber_lipid=Lipid.LIPID21)

List the lipids a membrane quick-build can use.

The library that ships with the backend holds a per-lipid area (area per lipid, in A^2) that the membrane builder needs to work out how many lipids fit in the box. The web client fetches this table and fills the value in behind the scenes; create_project() does the same, so this method is mainly useful for browsing what is available.

Parameters:
  • ff (ForceField) – Project force field.

  • amber_lipid (Lipid) – AMBER lipid force field. Ignored for CHARMM, which has a single table.

Returns:

{lipid_name: {"area": float, "charge": int, ...}}.

Return type:

dict

Example

afes.get_available_lipids()[“POPC”][“area”]

get_closest_atoms(lig_ff, ligand_name='', visualize=True)

Compute and visualize closest receptor-ligand atom candidates for ABFE.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • ligand_name (str) – Optional target ligand name.

  • visualize (bool) – visualize graphic

Returns:

None

get_core_indices(lig_ff, ligand_name='', set_num=1, group_index=0, visualize=True)

Show current core indices and visualize highlighted atoms.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • ligand_name (str) – Ligand name for non-morph workflows.

  • set_num (int) – Morph set number (1-based).

  • group_index (int) – Ligand group index for BLaDE.

  • visualize (bool) – show the core indices as pngs or return the svg(s)

Returns:

None | svg | (svg, svg)

get_distance(lig_ff=None, ligand_name='')

Open interactive 3D distance measurement view for receptor-ligand atoms.

Parameters:
  • lig_ff (LigandForceField) – Optional ligand FF to select ligand.

  • ligand_name (str) – Optional ligand name.

Returns:

None

get_ligand_groups(lig_ff)

Print current hybrid ligand groups for BLaDE workflow.

Parameters:

lig_ff (LigandForceField) – Ligand force field key.

Returns:

None

get_similarity_score(lig_ff, visualize=True)

Visualize ligand similarity matrix and dendrogram for one FF.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • visualize (bool) – whether or not to display the data as a graph, or return the dataframe

Returns:

None or DataFrame

parse_avail_mutation()

Load mutation-FE required data from current project.

Parameters:

None

Returns:

None

processing_ligand(ligand_modeler_project_id='', ligand_ff=None, selected_ligands=None, visualize=True, reference_ligand=None)

Process ligand data and prepare step-2 FE configuration payload.

Parameters:
  • reference_ligand (dict) – Receptor ligand marking the binding site, e.g. {"chainIndex": "HETE_C", "residueName": "53U"} – pick one from check_reference_ligands(). Optional: when omitted the SDK falls back to the reference ligand stored on the LRM project. See set_reference_ligand().

  • ligand_modeler_project_id (str) – LRM project ID.

  • ligand_ff (list[LigandForceField]) – Ligand FF list.

  • selected_ligands (dict[LigandForceField, list[str]]) – Ligand subset by FF.

  • visualize (bool) – covert svgs to pngs and display (True) them or do not (False)

Returns:

Next-step preview result (depends on workflow) or False.

Return type:

Any

Example

afes.processing_ligand()

read_ligand_modeler_project(project_id)

Read generated ligands from an existing LRM project.

Parameters:

project_id (str) – Ligand Reader & Modeler project ID.

Returns:

None

set_ligand_group(lig_ff, n_groups, max_rsub_count)

Set K and max R-substituent count for one ligand FF group config.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • n_groups (int) – Number of ligand groups.

  • max_rsub_count (int) – Max R-substituent per site.

Returns:

None

set_mutation(mutation_info, merge=False)

Add one mutation entry to mutation configuration list.

Parameters:
  • mutation_info (dict) – Mutation info (chainIndex, resid, mutation). mutation is a single amino acid (str | MutationResidueName) for AMBER/GROMACS (one target per site), or a list of amino acids for BLaDE MSλD, which evaluates multiple candidate substituents at one site within a single simulation.

  • merge (bool) – BLaDE MSλD only. Add the targets to the site’s existing entry instead of rejecting the call, so candidates can be built up over several calls. Off by default: without it a repeated site is treated as a mistyped resid and refused. Targets already configured for the site are ignored.

Returns:

None

Example

# AMBER / GROMACS — one target per site afes.set_mutation({“chainIndex”: “PROT_A”, “resid”: 20, “mutation”: “VAL”})

# BLaDE MSλD — multiple candidates at one site afes.set_mutation(

{“chainIndex”: “PROT_A”, “resid”: 20, “mutation”: [“VAL”, “SER”, “ALA”]}

)

# BLaDE MSλD — same site, built up over several calls afes.set_mutation({“chainIndex”: “PROT_A”, “resid”: 20, “mutation”: “VAL”}) afes.set_mutation(

{“chainIndex”: “PROT_A”, “resid”: 20, “mutation”: “SER”}, merge=True

)

set_reference_ligand(reference_ligand)

Pin which receptor ligand marks the binding site.

This is the SDK counterpart of the web client’s Step 2 “Target Ligand” picker: the choice comes from this AFES project’s own receptor (check_reference_ligands()) and is independent of the Ligand Reader & Modeler project that supplies the ligand set.

When it is not set, the SDK falls back to the reference ligand stored on the LRM project, which only works when the LRM project was aligned against the very same structure this AFES project was built from.

Parameters:

reference_ligand (dict) – {"chainIndex": ..., "residueName": ...}. Extra keys (resid, …) are ignored; the matching entry returned by the backend is stored as-is.

Returns:

The stored target-ligand entry.

Return type:

dict

Example

afes.set_reference_ligand({“chainIndex”: “HETE_C”, “residueName”: “53U”})

set_target_chain(chain_index)

Set mutation target (binding partner) chain(s) for Mutation FE workflow.

Chain(s) set here are excluded from mutation and treated as the reference/binding-partner structure — mirrors the web UI’s multi-chain binding partner selection (Reference Structure).

Parameters:

chain_index (str | list[str]) – Target chain index, or a list of target chain indices to select multiple binding partner chains at once.

Returns:

None

update_boresh_restraint(lig_ff, ligand_name, target, receptor_info={}, ligand_atom_name='')

Update a selected receptor/ligand anchor in existing Boresch restraints.

Parameters:
  • lig_ff (LigandForceField) – Ligand force field key.

  • ligand_name (str) – Ligand name.

  • target (str) – One of p1, p2, p3, l1, l2, l3.

  • receptor_info (dict) – Receptor atom info for p* updates.

  • ligand_atom_name (str) – Ligand atom name for l* updates.

Returns:

None

update_ring_match(ring_match, lig_ff, set_num=1)

Update complete-ring-match flag for a selected morph set.

Parameters:
  • ring_match (bool) – Whether to enforce complete ring matching.

  • lig_ff (LigandForceField) – Ligand force field key.

  • set_num (int) – 1-based morph set index.

Returns:

None

Schema

molcube.free_energy.conf

AMBER_AMINO_ACIDS = ['ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'GLN', 'GLU', 'GLY', 'HID', 'HIE', 'HIP', 'ILE', 'LEU', 'LYS', 'MET', 'PHE', 'PRO', 'SER', 'THR', 'TRP', 'TYR', 'VAL']

AMBER Force Field

CHARMM_AMINO_ACIDS = ['ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'GLN', 'GLU', 'GLY', 'HSD', 'HSE', 'HSP', 'ILE', 'LEU', 'LYS', 'MET', 'PHE', 'PRO', 'SER', 'THR', 'TRP', 'TYR', 'VAL']

CHARMM & Drude Force Fields

MARTINI_AMINO_ACIDS = ['ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'GLN', 'GLU', 'GLY', 'HIS', 'ILE', 'LEU', 'LYS', 'MET', 'PHE', 'PRO', 'SER', 'THR', 'TRP', 'TYR', 'VAL']

Martini Force Field

molcube.free_energy.enum

class Application(*values)

Bases: StrEnum

ABSOLUTE_BINDING = 'absolute binding'
MUTATION_FE = 'mutation free energy'
RELATIVE_BINDING = 'relative binding'
class BuilderType(*values)

Bases: StrEnum

Quick-build type for an AFES project referencing a raw PDB Reader project.

MEMBRANE = 'membrane'
SOLUTION = 'solution'
class ForceField(*values)

Bases: StrEnum

AMBER = 'amberff'
CHARMM = 'charmmff'
class GenerateMorphsetType(*values)

Bases: StrEnum

CLOSED = 'closed'
CUSTOM = 'custom'
LOMAP = 'lomap'
MST = 'minimum_spanning_tree'
RADIAL = 'radial'
class LigandForceField(*values)

Bases: StrEnum

GAFF = 'gaff'
GAFF_FAST = 'gaff-fast'
OPENFF = 'openff'
OPENFF_FAST = 'openff-fast'
XFF = 'xff'
XFF_FAST = 'xff-fast'
class Lipid(*values)

Bases: StrEnum

LIPID17 = 'Lipid17'
LIPID21 = 'Lipid21'
class Method(*values)

Bases: StrEnum

FEP = 'fep'
MSLD = 'msld'
NON_EQ_TI = 'non-eq ti'
TI = 'ti'
class MutationResidueName(*values)

Bases: StrEnum

ALA = 'ALA'
ARG = 'ARG'
ASN = 'ASN'
ASP = 'ASP'
CYS = 'CYS'
GLN = 'GLN'
GLU = 'GLU'
GLY = 'GLY'
HID = 'HID'
HIE = 'HIE'
HIP = 'HIP'
HIS = 'HIS'
HSD = 'HSD'
HSE = 'HSE'
HSP = 'HSP'
ILE = 'ILE'
LEU = 'LEU'
LYS = 'LYS'
MET = 'MET'
PHE = 'PHE'
PRO = 'PRO'
SER = 'SER'
THR = 'THR'
TRP = 'TRP'
TYR = 'TYR'
VAL = 'VAL'
class Program(*values)

Bases: StrEnum

AMBER = 'amber'
BLADE = 'blade'
GROMACS = 'gromacs'
OPENMM = 'openmm'
class Protein(*values)

Bases: StrEnum

FF14SB = 'FF14SB'
FF14SBonlysc = 'FF14SBonlysc'
FF19SB = 'FF19SB'
class Water(*values)

Bases: StrEnum

OPC = 'OPC'
TIP3P = 'TIP3P'
TIP4PD = 'TIP4PD'
TIP4PEW = 'TIP4PEW'