Antibody Designer ================= Create Antibody Designer Project --------------------------------- Let's walk through the full Antibody Designer workflow. You can design antibodies (scFv) or nanobodies against a target antigen by specifying the PDB source, configuring CDR loops, defining the antigen target, and submitting for co-folding validation. Start by creating a project object and optionally browsing existing PDB Reader projects:: import molcube as mc from molcube.antibody_designer import ( Framework, LoopMode, PDBSource, PredictorModel, ) molcube = mc.API("api.molcube.com", 443) molcube.authenticate(api_token="your-api-token") antibody_designer = molcube.create_antibody_designer_project() antibody_designer.list_pdbreader_projects() Use ``create_project()`` to initialize the project. The available options are: * title (str): Project title. * framework_choice (Framework): ``ANTIBODY`` (scFv) or ``NANOBODY`` (default: ``ANTIBODY``). * pdb_source (PDBSource): ``PDB_READER``, ``RCSB``, ``ALPHAFOLD``, or ``CUSTOM`` (default: ``PDB_READER``). * workspace (str): ``"personal"`` or ``"team"`` (default: ``"personal"``). * pdbreader_project_id (str): Required when ``pdb_source=PDB_READER``. * pdb_id (str): Required when ``pdb_source=RCSB``. * uniprot_id (str): Required when ``pdb_source=ALPHAFOLD``. * custom_pdb_path (str | Path): Required when ``pdb_source=CUSTOM``. **PDB_READER** — use a structure prepared by a PDB Reader project:: # List available PDB Reader projects to get the project ID antibody_designer.list_pdbreader_projects() # Save pdbreader_project_id in variable pdbreader_project_id = "12345678-90ab-cdef-1234-567890abcdef" assert antibody_designer.create_project( title="my_antibody_project", framework_choice=Framework.ANTIBODY, # or Framework.NANOBODY pdb_source=PDBSource.PDB_READER, pdbreader_project_id=pdbreader_project_id, ) **RCSB** — fetch a structure directly from the RCSB PDB by its 4-letter ID:: assert antibody_designer.create_project( title="my_antibody_project", framework_choice=Framework.ANTIBODY, # or Framework.NANOBODY pdb_source=PDBSource.RCSB, pdb_id="2hac", ) **ALPHAFOLD** — fetch a predicted structure from AlphaFold DB by UniProt accession:: assert antibody_designer.create_project( title="my_antibody_project", framework_choice=Framework.ANTIBODY, # or Framework.NANOBODY pdb_source=PDBSource.ALPHAFOLD, uniprot_id="P00533", ) **CUSTOM** — upload a local PDB file:: assert antibody_designer.create_project( title="my_antibody_project", framework_choice=Framework.ANTIBODY, # or Framework.NANOBODY pdb_source=PDBSource.CUSTOM, custom_pdb_path="/path/to/structure.pdb", ) Step 2 — Settings ----------------- Design Loop ^^^^^^^^^^^ Configure CDR loop lengths for the antibody design. Use :py:meth:`list_design_loops() ` to see which loops are valid for this project's framework: * ``ANTIBODY`` (scFv): H1, H2, H3, L1, L2, L3 * ``NANOBODY``: H1, H2, H3 only Use :py:meth:`get_design_loop_ranges() ` to see the natural length range ``(min, max)`` for each loop:: antibody_designer.list_design_loops() antibody_designer.get_design_loop_ranges() Use ``set_design_loop()`` to configure a single CDR loop, or ``set_design_loops()`` to replace all at once. ``set_design_loop()`` options: * loop (str): Loop name — ``"H1"``, ``"H2"``, ``"H3"``, ``"L1"``, ``"L2"``, ``"L3"``. * mode (LoopMode): ``AUTO`` (default), ``FIXED``, or ``RANGE``. - ``AUTO``: Preserves the length from the input framework. - ``FIXED``: Fixed CDR length (requires ``length: int``). - ``RANGE``: Uniform random sampling within a range (requires ``length: (min, max)``). Note: Setting a loop that is invalid for the current framework raises an error immediately — no need to wait until ``submit_project()``. :: antibody_designer.set_design_loop("H1", mode=LoopMode.AUTO) antibody_designer.set_design_loop("H2", mode=LoopMode.FIXED, length=6) antibody_designer.set_design_loop("H3", mode=LoopMode.RANGE, length=(5, 13)) antibody_designer.set_design_loop("L1", mode=LoopMode.AUTO) antibody_designer.set_design_loop("L2", mode=LoopMode.FIXED, length=6) antibody_designer.set_design_loop("L3", mode=LoopMode.RANGE, length=(5, 13)) Target — Antigen Chain / Truncation / Hotspot ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Define the antigen target in three ordered steps: 1. **Antigen Chain** — select which protein chains to design against. 2. **Truncation** — narrow the target to a specific residue range (epitope & 10 Å truncation). 3. **Hotspot Residues** — mark binding-site contacts within the truncation region. Each step validates against the previous one. Use :py:meth:`list_antigen_chains() ` to see selectable protein chains. Use :py:meth:`list_residues(chain) ` to inspect all residue indices on a given chain (raises ``ValueError`` listing the available chains if ``chain`` is not in the input structure). **Antigen Chain** — calling ``set_antigen_chains()`` with no argument auto-selects all protein chains:: antibody_designer.list_antigen_chains() # e.g. ['A', 'B'] antibody_designer.set_antigen_chains(["A", "B"]) # or set_antigen_chains() for all **Truncation** — set the subset of residues on each antigen chain that the antibody will target. Use ``get_truncation_sequence()`` to inspect the sequence of the currently selected region. * ``add_single_truncation(chain, resid)`` — adds a single residue to the existing selection. * ``add_truncation_range(chain, start, end)`` — adds a contiguous range to the existing selection; repeated calls build a non-contiguous region across chains. * ``reset_truncation()`` — clears the current truncation selection. :: antibody_designer.get_truncation_sequence() # Add a single residue: antibody_designer.add_single_truncation("A", 15) # Accumulate a non-contiguous, multi-chain truncation region: antibody_designer.add_truncation_range("A", 10, 20) antibody_designer.add_truncation_range("B", 10, 20) # Reset if needed: antibody_designer.reset_truncation() **Hotspot Residues** — mark specific binding-site contacts within the truncation region. * ``add_single_hotspot(chain, resid)`` — adds a single residue. * ``add_hotspot_range(chain, start, end)`` — adds an inclusive range ``[start, end]``. * ``reset_hotspot_residues()`` — clears all hotspot residues. :: antibody_designer.add_hotspot_range("A", 10, 20) antibody_designer.add_single_hotspot("B", 10) # Reset if needed: antibody_designer.reset_hotspot_residues() General — Generation Parameters / Co-folding Validation Model ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use ``set_general_options()`` to set generation counts and choose the co-folding validation model. ``set_general_options()`` options: * predictor (PredictorModel): Co-folding validation model — ``ROSETTAFOLD``, ``BOLTZ2``, or ``PROTENIX`` (default: ``ROSETTAFOLD``). * num_designs (int): Number of designs to generate, 1–10 (default: 1). * num_seq_per_target (int): Sequences generated per target (default: 5). :: antibody_designer.set_general_options( predictor=PredictorModel.ROSETTAFOLD, num_designs=1, num_seq_per_target=5, ) Inspect State / Preview Payload ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Before submitting, you can inspect the current project state or preview the exact payload that will be sent to the server. * ``get_state()`` — returns the current local state (Step 1 fields and Step 2 settings) as a dict. Does not contact the server. * ``preview_payload()`` — returns the Step 2 payload after running the same validation as ``submit_project()``, for inspection. :: antibody_designer.get_state() antibody_designer.preview_payload() Submit ------ * ``submit_project()`` — submits Step 2 and blocks until the prediction pipeline completes. * ``stop_project()`` — cancels the running task (mirrors the Cancel button in the web app). :: assert antibody_designer.submit_project() # Cancel if needed: antibody_designer.stop_project() Step 3 — Results ---------------- After the job completes, retrieve result metadata and structures. * ``list_pdbs()`` — list all available PDB files (input and results). * ``get_summary()`` — retrieve confidence metrics for each designed sequence. * ``list_result_binders()`` — list the binder names of result designs (e.g. ``design_1_seq_1``). * ``get_chain_info(binder_name)`` — chain and residue information for a specific result. * ``get_input_pdb()`` — return the prepared input target PDB as text. * ``get_result_pdb(binder_name)`` — return the result PDB as text. * ``get_structure_meta()`` — return the project's stored options/metadata for the input structure. * ``get_substitutions()`` — review non-standard residue substitutions applied to the input structure. :: antibody_designer.list_pdbs() antibody_designer.get_summary() result_binders = antibody_designer.list_result_binders() binder_name = result_binders[0] antibody_designer.get_input_pdb() antibody_designer.get_result_pdb(binder_name) antibody_designer.get_chain_info(binder_name=binder_name) antibody_designer.get_structure_meta() Download Artifacts ------------------ * ``download_input_pdb(output_path)`` — save the prepared input target PDB. * ``download_selected_pdbs(selected_pdbs)`` — save several result PDBs at once. * ``download_project(output_path)`` — download the full project archive (``.tar.gz``). Note: ``output_path`` is optional. If omitted, files are saved to the current directory. Each result is saved as ``{binder_name}.pdb``. ``download_selected_pdbs()`` takes binder names — the values returned by ``list_result_binders()``. A binder name (``design__seq_``) is the result identifier; the ``seqNum`` shown in ``get_summary()`` is derived from it and only counts within one design, so it repeats once ``num_designs > 1`` and cannot name a result on its own. :: antibody_designer.download_input_pdb() result_binders = antibody_designer.list_result_binders() antibody_designer.download_selected_pdbs(result_binders[:3]) antibody_designer.download_selected_pdbs(["design_0_seq_0", "design_1_seq_0"]) antibody_designer.download_project() 3D Viewer --------- Use ``show_3d_viewer()`` to visualize the input or result structure. * **Jupyter notebook**: renders inline in the output cell. * **CLI / script**: opens the structure in the default web browser. When ``binder_name`` is omitted, the prepared input structure is displayed. When ``binder_name`` is provided, the corresponding result binder is displayed. ``show_3d_viewer()`` options: * binder_name (str | None): Result binder name (default: ``None`` — shows input structure). * width (int): Viewer width in pixels (default: ``800``). * height (int): Viewer height in pixels (default: ``600``). * protein_style (str): Protein rendering style — ``"cartoon"``, ``"stick"``, ``"line"``, or ``"surface"`` (default: ``"cartoon"``). * protein_color (str): Protein coloring scheme (default: ``"spectrum"``). * hotspot_style (str | None): Hotspot residue style — ``"cartoon"``, ``"stick"``, or ``"line"`` (default: ``"cartoon"``). * enable_surface (bool | None): Whether to render a transparent surface (default: ``True``). * surface_opacity (float | None): Surface opacity, 0.0–1.0 (default: ``0.7``). * show_label (bool | None): Whether to show residue labels on hotspots (default: ``True``). :: # Show input structure antibody_designer.show_3d_viewer() # Show a specific result binder antibody_designer.show_3d_viewer(binder_name="design_1_seq_1") # Customise rendering antibody_designer.show_3d_viewer( binder_name="design_1_seq_1", protein_style="cartoon", hotspot_style="stick", enable_surface=True, surface_opacity=0.5, )