Skip to main content

Provides access to Leadscope Web Services REST API via Python.

Project description

Leadscope Python Interface

Provides access to Leadscope Web Services REST API via Python. This is an interface client which requires access to a Leadscope Enterprise server, v2023.0.1 or later.

Getting started

Install the package:

pip install lserest

Server connection details should be set in config.toml (see below for format) and placed in working directory, or specified: LSEClient(config_file=<path>). Alternatively, some or all of the parameters root_url, username, password and company may be passed directly to the constructor.

Config file

The config.toml file (if used) should contain the following section:

[server]
root_url = "http://server_host_name:8080/rs/resources"
username = "<user>"
password = "<password>"
company  = "<company>"

Server sessions

Most server requests require an active session to be created via LSEClient.start_session. Such sessions must be closed after use using LSEClient.end_session. A preferable option is to use LSEClient.with_session, which creates a session and then closes it at the end, handling any exceptions which may be thrown, all examples will use this method. See the documentation for the classes LSEClient, StructureSet, StructureSearch, ModelApplication and NitrosamineAssessment for a full list of which methods require a session to be open.

Examples

Requesting a list of available statistical models from the Leadscope server:

from lserest import LSEClient, StructureSet, ModelApplication
client = LSEClient()

def example1(c):
    c.list_models()

client.with_session(example1)

Running a model application, specifically the ICH M7 Consensus, on two structures:

from lserest import LSEClient, StructureSet, ModelApplication
client = LSEClient()

def example2(c, molfiles):
    structures = StructureSet(c, molfiles)
    model = ModelApplication(c, structures, consensus_names=['Genetox'])
    model.apply()
    return model

model = client.with_session(example2, ['structure1.mol', 'structure2.mol'])

print(model.consensus_results())

Searching the database for similar molecules to a given structure, downloading structural images of each search result and saving them to a zip archive:

from lserest import LSEClient, StructureSet, StructureSearch
import numpy as np
client = LSEClient()

def example3(c):
    structures = StructureSet(c, molfile)
    search = StructureSearch(c, structures)
    search.similar(match_pct=70)
    c.save_structure_images(np.unique(search.results()['Structure ID']), 'search_results.zip')

client.with_session(example3, 'structure.mol')

Running an N-nitrosamine potency assessment, on two structures:

from lserest import LSEClient, StructureSet, NitrosamineAssessment
client = LSEClient()

def example4(c):
    structures = StructureSet(c, 'structure1.mol', 'structure2.mol')
    nitro = NitrosamineAssessment(c, structures)
    nitro.apply()
    return nitro

nitro = client.with_session(example4)
print(nitro.results())

Creating a StructureSet from mol strings:

mol_string = '<mol string>'
from lserest import LSEClient, StructureSet, NitrosamineAssessment
client = LSEClient()
structures = StructureSet(client)
structures.mol_strings.append(mol_string)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lserest-1.1.2.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lserest-1.1.2-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file lserest-1.1.2.tar.gz.

File metadata

  • Download URL: lserest-1.1.2.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for lserest-1.1.2.tar.gz
Algorithm Hash digest
SHA256 b16d1af8344f1c96e3081d2067b9fa0ba64f945827862440c603b7eb5731aafb
MD5 a53d0ee6af8cd9781eda997c7121cc15
BLAKE2b-256 31dc5e12b43573d54a6fd9605c8f956daeec7ec063af6b80ac3596f90c0d3af0

See more details on using hashes here.

File details

Details for the file lserest-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: lserest-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for lserest-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 78a88e67b41970c287ed841358e6c05dad07172ec9dbd6f6eedf2ae05c1246a1
MD5 88b7a703392745d26e7096fb197ae0f0
BLAKE2b-256 696b8154d4604da841278c84bf1d7db95e7b87a2691c9c12c51c82211cfb4b36

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page