XML/RPC server


Provided that the Wit!P client has been compiled and linked against the xmlrpc-c library external applications (e.g. Python scripts) may send requests to execute predefined remote procedures to the XML/RPC server built into Wit!P. Before sending request, the server must be started, either using the "xmlrpc open" command of Wit!P:

Wit!P> xmlrpc open portnumber

or by using the "rpc" command line option of the "witnotp" command:

$ witnotp rpc portnumber ...

where portnumber is an arbitrary number which is not already in use by a running service (5-digit numbers should be fine, avoid numbers listed in /etc/services).

The wnprpc Python module provides an easy access to Wit!P's XML/RPC server from Python scripts. Users of the Python module will probably have no need to read the rest of this page.


List of currently defined procedures:

wnp.cmd(commands):
Execution type: queued
Input:
commands, a string of commands to be executed by the Wit!P client.
Response: (status, prompt, messages)
status: integer, number of errors that occured during the execution of commands.
prompt
: string, the client's prompt string at the end of the execution of commands.
messages
: array of strings containing the messages issued by the client during the execution of commands.

wnp.dataBlock(size,data):
Execution type: immediate
Input:
size: integer, >0: size of data block to be created,  <0: delete data block, =0: append data to data block.
data: string, data to be added to data block (size > or = 0).
Response: n-added
n-added: integer, number of bytes added to data block.
Notes: if size > 0, previous data will be lost.


wnp.loadMOLtypes(name_and_type):
Execution type: queued
Input:
name_and_type: string, name and type of molecule to be created from the current data block.
Response: (status, prompt, messages)
status: integer, number of errors that occured during the creation of the molecule from the data block.
prompt: string, the client's prompt string at the end of the creaton of the molecule from the data block.
messages: array of strings containing the messages issued by the client during the creaton of the molecule.
Notes: name_and_type is a string of the form name:type, where name is the name of the molecule to be created, and type is one of "mol", "mol2", "cif", "pdb", "xpdb", "shelx", "mmod", "diana", "par", "maccs", "csd", and must be in accordance with the format of the data in the current data block. For "maccs" and "csd", only the first molecule in the data block will be created.

wnp.loadPDB(name):
Execution type: queued
Input: name, string, name of molecule to be created from current data block.
Response: (status, prompt, messages)
status: integer, number of errors that occured during the creation of the molecule from the data block.
prompt: string, the client's prompt string at the end of the creaton of the molecule from the data block.
messages: array of strings containing the messages issued by the client during the creaton of the molecule.
Notes: this procedure has been made redundant by the more general wnp.loadMOLtypes procedure.

wnp.getenv(name):
Execution type: immediate
Input: name, string, name of environment varible in Wit!P client to be looked up.
Response:
definition: string, definition of the environment varible name in Wit!P.

wnp.getprompt(
):
Execution type: queued
Input: none.
Response:
prompt: string, current prompt string in Wit!P.
Notes: may be used to check if Wit!P parser is in expected state before sending commands via wnp.cmd.

wnp.shutdown():
Execution type: queued
Input: none
Response: "", string.
Notes: shut down the XML/RPC server.

The following procedures were implemented to support RDKit's SDViewer:

ping():

Execution type: immediate
Input: none
Response: 1 (integer).
Notes: may be used to check is server is alive.

loadMolBlock(ctab,name):
Execution type: queued
Input:
ctab, string, a MDL CTAB block.
name, string, a name which wil be ignored.
Response: "", string.
Notes: ctab may be a CTAB block, an MDL MOL file, or an SDF file. The name of the molecule to be cretaed will be taken from the title of ctab. The molecule will be created as a descendant of /a_LMB in the client's molecular data tree. If ctab is an SDF file, only the first entry in the file will be added to /a_LMB.

do(command):
Execution type: queued
Input: command, string, any PyMol command.
Response: "", string.
Notes: the procedure accepts any string, but in the current implementation only "disable all" will be executed, equivalent to "delete molecule /a_LMB".

zoom(mode):
Execution type: queued
Input: mode, string
Response: "", string.
Notes: the only mode that is implemented is "visible", which will bring the center of the displayed atoms in /a_LMB to the center of the screen ("display find / selection" where selection contains all displayed atoms in the /a_LMB subtree).



A.Widmer, NIBR/CPC/CSG-SB