openprotein.api.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.

Endpoints#

class openprotein.api.fold.FoldAPI[source]#

This class defines a high level interface for accessing the fold API.

esmfold: ESMFoldModel#
alphafold2: AlphaFold2Model#
__init__(session)[source]#
Parameters:

session (APISession)

property af2#

Alias for AlphaFold2

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.

get_results(job)[source]#

Retrieves the results of a fold job.

Parameters:

job (Job) – The fold job whose results are to be retrieved.

Returns:

An instance of FoldResultFuture

Return type:

FoldResultFuture

Models#

class openprotein.api.fold.ESMFoldModel[source]#
model_id = 'esmfold'#
__init__(session, model_id, metadata=None)[source]#
fold(sequences, num_recycles=1)[source]#

Fold sequences using this model.

Parameters:
  • sequences (List[bytes]) – sequences to fold

  • num_recycles (int) – number of times to recycle models

Return type:

FoldResultFuture

get_metadata()#

Get model metadata for this model.

Return type:

ModelMetadata

classmethod get_model()#
property metadata#
class openprotein.api.fold.AlphaFold2Model[source]#
__init__(session, model_id, metadata=None)[source]#
fold(msa, num_recycles=None, num_models=1, num_relax=0)[source]#

Post sequences to alphafold model.

Parameters:
  • msa (Union[str, MSAFuture]) – msa

  • 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 | None)

Returns:

job

Return type:

Job

get_metadata()#

Get model metadata for this model.

Return type:

ModelMetadata

Results#

class openprotein.api.fold.FoldResultFuture[source]#
job_type: Any | None = ['/embeddings/fold']#

Future Job for manipulating results

__init__(session, job, sequences=None, max_workers=10)[source]#

Retrieve results from asynchronous, mapped endpoints. Use max_workers > 0 to enable concurrent retrieval of multiple pages.

Parameters:
get_item(sequence)[source]#

Get fold results for specified sequence.

Parameters:

sequence (bytes) – sequence to fetch results for

Returns:

fold

Return type:

np.ndarray

classmethod get_job_type()#

Return the job type associated with this Future class.

refresh()#

refresh job status

wait(interval=5, timeout=None, verbose=False)#

Wait for job to complete, then fetch results.

Parameters:
  • interval (int, optional) – time between polling. Defaults to config.POLLING_INTERVAL.

  • timeout (int, optional) – max time to wait. Defaults to None.

  • verbose (bool, optional) – verbosity flag. Defaults to False.

Returns:

results of job

Return type:

results

wait_until_done(interval=5, timeout=None, verbose=False)#

Wait for job to complete. Do not fetch results (unlike wait())

Parameters:
  • interval (int, optional) – time between polling. Defaults to config.POLLING_INTERVAL.

  • timeout (int, optional) – max time to wait. Defaults to None.

  • verbose (bool, optional) – verbosity flag. Defaults to False.

Returns:

results of job

Return type:

results