Viewer Module
The viewer module provides interactive, browser-based 3D visualization for protein structures generated by synth-pdb.
viewer
3D Molecular Viewer for synth-pdb.
Opens generated PDB structures in browser-based 3D viewer using 3Dmol.js. Based on pdbstat's molecular viewer implementation.
Functions
view_structure_in_browser(pdb_content, filename='structure.pdb', style='cartoon', color='spectrum', restraints=None, highlights=None, show_hbonds=True)
Open 3D structure viewer in browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pdb_content
|
str
|
PDB file contents as string |
required |
filename
|
str
|
Name to display in viewer title |
'structure.pdb'
|
style
|
str
|
Initial representation style (cartoon/stick/sphere/line) |
'cartoon'
|
color
|
str
|
Initial color scheme (spectrum/chain/ss/white) |
'spectrum'
|
restraints
|
Optional[List[Any]]
|
Optional list of restraint dicts to visualize |
None
|
Example
pdb = generate_pdb_content(length=20) view_structure_in_browser(pdb, "my_peptide.pdb")
Raises:
| Type | Description |
|---|---|
Exception
|
If viewer fails to open |