GLViewerWidget¶
-
class
visualife.widget.GLViewerWidget(div_id, **kwargs)¶ Bases:
objectRepresents a viewer for biological molecules.
It contains 3DMol viewer inside. It may display .pdb or .mol formats. See full documentation here https://3dmol.csb.pitt.edu/index.html
Methods Summary
active_selection(selection_dict)Defines an active selection. add_atom(a, cor[, model])Adds an atom to a viewer add_model(name, pdb_text[, if_show])Adds a new structure to this viewer. add_on_clear(callback)Add a callback function to be called when this viewer is cleared, e.g. add_style(selection, style)Modify a style used to display a fragment of a model :param selection: dictionary used to create a 3DMol.AtomSelectionSpecobject :param style: dictionary used to create a3DMol.AtomStyleSpecobject :return: Noneadd_to_menu(button_name, callback)as_cartoon(evt, **kwargs)Displays a molecule or its fragment as cartoon as_lines(evt)Displays a molecule or its fragment as lines as_spheres(evt)Displays a molecule or its fragment as spheres as_sticks(evt)Displays a molecule or its fragment as sticks atomcallback(atom, viewer, b, a)Function to run on atom click center(evt)Zooms out so the whole structure is visible :param evt: event object; its not used by this method must must appear in the method definition so it can be used as a callback for an HTML event :return: check_clicked_atoms(ev)Returns a list of atoms that are clicked clear()Clears this panel and removes all structures from memory clear_all(evt)finalize()Force the viewer to refresh hide_structure(structure_id)Hides a requested structure (i.e. remove_model(structure_id)Removes a model from this widget and from the 3Dmol viewer save_as_png(evt)show_ligand_contacts(ligand_code, …)Show contacts between ligand and receptor show_structure(structure_id)Makes visible a requested structure (i.e. update_viewer(decoys)Shows decoys from a given list zoom_heteroatom(evt)Zooms to the heteroatoms group zoom_to(evt)Zooms to the active selection Methods Documentation
-
active_selection(selection_dict)¶ Defines an active selection.
The selected residues will be subjected to
as_sticks(),as_lines(),as_spheres(),as_cartoon()andzoom_to()methods. By default the whole molecule is selected.Parameters: selection_dict – selection as JSON-like dictionary; must a valid argument for
3DMol.AtomSelectionSpecobject. A few examples are given below:{chain:'B'}: selects chain Bresi:["91-95","42-50"]: selects two ranges of residues{resn:'PMP', byres:true,expand:5}: selects residue PMP and then extends the selection to any residue whose- atom is within 5A
{chain:'B', invert: True}: selects everything but chain B
Returns: None
-
add_atom(a, cor, model=0)¶ Adds an atom to a viewer
-
add_model(name, pdb_text, if_show=True)¶ Adds a new structure to this viewer.
Parameters: - name –
stringID used to identify that molecule - pdb_text –
stringbiomalecule structure as PDB data (text) - if_show –
boolif True, the structure will be immediately visible in the viewer
Returns: $3Dmol.GLModelobject- name –
-
add_on_clear(callback)¶ Add a callback function to be called when this viewer is cleared, e.g. by calling
clear()methodParameters: callback – a function to be called Returns: None
-
add_style(selection, style)¶ Modify a style used to display a fragment of a model :param selection: dictionary used to create a
3DMol.AtomSelectionSpecobject :param style: dictionary used to create a3DMol.AtomStyleSpecobject :return: None
-
as_cartoon(evt, **kwargs)¶ Displays a molecule or its fragment as cartoon
The method will be applied to residues (chains, atoms) that have been recently selected by
active_selection()method. By default the whole structure is selectedParameters: - evt – event object; its not used by this method must must appear in the method definition so it can be used as a callback for an HTML event
- kwargs – see below
Returns: None
-
as_lines(evt)¶ Displays a molecule or its fragment as lines
The method will be applied to residues (chains, atoms) that have been recently selected by
active_selection()method. By default the whole structure is selectedParameters: - evt – event object; its not used by this method must must appear in the method definition so it can be used as a callback for an HTML event
- kwargs – see below
Returns: None
-
as_spheres(evt)¶ Displays a molecule or its fragment as spheres
The method will be applied to residues (chains, atoms) that have been recently selected by
active_selection()method. By default the whole structure is selectedParameters: - evt – event object; its not used by this method must must appear in the method definition so it can be used as a callback for an HTML event
- kwargs – see below
Returns: None
-
as_sticks(evt)¶ Displays a molecule or its fragment as sticks
The method will be applied to residues (chains, atoms) that have been recently selected by
active_selection()method. By default the whole structure is selectedParameters: - evt – event object; its not used by this method must must appear in the method definition so it can be used as a callback for an HTML event
- kwargs – see below
Returns: None
-
atomcallback(atom, viewer, b, a)¶ Function to run on atom click
-
center(evt)¶ Zooms out so the whole structure is visible :param evt: event object; its not used by this method must must appear
in the method definition so it can be used as a callback for an HTML eventReturns:
-
check_clicked_atoms(ev)¶ Returns a list of atoms that are clicked
Returns a list of clicked atoms
serialnumber
-
clear()¶ Clears this panel and removes all structures from memory
This call also triggers all
on_clearcallbacks functions
-
clear_all(evt)¶
-
finalize()¶ Force the viewer to refresh
-
hide_structure(structure_id)¶ Hides a requested structure (i.e. a model).
This method does not remove the structure, it just make it invisible. You can always show the structure again by calling
show()method. The structure must have been already added to this WidgetParameters: structure_id – stringID of a model to showReturns: True if shown successfully, false if this called failed (e.g. when the requested structure has not been registered in this Widget)
-
remove_model(structure_id)¶ Removes a model from this widget and from the 3Dmol viewer
Parameters: structure_id – stringID of a model to be removedReturns: True if the structure was actually removed
-
save_as_png(evt)¶
-
show_ligand_contacts(ligand_code, ligand_atom, rcptr_resi, rcptr_atoms)¶ Show contacts between ligand and receptor
-
show_structure(structure_id)¶ Makes visible a requested structure (i.e. a model).
The structure must have been already added to this Widget :param structure_id:
stringID of a model to show :return: True if shown successfully, false if this called failed(e.g. when the requested structure has not been registered in this Widget)
-
update_viewer(decoys)¶ Shows decoys from a given list
-
zoom_heteroatom(evt)¶ Zooms to the heteroatoms group
Parameters: - evt – event object; its not used by this method must must appear in the method definition so it can be used as a callback for an HTML event
- kwargs – see below
Returns: None
-
zoom_to(evt)¶ Zooms to the active selection
The method will zoom and center the view on residues (chains, atoms) that have been recently selected by
active_selection()method. By default the whole structure is selectedParameters: - evt – event object; its not used by this method must must appear in the method definition so it can be used as a callback for an HTML event
- kwargs – see below
Returns: None
-