will be available in the upcoming Frequent Release
Install Python version 3.7 or better. Confirm that Python is properly installed. The simplest way to test for a Python installation is to open a command prompt. Once a command prompt window opens, type python and press Enter. If Python is installed correctly, you should see output similar to what is shown below.
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
If you receive a message like:
Python is not recognized as an internal or external command, operable program or batch file.
Python is either not installed correctly or the system variable path
has not been set.
Python library for Connect scripting can be downloaded from Chemaxon download pages with appropriate Connect version.
connect_api
library of same version as Connect is required to run Connect Python scripts.
Python library can be installed by using pip install connect-api-*.tar.gz
*
Pip is a tool that installs packages, pip itself is a package that someone might want to install, if it is not a part of Python.
(this part would be removed, it is for internal Usage)or by using pip install -e.
in scripting
directory of connect-backend sources.
Follwoing basic workflow when using connect_api
in Python script is:
DataApi
Session
Session
Simple example script bellow is written for Demo Project Pubchem Grid View
:
# Create api : api = DataApi('username', 'password')
api = DataApi('admin', 'admin')
# Open Session
session = api.openViewSession(
api.getViewByName('Pubchem grid view')
)
# empty query to load all data into session
session.query()
# get values for some of the columns
result = session.getData(['Mol weight', 'Structure', 'CdId', 'Acceptors'])
print(result)
Installing Jupyter using Anaconda and conda, follow the instructions provided here.
From command prompt use pip3 install jupyter
For more details visit Jupyer web https://jupyter.org/
To use connect_api
for scripting Connect frontend you need to create subclass of ConnectScript
first. This lets you react on user input and modify frontend state.
ConnectScript
is a Python script which can be called by Connect frontend and react on the the user actions like opne view, clicking, querying etc.
Example of simple script:
class SimpleScript(ConnectScript):
def onLoad(self):
self.response.showMessage('Hello World')
SimpleScript().execute()
For usage from Connect Frontend, this script needs to be saved in
~/.chemaxon/plexus-suite/scripts-data/{schemaId}/
~/.chemaxon/plexus-suite/scripts-data/{schemaId}/
and mapped to view using ViewId in scripts.conf in the same directory.
ViewId can be obtained from Connect URL, when view is opened in browser: http://Plexus_Connect.com/grid/6C6F63616C6462_**213A0E201AB2EB5DA54552018904C869**/1More examples can be found in examples
directory.
You can use DevelopmentConnectScriptContext
to make development loop shorter by running frontend script locally without copying it to server.
Basic workflow looks like this:
DevelopmentConnectScriptContext
DevelopmentConnectScriptContext
DevelopmentConnectScriptContext
and copy finished script to serverExample script:
class SimpleScript(ConnectScript):
def onLoad(self):
self.response.showMessage('Hello World')
SimpleScript().execute(DevelopmentConnectScriptContext(
username="<USERNAME>",
password="<PASSWORD>",
connectUrl="http://localhost:3002", # Connect backend location
sessionUrl="http://localhost:3002/grid/6C6F63616C6462_213A0E201AB2EB5DA54552018904C869/6", # URL to parse Session out of
# Event to process - captured using Connect Frontend scripting tool
event="""{
"viewId": "6C6F63616C6462_213A0E201AB2EB5DA54552018904C869",
"eventType": "onSelectionChange",
"params": {
"selection": [
4
]
}
}"""
))