Design Hub developer guide - plugins¶
Design Hub's functionality can be extended by plugins in several workflows to meet the expectations for different user groups and use-cases. Plugins are generally implemented as NodeJS modules implementing a simple stateless API, connecting to one or more web services or databases.
Table of contents:
Plugin types¶
Realtime plugins
Realtime plugins encapsulate functionality that describe 1 virtual compound in 1 specific area of phys-chem properties, ADMET, commercial availability, literature data, in-silico assay data, structure checks or modeling.
For more information specifically related to realtime plugins, check the Developer guide - real time plugins.
Resolver plugins
A resolver plugin converts a corporate identifier into a chemical structure using a structure database lookup.
For more information specifically related to resolver plugins, check the Developer guide - resolver plugins.
Storage plugins
A storage plugin establishes and maintains a flat database of all virtual compounds in Design Hub. Typically implemented with a SQL database connection, this can be used to support advanced analysis, visualizations, or a backup.
For more information specifically related to storage plugins, check the Developer guide - storage plugins.
Registry plugins
A registry plugin helps lookup the synthesis status and substance ID of a compound by periodically executing searches in a compound registration system or ELN.
For more information specifically related to registry plugins, check the Developer guide - registry plugins.
Import plugins
Import plugins load chemical structures into Design Hub based on user input or automatically, followed by deduplication and processing of records.
For more information specifically related to import plugins, check the Developer guide - import plugins.
Company plugins
A company plugin assists authorizing a user by fetching project and group membership for the user.
For more information specifically related to registry plugins, check the Developer guide - company plugins.
Configuration¶
All plugins are loaded by the automatically during start up of the application. The definition of plugins to load are set in the configuration guide. For more, check the Configuration guide's servicesDirectory section.
Development¶
For the successful development of a plugin, we recommend the following preparation:
- an instance of Design Hub available for development purposes, i.e.: the ability to stop and start it, to try different configuration options
- familiarity with JavaScript, NodeJS and its module system
- good understanding of Promises / async await
NodeJS introduction material: https://www.youtube.com/watch?v=_l96hPlqzcI (78m), https://www.youtube.com/watch?v=hKQr2DGJjUQ (19m), https://www.youtube.com/watch?v=cJVXP1bU68Y (48m)
NodeJS module description: https://nodejs.org/api/modules.html
Promise introduction: https://www.html5rocks.com/en/tutorials/es6/promises/#toc-async, https://github.com/kriskowal/q#readme
Utility functions¶
Most Design Hub plugins benefit from a library of commonly used functions. Chemaxon is providing one as an npm package called @chemaxon/dh-utils, including the following functions:
- chemical file format conversion using JChem Microservices IO, used whenever a non-Chemaxon backend is involved in the plugin functionality
- 2D rendering of chemical structures using JChem Microservices IO, used whenever the (realtime) plugin needs to depict molecules
- a general purpose HTTP library for REST/JSON, multipart or form-urlencoded requests, with basic or Bearer token authentication
- a utility library for processing PDB files
Download @chemaxon/dh-utils¶
This utility library is published as a scoped npm package. The @chemaxon scope can be accessed by obtaining a Chemaxon account and setting up an npm registry for the scope to Chemaxon's public package repository. The full list of steps to configure this npm registry is:
Example usage¶
API¶
async get(data): String | Buffer | Object
Sends an HTTP GET request using the request library. For parameterization, see the options object.
Returns (a Promise of) the response body depending on encoding specified in the request.
async post(data): String | Buffer | Object
Sends an HTTP POST request using the request library. For parameterization, see the options object.
Returns (a Promise of) the response body depending on encoding specified in the request.
async req(data): String | Buffer | Object
Sends an HTTP request using the request library. For parameterization, see the options object.
Returns (a Promise of) the response body depending on encoding specified in the request.
async convert(structure, toFormat): String
Converts the input chemical structure to the specified format using JChem Microservices IO.
Parameters:
structure(string): the chemical structure to converttoFormat(string): the desired format string. See File Formats.
Note: use of this method requires configuring the following environment variable:
JMS_IO_URL: URL of JChem Microservices IO, e.g.: http://localhost:8070/jwsio/
Returns:
- the input chemical structure converted to the desired format.
async convertFile(fileContents, toFormat): Buffer
Converts the input chemical structure file to the specified format using JChem Microservices IO.
Parameters:
fileContents(Buffer | String): the chemical structure file to converttoFormat(string): the desired format string. See File Formats.
Note: use of this method requires configuring the following environment variable:
JMS_IO_URL: URL of JChem Microservices IO, e.g.: http://localhost:8070/jwsio/
Returns:
- the input converted to the desired format.
async batchConvert(structures, toFormat): string[]
Converts the input chemical structure to the specified format using JChem Microservices IO.
Parameters:
structures(string[]): an array of chemical structure to converttoFormat(string): the desired format string. See File Formats.
Note: use of this method requires configuring the following environment variable:
JMS_IO_URL: URL of JChem Microservices IO, e.g.: http://localhost:8070/jwsio/
Returns:
- the input chemical structure array converted to the desired format.
async append(structures, toFormat): string[]
Merges multiple input chemical structure into a single one in the specified format using JChem Microservices IO.
Parameters:
structures(string[]): an array of chemical structurestoFormat(string): the desired format string. See File Formats.
Note: use of this method requires configuring the following environment variable:
JMS_IO_URL: URL of JChem Microservices IO, e.g.: http://localhost:8070/jwsio/
Returns:
- the input chemical structure array merge into a single multistructure file.
async clean(structure, dimension, format): string
Rearranges of the atomic coordinates of the input structure.
Parameters:
structure(string): the chemical structure to processdimension(number): dimension to clean to. Values:2,3. Optional. Default:2.format(string): the desired format string. See File Formats. Optional. Default:mrv.
Note: use of this method requires configuring the following environment variable:
JMS_STRUCTURE_MANIPULATION_URL: URL of JChem Microservices Structure Manipulation, e.g.: http://localhost:8070/structure-manipulation/
Returns:
- the input chemical structure with new atomic coordinates in the desired format.
async getImageURLs(structures, width?, height?): string[]
Generates data URLs with base64 encoded PNG images of the input chemical structures using the following format configuration: w${width},h${height},transbg,cpk,wireframe,nosource,marginSize2,maxscale28. See File Formats for specifications.
Parameters:
structures(string[]): an array of chemical structure to render as imageswidth(number): width of the image. Optional. Default:400.height(number): height of the image. Optional. Default:260.
Note: use of this method requires configuring the following environment variable:
JMS_IO_URL: URL of JChem Microservices IO, e.g.: http://localhost:8070/jwsio/
Returns:
- an array of data URLs with base64 encoded PNG images as strings. For more details see Data URLs.
async getCleanedImageURLs(structures, width = 400, height = 200): string[]
Rearranges the atomic coordinates of the input chemical structures, and then generates data URLs with base64 encoded PNG images using the following format configuration: w${width},h${height},transbg,cpk,wireframe,nosource,marginSize2,maxscale28. See File Formats for specifications.
Parameters:
structures(string[]): an array of chemical structure to render as imageswidth(number): width of the image. Optional. Default:400.height(number): height of the image. Optional. Default:260.
Note: use of this method requires configuring the following environment variable:
JMS_IO_URL: URL of JChem Microservices IO, e.g.: http://localhost:8070/jwsio/JMS_STRUCTURE_MANIPULATION_URL: URL of JChem Microservices Structure Manipulation, e.g.: http://localhost:8070/structure-manipulation/
Returns:
- an array of data URLs with base64 encoded PNG images as strings. For more details see Data URLs.
async PDBUtilities.load(pdbCode): string
Downloads a PDB file with the specified 4 letter code from the Protein Data Bank.
Parameters:
pdbCode(string): the 4 letter code of a PDB file
Returns:
- the PDB file
async PDBUtilities.findLigands(pdbCode): string[]
Downloads a PDB file with the specified 4 letter code from the Protein Data Bank and extracts the list of available ligands.
Parameters:
pdbCode(string): the 4 letter code of a PDB file
Returns:
- the residue codes of the available ligands in the file as an array of strings.
async PDBUtilities.getResidue(pdbCode, ligandCode): string
Downloads a PDB file with the specified 4 letter code from the Protein Data Bank and extracts a specific ligand.
Parameters:
pdbCode(string): the 4 letter code of a PDB fileligandCode(string): code of the ligand to extract, e.g.:HEM,A:HEM, orA:HEM350
Returns:
- the ligand as a valid minimal PDB file
async PDBUtilities.findLigandsFromFile(pdbFile): string[]
Extracts the list of available ligands from the specified PDB file.
Parameters:
pdbFile(string): the contents of the PDB file
Returns:
- the residue codes of the available ligands in the file as an array of strings.
async PDBUtilities.getResidueFromFile(pdbFile, residueCode): string[]
Extracts a specific ligand from the specified PDB file.
Parameters:
pdbFile(string): the contents of the PDB fileligandCode(string): code of the ligand to extract, e.g.:HEM,A:HEM, orA:HEM350
Returns:
- the ligand as a valid minimal PDB file
History of changes¶
v3.1.0
- added
appendmethod
v3.0.1
- package renamed from
ml-utilstodh-utils
v2.5.0
- added
convertFilemethod
v2.4.0
- added
PDBUtilities.findLigandsFromFilemethod
v2.2.2
- added
batchConvertmethod
v2.1.6
- added
cleanmethod
v2.0.0
- initial version with compatibility to JChem Microservices
To find all available version numbers, use:
Example plugins¶
You can find a brief selection of plugins in our Github repository for various plugin types.