File size: 3,604 Bytes
6f1e670 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | {
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# # (optional) check if the installation is successful\n",
"# import torch_sparse\n",
"# import torch_geometric\n",
"# import torch_cluster\n",
"# import torch_scatter\n",
"# import torch_spline_conv"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction\n",
"\n",
"This notebook shows you how to run zero-shot with an ensemble of non-structure-informed models (ESM-1v, ESM-2 3B) with the ```zero_shot_esm_dms``` function as well as run zero-shot with a structure-informed model (ESM-IF) using ```zero_shot_esm_if_dms``` function. \n",
"\n",
"```zero_shot_esm_dms``` requires the wild-type amino acid sequence of the protein of the interest\n",
"\n",
"```zero_shot_esm_if_dms``` requires the wild-type amino acid sequence and the structure of the protein of the interest, including the chain id of the protein of interest in the structure file.\n",
"\n",
"Both functions return a dataframe with all the possible single amino acid mutations and their corresponding log likelihood ratio scores (i.e. the ratio of the likelihood compared to the wild-type sequence)."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from Bio import SeqIO\n",
"\n",
"from model import zero_shot_esm_dms, zero_shot_esm_if_dms"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"wt_file = \"../../../data/example_protein/apex.fasta\"\n",
"pdb_file = \"../../../data/example_protein/apex.cif\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"wt_seq = str(SeqIO.read(wt_file, \"fasta\").seq)\n",
"\n",
"esm_zeroshot = zero_shot_esm_dms(wt_seq)\n",
"esm_if_zeroshot = zero_shot_esm_if_dms(wt_seq, pdb_file, chain_id = 'A', scoring_strategy='wt-marginals')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ```zero_shot_esm_dms``` returns a dataframe with the log likelihood ratio scores for each model as well as whether the mutation had a ratio greater than 1 indicated by the corresponding ```model#_pass``` column."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"esm_zeroshot.head(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ```zero_shot_esm_if_dms``` returns a dataframe with the log likelihood ratio scores."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"esm_if_zeroshot.head(10)"
]
}
],
"metadata": {
"environment": {
"kernel": "multievolve",
"name": "workbench-notebooks.m128",
"type": "gcloud",
"uri": "us-docker.pkg.dev/deeplearning-platform-release/gcr.io/workbench-notebooks:m128"
},
"kernelspec": {
"display_name": "multievolve_public",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.14"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
|