Other

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:FreeBindCraft(FreeBindCraft)

项目背景与痛点

FreeBindCraft 是对 BindCraft 的一个改进版本,旨在使 PyRosetta 的使用和安装可选化,即不需要任何许可证。BindCraft 本身是一个强大的分子对接软件,能够帮助科研人员在结构生物学中进行蛋白质与小分子之间的对接实验。然而,传统的 BindCraft 依赖于 PyRosetta,这是一个由 Rosetta 程序库衍生而来的 Python 库,其开源性不完全,使用上存在较大限制。FreeBindCraft 的出现,正是为了解决这一痛点,使得更多的科研人员能够自由使用 BindCraft,而无需受到 PyRosetta 许可证的限制。

核心技术揭秘

FreeBindCraft 通过重新设计软件的结构,简化了 PyRosetta 的依赖性。其核心在于,通过重构代码逻辑和使用可选性依赖,实现了 PyRosetta 的无缝集成或省略。以下是其技术架构和数据流的概览:

graph TD A[用户输入] B[配置加载] C1{"使用PyRosetta?"} C2{"无需PyRosetta"} D1[加载PyRosetta配置] D2[非PyRosetta配置] E1[处理] E2[处理] F[输出结果] A --> B B --> C1 C1 -.-> D1 C2 -.-> D2 D1 --> E1 D2 --> E2 E1 --> F E2 --> F

技术栈与设计模式

该项目主要采用 Python 作为开发语言,得益于 Python 对于科学计算的强大支持以及丰富的生态资源,FreeBindCraft 能够更高效地完成分子对接任务。此外,其核心算法基于分子动力学和机器学习方法,通过优化与调优参数,能够达到很高的对接精度。

在设计上,FreeBindCraft 采用了模块化的设计思想。将 PyRosetta 的逻辑与其他核心指令分离,使得用户可以灵活选择是否使用 PyRosetta 进行运算。这种松耦合的设计不仅提升了软件的可维护性,也使得未来的扩展性和适应性更强。

功能亮点与差异

FreeBindCraft 的最大亮点在于其对许可证的宽松处理。由于免去了 PyRosetta 的许可限制,使得原本受许可证束缚的用户群体能够自由使用。除此之外,由于模块化的实现方式,FreeBindCraft 支持非 PyRosetta 环境下的使用,允许用户依据自身需求选择运行方式,极大地增强了软件的灵活性与适用性。

相较于其他同类竞品,FreeBindCraft 在保证精度的同时,更加注重用户的使用体验。例如,通过提供详细的配置选项和文档说明,使得新用户能够快速上手;同时,对于进阶用户而言,也提供了丰富的自定义接口以便进行二次开发。

应用场景与落地建议

在医学研究,药物开发,以及生物学领域,FreeBindCraft 都有广泛的应用前景。其强大的分子对接功能,可以帮助科研人员更好地理解蛋白质与小分子之间的相互作用,从而加速新型药物的研发过程。此外,由于其非依赖 PyRosetta 的特性,FreeBindCraft 也能适应更多环境,例如低成本的计算集群,为资源受限的研究团队提供更多可能性。

在使用 FreeBindCraft 时,建议用户:

  • 在执行任务前,明确是否需要使用 PyRosetta 的特定功能,并进行相应的配置选择。
  • 对于复杂的任务,考虑使用更强大的计算资源,以达到更好的性能表现。
  • 通过详细阅读文档,把握其中各项功能的使用细节,发挥软件的最大潜力。

综合评价

FreeBindCraft 作为 BindCraft 的改进版本,通过去除 PyRosetta 许可的限制,显著降低了使用门槛。其模块化的设计思想,以及强大的功能支持,使得它在同类竞品中具备显著的差异化优势。对于依赖资源有限的研究团队而言,FreeBindCraft 提供了一个自由而高效的分子对接工具,极大地提升了科研工作的效率。当然,需要注意的是,由于依赖不同库环境,用户需根据实际需求做出选择。

关于

GitHub 原始描述(英文)

BindCraft modified to make PyRosetta use and installation optional: no license needed

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
198
价值分
94
活跃状态
活跃

语言占比

Dockerfile
Python
Shell

Release

README

FreeBindCraft: BindCraft with Optional PyRosetta Bypass

FreeBindCraft

This repository contains a modified version of Martin Pacesa’s BindCraft (v1.52). The primary change is the introduction of an optional PyRosetta bypass mechanism.

For comprehensive details on the original BindCraft pipeline, features, advanced settings, and filter explanations, please refer to the original BindCraft repository: https://github.com/martinpacesa/BindCraft and the original preprint. This fork is hosted at: https://github.com/cytokineking/FreeBindCraft.

Key Modification: PyRosetta Bypass Functionality

The --no-pyrosetta flag, usable during both installation and runtime, enables the following behavior:

  • OpenMM Relaxation: Structural relaxation uses an OpenMM-based protocol instead of PyRosetta’s FastRelax. This includes structure preparation with PDBFixer, ramped backbone restraints, OBC2 implicit solvation, an additional short-range repulsive term to mitigate clashes, and short MD “shakes” for early stages. Integration with FASPR (Fast, Accurate, and Deterministic Protein Side-chain Packing) for side-chain repacking and further refinement. This function is GPU-accelerated and typically is 2-4x faster than the CPU-based FastRelax, depending on the platform. OpenMM and FASPR are both open-source.
  • Shape Complementarity (SC): Replaced with an open-source implementation via sc-rs when available. See sc-rs project: https://github.com/cytokineking/sc-rs. The results of sc-rs are nearly identical to the same calculations performed by PyRosetta.
  • SASA Calculations: Surface area and derived metrics are computed using FreeSASA or a Biopython Shrake–Rupley fallback. These values align closely with the PyRosetta-derived values.
  • Interface Residues and Alignment: Uses Biopython-based routines for interface residue identification, RMSD, and PDB alignment.

Important Note: Rosetta-specific metrics that lack open-source equivalents are not computed; placeholder values are used where needed for compatibility with default filters. Evaluate design quality accordingly.

ipSAE Scoring

FreeBindCraft includes support for ipSAE (interface predicted Structural Alignment Error), a metric for evaluating protein-protein interface quality based on AlphaFold’s PAE matrix. This implementation is based on Dunbrack et al. (2025).

What is ipSAE?

  • ipSAE transforms interface PAE values using a PTM-style scoring function with adaptive normalization
  • Higher scores indicate better predicted interface quality (range 0–1)
  • Unlike i_pTM which uses a global d0, ipSAE uses per-residue d0 based on the number of interface contacts
  • ipSAE is computed for both trajectory statistics and final MPNN design statistics

Ranking by ipSAE: By default, final designs are ranked by i_pTM. You can optionally rank by ipSAE instead:

python bindcraft.py --settings ... --rank-by ipSAE

The interactive CLI (both local and Docker) also prompts for ranking method selection.

Technical Overview & Rationale

For the motivation behind the PyRosetta bypass, implementation details (OpenMM relax, FreeSASA/Biopython SASA, sc-rs shape complementarity), and empirical impact on filter decisions, see the in-depth technical overview:

  • technical_overview/FreeBindCraft_Technical_Overview.md

Installation

  1. Clone this modified repository:

    git clone https://github.com/cytokineking/FreeBindCraft [install_folder]
    
  2. Navigate into your install folder (cd [install_folder]) and run the installation script. A CUDA-compatible Nvidia graphics card is required.

    Installation script options:

    • --cuda CUDAVERSION: Specify your CUDA version (e.g., ‘12.4’).
    • --pkg_manager MANAGER: Specify ‘mamba’ or ‘conda’ (default: ‘conda’).
    • --no-pyrosetta: Use this flag to install without PyRosetta.
    • --fix-channels: Fix conda channel configuration to resolve dependency conflicts (recommended if experiencing installation issues).

    Example: PyRosetta-Free Installation

    bash install_bindcraft.sh --cuda '12.4' --pkg_manager 'conda' --no-pyrosetta
    

    Example: Standard Installation (Includes PyRosetta) If you choose to install with PyRosetta, a license is required for commercial use.

    bash install_bindcraft.sh --cuda '12.4' --pkg_manager 'conda'
    

You can also run BindCraft entirely inside a Docker container without a local installation. See the Containerized usage section below for details and an interactive wrapper.

Running BindCraft

Activate the Conda environment:

conda activate BindCraft

Change to your BindCraft installation directory:

# cd /path/to/your/bindcraft/folder/

To use the PyRosetta bypass at runtime, include the --no-pyrosetta flag:

python -u ./bindcraft.py --settings './settings_target/your_target.json' --filters './settings_filters/default_filters.json' --advanced './settings_advanced/default_4stage_multimer.json' --no-pyrosetta

To run with PyRosetta enabled (assuming it was installed):

python -u ./bindcraft.py --settings './settings_target/your_target.json' --filters './settings_filters/default_filters.json' --advanced './settings_advanced/default_4stage_multimer.json'

Note: Even if you installed BindCraft with PyRosetta, you can still run in bypass mode by adding the --no-pyrosetta flag at runtime.

For details on configuring target settings (--settings), filters (--filters), advanced parameters (--advanced), and other operational aspects of BindCraft, please consult the documentation in the original BindCraft repository.

Interactive CLI

If you run BindCraft without --settings in a terminal (TTY) or pass --interactive, an interactive setup wizard guides you through configuration.

  • Quickstart (local):
    python bindcraft.py               # auto-detects TTY and enters interactive mode
    # or
    python bindcraft.py --interactive
    
  • What it asks:
    • Project/binder name, input PDB path (validated must exist), output directory (auto-created)
    • Design type: Miniprotein (≥31 aa) or Peptide (8–30 aa)
      • Peptides: default length 8–25; filters limited to peptide_filters, peptide_relaxed_filters, no_filters; advanced limited to peptide profiles
      • Miniproteins: default length 65–150 (min ≥31); filters limited to default_filters, relaxed_filters, no_filters; advanced excludes peptide profiles
    • Verbose logging, plots, animations, and whether to run with PyRosetta
    • Ranking method for final designs: i_pTM (default) or ipSAE
  • Behavior:
    • Generates a target settings JSON inside your chosen output directory and then runs the standard pipeline

Additional New CLI Flags

You can further control runtime behavior with these flags:

  • --verbose: Enable detailed timing/progress logs for BindCraft internals.
  • --debug-pdbs: Write intermediate PDBs from OpenMM relax (.debug_deconcat.pdb, .debug_pdbfixer.pdb, .debug_post_initial_relax.pdb, .debug_post_faspr.pdb)
  • --no-plots: Disable saving design trajectory plots (overrides advanced settings).
  • --no-animations: Disable saving trajectory animations (overrides advanced settings).
  • --rank-by {i_pTM,ipSAE}: Metric to rank final designs by (default: i_pTM). Use ipSAE to rank by interface predicted Structural Alignment Error instead.

Example:

python -u ./bindcraft.py \
  --settings './settings_target/your_target.json' \
  --filters './settings_filters/default_filters.json' \
  --advanced './settings_advanced/default_4stage_multimer.json' \
  --no-animations --no-plots --verbose --rank-by ipSAE

Containerized usage (Docker)

Run FreeBindCraft in a GPU-enabled Docker container (build locally).

Prerequisites (on the host)

  • NVIDIA driver installed (check with nvidia-smi).
  • Docker CE and NVIDIA Container Toolkit:
    • Linux (Ubuntu):
      1. Install Docker CE and restart the daemon.
      2. sudo apt-get install -y nvidia-container-toolkit
      3. sudo nvidia-ctk runtime configure --runtime=docker && sudo systemctl restart docker
    • Validate GPU availability inside containers:
      docker run --rm --gpus all nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 nvidia-smi
      

Build the image from this repository

Build without PyRosetta (default):

docker build -t freebindcraft:gpu .

Build with PyRosetta:

docker build --build-arg WITH_PYROSETTA=true -t freebindcraft:pyrosetta .

Sanity test (OpenMM relax):

mkdir -p ~/bindcraft_out
docker run --gpus all --rm -it \
  --ulimit nofile=65536:65536 \
  -v ~/bindcraft_out:/work/out \
  freebindcraft:gpu \
  python extras/test_openmm_relax.py example/PDL1.pdb /work/out/relax_test

Running BindCraft in Docker (general guidance)

Decide where your inputs and outputs live. Typical layout:

  • Host input PDB: /path/on/host/your_target.pdb
  • Host output dir: /path/on/host/run_outputs
  • Settings files: either use repo defaults inside the container or mount your own copies from the host

Examples:

  1. Use repository defaults for settings (inside container), but mount outputs to host.
mkdir -p /path/on/host/run_outputs
docker run --gpus all --rm -it \
  --ulimit nofile=65536:65536 \
  -v /path/on/host/run_outputs:/root/software/pdl1 \
  freebindcraft:gpu \
  python bindcraft.py \
    --settings settings_target/PDL1.json \
    --filters settings_filters/default_filters.json \
    --advanced settings_advanced/default_4stage_multimer.json \
    --no-pyrosetta
  1. Mount a custom target settings JSON from the host (also mount your input PDB):
mkdir -p /path/on/host/run_outputs
docker run --gpus all --rm -it \
  --ulimit nofile=65536:65536 \
  -v /path/on/host/run_outputs:/root/software/pdl1 \
  -v /path/on/host/my_settings.json:/app/settings_target/my_settings.json:ro \
  -v /path/on/host/your_target.pdb:/app/example/your_target.pdb:ro \
  freebindcraft:gpu \
  python bindcraft.py \
    --settings /app/settings_target/my_settings.json \
    --filters settings_filters/default_filters.json \
    --advanced settings_advanced/default_4stage_multimer.json \
    --no-pyrosetta
  1. Mount custom filters/advanced settings from the host too:
docker run --gpus all --rm -it \
  --ulimit nofile=65536:65536 \
  -v /path/on/host/run_outputs:/root/software/pdl1 \
  -v /path/on/host/my_settings.json:/app/settings_target/my_settings.json:ro \
  -v /path/on/host/my_filters.json:/app/settings_filters/my_filters.json:ro \
  -v /path/on/host/my_advanced.json:/app/settings_advanced/my_advanced.json:ro \
  -v /path/on/host/your_target.pdb:/app/example/your_target.pdb:ro \
  freebindcraft:gpu \
  python bindcraft.py \
    --settings /app/settings_target/my_settings.json \
    --filters /app/settings_filters/my_filters.json \
    --advanced /app/settings_advanced/my_advanced.json \
    --no-pyrosetta

Notes:

  • Always mount your output directory to the path set as design_path in your target settings (e.g., /root/software/pdl1).
  • Always increase file descriptor limits with --ulimit nofile=65536:65536. The image’s entrypoint also attempts to raise the soft limit inside the container.

Interactive wrapper for Docker

After you build an image locally, you can use the interactive Docker wrapper:

python docker_cli.py

This wizard:

  • Lists local Docker images and lets you choose one (defaults to freebindcraft:gpu if present, or enter another local image tag such as freebindcraft:pyrosetta)
  • Asks for a single GPU index to expose
  • Prompts for all inputs identical to the local interactive CLI (design type, validated PDB path, output directory auto-created, chains, hotspots, peptide/miniprotein-specific filters and advanced profiles, verbose/plots/animations, PyRosetta, ranking method)
  • Writes a target settings JSON into your chosen output directory
  • Launches docker run --rm -it --gpus device=<idx> with host paths mounted to identical locations in the container so your paths work unchanged

On completion or Ctrl+C, the container exits and is auto-removed; outputs persist on the host via the mounted output directory.

Citations & External Tools

Extras: Analysis and Utility Scripts

This repository includes additional scripts and documents in extras/ to assist with analysis and testing:

  • extras/analyze_bindcraft_rejections.py: Analyze MPNN rejections across runs and quantify which filters are most responsible; can estimate hypothetical rankings when Rosetta-only filters trigger.
  • extras/bindcraft_rejection_analysis_spec.md: Specification describing the rejection analysis outputs and methodology.
  • extras/BUGFIX_FILE_DESCRIPTORS.md: Notes on file descriptor fixes in high-throughput runs.
  • extras/check_ulimit.sh: Helper script to check system ulimit and suggest adjustments for many-parallel-file workloads.
  • extras/compare_interface_metrics_all.py: Compute interface metrics via PyRosetta (if available), FreeSASA, and Biopython across a folder of PDBs; outputs a combined CSV.
  • extras/compare_pyrosetta_bypass_scores.py: Side-by-side comparison of PyRosetta vs Biopython-only metrics for a folder of PDBs.
  • extras/rescore_accepted_with_rosetta.py: Rescore accepted (Ranked preferred) PDBs from a --no-pyrosetta run using PyRosetta, evaluate whether PyRosetta-driven filters would reject each design, and report failing filters. Supports dynamic filters (default|relaxed|design|custom), parallel workers, and an optional --fast-relax mode to run PyRosetta FastRelax prior to scoring.
  • extras/test_openmm_relax.py: Quick test harness for OpenMM and PyRosetta relax routines.

See extras/README.md for detailed usage examples and options.

Contributing

Pull requests are welcome.

Known Issues

  • OpenMM GPU backend selection (OpenCL preferred over CUDA): We deliberately prefer OpenCL over CUDA for OpenMM relax because we have not been able to get the CUDA backend reliably working in our environments. OpenCL works, but it is less stable over long runs, so the relax step is executed in a subprocess for isolation and reliability. It also produces JIT log spam; see the next item for a suppression example.
  • OpenCL JIT “log spam”: You may see repeated lines such as “Failed to read file: /tmp/dep-76532a.d” emitted to stdout/stderr during OpenCL kernel builds.
    • Recommend line buffering to keep logs responsive when filtering
      • Combined output (preferred when piping/teeing):
      python -u ./bindcraft.py \
        --settings ./settings_target/your_target.json \
        --filters ./settings_filters/default_filters.json \
        --advanced ./settings_advanced/default_4stage_multimer.json \
        --no-pyrosetta \
        |& stdbuf -oL -eL grep -v -E 'Failed to read file: .*/dep-[0-9a-fA-F]+\.d([[:space:]]*)?$' \
        | stdbuf -oL tee -a ./output/your_target.log
      
      • Stderr-only (no further pipes):
      python -u ./bindcraft.py \
        --settings ./settings_target/your_target.json \
        --filters ./settings_filters/default_filters.json \
        --advanced ./settings_advanced/default_4stage_multimer.json \
        --no-pyrosetta \
        2> >(stdbuf -oL -eL grep -v -E 'Failed to read file: .*/dep-[0-9a-fA-F]+\.d([[:space:]]*)?$' >&2)
      
      • Notes:
        • stdbuf forces line buffering for both stdout and stderr, preventing pipeline buffering delays.
        • Use POSIX character class [[:space:]] for portability.
        • If preserving exit code across pipes matters, consider: set -o pipefail.

评论

暂无评论