fetch
DownloadableFormat = Literal['bcif', 'cif', 'pdb', 'paeImage', 'paeDoc', 'amAnnotations', 'amAnnotationsHg19', 'amAnnotationsHg38']
module-attribute
Types of formats that can be downloaded from the AlphaFold web service.
downloadable_formats = {'bcif', 'cif', 'pdb', 'paeImage', 'paeDoc', 'amAnnotations', 'amAnnotationsHg19', 'amAnnotationsHg38'}
module-attribute
Set of formats that can be downloaded from the AlphaFold web service.
AlphaFoldEntry
dataclass
AlphaFoldEntry represents a minimal single entry in the AlphaFold database.
See https://alphafold.ebi.ac.uk/api-docs for more details on the API and data structure.
by_format(dl_format)
Get the file path for a specific format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dl_format
|
DownloadableFormat
|
The format for which to get the file path. |
required |
Returns:
Type | Description |
---|---|
Path | None
|
The file path corresponding to the download format. |
Path | None
|
Or None if the file is not set. |
Raises:
Type | Description |
---|---|
ValueError
|
If the format is not valid. |
format2attr(dl_format)
classmethod
Get the attribute name for a specific download format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dl_format
|
DownloadableFormat
|
The format for which to get the attribute name. |
required |
Returns:
Type | Description |
---|---|
str
|
The attribute name corresponding to the download format. |
Raises:
Type | Description |
---|---|
ValueError
|
If the format is not valid. |
nr_of_files()
Nr of _file properties that are set
Returns:
Type | Description |
---|---|
int
|
The number of _file properties that are set. |
fetch_many(ids, save_dir, what, max_parallel_downloads=5)
Synchronously fetches summaries and pdb and pae files from AlphaFold Protein Structure Database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids
|
Iterable[str]
|
A set of Uniprot IDs to fetch. |
required |
save_dir
|
Path
|
The directory to save the fetched files to. |
required |
what
|
set[DownloadableFormat]
|
A set of formats to download. |
required |
max_parallel_downloads
|
int
|
The maximum number of parallel downloads. |
5
|
Returns:
Type | Description |
---|---|
list[AlphaFoldEntry]
|
A list of AlphaFoldEntry dataclasses containing the summary, pdb file, and pae file. |
fetch_many_async(ids, save_dir, what, max_parallel_downloads=5)
async
Asynchronously fetches summaries and pdb and pae (predicted alignment error) files from AlphaFold Protein Structure Database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids
|
Iterable[str]
|
A set of Uniprot IDs to fetch. |
required |
save_dir
|
Path
|
The directory to save the fetched files to. |
required |
what
|
set[DownloadableFormat]
|
A set of formats to download. |
required |
max_parallel_downloads
|
int
|
The maximum number of parallel downloads. |
5
|
Yields:
Type | Description |
---|---|
AsyncGenerator[AlphaFoldEntry]
|
A dataclass containing the summary, pdb file, and pae file. |
fetch_summary(qualifier, session, semaphore, save_dir)
async
Fetches a summary from the AlphaFold database for a given qualifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qualifier
|
str
|
The uniprot accession for the protein or entry to fetch.
For example |
required |
session
|
RetryClient
|
An asynchronous HTTP client session with retry capabilities. |
required |
semaphore
|
Semaphore
|
A semaphore to limit the number of concurrent requests. |
required |
save_dir
|
Path | None
|
An optional directory to save the fetched summary as a JSON file. If set and summary exists then summary will be loaded from disk instead of being fetched from the API. If not set then the summary will not be saved to disk and will always be fetched from the API. |
required |
Returns:
Type | Description |
---|---|
list[EntrySummary]
|
A list of EntrySummary objects representing the fetched summary. |
Raises:
Type | Description |
---|---|
HTTPError
|
If the HTTP request returns an error status code. |
Exception
|
If there is an error during file reading/writing or data conversion. |
relative_to(entry, session_dir)
Convert paths in an AlphaFoldEntry to be relative to the session directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry
|
AlphaFoldEntry
|
An AlphaFoldEntry instance with absolute paths. |
required |
session_dir
|
Path
|
The session directory to which the paths should be made relative. |
required |
Returns:
Type | Description |
---|---|
AlphaFoldEntry
|
An AlphaFoldEntry instance with paths relative to the session directory. |
url2name(url)
Given a URL, return the final path component as the name of the file.