# embeddings


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Utils

## Example Data

``` python
df = pd.DataFrame(
    {
        "sequence": [
            "MKWVTFISLLLLFSSAYSRGVFRRDAHKSEVAHRFKDLGE",
            "GSSHHHHHHSSGLVPRGSHMNNIRRVAILAALVAGQALA",
        ]
    }
)
df.shape
```

``` python
df.head()
```

``` python
run_model_examples = False
```

## ESM2

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/kprot/blob/main/kprot/embeddings.py#L23"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_esm

``` python

def get_esm(
    df:DataFrame, # dataframe containing protein sequences
    col:str, # column containing amino acid sequences
    model_name:str='esm2_t33_650M_UR50D', batch_size:int=1, # number of sequences per inference batch
)->DataFrame:

```

*Extract ESM2 embeddings (mean pooled per sequence).*

``` python
if run_model_examples:
    get_esm(df, "sequence").head()
else:
    print("Skipped get_esm example: set run_model_examples=True to allow model downloads.")
```

## ProtT5 Uniref50

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/kprot/blob/main/kprot/embeddings.py#L81"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_t5

``` python

def get_t5(
    df:DataFrame, # dataframe containing protein sequences
    col:str='sequence', # column containing amino acid sequences
)->DataFrame:

```

*Extract ProtT5-XL-uniref50 embeddings from protein sequences in a
dataframe.*

``` python
if run_model_examples:
    get_t5(df, "sequence").head()
else:
    print("Skipped get_t5 example: set run_model_examples=True to allow model downloads.")
```

## ProtT5 BFD

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/kprot/blob/main/kprot/embeddings.py#L110"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_t5_bfd

``` python

def get_t5_bfd(
    df:DataFrame, # dataframe containing protein sequences
    col:str='sequence', # column containing amino acid sequences
)->DataFrame:

```

*Extract ProtT5-XL-BFD embeddings from protein sequences in a
dataframe.*

``` python
if run_model_examples:
    get_t5_bfd(df, "sequence").head()
else:
    print("Skipped get_t5_bfd example: set run_model_examples=True to allow model downloads.")
```
