seqme.models.ESMIF1

seqme.models.ESMIF1#

class seqme.models.ESMIF1(*, device=None, batch_size=256, verbose=False)[source]#

Wrapper for the ESM inverse folding (ESM-IF1) model.

Installation: pip install "seqme[esmif1]"

Note

If you have an issue with installing ESM-IF1 on a machine with cuda support due to torch-scatter, try running pip install torch-scatter --no-build-isolation first.

Warning

Experimental. May change in the future or get removed.

Examples

>>> sequences = ["MKRM", "KKRPR"]
>>> folder = sm.models.ESMFold()  # Folding model
>>> folds = folder.fold(sequences, convention="atom37", compute_ptm=False, return_type="dict")
>>> atom_indices = [0, 1, 2]  # atoms: N, CA, C
>>> coords = [seq_pos[:, atom_indices, :] for seq_pos in folds["positions"]]
>>> inv_folder = sm.models.ESMIF1()  # Inverse folding model
>>> inv_folder.compute_perplexity(coords, sequences)  # scPerplexity
Reference:

Hsu et al., “Learning inverse folding from millions of predicted structures” (https://www.biorxiv.org/content/10.1101/2022.04.10.487779v2)

__init__(*, device=None, batch_size=256, verbose=False)[source]#

Initialize the model.

Parameters:
  • device (Optional[str]) – Device to run inference on, e.g., "cuda" or "cpu".

  • batch_size (int) – Number of sequences to process per batch.

  • verbose (bool) – Whether to display a progress bar.

Methods

__init__(*[, device, batch_size, verbose])

Initialize the model.

compute_perplexity(coordinates, sequences)

Compute perplexity after inverse folding the backbones (coordinates) and comparing against the target sequences.