openprotein.fold#
Create PDBs of your protein sequences via our folding models!
Note that for AlphaFold2 Models, you will also need to utilize our align. workflow.
Interface#
- class openprotein.fold.FoldAPI(session)[source]#
Fold API provides a high level interface for making protein structure predictions.
- Parameters:
session (APISession)
- boltz2: Boltz2Model#
Boltz-2 model
- boltz_2: Boltz2Model#
- boltz1x: Boltz1xModel#
Boltz-1x model
- boltz_1x: Boltz1xModel#
- boltz1: Boltz1Model#
Boltz-1 model
- boltz_1: Boltz1Model#
- af2: AlphaFold2Model#
- alphafold2: AlphaFold2Model#
AlphaFold-2 model
- esmfold: ESMFoldModel#
ESMFold model
- list_models()[source]#
list models available for creating folds of your sequences
- Return type:
list[FoldModel]
- get_model(model_id)[source]#
Get model by model_id.
FoldModel allows all the usual job manipulation: e.g. making POST and GET requests for this model specifically.
- Parameters:
model_id (str) – the model identifier
- Returns:
The model
- Return type:
FoldModel
- Raises:
HTTPError – If the GET request does not succeed.
Models#
- class openprotein.fold.Boltz2Model(session, model_id, metadata=None)[source]#
Class providing inference endpoints for Boltz-2 structure prediction model which jointly models complex structures and binding affinities.
- Parameters:
session (APISession)
model_id (str)
metadata (ModelMetadata | None)
- fold(proteins=None, dnas=None, rnas=None, ligands=None, diffusion_samples=1, recycling_steps=3, sampling_steps=200, step_scale=1.638, use_potentials=False, constraints=None, templates=None, properties=None, method=None)[source]#
Request structure prediction with Boltz-2 model.
- Parameters:
proteins (List[Protein] | MSAFuture | None) – List of protein sequences to include in folded output. Protein objects must be tagged with an msa, which can be a Protein.single_sequence_mode for single sequence mode. Alternatively, supply an MSAFuture to use all query sequences as a multimer.
dna (List[DNA] | None) – List of DNA sequences to include in folded output.
rna (List[RNA] | None) – List of RNA sequences to include in folded output.
ligands (List[Ligand] | None) – List of ligands to include in folded output.
diffusion_samples (int) – Number of diffusion samples to use
recycling_steps (int) – Number of recycling steps to use
sampling_steps (int) – Number of sampling steps to use
step_scale (float) – Scaling factor for diffusion steps.
use_potentials (bool = False.) – Whether or not to use potentials.
constraints (list[dict] | None = None) – List of constraints.
templates (list[dict] | None = None) – List of templates to use for structure prediction.
properties (list[dict] | None = None) – List of additional properties to predict. Should match the BoltzProperties
method (str | None) – The experimental method or supervision source used for the prediction. Defults to None. Supported values (case-insensitive) include: ‘MD’, ‘X-RAY DIFFRACTION’, ‘ELECTRON MICROSCOPY’, ‘SOLUTION NMR’, ‘SOLID-STATE NMR’, ‘NEUTRON DIFFRACTION’, ‘ELECTRON CRYSTALLOGRAPHY’, ‘FIBER DIFFRACTION’, ‘POWDER DIFFRACTION’, ‘INFRARED SPECTROSCOPY’, ‘FLUORESCENCE TRANSFER’, ‘EPR’, ‘THEORETICAL MODEL’, ‘SOLUTION SCATTERING’, ‘OTHER’, ‘AFDB’, ‘BOLTZ-1’. View the documentation on Boltz for upstream details.
dnas (list[DNA] | None)
rnas (list[RNA] | None)
- Returns:
Future for the folding result.
- Return type:
- class openprotein.fold.Boltz1xModel(session, model_id, metadata=None)[source]#
Class providing inference endpoints for Boltz-1x open-source structure prediction model, which adds the use of inference potentials to improve performance.
- Parameters:
session (APISession)
model_id (str)
metadata (ModelMetadata | None)
- fold(proteins=None, dnas=None, rnas=None, ligands=None, diffusion_samples=1, recycling_steps=3, sampling_steps=200, step_scale=1.638, constraints=None)[source]#
Request structure prediction with Boltz-1x model. Uses potentials with Boltz-1 model.
- Parameters:
proteins (List[Protein] | MSAFuture | None) – List of protein sequences to include in folded output. Protein objects must be tagged with an msa, which can be a Protein.single_sequence_mode for single sequence mode. Alternatively, supply an MSAFuture to use all query sequences as a multimer.
dna (List[DNA] | None) – List of DNA sequences to include in folded output.
rna (List[RNA] | None) – List of RNA sequences to include in folded output.
ligands (List[Ligand] | None) – List of ligands to include in folded output.
diffusion_samples (int) – Number of diffusion samples to use
recycling_steps (int) – Number of recycling steps to use
sampling_steps (int) – Number of sampling steps to use
step_scale (float) – Scaling factor for diffusion steps.
constraints (Optional[List[dict]]) – List of constraints.
dnas (list[DNA] | None)
rnas (list[RNA] | None)
- Returns:
Future for the folding complex result.
- Return type:
- class openprotein.fold.Boltz1Model(session, model_id, metadata=None)[source]#
Class providing inference endpoints for Boltz-1 open-source structure prediction model.
- Parameters:
session (APISession)
model_id (str)
metadata (ModelMetadata | None)
- fold(proteins=None, dnas=None, rnas=None, ligands=None, diffusion_samples=1, recycling_steps=3, sampling_steps=200, step_scale=1.638, use_potentials=False, constraints=None)[source]#
Request structure prediction with Boltz-1 model.
- Parameters:
proteins (List[Protein] | MSAFuture | None) – List of protein sequences to include in folded output. Protein objects must be tagged with an msa, which can be a Protein.single_sequence_mode for single sequence mode. Alternatively, supply an MSAFuture to use all query sequences as a multimer.
dna (List[DNA] | None) – List of DNA sequences to include in folded output.
rna (List[RNA] | None) – List of RNA sequences to include in folded output.
ligands (List[Ligand] | None) – List of ligands to include in folded output.
diffusion_samples (int) – Number of diffusion samples to use
recycling_steps (int) – Number of recycling steps to use
sampling_steps (int) – Number of sampling steps to use
step_scale (float) – Scaling factor for diffusion steps.
use_potentials (bool = False.) – Whether or not to use potentials.
constraints (Optional[List[dict]]) – List of constraints.
dnas (list[DNA] | None)
rnas (list[RNA] | None)
- Returns:
Future for the folding complex result.
- Return type:
- class openprotein.fold.AlphaFold2Model(session, model_id, metadata=None)[source]#
Class providing inference endpoints for AlphaFold2 structure prediction models, based on the implementation by ColabFold.
- Parameters:
session (APISession)
model_id (str)
metadata (ModelMetadata | None)
- fold(proteins=None, num_recycles=None, num_models=1, num_relax=0, **kwargs)[source]#
Post sequences to alphafold model.
- Parameters:
proteins (List[Protein] | MSAFuture) – List of protein sequences to fold. Protein objects must be tagged with an msa. Alternatively, supply an MSAFuture to use all query sequences as a multimer.
num_recycles (int) – number of times to recycle models
num_models (int) – number of models to train - best model will be used
max_msa (Union[str, int]) – maximum number of sequences in the msa to use.
relax_max_iterations (int) – maximum number of iterations
num_relax (int)
- Returns:
job
- Return type:
- class openprotein.fold.ESMFoldModel(session, model_id, metadata=None)[source]#
Class providing inference endpoints for Facebook’s ESMFold structure prediction models.
- Parameters:
session (APISession)
model_id (str)
metadata (ModelMetadata | None)
- model_id: str = 'esmfold'#
Results#
- class openprotein.fold.FoldResultFuture(session, job, sequences=None, max_workers=10)[source]#
Fold results represented as a future.
- Parameters:
session (APISession)
job (FoldJob)
sequences (list[bytes] | None)
max_workers (int)
- job#
The fold job associated with this future.
- Type:
FoldJob
- classmethod create(session, job, **kwargs)[source]#
Factory method to create a FoldResultFuture or FoldComplexResultFuture.
- Parameters:
session (APISession) – The API session to use for requests.
job (FoldJob) – The fold job associated with this future.
**kwargs – Additional keyword arguments.
- Returns:
An instance of FoldResultFuture or FoldComplexResultFuture depending on the model.
- Return type:
- property sequences: list[bytes]#
Get the sequences submitted for the fold request.
- Returns:
List of sequences.
- Return type:
list[bytes]
- property model_id: str#
Get the model ID used for the fold request.
- Returns:
Model ID.
- Return type:
str
- property id#
Get the ID of the fold request.
- Returns:
Fold job ID.
- Return type:
str
- get(verbose=False)[source]#
Retrieve the fold results as a list of tuples mapping sequence to PDB-encoded string.
- Parameters:
verbose (bool, optional) – If True, print verbose output. Default is False.
- Returns:
List of tuples mapping sequence to PDB-encoded string.
- Return type:
list[tuple[str, str]]
- get_item(sequence)[source]#
Get fold results for a specified sequence.
- Parameters:
sequence (bytes) – Sequence to fetch results for.
- Returns:
Fold result for the specified sequence.
- Return type:
bytes
- cancelled()#
Check if the job has been cancelled.
- Returns:
True if the job is cancelled, False otherwise.
- Return type:
bool
- property created_date: datetime#
The creation timestamp of the job.
- done()#
Check if the job has completed.
- Returns:
True if the job is done, False otherwise.
- Return type:
bool
- property end_date: datetime | None#
The end timestamp of the job.
- property job_id: str#
The unique identifier of the job.
- property job_type: str#
The type of the job.
- property progress_counter: int#
The progress counter of the job.
- refresh()#
Refresh the job status and internal job object.
- property start_date: datetime | None#
The start timestamp of the job.
- property status: JobStatus#
The current status of the job.
- stream()#
Retrieve results for this job as a stream.
- Returns:
A generator that yields (key, value) tuples.
- Return type:
Generator
- wait(interval=5, timeout=None, verbose=False)#
Wait for the job to complete, then fetch results.
- Parameters:
interval (int, optional) – Time in seconds between polling. Defaults to config.POLLING_INTERVAL.
timeout (int | None, optional) – Maximum time in seconds to wait. Defaults to None.
verbose (bool, optional) – Verbosity flag. Defaults to False.
- Returns:
The results of the job.
- Return type:
Any
- wait_until_done(interval=5, timeout=None, verbose=False)#
Wait for the job to complete.
- Parameters:
interval (float, optional) – Time in seconds between polling. Defaults to config.POLLING_INTERVAL.
timeout (int, optional) – Maximum time in seconds to wait. Defaults to None.
verbose (bool, optional) – Verbosity flag. Defaults to False.
- Returns:
True if the job completed successfully.
- Return type:
bool
Notes
This method does not fetch the job results, unlike wait().
- class openprotein.fold.FoldComplexResultFuture(session, job, model_id=None, proteins=None, ligands=None, dnas=None, rnas=None)[source]#
Future for manipulating results of a fold complex request.
- Parameters:
session (APISession)
job (FoldJob)
model_id (str | None)
proteins (list[Protein] | None)
ligands (list[Ligand] | None)
dnas (list[DNA] | None)
rnas (list[RNA] | None)
- job#
The fold job associated with this future.
- Type:
FoldJob
- property model_id: str#
Get the model ID used for the fold request.
- Returns:
Model ID.
- Return type:
str
- property proteins: list[Protein] | None#
Get the proteins submitted for the fold request.
- Returns:
List of Protein objects or None.
- Return type:
list[Protein] or None
- property dnas: list[DNA] | None#
Get the DNAs submitted for the fold request.
- Returns:
List of DNA objects or None.
- Return type:
list[DNA] or None
- property rnas: list[RNA] | None#
Get the RNAs submitted for the fold request.
- Returns:
List of RNA objects or None.
- Return type:
list[RNA] or None
- property ligands: list[Ligand] | None#
Get the ligands submitted for the fold request.
- Returns:
List of Ligand objects or None.
- Return type:
list[Ligand] or None
- property pae: ndarray#
Get the Predicted Aligned Error (PAE) matrix.
- Returns:
PAE matrix.
- Return type:
np.ndarray
- Raises:
AttributeError – If PAE is not supported for the model.
- property pde: ndarray#
Get the Predicted Distance Error (PDE) matrix.
- Returns:
PDE matrix.
- Return type:
np.ndarray
- Raises:
AttributeError – If PDE is not supported for the model.
- property plddt: ndarray#
Get the Predicted Local Distance Difference Test (pLDDT) scores.
- Returns:
pLDDT scores.
- Return type:
np.ndarray
- Raises:
AttributeError – If pLDDT is not supported for the model.
- property confidence: list[BoltzConfidence]#
Retrieve the confidences of the structure prediction.
Note
This is only currently supported for Boltz models.
- Returns:
List of BoltzConfidence objects.
- Return type:
list[BoltzConfidence]
- Raises:
AttributeError – If confidence is not supported for the model.
- property affinity: BoltzAffinity#
Retrieve the predicted binding affinities.
Note
This is only currently supported for Boltz models.
- Returns:
BoltzAffinity object containing the predicted affinities.
- Return type:
BoltzAffinity
- Raises:
AttributeError – If affinity is not supported for the model.
- property id#
Get the ID of the fold request.
- Returns:
Fold job ID.
- Return type:
str
- get(format='mmcif', verbose=False)[source]#
Retrieve the fold results as a single bytestring.
Defaults to mmCIF for complexes. Additional predicted properties like plddt and pae should be accessed from their respective properties, i.e. .plddt and .pae.
- Parameters:
format ({'pdb', 'mmcif'}, optional) – Output format. Default is ‘mmcif’.
verbose (bool, optional) – If True, print verbose output. Default is False.
- Returns:
Fold result as a bytestring.
- Return type:
bytes
- cancelled()#
Check if the job has been cancelled.
- Returns:
True if the job is cancelled, False otherwise.
- Return type:
bool
- property created_date: datetime#
The creation timestamp of the job.
- done()#
Check if the job has completed.
- Returns:
True if the job is done, False otherwise.
- Return type:
bool
- property end_date: datetime | None#
The end timestamp of the job.
- property job_id: str#
The unique identifier of the job.
- property job_type: str#
The type of the job.
- property progress_counter: int#
The progress counter of the job.
- refresh()#
Refresh the job status and internal job object.
- property start_date: datetime | None#
The start timestamp of the job.
- property status: JobStatus#
The current status of the job.
- wait(interval=5, timeout=None, verbose=False)#
Wait for the job to complete, then fetch results.
- Parameters:
interval (int, optional) – Time in seconds between polling. Defaults to config.POLLING_INTERVAL.
timeout (int | None, optional) – Maximum time in seconds to wait. Defaults to None.
verbose (bool, optional) – Verbosity flag. Defaults to False.
- Returns:
The results of the job.
- Return type:
Any
- wait_until_done(interval=5, timeout=None, verbose=False)#
Wait for the job to complete.
- Parameters:
interval (float, optional) – Time in seconds between polling. Defaults to config.POLLING_INTERVAL.
timeout (int, optional) – Maximum time in seconds to wait. Defaults to None.
verbose (bool, optional) – Verbosity flag. Defaults to False.
- Returns:
True if the job completed successfully.
- Return type:
bool
Notes
This method does not fetch the job results, unlike wait().