### Clone BindFlow Repository and Navigate to Example Source: https://bindflow.readthedocs.io/en/latest/_sources/source/tutorials.md This command clones the BindFlow repository and navigates into the CyclophilinD example directory. It's the first step to access the tutorial files and begin the simulation setup. ```bash git clone --depth 1 git@github.com:ale94mleon/BindFlow.git cd BindFlow/examples/CyclophilinD ``` -------------------------------- ### Manage Documentation Dependencies and Build Source: https://bindflow.readthedocs.io/en/latest/source/installation.html Commands to install Python dependencies for documentation and launch a local Sphinx server for live previewing. ```bash pip install -r requirements_docs.txt sphinx-autobuild docs public -a ``` -------------------------------- ### Install Documentation Dependencies Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md This command installs the Python dependencies required to build the Sphinx documentation for BindFlow. It uses pip to install packages listed in the requirements_docs.txt file. ```bash pip install -r requirements_docs.txt ``` -------------------------------- ### Build and Serve Sphinx Documentation Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md This command builds the Sphinx documentation for BindFlow and serves it locally using `sphinx-autobuild`. It watches for changes in the 'docs' directory and rebuilds the HTML documentation in the 'public' directory, making it accessible at http://localhost:8000. ```bash sphinx-autobuild docs public -a ``` -------------------------------- ### BindFlow Extra Directives: Dependencies (Bash Example) Source: https://bindflow.readthedocs.io/en/latest/source/guides/customizing.html Example of the `extra_directives` section, specifically the `dependencies` list. This demonstrates how to specify bash commands to load modules and set environment variables required before executing GROMACS commands. ```bash extra_directives: dependencies: - source /groups/CBG/opt/spack-0.18.1/shared.bash - module load gromacs/2022.4 - module load nvidia/latest - export GMX_MAXBACKUP=-1 ``` -------------------------------- ### BindFlow Cluster Configuration (FrontEnd Example) Source: https://bindflow.readthedocs.io/en/latest/source/guides/customizing.html Example of the `cluster` configuration section for the FrontEnd environment. This specifies that no specific options are needed for calculation jobs. ```yaml cluster: options: calculation: None ``` -------------------------------- ### Build GROMACS from Source Source: https://bindflow.readthedocs.io/en/latest/source/installation.html Automated shell scripts to download, compile, and install GROMACS from source code. Includes specific configurations for CUDA on Linux and OpenCL on macOS. ```bash VERSION="2022.4" TARGET_LOCATION="gromacs/${VERSION}" SOURCE="https://gitlab.com/gromacs/gromacs.git" SOURCE_REF="v${VERSION}" mkdir -p ${TARGET_LOCATION} git clone --depth 1 --branch ${SOURCE_REF} "${SOURCE}" "${TARGET_LOCATION}-src" cmake -DGMX_GPU="CUDA" -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13 -DGMX_BUILD_OWN_FFTW=ON -DCMAKE_INSTALL_PREFIX="$(pwd)/${TARGET_LOCATION}" -S "${TARGET_LOCATION}-src" -B "${TARGET_LOCATION}-build" nice -19 cmake --build "${TARGET_LOCATION}-build" --target install -j 8 rm -rf "${TARGET_LOCATION}-build" rm -rf "${TARGET_LOCATION}-src" source "${TARGET_LOCATION}/bin/GMXRC.bash" ``` ```bash brew install hwloc cmake gcc@13 VERSION=2022.4 git clone --depth 1 --branch v${VERSION} https://gitlab.com/gromacs/gromacs.git gromacs-src cmake -DGMX_BUILD_OWN_FFTW=ON -DCMAKE_INSTALL_PREFIX="$(pwd)/gromacs-${VERSION}" -DGMX_GPU=OpenCL -DGMX_HWLOC=ON -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13 -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -B gromacs-build -S gromacs-src cmake --build "gromacs-build" --target install -j $(sysctl -n hw.logicalcpu) rm -rf gromacs-build rm -rf gromacs-src source gromacs-${VERSION}/bin/GMXRC.bash ``` -------------------------------- ### GET /water-models/files Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/preparation/solvent.html Retrieves the absolute paths for the required GROMACS topology and configuration files for a previously initialized water model. ```APIDOC ## GET /water-models/files ### Description Returns the file paths for the water itp, ions itp, configuration gro, and atom type definitions. ### Method GET ### Endpoint /water-models/files ### Parameters None ### Response #### Success Response (200) - **water_itp** (string) - Absolute path to the water topology file. - **ions_itp** (string) - Absolute path to the ions topology file. - **water_gro** (string) - Absolute path to the configuration file. - **ffnonbonded_itp** (string) - Absolute path to the atom type definitions. #### Response Example { "water_itp": "/data/gmx_water_models/oplsaa/tip3p.itp", "ions_itp": "/data/gmx_water_models/oplsaa/ions.itp", "water_gro": "/data/gmx_water_models/configurations/tip3p.gro", "ffnonbonded_itp": "/data/gmx_water_models/oplsaa/ffnonbonded.itp" } ``` -------------------------------- ### Run BindFlow Tests Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md This command executes the pytest test suite for BindFlow. It is used to verify the installation and functionality of BindFlow after setup. The command assumes the user is in the root directory of the BindFlow repository. ```bash cd BindFlow # The path to your local copy of the repository python -m pytest tests ``` ```bash git clone --depth 1 git@github.com:ale94mleon/BindFlow.git cd BindFlow python -m pytest tests ``` -------------------------------- ### Configure System Components with Partial Definitions Source: https://bindflow.readthedocs.io/en/latest/source/guides/force-fields.html Demonstrates how to define proteins, membranes, ligands, and cofactors using simple file paths within the calculate runner. ```python calculate( protein="path/to/protein.{pdb;gro}", membrane="path/to/membrane.pdb", ligands=[ "path/to/ligand1.{mol;sdf}", "path/to/ligand2.{mol;sdf}" ], cofactor="path/to/cofactor.{mol;sdf}" ) ``` -------------------------------- ### Install gmx_MMPBSA (Stable Release) Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md Installs a specific commit of the gmx_MMPBSA package, which provides MM(P/G)BSA capabilities. This is an optional dependency for BindFlow. ```bash micromamba activate BindFlow python -m pip install -U git+https://github.com/Valdes-Tresanco-MS/gmx_MMPBSA.git@27929e02067bc2321286809818d778a77a872010 --no-deps ``` -------------------------------- ### Download Protein PDB File Source: https://bindflow.readthedocs.io/en/latest/_sources/source/faq.md Downloads a sample protein PDB file from the protein-ligand-benchmark repository for testing purposes. ```bash wget https://raw.githubusercontent.com/openforcefield/protein-ligand-benchmark/main/data/mcl1/01_protein/crd/protein.pdb ``` -------------------------------- ### Install BindFlow (Stable Release) Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md Installs the stable release of the BindFlow package using pip. The `--no-deps` flag is used, implying that dependencies should be managed by the environment. ```bash micromamba activate BindFlow python -m pip install bindflow --no-deps ``` -------------------------------- ### Install GROMACS from Source on Linux Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md This script installs GROMACS version 2022.4 from source on a Linux system. It clones the GROMACS repository, configures the build with CMake specifying CUDA support and GCC 13, builds and installs GROMACS, and finally sources the GMXRC.bash script to set up the environment. ```bash VERSION="2022.4" TARGET_LOCATION="gromacs/${VERSION}" SOURCE="https://gitlab.com/gromacs/gromacs.git" SOURCE_REF="v${VERSION}" mkdir -p ${TARGET_LOCATION} git clone --depth 1 --branch ${SOURCE_REF} "${SOURCE}" "${TARGET_LOCATION}-src" cmake -DGMX_GPU="CUDA" -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13 \ -DGMX_BUILD_OWN_FFTW=ON -DCMAKE_INSTALL_PREFIX="$(pwd)/${TARGET_LOCATION}" -S "${TARGET_LOCATION}-src" -B "${TARGET_LOCATION}-build" nice -19 cmake --build "${TARGET_LOCATION}-build" --target install -j 8 rm -rf "${TARGET_LOCATION}-build" rm -rf "${TARGET_LOCATION}-src" source "${TARGET_LOCATION}/bin/GMXRC.bash" ``` -------------------------------- ### Add Water and Ions to System (Python) Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/preparation/solvent.html This function prepares a system by creating a box, solvating it, and adding ions. It utilizes several GROMACS commands via custom wrappers: `editconf`, `solvate`, `grompp`, and `genion`. It requires input configuration (`gro`) and topology (`top`) files, and allows customization of box type, dimensions, ion concentration, and more. The function changes the current directory to `self.solvated_dir`. ```python def _add_water_and_ions( self, gro: tools.PathLike, top: tools.PathLike, bt: str = "triclinic", box: list[float] = None, angles: list[float] = None, d: float = None, c: bool = False, pname: str = "NA", nname: str = "CL", ion_conc: float = 150E-3, rmin: float = 1.0) -> None: """Make box, solvate and add ions to the system Parameters ---------- gro : tools.PathLike The configuration file. top: tools.PathLike The GMX's topology file. bt : str, optional Box type for -box and -d: triclinic, cubic, dodecahedron, octahedron, by default triclinic box : str, optional Box vector lengths (a,b,c) in nm (remember that PDB are in Angstroms), by default None. Which means that gmx editconf will use (0 0 0) angles : Iterable[float], optional This is the angles between the components of the vector in DEGREES. It is important that the provided vector has the correct units, by default None. For membrane systems (90,90,60) is advisable. d : float, optional Distance between the solute and the box, by default None. Which means that gmx editconf will use 0 c : bool, optional Center molecule in box (implied by -box and -d), by default False pname : str, optional Name of the positive ion, by default NA nname : str, optional Name of the negative ion, by default CL ion_conc : float, optional Ion concentration used during neutralization of the system, by default 150E-3 rmin : float, optional Minimum distance between ions and non-solvent, by default 1.0 out_dir : PathLike, optional Where the files will be written: solvated.gro, solvated.top, by default '.' """ # We can change directory because all the path used are already converted to absolute paths os.chdir(self.solvated_dir) editconf_kwargs = dict( f=gro, o=gro, bt=bt ) if box: editconf_kwargs['box'] = ' '.join([str(i) for i in box]) if angles: editconf_kwargs['angles'] = ' '.join([str(i) for i in angles]) if d: editconf_kwargs['d'] = d if c: editconf_kwargs['c'] = True # First write an mdp file. with open("ions.mdp", "w") as file: file.write("; Neighbor searching\n" "cutoff-scheme = Verlet\n" "rlist = 1.1\n" "pbc = xyz\n" "verlet-buffer-tolerance = -1\n" "\n; Electrostatics\n" "coulombtype = cut-off\n" "\n; VdW\n" "rvdw = 1.0\n") # It is failing becasue There is not define the atom type for the water molecules # Define GMX functions @tools.gmx_command(load_dependencies=self.load_dependencies) def editconf(**kwargs): ... @tools.gmx_command(load_dependencies=self.load_dependencies) def solvate(**kwargs): ... @tools.gmx_command(load_dependencies=self.load_dependencies) def grompp(**kwargs): ... @tools.gmx_command(load_dependencies=self.load_dependencies, stdin_command="echo \"SOL\"") def genion(**kwargs): ... # Execute the GMX functions editconf(**editconf_kwargs) solvate(cp=gro, p=top, cs=self.water_gro, o=gro) grompp(f="ions.mdp", c=gro, p=top, o="ions.tpr") genion(s="ions.tpr", p=top, o=gro, neutral=True, pname=pname, nname=nname, rmin=rmin, conc=ion_conc) # Just to clean the topology. In this way only the used atom types are written. # And the include statements are removed # It builds a monolithic topology struc = tools.readParmEDMolecule(top_file=top, gro_file=gro) ``` -------------------------------- ### Configure Ligands with Custom Topology Source: https://bindflow.readthedocs.io/en/latest/_sources/source/guides/force-fields.md Shows how to define ligands using custom topology files (.top) and coordinate files (.gro). It is recommended to use absolute paths for any include statements within the topology files. ```python ligands = [ {"conf": "path/to/ligand1.gro", "top": "path/to/ligand1.top"}, {"conf": "path/to/ligand2.gro", "top": "path/to/ligand2.top"} ] calculate(ligands=ligands) ``` -------------------------------- ### Install BindFlow from GitHub (Latest Commit) Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md Installs the latest version of BindFlow directly from its GitHub repository using pip. This is useful for accessing the most recent features or bug fixes. ```bash micromamba activate BindFlow python -m pip install git+https://github.com/ale94mleon/BindFlow.git --no-deps ``` -------------------------------- ### Install BindFlow in Developer Mode (Editable) Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md Installs BindFlow in editable mode, allowing for direct code modifications to be reflected without reinstallation. This is typically used by developers contributing to the project. ```bash micromamba activate BindFlow git clone --depth 1 git@github.com:ale94mleon/BindFlow.git cd BindFlow python -m pip install -e . --no-deps ``` -------------------------------- ### Configure Membrane System Source: https://bindflow.readthedocs.io/en/latest/source/guides/force-fields.html Sets up a membrane system by providing both a PDB structure and a topology file. The PDB file is mandatory, and topology files should avoid relative include paths. ```python calculate( ... membrane={ "conf": "path/to/membrane.pdb", "top": "path/to/membrane.top", } ... ) ``` -------------------------------- ### Install GROMACS from Source on macOS Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md This script installs GROMACS version 2022.4 from source on macOS using Homebrew for dependencies. It clones the GROMACS repository, configures the build with CMake specifying OpenCL GPU support and GCC 13, builds and installs GROMACS, and sources the GMXRC.bash script. It also includes instructions for enabling GPU compatibility checks. ```bash brew install hwloc cmake gcc@13 ``` ```bash VERSION=2022.4 git clone --depth 1 --branch v${VERSION} https://gitlab.com/gromacs/gromacs.git gromacs-src cmake -DGMX_BUILD_OWN_FFTW=ON -DCMAKE_INSTALL_PREFIX="$(pwd)/gromacs-${VERSION}" -DGMX_GPU=OpenCL -DGMX_HWLOC=ON -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13 -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -B gromacs-build -S gromacs-src cmake --build "gromacs-build" --target install -j $(sysctl -n hw.logicalcpu) rm -rf gromacs-build rm -rf gromacs-src source gromacs-${VERSION}/bin/GMXRC.bash ``` ```bash export GMX_GPU_DISABLE_COMPATIBILITY_CHECK=1 ``` -------------------------------- ### Configure Ligands with Force Fields Source: https://bindflow.readthedocs.io/en/latest/_sources/source/guides/force-fields.md Demonstrates how to prepare a list of ligand configurations using Espaloma or GAFF force fields. The input requires a list of dictionaries containing file paths and force field specifications. ```python ligands = [] for ligand_file in ligand_files: ligands.append({ "conf": ligand_file, "ff":{ "type": "espaloma", "code": "espaloma-0.3.1" } }) calculate(ligands=ligands) ``` ```python ligand_files = ["path/to/ligand1.mol", "path/to/ligand2.mol"] ligands = [] for ligand_file in ligand_files: ligands.append({ "conf": ligand_file, "ff":{ "type": "gaff", "code": "gaff-2.11" } }) calculate(ligands=ligands) ``` -------------------------------- ### Initialize Bindflow configuration class Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/preparation/system_builder.html This Python snippet demonstrates the initialization of the Bindflow configuration class, which sets up environment variables for custom force fields, creates the working directory, and assigns various molecular dynamics parameters. ```python import os from pathlib import Path # Example initialization logic self.wd = Path(builder_dir).resolve() self.wd.mkdir(exist_ok=True, parents=True) # Setting environmental variable for user custom force field: if custom_ff_path: self.custom_ff_path = Path(custom_ff_path).resolve() os.environ["GMXLIB"] = str(self.custom_ff_path) else: self.custom_ff_path = None ``` -------------------------------- ### Build and Assemble Molecular Systems Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/preparation/system_builder.html The make_system method processes individual components (ligand, protein, membrane, cofactor) and merges them into a single MD system. It supports caching of components to optimize performance when processing multiple ligands. ```python def make_system(self, ligand_definition: dict): logger.info("Processing system components") self.sys_ligand = self.small_mol_process( mol_definition=ligand_definition, name="LIG", safe_naming_prefix='x') if self.__self_was_called: logger.info("Reusing components from cache") else: if self.cofactor: self.sys_cofactor = self.small_mol_process( mol_definition=self.cofactor, name="COF", safe_naming_prefix='z') else: self.sys_cofactor = None self.sys_protein = self.gmx_process(mol_definition=self.protein) self.sys_membrane = self.gmx_process(mol_definition=self.membrane, is_membrane=True) logger.info("Merging Components") self.md_system = system_combiner(protein=self.sys_protein, membrane=self.sys_membrane, ligand=self.sys_ligand, cofactor=self.sys_cofactor) ``` -------------------------------- ### make_system Source: https://bindflow.readthedocs.io/en/latest/source/modules/system_builder.html Creates simulation system components including ligand, cofactor, protein, and membrane. It can update existing system components or create a new system from scratch. ```APIDOC ## POST /make_system ### Description Creates simulation system components including ligand, cofactor, protein, and membrane. It can update existing system components or create a new system from scratch. ### Method POST ### Endpoint /make_system ### Parameters #### Request Body - **ligand_definition** (dict) - Required - Dictionary defining the ligand, similar to `mol_definition` in `small_mol_process`. ### Response #### Success Response (200) - **Structure** - A parameterize Structure object representing the system. #### Response Example { "example": "Parameterized Structure object" } ``` -------------------------------- ### BindFlow Cluster Configuration (SLURM Example) Source: https://bindflow.readthedocs.io/en/latest/source/guides/customizing.html Example of the `cluster` configuration section for the SLURM workload manager. It defines resource allocation for both calculation and job launcher components, including partition, time, GPUs, memory, and CPU constraints. ```yaml cluster: options: calculation: partition: uds-hub time: "2-00:00:00" gpus: 1 mem: '4G' constraint: Ryzen_3975WX job: partition: uds-hub time: "2-00:00:00" mem: '1G' cpus-per-task: 2 ``` -------------------------------- ### Initialize from PDB File - Python Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/preparation/system_builder.html Initializes a class instance by reading crystal information from a PDB file. It specifically looks for the 'CRYST1' record to set up the object. If no 'CRYST1' record is found, a warning is issued. ```python def from_pdb(self, file): """Initialize the class from a pdb file Parameters ---------- file : PathLike The PDB file """ with open(file, 'r') as f: for line in f.readlines(): if line.startswith('CRYST1'): self.__init__(line) self.__is_init = True break if not self.__is_init: warnings.warn('from_pdb was not able to initialize {self.__class__.__name__}') ``` -------------------------------- ### Create FEP Simulation Directory Structure Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/mdp/mdp.html A utility function to generate the directory structure for FEP simulations, typically used in ligand or complex FEP setups. It creates nested directories based on simulation parameters like lambda values, type, and system type, placing MDP files within the structure. This function is intended for use within specific simulation setup rules. ```python def make_fep_dir_structure(sim_dir: PathLike, template_dir: PathLike, lambda_values: List[float], lambda_type: str, sys_type: str, dt_max: float, mdp_extra_kwargs: dict = None): """This function is meant to be used on ``ligand_fep_setup`` and ``complex_fet_setup`` rules. It will create the structure of the simulation directory: ``{sim_dir}/simulation/{lambda_type}.{i}/{step}/{step}.mdp`` Where: * i: init-lambda-state, """ pass ``` -------------------------------- ### List Equilibration Steps for Ligand in Water Source: https://bindflow.readthedocs.io/en/latest/_sources/source/guides/customizing.md Prints the simulation steps for the equilibration phase when the ligand is in water. This is useful for setting up initial simulations for the ligand alone. ```python from bindflow.utils.tools import list_if_file from bindflow.mdp._path_handler import _TemplatePath print(list_if_file(_TemplatePath.ligand.equi)) ``` -------------------------------- ### POST /water-models/initialize Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/preparation/solvent.html Initializes the water model environment by validating the force field family and water model code, and setting up the necessary directory structure for simulation files. ```APIDOC ## POST /water-models/initialize ### Description Validates the requested water model code against available force field families and prepares the workspace for simulation. ### Method POST ### Endpoint /water-models/initialize ### Parameters #### Request Body - **water_model_code** (string) - Required - The identifier in format "{force field family}/{water model}" (e.g., "oplsaa/tip3p"). - **builder_dir** (string) - Optional - Path where temporal files will be written. - **load_dependencies** (array) - Optional - List of shell commands to load GROMACS dependencies. ### Request Example { "water_model_code": "oplsaa/tip3p", "builder_dir": "/tmp/sim_data", "load_dependencies": ["module load gromacs/2022.4"] } ### Response #### Success Response (200) - **status** (string) - Initialization success message. - **solvated_dir** (string) - Path to the directory where solvated systems are stored. #### Response Example { "status": "success", "solvated_dir": "/tmp/sim_data/solvated_sys" } ``` -------------------------------- ### Initialize StepMDP with Parameters (Python) Source: https://bindflow.readthedocs.io/en/latest/source/modules/mdp.html Demonstrates initializing a StepMDP object with a specific step and path, then setting simulation parameters like lambda states and Coulomb interactions. This is useful for configuring free energy calculations. ```python from bindflow.mdp import mdp from bindflow.mdp.templates import TemplatePath from pathlib import Path my_mdp = mdp.StepMDP(step='00_min', step_path=Path(TemplatePath.ligand.fep)/'coul') my_mdp.set_parameters(**{"init-lambda-state": "0", "coul-lambdas": "0 0.5 1"}) print(my_mdp) ``` -------------------------------- ### Configure GROMACS Soft-Core Interaction Parameters Source: https://bindflow.readthedocs.io/en/latest/source/CHANGELOG.html Example configuration for GROMACS MDP files defining soft-core interaction parameters. These settings control the alpha, power, and sigma values for decoupled interactions. ```ini sc-alpha = 0.5 sc-power = 1 sc-sigma = 0.3 ``` -------------------------------- ### Configure Approach and Initialize Scheduler Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/orchestration/flow_builder.html This snippet processes global configuration to set up calculation parameters (FEP/MMPBSA), creates necessary directory structures for replicas, archives input files, and initializes the job scheduler for Snakemake execution. ```python if global_config["calculation_type"] == 'fep': global_config = update_nwindows_config(global_config) approach_config['lambdas'] = { 'ligand': { 'vdw': list(np.round(np.linspace(0, 1, global_config['nwindows']['ligand']['vdw']), 2)), 'coul': list(np.round(np.linspace(0, 1, global_config['nwindows']['ligand']['coul']), 2)), }, 'complex': { 'vdw': list(np.round(np.linspace(0, 1, global_config['nwindows']['complex']['vdw']), 2)), 'coul': list(np.round(np.linspace(0, 1, global_config['nwindows']['complex']['coul']), 2)), 'bonded': list(np.round(np.linspace(0, 1, global_config['nwindows']['complex']['bonded']), 2)), }, } # Directory and Archive Setup for ligand_definition in global_config["inputs"]["ligands"]: input_ligand_path = Path(ligand_definition['conf']) out_ligand_path = Path(global_config["out_approach_path"])/input_ligand_path.stem out_ligand_path.mkdir(exist_ok=True, parents=True) with tarfile.open(out_ligand_path/"input"/'orig_in.tar.gz', "w:gz") as tar: tar.add(input_ligand_path, arcname=input_ligand_path.name) # ... additional file adding ... # Scheduler Initialization scheduler = scheduler_class( cluster_config=global_config["cluster"]["options"]["calculation"], out_dir=out_path, prefix_name=f"{global_config['job_prefix']}", snake_executor_file='job.sh') scheduler.build_snakemake(jobs=global_config["num_jobs"]) ``` -------------------------------- ### Prepare Molecular Topology Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/preparation/system_builder.html This snippet demonstrates the use of PDBFixer and GROMACS tools to prepare a PDB file for simulation, followed by hydrogen mass repartitioning using ParmED. ```python fixed_pdb = self.wd/f"{name}_fixed.pdb" run(f"{env_prefix}/bin/pdbfixer {dict_to_work['conf']} --output={fixed_pdb} --add-atoms=all --replace-nonstandard") pdb2gmx(f=fixed_pdb, merge="all", ff=dict_to_work['ff']['code'], water="none", o=gro_out, p=top_out, i=posre_out, ignh=True) system = tools.readParmEDMolecule(top_file=top_out, gro_file=gro_out, check_box=check_box) if self.hmr_factor: HMassRepartition(system, self.hmr_factor).execute() system.write(str(self.wd/f'{name}_final.top')) ``` -------------------------------- ### Configure MDP for CHARMM36-like Force Fields Source: https://bindflow.readthedocs.io/en/latest/source/guides/force-fields.html Required MDP configuration for CHARMM36-like force fields in GROMACS. This setup adjusts the van der Waals modifier and switching distances, which are critical for lipid bilayer simulations. ```text constraints: h-bonds cutoff-scheme: Verlet vdwtype: cutoff vdw-modifier: force-switch rlist: 1.2 rvdw: 1.2 rvdw-switch: 1.0 coulombtype: PME rcoulomb: 1.2 DispCorr: no ``` -------------------------------- ### List FEP Steps for Soluble Protein-Ligand System Source: https://bindflow.readthedocs.io/en/latest/_sources/source/guides/customizing.md Prints a list of simulation steps involved in the FEP calculation for a soluble protein-ligand system. It leverages BindFlow's path handling utilities to retrieve the relevant template paths. ```python from bindflow.utils.tools import list_if_file from bindflow.mdp._path_handler import _TemplatePath print(list_if_file(_TemplatePath.complex.soluble.fep)) ``` -------------------------------- ### Execute BindFlow on Frontend Source: https://bindflow.readthedocs.io/en/latest/source/guides/deploy.html Command to run BindFlow workflows locally on a frontend system. This is suitable for testing or small-scale calculations, requiring manual configuration of threads and job counts. ```bash snakemake --jobs 12 --latency-wait 360 --rerun-incomplete --keep-incomplete --keep-going ``` -------------------------------- ### Create and Activate Micromamba Environment Source: https://bindflow.readthedocs.io/en/latest/_sources/source/installation.md This snippet demonstrates how to create a new conda environment using micromamba with a specified environment file and then activate it. It's a common first step for setting up reproducible environments. ```bash micromamba env create -f environment.yml --channel-priority flexible -y micromamba activate BindFlow ``` -------------------------------- ### List Equilibration Steps for Membrane Protein-Ligand System Source: https://bindflow.readthedocs.io/en/latest/_sources/source/guides/customizing.md Prints a list of simulation steps involved in the equilibration phase for a membrane protein-ligand system. It utilizes utility functions from BindFlow to handle file path templating. ```python from bindflow.utils.tools import list_if_file from bindflow.mdp._path_handler import _TemplatePath print(list_if_file(_TemplatePath.complex.membrane.equi)) ``` -------------------------------- ### Control Molecular Dynamics Parameters (MDP) - Equilibration Source: https://bindflow.readthedocs.io/en/latest/_sources/source/guides/customizing.md Configures Molecular Dynamics Parameters for simulation steps, specifically for the equilibration phase. This example shows how to set the 'nsteps' parameter for different stages of ligand and complex equilibration. ```yaml mdp: ligand: equi: 01_nvt: nsteps: 25 prod: nsteps: 250 complex: equi: 04_npt: nsteps: 25 prod: nsteps: 250 ``` -------------------------------- ### Solvate and prepare molecular system in Python Source: https://bindflow.readthedocs.io/en/latest/_modules/bindflow/preparation/solvent.html Automates the solvation, ion addition, and topology preparation for a molecular structure. It handles file I/O for .top and .gro files and applies position restraints. ```python def __call__(self, structure: Structure, bt: str = "triclinic", out_dir: tools.PathLike = '.', out_name: str = 'solvated', **kwargs) -> None: self.clean(self.solvated_dir) self.solvated_dir.mkdir(exist_ok=True, parents=True) init_top = self.solvated_dir/'init.top' init_gro = self.solvated_dir/'init.gro' structure.save(str(init_top), overwrite=True) structure.save(str(init_gro), overwrite=True) self._include_water_ions_params(init_top) self._add_water_and_ions(gro=init_gro, top=init_top, **kwargs) shutil.copy(init_top, out_dir/f'{out_name}.top') shutil.copy(init_gro, out_dir/f'{out_name}.gro') ``` -------------------------------- ### Partial Workflow Execution Source: https://bindflow.readthedocs.io/en/latest/source/guides/deploy.html Commands to control workflow execution flow using Snakemake. Includes stopping at specific rules with --until and targeting specific job instances with --target-jobs. ```bash snakemake (...) --until mmxbsa_sample_prod (...) snakemake (...) --target-jobs run_gmx_mmpbsa:ligand_name=ligand1,replica=3,sample=2 (...) ``` -------------------------------- ### Configure Ligands with Custom Topologies Source: https://bindflow.readthedocs.io/en/latest/source/guides/force-fields.html Configures ligands using pre-defined topology and structure files instead of automatic force field parameterization. ```python ligands = [ {"conf": "path/to/ligand1.gro", "top": "path/to/ligand1.top"}, {"conf": "path/to/ligand2.gro", "top": "path/to/ligand2.top"} ] calculate(ligands=ligands) ``` -------------------------------- ### Cite BindFlow using BibTeX Source: https://bindflow.readthedocs.io/en/latest/source/citations.html This BibTeX entry provides the necessary metadata to cite the BindFlow research paper. It includes the authors, journal details, and DOI for integration into reference management software. ```BibTeX @article{leon2026bindflow, author = {Martínez León, Alejandro and Andersen, Lucas and Hub, Jochen S.}, title = {BindFlow: A Free, User-Friendly Pipeline for Absolute Binding Free Energy Calculations Using Free Energy Perturbation or MM(PB/GB)SA}, journal = {Journal of Chemical Theory and Computation}, volume = {0}, number = {0}, pages = {null}, year = {0}, doi = {10.1021/acs.jctc.5c02026}, note ={PMID: 41498855}, URL = {https://doi.org/10.1021/acs.jctc.5c02026}, eprint = { https://doi.org/10.1021/acs.jctc.5c02026} } ``` -------------------------------- ### Configure Ligands with Force Fields Source: https://bindflow.readthedocs.io/en/latest/source/guides/force-fields.html Demonstrates how to parameterize ligands using OpenFF, Espaloma, or GAFF force fields. The code iterates through a list of ligand files and assigns the appropriate force field type and code. ```python ligand_files = ["path/to/ligand1.{mol;sdf}", "path/to/ligand2.{mol;sdf}"] ligands = [] for ligand_file in ligand_files: ligands.append({ "conf": ligand_file, "ff":{ "type": "openff", "code": "openff_unconstrained-2.0.0.offxml" } }) calculate(ligands=ligands) ``` -------------------------------- ### Control Molecular Dynamics Parameters (MDP) - MM(PB/GB)SA Source: https://bindflow.readthedocs.io/en/latest/_sources/source/guides/customizing.md Configures Molecular Dynamics Parameters specifically for the MM(PB/GB)SA calculation phase. This example shows setting the 'nsteps' parameter for the production run of a complex system. ```yaml mdp: complex: mmpbsa: prod: nsteps: 400 ``` -------------------------------- ### Initialize BindFlow System Builder Source: https://bindflow.readthedocs.io/en/latest/_sources/source/faq.md Demonstrates the initialization of the BindFlow MakeInputs class, which may trigger PDB standardization errors depending on the input file quality. ```python from bindflow.preparation.system_builder import MakeInputs ligands = ["lig_63.mol"] protein = {'conf': 'protein.pdb'} builder = MakeInputs( protein=protein, water_model='amber/tip3p', hmr_factor=2.5, builder_dir="builder") builder(ligand_definition=ligands[0], out_dir='test_test') ``` -------------------------------- ### Execute BindFlow on SLURM Cluster Source: https://bindflow.readthedocs.io/en/latest/source/guides/deploy.html Command to run BindFlow workflows on a SLURM-managed cluster. It utilizes the --cluster flag to define sbatch parameters for resource allocation, such as GPU usage and memory limits. ```bash snakemake --jobs 100000 --latency-wait 360 --cluster-cancel scancel --rerun-incomplete --keep-incomplete --keep-going --cluster 'sbatch --partition=uds-hub --time=2-00:00:00 --gpus=1 --gres=gpu:1 --mem=4G --cpus-per-task={threads} --job-name=test.{rule}.{jobid} --output=approach/slurm_logs/test.{rule}.{jobid}.out --error=approach/slurm_logs/test.{rule}.{jobid}.err' ``` -------------------------------- ### Modify executor-fep.py for CyclophilinD FEP Tutorial Source: https://bindflow.readthedocs.io/en/latest/source/tutorials.html These code snippets demonstrate modifications to the executor-fep.py file to customize the FEP simulation for the CyclophilinD system. Changes include selecting force fields, reducing the number of ligands and replicas, and enabling job submission. ```diff 10,17d9 < "openff_unconstrained-2.0.0": { < "type": "openff", < "code": "openff_unconstrained-2.0.0.offxml", < }, < "espaloma-0.3.1": { < "type": "espaloma", < "code": "espaloma-0.3.1", < }, 43c35 < ligands=ligands, --- > ligands=ligands[:2], 49c41 < replicas=3, --- > replicas=2, 53c45 < submit=False, --- > submit=True, ```