schrodinger.application.glide.http_server module

Glide HTTP Server

This module implements the functions necessary to turn Glide into a persistent HTTP server that accepts ligands via POST requests and sends the poses back.

To use, just add the following lines to a Glide input file:

CLIENT_MODULE schrodinger.application.glide.http_server CLIENT_OPTIONS “host=localhost; port=8000”

The server may then be tested using a web browser by opening http://localhost:8000/. For programmatic access, see schrodinger.application.glide.http_client.py.

The server responds to the following paths:

/ a form that can be used for testing from a browser /shutdown break out of the ligand loop and terminate /dock_ligand POST a ligand and get the poses back

NOTE: the server is single-threaded, single-process, hence it’s not designed to accept concurrent connections. While Glide is busy docking a ligand, the server won’t be accepting connections. This server is meant for uses where there is a single client that only needs to do one ligand at a time!

class schrodinger.application.glide.http_server.GlideHTTPHandler(request, client_address, server)

Bases: BaseHTTPServer.BaseHTTPRequestHandler

This class, derived from BaseHTTPRequestHandler, implements the do_GET and do_POST methods. Unlike the parent class, this handler does not “finish” immediately after calling do_GET/do_POST, but waits until glide_finish() is called.

Properties:

  • glide_data: a dictionary containing the posted form data.
  • glide_stop: a boolean, set to True if the client asked us to stop.
  • glide_form: the form to send out when getting “/”.
do_GET()
do_POST()
finish()
glide_finish()

Finish the handler by calling the finish() method from the parent class. Among other things, this closes the connection.

glide_send_response(ctype, body)

Convenience method to send the response line, content-type header, and body in just one call.

setup()
class schrodinger.application.glide.http_server.GlideHTTPServer(server_address, RequestHandlerClass, bind_and_activate=True)

Bases: BaseHTTPServer.HTTPServer

This is a variant on HTTPServer that doesn’t shut down requests immediately, but keeps them around until glide_shutdown_request is called. This allows us to split the processing of the request into two steps: one to get the request, and the other to respond to it.

In the meantime, the handler object is kept around in the glide_http_handler property.

finish_request(request, client_address)
glide_shutdown_request()

Shut down the current request by calling the shutdown_request method from the parent class.

handle_request()
handle_timeout()
shutdown_request(request)
schrodinger.application.glide.http_server.pull_ligand()

Wait until someone POSTs a ligand and return its mmct handle. If we were asked to shut down by the client, return -1.

schrodinger.application.glide.http_server.push_ligand(poses, msg)

Sent the HTTP response as an m2io file of docked poses. Takes an array of mmct handles and an error message (the latter is currently unused.)

schrodinger.application.glide.http_server.start(options)

Start the HTTP server. Takes a string as an argument that may specify the host and port as, for example, “host=localhost; port=8000; timeout=0”. These are in fact the default values. To accept connections from remote hosts, set host to an empty string (i.e., “host=”). If the timeout value is greater than zero, pull_ligand will return -1, indicating no more ligands, after waiting for that time in seconds.

schrodinger.application.glide.http_server.stop()

Delete the HTTP server object and stop listening.