Bio.PDB.SCADIO module

SCADIO: write OpenSCAD program to create protein structure 3D model.

3D printing a protein structure is a non-trivial exercise due to the overall complexity and the general requirement for supporting overhang regions while printing. This software is a path to generating a model for printing (e.g. an STL file), and does not address the issues around converting the model to a physical product. OpenSCAD <http://www.openscad.org/> can create a printable model from the script this software produces. MeshMixer <http://www.meshmixer.com/>, various slicer software, and the 3D printer technology available to you provide options for addressing the problems around physically rendering the model.

The model generated here consists of OpenSCAD primitives, e.g. spheres and cylinders, representing individual atoms and bonds in an explicit model of a protein structure. The benefit is that individual atoms/bonds may be selected for specific print customizations relevant to 3D printing (such as rotatable bond mechanisms or hydrogen bond magnets). Alternatively, use e.g. Chimera to render a structure as ribbons or similar for printing as a single object.

I suggest generating your initial model using the OpenSCAD script provided here, then modifying that script according to your needs. Changing the atomScale and bondRadius values can simplify the model by removing gaps and the corresponding need for supports, or you may wish to modify the hedronDispatch() routine to select residues or chain sections for printing separately and subsequently joining with rotatable bonds. During this development phase you will likely have your version include only the data matrices generated here, by using the includeCode=False option to write_SCAD(). An example project using rotatable backbone and magnetic hydrogen bonds is at <https://www.thingiverse.com/thing:3957471>.

Bio.PDB.SCADIO.write_SCAD(entity, file, scale=None, pdbid=None, backboneOnly=False, includeCode=True, maxPeptideBond=None, start=None, fin=None, handle='protein')

Write hedron assembly to file as OpenSCAD matrices.

This routine calls both IC_Chain.internal_to_atom_coordinates() and IC_Chain.atom_to_internal_coordinates() due to requirements for scaling, explicit bonds around rings, and setting the coordinate space of the output model.

Output data format is primarily:

  • matrix for each hedron:

    len1, angle2, len3, atom covalent bond class, flags to indicate atom/bond represented in previous hedron (OpenSCAD very slow with redundant overlapping elements), flags for bond features

  • transform matrices to assemble each hedron into residue dihedra sets

  • transform matrices for each residue to position in chain

OpenSCAD software is included in this Python file to process these matrices into a model suitable for a 3D printing project.

Parameters
  • entity – Biopython PDB Structure entity structure data to export

  • file – Bipoython as_handle() filename or open file pointer file to write data to

  • scale (float) – units (usually mm) per angstrom for STL output, written in output

  • pdbid (str) – PDB idcode, written in output. Defaults to ‘0PDB’ if not supplied and no ‘idcode’ set in entity

  • backboneOnly (bool) – default False. Do not output side chain data past Cbeta if True

  • includeCode (bool) – default True. Include OpenSCAD software (inline below) so output file can be loaded into OpenSCAD; if False, output data matrices only

  • maxPeptideBond (float) – Optional default None. Override the cut-off in IC_Chain class (default 1.4) for detecting chain breaks. If your target has chain breaks, pass a large number here to create a very long ‘bond’ spanning the break.

  • start,fin (int) – default None Parameters for internal_to_atom_coords() to limit chain segment.

  • handle (str) – default ‘protein’ name for top level of generated OpenSCAD matrix structure

See IC_Residue.set_flexible() to set flags for specific residues to have rotatable bonds, and IC_Residue.set_hbond() to include cavities for small magnets to work as hydrogen bonds. See <https://www.thingiverse.com/thing:3957471> for implementation example.

The OpenSCAD code explicitly creates spheres and cylinders to represent atoms and bonds in a 3D model. Options are available to support rotatable bonds and magnetic hydrogen bonds.

Matrices are written to link, enumerate and describe residues, dihedra, hedra, and chains, mirroring contents of the relevant IC_* data structures.

The OpenSCAD matrix of hedra has additional information as follows:

  • the atom and bond state (single, double, resonance) are logged

    so that covalent radii may be used for atom spheres in the 3D models

  • bonds and atoms are tracked so that each is only created once

  • bond options for rotation and magnet holders for hydrogen bonds

    may be specified (see IC_Residue.set_flexible() and IC_Residue.set_hbond() )

Note the application of Bio.PDB.internal_coords.IC_Chain.MaxPeptideBond : missing residues may be linked (joining chain segments with arbitrarily long bonds) by setting this to a large value.

Note this uses the serial assembly per residue, placing each residue at the origin and supplying the coordinate space transform to OpenaSCAD

All ALTLOC (disordered) residues and atoms are written to the output model. (see Bio.PDB.internal_coords.IC_Residue.no_altloc)