Skip to content

Commit

Permalink
Merge pull request #5 from cheminfo-py/dev_MM
Browse files Browse the repository at this point in the history
dev MM
  • Loading branch information
lpatiny committed Jun 11, 2024
2 parents 763aa15 + 2788834 commit 660545c
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 347 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ services:
- CACHEDIR=/xpscache
- WORKERS=${WORKERS}
- OMP_NUM_THREADS=${OMP_NUM_THREADS}
- MAX_ATOMS_XTB=100
- MAX_ATOMS_FF=100
- MAX_ATOMS_XTB=200
- MAX_ATOMS_FF=200
- TIMEOUT=${TIMEOUT}
- LOG_LEVEL=DEBUG
ports:
Expand Down
2 changes: 1 addition & 1 deletion run_docker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

echo "connect to http://localhost:8091"
docker run -d -p 8091:8091 -e PORT=8091 -e WORKERS=1 -e OMP_NUM_THREADS=1 -e TIMEOUT=200 --rm --name=xps-serviceinstance --security-opt=seccomp:unconfined xps-service
docker run -d -p 8091:8091 -e PORT=8091 -e WORKERS=1 -e OMP_NUM_THREADS=1 -e TIMEOUT=500 --rm --name=xps-serviceinstance --security-opt=seccomp:unconfined xps-service
14 changes: 12 additions & 2 deletions xpsservice/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ase import Atoms
from pydantic import BaseModel, Field, validator
from rdkit import Chem
from .settings import ALLOWED_FMAX, ALLOWED_ELEMENTS, ALLOWED_FF, ALLOWED_METHODS, transition_map
from .settings import ALLOWED_FMAX, ALLOWED_ELEMENTS, ALLOWED_FF, ALLOWED_METHODS, ALLOWED_ENERGY_REFERENCE, transition_map


class TransitionValidator(BaseModel):
Expand All @@ -33,9 +33,13 @@ class XPSRequest(BaseModel):
description="Method for geometry optimization and XPS binding energies calculation. Allowed values: `GFNFF`, `GFN2xTB`, `GFN1xTB`.",
)
fmax: Optional[float] = Field(
0.01,
0.001,
description="Maximum force admissible during geometry optimization. Typically ranging from 0.1 to 0.0001."
)
energyReference: Optional[str] = Field(
"solid",
description="Energy referencing performed through polynomial regression, for gaz phase, solid state or none (raw data)"
)

@validator("smiles")
def validate_smiles(cls, v):
Expand Down Expand Up @@ -70,6 +74,12 @@ def validate_fmax(cls, v):
if not (ALLOWED_FMAX[0] <= v <= ALLOWED_FMAX[1]):
raise ValueError(f"fmax must be within the range {ALLOWED_FMAX}")
return v

@validator("energyReference")
def validate_energy_reference(cls, v):
if v not in ALLOWED_ENERGY_REFERENCE:
raise ValueError(f"Method must be in {ALLOWED_ENERGY_REFERENCE}")
return v


class Position(BaseModel):
Expand Down
18 changes: 13 additions & 5 deletions xpsservice/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,44 @@

#Conformer generation method
ALLOWED_FF = ("uff", "mmff94", "mmff94s")
MAX_ATOMS_FF = int(os.getenv("MAX_ATOMS_FF", 100))
MAX_ATOMS_FF = int(os.getenv("MAX_ATOMS_FF", 200))


#XTB optimization method
ALLOWED_METHODS = ("GFNFF", "GFN2xTB", "GFN1xTB")
MAX_ATOMS_XTB = int(os.getenv("MAX_ATOMS_XTB", 100))
MAX_ATOMS_XTB = int(os.getenv("MAX_ATOMS_XTB", 200))
ALLOWED_FMAX = (0.000001, 0.1)
ALLOWED_ENERGY_REFERENCE = ("none", "solid")


#timeout for the overall calculation
TIMEOUT = int(os.getenv("TIMEOUT", 100))
TIMEOUT = int(os.getenv("TIMEOUT", 500))


# Define transition_map dictionary(list of orbitals for which a photoelectron emission is calculated)
# Several maps possible. Adjust which one to load in xpsservice
# The regression coefficient are for polynomial a + bx + cx^2 + ..., given in an array [a,b,c,...]
transition_map = {
"C1s": {
"element": "C",
"orbital": "1s",
"soap_config_filepath": os.path.abspath("SOAP_configs/soap_config_C1s.pkl"),
"model_filepath": os.path.abspath("ML_models/XPS_GPR_C1s_xtb.pkl")
"model_filepath": os.path.abspath("ML_models/XPS_GPR_C1s_xtb.pkl"),
"regression_coefficients": [-2501.002792622873, 18.12807741, -0.02938832]
},
"O1s": {
"element": "O",
"orbital": "1s",
"soap_config_filepath": os.path.abspath("SOAP_configs/soap_config_O1s.pkl"),
"model_filepath": os.path.abspath("ML_models/XPS_GPR_O1s_xtb.pkl")
"model_filepath": os.path.abspath("ML_models/XPS_GPR_O1s_xtb.pkl"),
"regression_coefficients": [-14914.578039681715, 5.67166123e+01, -5.20506217e-02]
}
}

# Derive allowed elements from transition_map
def derive_allowed_elements(transition_map: dict) -> Set[str]:
allowed_elements = {info["element"] for info in transition_map .values()}
return allowed_elements

# Derive allowed elements from transition_map
def derive_allowed_elements(transition_map: dict) -> Set[str]:
Expand Down
Loading

0 comments on commit 660545c

Please sign in to comment.