Skip to content

Commit

Permalink
Add compound series schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mcwitt committed Sep 11, 2020
1 parent 698e3d9 commit 8072617
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 1 deletion.
71 changes: 71 additions & 0 deletions fah_xchem/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import datetime as dt
from typing import Dict, List, Optional

from pydantic import BaseModel


class Model(BaseModel):
class Config:
allow_mutation = False
extra = "forbid"


class CompoundSeriesMetadata(Model):
name: str
description: str
creator: str
creation_date: dt.date
xchem_project: str
receptor_variant: Dict[str, str]
temperature_kelvin: float
ionic_strength_millimolar: float
pH: float


class Microstate(Model):
microstate_id: str
smiles: str


class Compound(Model):
compound_id: str
smiles: str
experimental_data: Dict[str, float]
microstates: List[Microstate]


class CompoundMicrostate(Model):
compound_id: str
microstate_id: str


class Transformation(Model):
run: int
initial_microstate: CompoundMicrostate
final_microstate: CompoundMicrostate
xchem_fragment_id: str


class CompoundSeries(Model):
metadata: CompoundSeriesMetadata
compounds: List[Compound]
transformations: List[Transformation]


class ServerConfig(Model):
projects_path: str
data_path: str


class AnalysisConfig(Model):
max_binding_delta_f: Optional[float] = None
min_num_work_values: Optional[int] = 40
work_precision_decimals: Optional[int] = 3


class Config(Model):
server: ServerConfig
complex_project: int
solvent_project: int
analysis: AnalysisConfig
output_dir: str
86 changes: 85 additions & 1 deletion fah_xchem/tests/test_fah_xchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,95 @@
"""

# Import package, test suite, and other packages as needed
import fah_xchem
import pytest
import sys
from fah_xchem.schema import *


@pytest.fixture
def compound_series():
return CompoundSeries(
metadata=CompoundSeriesMetadata(
name="2020-08-20-benzotriazoles",
description="Sprint 3: Prioritization of benzotriazole derivatives",
creator="John D. Chodera",
creation_date=dt.datetime(2020, 9, 8, 10, 14, 48, 607238),
xchem_project="Mpro",
receptor_variant=dict(
biological_assembly="monomer", protein_variant="thiolate"
),
temperature_kelvin=300,
ionic_strength_millimolar=70,
pH=7.4,
),
compounds=[
Compound(
compound_id="MAT-POS-f42f3716-1",
smiles="Cc1ccncc1NC(=O)Cc1cc(Cl)cc(-c2ccc(C3CC3(F)F)cc2)c1",
experimental_data={"pIC50": 4.324},
microstates=[
Microstate(
microstate_id="MAT-POS-f42f3716-1-1",
smiles="Cc1ccncc1NC(=O)Cc1cc(Cl)cc(-c2ccc(C3CC3(F)F)cc2)c1",
),
Microstate(
microstate_id="MAT-POS-f42f3716-1-2",
smiles="Cc1ccn[H+]cc1NC(=O)Cc1cc(Cl)cc(-c2ccc(C3CC3(F)F)cc2)c1",
),
],
),
Compound(
compound_id="MAT-POS-f42f3716-2",
smiles="Cc1ccncc1NC(=O)Cc1cc(Cl)cc(-c2ccc(S(C)(=O)=O)cc2Cl)c1",
experimental_data={"pIC50": 4.324},
microstates=[
Microstate(
microstate_id="MAT-POS-f42f3716-2-1",
smiles="Cc1ccncc1NC(=O)Cc1cc(Cl)cc(-c2ccc(C3CC3(F)F)cc2)c1",
),
Microstate(
microstate_id="MAT-POS-f42f3716-2-2",
smiles="Cc1ccncc1NC(=O)Cc1cc(Cl)cc(-c2ccc(C3CC3(F)F)cc2)c1",
),
],
),
],
transformations=[
Transformation(
run=0,
initial_microstate=CompoundMicrostate(
compound_id="MAT-POS-f42f3716-1",
microstate_id="MAT-POS-f42f3716-1-1",
),
final_microstate=CompoundMicrostate(
compound_id="MAT-POS-f42f3716-1",
microstate_id="MAT-POS-f42f3716-1-2",
),
xchem_fragment_id="x10789",
),
Transformation(
run=1,
initial_microstate=CompoundMicrostate(
compound_id="MAT-POS-f42f3716-2",
microstate_id="MAT-POS-f42f3716-2-1",
),
final_microstate=CompoundMicrostate(
compound_id="MAT-POS-f42f3716-2",
microstate_id="MAT-POS-f42f3716-2-2",
),
xchem_fragment_id="x10789",
),
],
)


def test_fah_xchem_imported():
"""Sample test, will always pass so long as import statement worked"""
assert "fah_xchem" in sys.modules


def test_compound_series_json_serialization(compound_series):
"""Test json serialize/deserialize roundtrip for CompoundSeries"""
json = compound_series.json()
deserialized = CompoundSeries.parse_raw(json)
assert deserialized == compound_series

0 comments on commit 8072617

Please sign in to comment.