Skip to main content

Python SDK for interacting with the QDX API

Project description

QDX-py: Python SDK for the QDX API

This package exposes a simple provider and CLI for the different tools exposed by the QDX GraphQL API.

Usage

As a library

import json
from pathlib import Path

import qdx
from  qdx.data import run_convert, QDXV1QCMol, QDXV1QCInput

URL = "url to the qdx api"
TOKEN = "your qdx access token"

# get our client to talk with the API
client = qdx.QDXProvider(url=URL, 
                         access_token=TOKEN)

# path to protein pdb with correct charges and protonation
protein_pdb = Path("./examples/4w9f_prepared_protein.pdb")
# path to ligand sdf with correct charges and protonation
ligand_sdf = Path("./examples/3JU_prepared.sdf")

# convert pdb to qdxf
protein_qdxf = client.obabel_to_complex(file=protein_pdb, format="pdb")
# convert ligand sdf to qdxf
ligand_qdxf = client.obabel_to_complex(file=ligand_sdf, format="sdf")

# We need to treat the ligand as a single fragment
ligand_qdxf["topology"]["fragments"] = [[ x for x, _ in enumerate(ligand_qdxf["topology"]["symbols"])]]
ligand_qdxf["topology"]["fragment_charges"] = [0]

# We also need to drop connectivity information (temporary)
ligand_qdxf["topology"]["connectivity"] = []

# fragment protein
fragged_protein = client.fragment_complex(protein_qdxf, backbone_steps=5)

# combine fragmented protein and ligand into a single complex
complex = client.combine_complexes(fragged_protein, ligand_qdxf)

# create a qdx/hermes input file for complex
qdx_input = qdx.data.run_convert(json.dumps(complex), "qdxcomplex2qdxv1")

# Configure input for lattice calculation
qdx_input.model.fragmentation = True
qdx_input.keywords.frag.lattice_energy_calc = True
# The reference monomer should be the final fragment,
# as that will be the ligand
qdx_input.keywords.frag.reference_monomer = len(
    qdx_input.molecule.fragments) - 1
qdx_input.keywords.frag.monomer_cutoff = 20
qdx_input.keywords.frag.dimer_cutoff = 10

qdx_input.model.method = "RIMP2"

# Start hermes calculation - 
# remember to set tags that reference your system
proc = client.start_quantum_energy_calculation(
    qdx_input, tags=["rimp2", "4w9f", "3ju", "manual_prep", "debug_charges"])


# Fetch results - you will have to run this multiple times until
# the calculation is done
result = client.get_proc(proc)

As a CLI

# All cli calls have these standard arguments, referred to as … in future examples
qdx --url QDX_API_URL --access-token QDX_ACCESS_TOKEN

# Post a hermes job, returning a task id --post-quantum-energy < ./path_to_qdxv1_input.json

# Retrieve the hermes job, or its progress --get-proc TASK_ID

## Other functions
# Return a qdx complex json object and save it as complex.json --pdb-to-complex PATH_TO_PDB_FILE > complex.json

# Prepare a protein for quauntum energy calculation --prepare-protein simulation --poll < ./complex.json > prepped_protein_complex.json

# Fragment a qdx complex json object --fragment-complex [MIN_STEPS_ALONG_PROTEIN_BACKBONE_BEFORE_CUTTING_AT_C-C_BOND] < prepped_protein_complex.json > fragmented_protein_complex.json

# Prepare a ligand for quauntum energy calculation --prepare-ligand simulation --poll < ./path_to_ligand.sdf > prepped_ligand_complex.json

# Combine protein and ligand complexes for simulation --combine-complexes ./prepped_protein_complex.json < ./prepped_ligand_complex.sdf > protein_ligand_complex.json

# Convert a qdx complex into a qdx input file --convert ./protein_ligand_complex.json --direction qdxcomplex2qdxv1 > qdx_input.json

# Convert a qdx complex into a exess input file --convert ./protein_ligand_complex.json --direction qdxcomplex2exess > exess_input.json

# Convert a qdx input file into an exess input file --convert qdx_input.json --direction qdxv12exess > exess_input.json

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

qdx-0.10.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

qdx-0.10.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file qdx-0.10.0.tar.gz.

File metadata

  • Download URL: qdx-0.10.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.10 Linux/6.2.12-zen1

File hashes

Hashes for qdx-0.10.0.tar.gz
Algorithm Hash digest
SHA256 630ee5994e2981b28ebb5f48b1e7bc8181ce8cd2c5bdc5913564b73ca754d886
MD5 8c24ffcffab14f84c5557f17fcb9d01f
BLAKE2b-256 4e03c1d5f780f9e0b64983a028bf1d90f6ac0af23445ec31b8132aaca29b011c

See more details on using hashes here.

File details

Details for the file qdx-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: qdx-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.10 Linux/6.2.12-zen1

File hashes

Hashes for qdx-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9f772039279aa823613e4e9faea9b243c36621f6c4e53c0eba0c08a441620bc
MD5 8cffa90a26147880163db7c6d69c068d
BLAKE2b-256 9364c4a4308c35adb74b7fc72d5648348427de2e2f132d42dd41a5913bd3ca65

See more details on using hashes here.

Supported by

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