schrodinger.application.glide.http_client module

Glide HTTP client

This module implements objects that connect to a Glide HTTP server (see schrodinger.application.glide.http_server) and use the server to dock ligands remotely.

Sample usage:

from schrodinger import structure from schrodinger.application.glide import http_client

client = http_client.HTTPClient(host=’localhost’, port=8000) ct = structure.Structure.read(‘mylig.mae’) poses = client.dock(ct) for pose in poses:

print “gscore=%f” % pose.properties[‘r_i_glide_gscore’]

For a higher level API that also starts up and monitors the server itself, see GlideServerManager.

exception schrodinger.application.glide.http_client.ServerTimedOutError

Bases: RuntimeError

Exception raised if the Glide server times out

__init__

Initialize self. See help(type(self)) for accurate signature.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class schrodinger.application.glide.http_client.GlideResult(poses, message='')

Bases: object

Sequence-like object containing the poses returned by Glide for one ligand. When no poses were produced, the reason is available in the .message property.

__init__(poses, message='')
Parameters:
  • poses (list of schrodinger.structure.Structure) – poses returned by glide (may be empty)
  • message (str) – status message explaining why no poses were returned
__len__()
toJson()

Return a JSON representation of the docking result.

Returns:JSON
Return type:str
classmethod fromJson(json_str)

Construct a GlideResult from its JSON representation.

Parameters:json_str (str) – JSON representation
Returns:GlideResult
Return type:GlideResult
class schrodinger.application.glide.http_client.GlideResultIterator(poses, message='')

Bases: object

Iterator over the poses returned by Glide for one ligand. When no poses were produced, the reason is available in the .message property.

__init__(poses, message='')
Parameters:
  • poses (list of schrodinger.structure.Structure) – poses returned by glide (may be empty)
  • message (str) – status message explaining why no poses were returned
asGlideResult()

Convert the iterator back into a GlideResult.

Returns:GlideResult
Rype:GlideResult
class schrodinger.application.glide.http_client.AbstractHTTPClient

Bases: object

Interface for connecting to a Glide HTTP server.

dock(ct)

Dock the ligand in Structure object ct using the remote Glide server.

shutdown_server()

Ask the Glide HTTP server to shut down.

static ct_to_multipart(ct)

Encode a CT in multipart/form-data format, ready to POST.

Parameters:ct (structure.Structure) – Structure to encode
Returns:The body of the request and the boundary
Return type:tuple(str, str)
__init__

Initialize self. See help(type(self)) for accurate signature.

class schrodinger.application.glide.http_client.HTTPClient(con=None, host='localhost', port=8000, timeout=1000)

Bases: schrodinger.application.glide.http_client.AbstractHTTPClient

This class provides an API to connect to an existing Glide HTTP server. For a higher level API that also starts up and monitors the server itself, see GlideServerManager.

__init__(con=None, host='localhost', port=8000, timeout=1000)

Initialize a new HTTPClient object. The optional ‘con’ is an existing httplib.HTTPConnection object. If not provided, then ‘host’, ‘port’, and ‘timeout’ will be used to create one. The default timeout value is very large to make sure that it is enough for most docking jobs to finish.

dock(ct)

Dock the ligand in Structure object ‘ct’ using the remote Glide server.

Parameters:ct (schrodinger.structure.Structure) – input ligand
Returns:docking results as an iterator
Return type:GlideResultIterator
dockSmiles(smiles)

Dock a ligand from SMILES. For best results, the server should have been launched with the LIGPREP keyword enabled.

Parameters:smiles (str) – ligand SMILES
Returns:docking results as an iterator
Return type:GlideResultIterator
shutdown_server()

Ask the Glide HTTP server to shut down.

static ct_to_multipart(ct)

Encode a CT in multipart/form-data format, ready to POST.

Parameters:ct (structure.Structure) – Structure to encode
Returns:The body of the request and the boundary
Return type:tuple(str, str)
class schrodinger.application.glide.http_client.NonBlockingHTTPClient(host=None, port=8000)

Bases: schrodinger.application.glide.http_client.AbstractHTTPClient, PyQt5.QtCore.QObject

Class for connecting to a Glide HTTP server and docking poses without blocking.

Variables:
  • posesDocked – Signal emitted when a ligand finishes docking. Emitted with a list of pose structures.
  • noPosesDocked – Signal emitted when a ligand goes through the docking workflow, but does not return any valid poses
  • errorOccurred – Signal emitted when there is an error communicating with the server.
  • finished – Signal emitted when an HTTP request finishes. Note: aliased from self.manager.finished
posesDocked
noPosesDocked
errorOccurred
__init__(host=None, port=8000)
Parameters:
  • host (str) – Hostname for server
  • port (int) – Port for server
dock(ct)

Docks the structure without blocking.

Parameters:ct (schrodinger.structure.Structure) – Structure to dock
shutdown_server()

Requests shutting down the server without blocking.

blockSignals(self, bool) → bool
childEvent(self, QChildEvent)
children(self) → List[QObject]
connectNotify(self, QMetaMethod)
static ct_to_multipart(ct)

Encode a CT in multipart/form-data format, ready to POST.

Parameters:ct (structure.Structure) – Structure to encode
Returns:The body of the request and the boundary
Return type:tuple(str, str)
customEvent(self, QEvent)
deleteLater(self)
destroyed

destroyed(self, object: QObject = None) [signal]

disconnect(self)
disconnectNotify(self, QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) → List[QByteArray]
event(self, QEvent) → bool
eventFilter(self, QObject, QEvent) → bool
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → QObject

findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject

findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → List[QObject]

findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]

inherits(self, str) → bool
installEventFilter(self, QObject)
isSignalConnected(self, QMetaMethod) → bool
isWidgetType(self) → bool
isWindowType(self) → bool
killTimer(self, int)
metaObject(self) → QMetaObject
moveToThread(self, QThread)
objectName(self) → str
objectNameChanged

objectNameChanged(self, str) [signal]

parent(self) → QObject
property(self, str) → Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

receivers(self, PYQT_SIGNAL) → int
removeEventFilter(self, QObject)
sender(self) → QObject
senderSignalIndex(self) → int
setObjectName(self, str)
setParent(self, QObject)
setProperty(self, str, Any) → bool
signalsBlocked(self) → bool
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) → int
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
thread(self) → QThread
timerEvent(self, QTimerEvent)
tr(self, str, disambiguation: str = None, n: int = -1) → str
class schrodinger.application.glide.http_client.SubprocessJobAdapter(cmd, logfile)

Bases: object

An adapter that starts a subprocess but makes it look a bit like a jobcontrol.Job object. This class does not attempt to expose the full Job API; it only has what is actually used within this module. Its purpose is so the GlideServerManager class can treat job control jobs and subprocesses equally.

__init__(cmd, logfile)
Parameters:
  • cmd (list of str) – command line to execute
  • logfile (file) – file to use for log stdout/stderr
readAgain()
Status
kill()
isComplete()
class schrodinger.application.glide.http_client.GlideServerManager(keywords, jobdir='.', jobname=None, host='localhost', port=0, timeout=1000, use_jc=True)

Bases: object

A class to start, stop, monitor, and use a Glide HTTP server. Sample use:

server = GlideServerManager({‘GRIDFILE’: ‘grid.zip’}) server.start() while not server.isReady():

time.sleep(1)

poses = server.dock(st) server.stop()

__init__(keywords, jobdir='.', jobname=None, host='localhost', port=0, timeout=1000, use_jc=True)
Parameters:keywords – Glide keywords to use for the job. The only required

keyword is GRIDFILE. :type keywords: dict

Parameters:
  • jobdir (str) – job directory
  • jobname – basename for input and output files and for job control. By default, a random jobname is chosen.
  • host – host to which the server should bind to
  • port (int) – port where the server should listen. If zero, pick one automatically.
  • timeout (int) – the server will shut down automatically if this time, in seconds, passes without receiving any connections.
  • use_jc (bool) – run the Glide backend under job control?
start(wait=None)

Launch the Glide Server job. By default, returns as soon as the job is launched, but to make sure that the job is ready to dock call .isReady() until True.

Parameters:wait (int or NoneType) – if given, wait for the server to be ready up to wait seconds; if the server is still not ready then, raise a RuntimeError.
isReady()
Returns:is the server ready to dock?
Return type:bool
waitUntilReady(timeout=60)

Wait for the server to be ready. If the timeout is reached and the server is still not ready, raise a RuntimeError.

Parameters:timeout (int) – maximum wait in seconds
dock(st)

Dock a ligand. Return a list of poses, which may be empty. If there was a problem connecting to the server, socket.error exceptions may be propagated.

Parameters:st (schrodinger.structure.Structure) – Structure to dock
Returns:docking result
Return type:GlideResult
dockSmiles(smiles)

Dock a ligand from SMILES. For best results, the server should have been launched with the LIGPREP keyword enabled.

Parameters:smiles (str) – ligand SMILES
Returns:docking result
Return type:GlideResult
stop()

Stop the server. First it will try to send it a shutdown request via HTTP; if that doesn’t work, it will kill via job control.

config

A dictionary with the information needed to connect with the server: host, port, and jobid. This data is obtained from a JSON file written by the server. If the file does not exist (yet?), the dict will be empty.

client

Client object to be used for connecting to the Glide server process.

Return type:HTTPClient
Returns:the client object.
class schrodinger.application.glide.http_client.NonBlockingGlideServerManager(*args, **kwargs)

Bases: schrodinger.application.glide.http_client.GlideServerManager, PyQt5.QtCore.QObject

A class to use a Glide HTTP server without blocking.

Variables:
  • posesDocked – Signal emitted when a ligand finishes docking. Emitted with a list of pose structures.
  • noPosesDocked – Signal emitted when a ligand goes through the docking workflow, but does not return any valid poses
  • errorOccurred – Signal emitted when there is an error communicating with the server.
  • batchFinished – Signal emitted when a docking batch finishes. Emitted with the number of ligands that were docked.
posesDocked
noPosesDocked
batchFinished
errorOccurred
__init__(*args, **kwargs)
Parameters:keywords – Glide keywords to use for the job. The only required

keyword is GRIDFILE. :type keywords: dict

Parameters:
  • jobdir (str) – job directory
  • jobname – basename for input and output files and for job control. By default, a random jobname is chosen.
  • host – host to which the server should bind to
  • port (int) – port where the server should listen. If zero, pick one automatically.
  • timeout (int) – the server will shut down automatically if this time, in seconds, passes without receiving any connections.
  • use_jc (bool) – run the Glide backend under job control?
stop()

Stop the server. First it will try to send it a shutdown request via HTTP; if that doesn’t work, it will kill via job control.

dock(st)

Dock a ligand. Return a list of poses, which may be empty. If there was a problem connecting to the server, socket.error exceptions may be propagated.

Parameters:st (schrodinger.structure.Structure) – Structure to dock
Returns:docking result
Return type:GlideResult
dockBatch(structures, done_adding=True)

Set a batch of structures to dock.

Parameters:
  • structures (iterable[schrodinger.structure.Structure]) – Structures to dock
  • done_adding (bool) – Whether to emit batchFinished when all sts in structures finish docking. Pass False if structures is a generator that can have more structures added to it at runtime.
cancelBatch()
addStructures(structures)

Add more structures to dock. Should call setDoneAdding once all structures have been added.

Parameters:structures (iterable[schrodinger.structure.Structure]) – Structures to dock
setDoneAdding()

Call this when done adding structures to a batch; once all structures have been docked, batchFinished will be emitted.

client

Client object to be used for connecting to the Glide server process.

Return type:HTTPClient
Returns:the client object.
blockSignals(self, bool) → bool
childEvent(self, QChildEvent)
children(self) → List[QObject]
config

A dictionary with the information needed to connect with the server: host, port, and jobid. This data is obtained from a JSON file written by the server. If the file does not exist (yet?), the dict will be empty.

connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deleteLater(self)
destroyed

destroyed(self, object: QObject = None) [signal]

disconnect(self)
disconnectNotify(self, QMetaMethod)
dockSmiles(smiles)

Dock a ligand from SMILES. For best results, the server should have been launched with the LIGPREP keyword enabled.

Parameters:smiles (str) – ligand SMILES
Returns:docking result
Return type:GlideResult
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) → List[QByteArray]
event(self, QEvent) → bool
eventFilter(self, QObject, QEvent) → bool
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → QObject

findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject

findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → List[QObject]

findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]

inherits(self, str) → bool
installEventFilter(self, QObject)
isReady()
Returns:is the server ready to dock?
Return type:bool
isSignalConnected(self, QMetaMethod) → bool
isWidgetType(self) → bool
isWindowType(self) → bool
killTimer(self, int)
metaObject(self) → QMetaObject
moveToThread(self, QThread)
objectName(self) → str
objectNameChanged

objectNameChanged(self, str) [signal]

parent(self) → QObject
property(self, str) → Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

receivers(self, PYQT_SIGNAL) → int
removeEventFilter(self, QObject)
sender(self) → QObject
senderSignalIndex(self) → int
setObjectName(self, str)
setParent(self, QObject)
setProperty(self, str, Any) → bool
signalsBlocked(self) → bool
start(wait=None)

Launch the Glide Server job. By default, returns as soon as the job is launched, but to make sure that the job is ready to dock call .isReady() until True.

Parameters:wait (int or NoneType) – if given, wait for the server to be ready up to wait seconds; if the server is still not ready then, raise a RuntimeError.
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) → int
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
thread(self) → QThread
timerEvent(self, QTimerEvent)
tr(self, str, disambiguation: str = None, n: int = -1) → str
waitUntilReady(timeout=60)

Wait for the server to be ready. If the timeout is reached and the server is still not ready, raise a RuntimeError.

Parameters:timeout (int) – maximum wait in seconds
class schrodinger.application.glide.http_client.NonBlockingBackendChecker(*args, **kwargs)

Bases: PyQt5.QtCore.QObject

Class to get an GlideServerManager object to the ready state without blocking the GUI.

Variables:ready – Whether the backend is ready
__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

wait(timeout=60)

Block python execution (but not the GUI) until the backend is ready or the timeout is reached.

Parameters:timeout (int or NoneType) – Timeout in seconds or None to not timeout.
Returns:Whether the backend is ready
setBackend(backend)

Set the backend object to call isReady on

stopChecking()

Stop checking whether the backend is ready

onServerTimeout()
blockSignals(self, bool) → bool
childEvent(self, QChildEvent)
children(self) → List[QObject]
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deleteLater(self)
destroyed

destroyed(self, object: QObject = None) [signal]

disconnect(self)
disconnectNotify(self, QMetaMethod)
dumpObjectInfo(self)
dumpObjectTree(self)
dynamicPropertyNames(self) → List[QByteArray]
event(self, QEvent) → bool
eventFilter(self, QObject, QEvent) → bool
findChild(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → QObject

findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject

findChildren(self, type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) → List[QObject]

findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, type, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject] findChildren(self, Tuple, QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]

inherits(self, str) → bool
installEventFilter(self, QObject)
isSignalConnected(self, QMetaMethod) → bool
isWidgetType(self) → bool
isWindowType(self) → bool
killTimer(self, int)
metaObject(self) → QMetaObject
moveToThread(self, QThread)
objectName(self) → str
objectNameChanged

objectNameChanged(self, str) [signal]

parent(self) → QObject
property(self, str) → Any
pyqtConfigure(...)

Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.

receivers(self, PYQT_SIGNAL) → int
removeEventFilter(self, QObject)
sender(self) → QObject
senderSignalIndex(self) → int
setObjectName(self, str)
setParent(self, QObject)
setProperty(self, str, Any) → bool
signalsBlocked(self) → bool
startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) → int
staticMetaObject = <PyQt5.QtCore.QMetaObject object>
thread(self) → QThread
timerEvent(self, QTimerEvent)
tr(self, str, disambiguation: str = None, n: int = -1) → str