haddock.clis.restraints.webservice module

Webservice for the haddock3 restraints module.

Exposes the haddock3-restraints CLI subcommands as a RESTful webservice. Also includes endpoint for PDB preprocessing.

Run with:

`shell uvicorn --port 5000 haddock.clis.restraints.webservice:app `

The Swagger UI is running at http://127.0.0.1:5000/docs .

To pass a PDB file in the JSON body of a request, it needs to be gzipped and then base64 encoded.

A base64 encoded gzipped PDB file can made with:

`shell cat examples/data/2oob.pdb | gzip | base64 -w 0 > 2oob.pdb.gz.base64 `

Background for PDB file handling:

To store a multiline string, like a pdb file, in JSON we need to encode it in base64. Base64 encoding make things 1.33 times bigger. A pdb is text which can be compressed a lot. To transfer less data we can compress the pdb with gzip before base64 encoding. For example the 2oob.pdb 74.8Kb becomes 101Kb when base64 encoded while first gzip and then base64 encode it is 25.4Kb.

class haddock.clis.restraints.webservice.ActPassToAmbigRequest(*, active1: list[int], active2: list[int], passive1: list[int], passive2: list[int], segid1: str = 'A', segid2: str = 'B')[source]

Bases: BaseModel

active1: list[int]
active2: list[int]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

passive1: list[int]
passive2: list[int]
segid1: str
segid2: str
class haddock.clis.restraints.webservice.CalcAccessibilityRequest(*, structure: str, cutoff: float)[source]

Bases: BaseModel

cutoff: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

structure: ', json_schema_extra={'contentMediaType': 'text/plain', 'contentEncoding': 'base64'})]
class haddock.clis.restraints.webservice.PDBPreprocessRequest(*, structure: str, from_chain: str, to_chain: str, delhetatm: bool = False, keepcoord: bool = False)[source]

Bases: BaseModel

delhetatm: bool
from_chain: str
keepcoord: bool
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

structure: ', json_schema_extra={'contentMediaType': 'text/plain', 'contentEncoding': 'base64'})]
to_chain: str
class haddock.clis.restraints.webservice.PassiveFromActiveRequest(*, structure: str, active: list[int], chain: str = 'A', surface: list[int] = [], radius: float = 6.5)[source]

Bases: BaseModel

active: list[int]
chain: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

radius: float
structure: ', json_schema_extra={'contentMediaType': 'text/plain', 'contentEncoding': 'base64'})]
surface: list[int]
class haddock.clis.restraints.webservice.RestrainBodiesRequest(*, structure: str, exclude: list[str] = [])[source]

Bases: BaseModel

exclude: list[str]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

structure: ', json_schema_extra={'contentMediaType': 'text/plain', 'contentEncoding': 'base64'})]
class haddock.clis.restraints.webservice.ValidateTblRequest(*, tbl: str, pcs: bool = False, quick: bool = False)[source]

Bases: BaseModel

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

pcs: bool
quick: bool
tbl: ', json_schema_extra={'contentMediaType': 'text/plain', 'contentEncoding': 'base64'})]
haddock.clis.restraints.webservice.calculate_accessibility(request: CalcAccessibilityRequest) dict[str, list[int]][source]

Calculate the accessibility of the side chains and apply a cutoff.

haddock.clis.restraints.webservice.calculate_actpass_to_ambig(request: ActPassToAmbigRequest) str[source]

Get the passive residues.

haddock.clis.restraints.webservice.calculate_passive_from_active(request: PassiveFromActiveRequest) list[int][source]

Calculate active restraints to passive restraints.

haddock.clis.restraints.webservice.preprocess_pdb(request: PDBPreprocessRequest) str[source]

Preprocess a PDB file.

Runs the following [pdbtools](http://www.bonvinlab.org/pdb-tools/) pipeline:

`shell cat pdb | pdb_tidy -strict | pdb_selchain -<from_chain> | pdb_chain -<to_chain> | pdb_fixinsert | pdb_selaltloc | pdb_tidy -strict `

or with delhetatm and keepcoord set to true:

`shell cat pdb | pdb_tidy -strict | pdb_selchain -<from_chain> | pdb_chain -<to_chain> | pdb_delhetatm |         pdb_fixinsert | pdb_keepcoord | pdb_selaltloc | pdb_tidy -strict `

haddock.clis.restraints.webservice.restrain_bodies(request: RestrainBodiesRequest) str[source]

Create distance restraints to lock several chains together.

haddock.clis.restraints.webservice.unpacked_structure(structure: str) bytes[source]

Gunzips a base64 encoded string.

haddock.clis.restraints.webservice.unpacked_tbl(tbl: str) str[source]

Gunzips a base64 encoded tbl file contents.

haddock.clis.restraints.webservice.validate_tbl(request: ValidateTblRequest) str[source]