nanome.api.plugin_instance module

class AsyncPluginInstance[source]

Bases: nanome.api.plugin_instance.PluginInstance

Base class of any asynchronous plugin.
Constructor should never be called by the user as it is network-instantiated when a session connects.
All methods available to PluginInstance are available to AsyncPluginInstance.
Decorating these methods with @async_callback will allow them to use the async keyword in their definition
is_async = True
class PluginInstance[source]

Bases: object

Base class of any plugin.
Constructor should never be called by the user as it is network-instantiated when a session connects.
Start, update, and all methods starting by “on” can be overridden by user, in order to get requests results
add_bonds(complex_list, callback=None, fast_mode=None)[source]
Calculate bonds
Requires openbabel to be installed
Parameters:
  • complex_list (list of Complex) – List of complexes to add bonds to
  • callback (Callable[[List[Complex]], None]) – Callback when bonds are calculated.
add_dssp(complex_list, callback=None)[source]
Use DSSP to calculate secondary structures
Parameters:
  • complex_list (list of Complex) – List of complexes to add ribbons to
  • callback (Callable[[List[Complex]], None]) – Callback when DSSP is calculated.
add_to_workspace(complex_list, callback=None)[source]
Add a list of complexes to the current workspace
Parameters:
  • complex_list (list of Complex) – List of Complexes to add
  • callback (Callable[[], None]) – Callback when request is done.
add_volume(complex, volume, properties, complex_to_align_index=-1, callback=None)[source]
apply_color_scheme(color_scheme, target, only_carbons)[source]

Applies a color scheme to selected atoms.

Parameters:
  • color_scheme (ColorScheme) – the color scheme to use on atoms
  • target (ColorSchemeTarget) – whether you want to color the atom, the surface, or the ribbon
  • only_carbons (bool) – whether you want to only color carbons, or all atoms.
center_on_structures(structures, callback=None)[source]
Repositions the workspace such that the provided structure(s) will be in the
center of the world.
Parameters:
  • structures (list of Base) – Molecular structure(s) to update.
  • callback (Callable[[], None]) – Callback when center is done.
create_atom_stream(atom_indices_list, stream_type, callback)[source]
create_reading_stream(indices_list, stream_type, callback=None)[source]
Create a stream allowing the plugin to continuously receive properties of many objects
Parameters:
  • indices_list (list of int) – List of indices of all objects that should be in the stream
  • stream_type (list of Type) – Type of stream to create
  • callback (Callable[[Stream, StreamCreationError], None]) – Callback to receive the created stream.
create_shape(shape_type)[source]
create_stream(atom_indices_list, callback)[source]
create_writing_stream(indices_list, stream_type, callback=None)[source]
Create a stream allowing the plugin to continuously update properties of many objects
Parameters:
  • indices_list (list of int) – List of indices of all objects that should be in the stream
  • stream_type (list of Type) – Type of stream to create
  • callback (Callable[[Stream, StreamCreationError], None]) – Callback to receive the created stream.
custom_data
Get custom data set with Plugin.set_custom_data
Type:tuple of objects or None if no data has been set
is_async = False
menu
on_advanced_settings()[source]
Called when user presses “Advanced Settings”
on_complex_added()[source]
Called whenever a complex is added to the workspace.
on_complex_list_changed()[source]
Called whenever a complex is added or removed from the workspace.
on_complex_removed()[source]
Called whenever a complex is removed from the workspace.
on_presenter_change()[source]
Called when room’s presenter changes.
on_run()[source]
Called when user presses “Run”
on_stop()[source]
Called when user disconnects or plugin crashes
open_url(url, desktop_browser=False)[source]
Opens a URL alongside the Nanome session in the default web browser.
Parameters:
  • url (str) – url to open
  • desktop_browser (bool) – Whether to open the URL in the default web browser or in the Nanome session
plugin_files_path
remove_from_workspace(complex_list, callback=None)[source]
Remove a list of complexes from the current workspace
Parameters:
  • complex_list (list of Complex) – List of Complexes to remove
  • callback (Callable[[], None]) – Callback when request is done.
request_complex_list(callback=None)[source]
Request the list of all complexes in the workspace, in shallow mode.
Parameters:callback (Callable[[List[Complex]], None]) – Callback to receive list of complexes.
request_complexes(id_list, callback=None)[source]
Requests a list of complexes by their indices
Complexes returned contains the full structure (atom/bond/residue/chain/molecule)
Parameters:
  • id_list (list of int) – List of indices
  • callback (Callable[[List[Complex]], None]) – Callback to receive list of complexes.
request_controller_transforms(callback=None)[source]
Requests presenter controller info (head position, head rotation, left controller position, left controller rotation, right controller position, right controller rotation)
Parameters:callback (Callable[[Vector3, Quaternion, Vector3, Quaternion, Vector3, Quaternion], None]) – Callback to receive the presenter controller info.
request_directory(path, callback=None, pattern='*')[source]
Requests the content of a directory on the machine running Nanome
Parameters:
  • path (str) – Path to request. E.g. “.” means Nanome’s running directory
  • pattern (str) – Pattern to match. E.g. “.txt” will match all .txt files. Default value is “” (match everything)
request_export(format, callback=None, entities=None)[source]

Request a file export using Nanome exporters Can request either molecule or workspace export, for entities in Nanome workspace or directly sent by the plugin (without begin uploaded to workspace)

Parameters:
  • format (ExportFormats) – File format to export
  • entities (list of or unique object of type Workspace or Complex, or None, or list of or unique int) – Entities to export (complexes to send, or indices if referencing complexes in workspace, or a workspace, or nothing if exporting Nanome workspace)
  • callback (Callable[[Union[str, bytes]], None]) – Callback when file is exported.
request_files(file_list, callback=None)[source]
Reads files on the machine running Nanome, and returns them
Parameters:file_list (list of str) – List of file name (with path) to read. E.g. [“a.sdf”, “../b.sdf”] will read a.sdf in running directory, b.sdf in parent directory, and return them
request_menu_transform(index, callback=None)[source]
Requests spatial information of the plugin menu (position, rotation, scale)
Parameters:
  • index (int) – Index of the menu you wish to read
  • callback (Callable[[Vector3, Quaternion, Vector3], None]) – Callback to receive the menu’s position, rotation, and scale.
request_presenter_info(callback=None)[source]
Requests presenter account info (unique ID, name, email)
Parameters:callback (Callable[[PresenterInfo], None]) – Callback to receive the presenter account info.
request_workspace(callback=None)[source]
Request the entire workspace, in deep mode
Parameters:callback (Callable[[Workspace], None]) – Callback to receive workspace.
save_files(file_list, callback=None)[source]
Save files on the machine running Nanome, and returns result
Parameters:
  • file_list (list of FileSaveData) – List of files to save with their content
  • callback – Callback to receive save file results.
send_files_to_load(files_list, callback=None)[source]
Send file(s) to Nanome to load directly using Nanome’s importers.
Can send just a list of paths, or a list of tuples containing (path, name)
Parameters:
  • files_list (list of or unique object of type str or (str, str)) – List of files to load
  • callback (Callable[[], None]) – Callback when files are loaded.
send_notification(type, message)[source]
Send a notification to the user
Parameters:
  • type (NotificationTypes) – Type of notification to send.
  • message (str) – Text to display to the user.
set_menu_transform(index, position, rotation, scale)[source]
Update the position, scale, and rotation of the menu
Parameters:
  • index (int) – Index of the menu you wish to update
  • position (vector3) – New position of the menu
  • rotation (quaternion) – New rotation of the menu
  • scale (vector3) – New scale of the menu
set_plugin_list_button(button, text=None, usable=None)[source]
Set text and/or usable state of the buttons on the plugin connection menu in Nanome
Parameters:
  • button (ButtonType) – Button to set
  • text (str) – Text displayed on the button. If None, doesn’t set text
  • usable (bool) – Set button to be usable or not. If None, doesn’t set usable text
start()[source]
Called when user “Activates” the plugin
update()[source]
Called when instance updates (multiple times per second)
update_content(*content)[source]
Update specific UI elements (button, slider, list…)
Parameters:content (UIBase or multiple UIBase or a list of UIBase) – UI elements to update
update_menu(menu, shallow=False)[source]
Update the menu in Nanome
Parameters:
  • menu (Menu) – Menu to update
  • shallow (bool) – Whether you want to update only the menu’s top level, or the whole tree.
update_node(*nodes)[source]
Updates layout nodes and their children
Parameters:nodes (LayoutNode or multiple LayoutNode or a list of LayoutNode) – Layout nodes to update
update_structures_deep(structures, callback=None)[source]
Update the specific molecular structures in the scene to match the structures in parameter.
Will also update descendent structures and can be used to remove descendent structures.
Parameters:
  • structures (list of Base) – List of molecular structures to update.
  • callback (Callable[[], None]) – Callback when update is done.
update_structures_shallow(structures)[source]
Update the specific molecular structures in the scene to match the structures in parameter
Only updates the structure’s data, will not update children or other descendents.
Parameters:structures (list of Base) – List of molecular structures to update.
update_workspace(workspace)[source]
Replace the current workspace in the scene by the workspace in parameter
Parameters:workspace (Workspace) – New workspace
zoom_on_structures(structures, callback=None)[source]
Repositions and resizes the workspace such that the provided structure(s) will be in the
center of the users view.
Parameters:
  • structures (list of Base) – Molecular structure(s) to update.
  • callback (Callable[[], None]) – Callback when zoom is done.