search
Module for searching structures from 3D beacons network.
3D beacons HUB API information:
- docs at https://www.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons/api/
- openapi spec at https://www.ebi.ac.uk/pdbe/pdbe-kb/3dbeacons/api/v2/openapi.json
- code at https://github.com/3D-Beacons/3d-beacons-hub-api/
MAX_POST_LIMIT = 10
module-attribute
Maximum number of uniprot accessions to query in each batch. The 3D beacons HUB API has a maximum limit of 10 accessions per POST request.
provider_request2response = {'pdbe': 'PDBe', 'ped': 'PED', 'swissmodel': 'SWISS-MODEL', 'alphafold': 'AlphaFold DB', 'sasbdb': 'SASBDB', 'alphafill': 'AlphaFill', 'hegelab': 'HEGELAB', 'modelarchive': 'ModelArchive', 'isoformio': 'isoform.io', 'levylab': 'levylab'}
module-attribute
The response uses slightly different provider names than the request. Use this mapping to convert between them.
FlattenedUniprotSummary
Bases: TypedDict
Typed representation of a flattened structure summary.
Attributes:
| Name | Type | Description |
|---|---|---|
uniprot_accession |
str
|
Uniprot accession. |
provider |
str
|
Provider of the structure. |
model_identifier |
str
|
Model identifier of the structure. |
model_url |
str
|
URL to download the structure. |
model_format |
str
|
Format of the structure file |
chain |
str
|
Chain identifier of the structure (first chain of first entity or "A" if no entities or chains). |
residue_count |
int
|
Number of residues in the structure |
PruneOptions
Options for pruning the summaries.
Attributes:
| Name | Type | Description |
|---|---|---|
providers |
set[Provider]
|
Set of providers to keep in the summaries.
Default is |
limit |
PositiveInt
|
Maximum number of structures per uniprot summary per provider to return. |
min_residues |
PositiveInt | None
|
Minimum number of residues a structure must have to be included. |
max_residues |
PositiveInt | None
|
Maximum number of residues a structure can have to be included. |
flatten_structure_summaries(summaries)
Flatten the summaries to a list of dicts with uniprot accession and structure information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summaries
|
list[UniprotSummary]
|
List of summaries to flatten. |
required |
Returns:
| Type | Description |
|---|---|
list[FlattenedUniprotSummary]
|
List of dicts. |
prune_on_limit(structures, response_providers, limit, summary)
Keep at most limit structures per provider.
uniprots2structures(uniprot_accessions, prune_options, timeout=1800, batch_size=MAX_POST_LIMIT, sleep_between_batches=0.1)
async
For list of uniprot accessions, find structures using 3D beacons HUB API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uniprot_accessions
|
set[str]
|
Set of uniprot accessions to find structures for. |
required |
prune_options
|
PruneOptions
|
Options controlling provider filtering and per-provider limits. |
required |
timeout
|
int
|
Maximum seconds to wait for each batch query to complete. |
1800
|
batch_size
|
int
|
Number of uniprot accessions to query in each batch. |
MAX_POST_LIMIT
|
sleep_between_batches
|
float
|
Seconds to wait between each batch query. |
0.1
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If batch_size is not between 1 and MAX_POST_LIMIT. Or if providers is not a subset of search_structure_provider_choices. |
ClientResponseError
|
If the 3D beacons HUB API returns an error response. |
Returns:
| Type | Description |
|---|---|
list[UniprotSummary]
|
List of summaries of structures for each uniprot accession. |