kripodb.webservice¶
Module for Client for kripo web service
-
exception
kripodb.webservice.client.
IncompletePharmacophores
(absent_identifiers, pharmacophores)[source]¶
-
class
kripodb.webservice.client.
WebserviceClient
(base_url)[source]¶ Client for kripo web service
Example
>>> client = WebserviceClient('http://localhost:8084/kripo') >>> client.similar_fragments('3j7u_NDP_frag24', 0.85) [{'query_frag_id': '3j7u_NDP_frag24', 'hit_frag_id': '3j7u_NDP_frag23', 'score': 0.8991}]
Parameters: base_url (str) – Base url of web service. e.g. http://localhost:8084/kripo -
fragments_by_id
(fragment_ids, chunk_size=100)[source]¶ Retrieve fragments by their identifier
Parameters: Returns: List of fragment information
Return type: Raises: IncompleteFragments
– When one or more of the identifiers could not be found.
-
fragments_by_pdb_codes
(pdb_codes, chunk_size=450)[source]¶ Retrieve fragments by their PDB code
Parameters: Returns: List of fragment information
Return type: Raises: requests.HTTPError
– When one of the PDB codes could not be found.
-
Kripo datafiles wrapped in a webservice
-
class
kripodb.webservice.server.
KripodbJSONEncoder
(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)[source]¶ JSON encoder for KripoDB object types
Copied from http://flask.pocoo.org/snippets/119/
-
default
(obj)[source]¶ Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) return JSONEncoder.default(self, o)
-
-
kripodb.webservice.server.
get_fragment_phar
(fragment_id)[source]¶ Pharmacophore in phar format of fragment
Parameters: fragment_id (str) – Fragment identifier Returns: Pharmacophore|problem Return type: flask.Response|connexion.lifecycle.ConnexionResponse
-
kripodb.webservice.server.
get_fragment_svg
(fragment_id, width, height)[source]¶ 2D drawing of fragment in SVG format
Parameters: Returns: SVG document|problem
Return type: flask.Response|connexion.lifecycle.ConnexionResponse
-
kripodb.webservice.server.
get_fragments
(fragment_ids=None, pdb_codes=None)[source]¶ Retrieve fragments based on their identifier or PDB code.
Parameters: Returns: List of fragment information
Return type: Raises: werkzeug.exceptions.NotFound
– When one of the fragments_ids or pdb_code could not be found
-
kripodb.webservice.server.
get_similar_fragments
(fragment_id, cutoff, limit)[source]¶ Find similar fragments to query.
Parameters: Returns: List of dict with query fragment identifier, hit fragment identifier and similarity score
Return type: Raises: werkzeug.exceptions.NotFound
– When the fragments_id could not be found
-
kripodb.webservice.server.
get_version
()[source]¶ Returns: Version of web service Return type: dict[version]
-
kripodb.webservice.server.
serve_app
(similarities, fragments, pharmacophores, internal_port=8084, external_url='http://localhost:8084/kripo')[source]¶ Serve webservice forever
Parameters: - similarities – Filename of similarity matrix hdf5 file
- fragments – Filename of fragments database file
- pharmacophores – Filename of pharmacophores hdf5 file
- internal_port – TCP port on which to listen
- external_url (str) – URL which should be used in Swagger spec
-
kripodb.webservice.server.
wsgi_app
(similarities, fragments, pharmacophores, external_url='http://localhost:8084/kripo')[source]¶ Create wsgi app
Parameters: - similarities (SimilarityMatrix) – Similarity matrix to use in webservice
- fragments (FragmentsDb) – Fragment database filename
- pharmacophores – Filename of pharmacophores hdf5 file
- external_url (str) – URL which should be used in Swagger spec
Returns: connexion.App