Skip to content

Commit

Permalink
update: added CRIPSR examples in notebooks issue pydna-group#259
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyama341 committed Oct 3, 2024
1 parent 0fa7719 commit 8ff1c76
Show file tree
Hide file tree
Showing 2 changed files with 293 additions and 22 deletions.
66 changes: 44 additions & 22 deletions docs/notebooks/CRISPR.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,54 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cutting with enzyme 1: (Dseqrecord(-17), Dseqrecord(-6))\n",
"protospacer: GTTACTTTACCCGACGTCCC\n",
"cutting with enzyme 2: (Dseqrecord(-17), Dseqrecord(-6))\n",
"cutting with no PAM in target: ()\n"
]
}
],
"source": [
"# Defining the target sequence\n",
"sequence = Dseqrecord(\"GTTACTTTACCCGACGTCCCCGG\")\n",
"from pydna.dseqrecord import Dseqrecord\n",
"from pydna.crispr import cas9, protospacer\n",
"\n",
"# <----protospacer---><-------scaffold----------------->\n",
"guide = \"GTTACTTTACCCGACGTCCCgttttagagctagaaatagcaagttaaaataagg\"\n",
"target = \"GTTACTTTACCCGACGTCCCaGG\"\n",
"# <->\n",
"# PAM\n",
"\n",
"# Create an enzyme object with the protospacer\n",
"enzyme = cas9(\"GTTACTTTACCCGACGTCCC\")\n",
"\n",
"target_dseq = Dseqrecord(target)\n",
"\n",
"# Cut using the enzyme\n",
"print('cutting with enzyme 1:', target_dseq.cut(enzyme))\n",
"\n",
"\n",
"# Get the protospacer from the full gRNA sequence\n",
"gRNA_protospacers = protospacer(Dseqrecord(guide), cas=cas9)\n",
"# Print the protospacer (it's a list because often plasmids contain multiple gRNAs)\n",
"print('protospacer:', gRNA_protospacers[0])\n",
"gRNA_protospacer = gRNA_protospacers[0]\n",
"\n",
"# Create an enzyme from the protospacer\n",
"enzyme2 = cas9(gRNA_protospacer)\n",
"\n",
"# Simulate the cut\n",
"print('cutting with enzyme 2:', target_dseq.cut(enzyme2))\n",
"\n",
"# Defining the guide RNA sequence\n",
"gRNA_sequence = protospacer(guide_construct = sequence, cas=cas9)\n",
"print(gRNA_sequence)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Initializing the Cas9 protein\n",
"enzyme = cas9(protospacer=gRNA_sequence[0])\n",
"\n",
"# Simulating the CRISPR-Cas9 cut by searching for the cut sites\n",
"cas9_sites = enzyme.search(sequence)\n",
"print(len(cas9_sites))\n",
"# Note that without the PAM, the cut will not be made.\n",
"\n",
"# The cas9_sites will contain the fragments resulting from the cut\n",
"for fragment in cas9_sites:\n",
" print(fragment.format(\"fasta\"))"
"target_noPAM_dseq = Dseqrecord(\"GTTACTTTACCCGACGTCCCaaa\")\n",
"print(\"cutting with no PAM in target:\", target_noPAM_dseq.cut(enzyme2))"
]
}
],
Expand Down
249 changes: 249 additions & 0 deletions docs/notebooks/Example_CRISPR.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# CRISPR-Cas9 Implementation with Oligonucleotide-based CRISPR-Cas9 toolbox for efficient engineering of Komagataella phaffii \n",
"\n",
"\n",
"In this example we wanted to give a real life intuition on how to use the module in practice. \n",
"For this purpose we have chosen to use the oligonucleotide-based CRISPR-Cas9 toolbox that i described here: \n",
"https://academic.oup.com/femsyr/article/doi/10.1093/femsyr/foae026/7740463?login=false "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<img src=\"https://oup.silverchair-cdn.com/oup/backfile/Content_public/Journal/femsyr/24/10.1093_femsyr_foae026/1/m_foae026fig3.jpeg?Expires=1730974846&Signature=iBKvkhkUn1823IljQ~1uFEnKO0VqWrwiXADvCwQLz6Yv8yDEAFkgt~tsLrXKFTmGYIq3ZINcj5a5yNgs4cP4NeCvRcQh7Ad~1ZejIwNrjqw51CJhGcZWPzz~NDr93QVLZZd2Re41cJNFKFmEu756KxrHQxwKTQe2QPMPfiKBvhvo8J28PERj3vNjZ3LQRsFp9qUPpdsZEyWIiNY92jsuy448YyuaGCgaC2ExGDLeuArTEJmq8gtb0QnTPV0dEdtoxIfZpgavdvO~QyqikjCLj6hebUYU1lH7StuS8oqCQE82CXO0IUcjYF6m2Lb0evXhqdLDQe90M-NrKjzNRmBA0A__&Key-Pair-Id=APKAIE5G5CRDK6RD3PGA\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.display import Image\n",
"Image(url=\"https://oup.silverchair-cdn.com/oup/backfile/Content_public/Journal/femsyr/24/10.1093_femsyr_foae026/1/m_foae026fig3.jpeg?Expires=1730974846&Signature=iBKvkhkUn1823IljQ~1uFEnKO0VqWrwiXADvCwQLz6Yv8yDEAFkgt~tsLrXKFTmGYIq3ZINcj5a5yNgs4cP4NeCvRcQh7Ad~1ZejIwNrjqw51CJhGcZWPzz~NDr93QVLZZd2Re41cJNFKFmEu756KxrHQxwKTQe2QPMPfiKBvhvo8J28PERj3vNjZ3LQRsFp9qUPpdsZEyWIiNY92jsuy448YyuaGCgaC2ExGDLeuArTEJmq8gtb0QnTPV0dEdtoxIfZpgavdvO~QyqikjCLj6hebUYU1lH7StuS8oqCQE82CXO0IUcjYF6m2Lb0evXhqdLDQe90M-NrKjzNRmBA0A__&Key-Pair-Id=APKAIE5G5CRDK6RD3PGA\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"Basically we can make two cuts in the genome, and repair it with an oligo.\n",
"\n",
"Let's see how this can be implemented in pydna\n",
"\n",
"We can start by loading in our target. Here we have integrated LAC12 in our K. phaffi strain but want to knock it out. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/BjornFJohansson/pydna/blob/dev_bjorn/docs/notebooks/Example_CRISPR.ipynb\">\n",
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
"</a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Install pydna for colab.\n",
"%%capture\n",
"!pip install pydna"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Dseqrecord\n",
"circular: False\n",
"size: 7127\n",
"ID: X06997.1\n",
"Name: X06997\n",
"Description: Kluyveromyces lactis LAC12 gene for lactose permease\n",
"Number of features: 8\n",
"/molecule_type=DNA\n",
"/topology=linear\n",
"/data_file_division=PLN\n",
"/date=25-JUL-2016\n",
"/accessions=['X06997']\n",
"/sequence_version=1\n",
"/keywords=['lactose permease', 'unidentified reading frame']\n",
"/source=Kluyveromyces lactis\n",
"/organism=Kluyveromyces lactis\n",
"/taxonomy=['Eukaryota', 'Fungi', 'Dikarya', 'Ascomycota', 'Saccharomycotina', 'Saccharomycetes', 'Saccharomycetales', 'Saccharomycetaceae', 'Kluyveromyces']\n",
"/references=[Reference(title='Primary structure of the lactose permease gene from the yeast Kluyveromyces lactis. Presence of an unusual transcript structure', ...), Reference(title='Direct Submission', ...)]\n",
"/comment=the sequence submitted starts from the 5'end of LAC4 gene but goes\n",
"to the opposite direction; therefore, base number 1 is -1199 of\n",
"LAC4 gene; for LAC4 gene seq. see\n",
"Mol. Cell. Biol. (1987)7,4369-4376.\n",
"Dseq(-7127)\n",
"GCGA..TTCG\n",
"CGCT..AAGC\n"
]
}
],
"source": [
"from pydna.dseqrecord import Dseqrecord\n",
"from pydna.crispr import cas9, protospacer\n",
"from pydna.genbank import Genbank\n",
"\n",
"# initalize your favourite gene\n",
"gb = Genbank(\"[email protected]\") # Tell Genbank who you are!\n",
"gene = gb.nucleotide(\"X06997\") # Kluyveromyces lactis LAC12 gene for lactose permease that have been integrated into K. phaffi\n",
"target_dseq = Dseqrecord(gene)\n",
"print(target_dseq)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next we have chosen some guides and can add them to our cas9 enzymes and simulate the cuts."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cutting with guide 1: (Dseqrecord(-135), Dseqrecord(-6992))\n",
"cutting with guide 2: (Dseqrecord(-6793), Dseqrecord(-334))\n"
]
}
],
"source": [
"\n",
"# Choose guides\n",
"guides = [\"CCCTAAGTCCTTTGAAGATT\", \"TATTATTTTGAGGTGCTTTA\"]\n",
"\n",
"# Create an enzyme object with the protospacer\n",
"enzyme = cas9(guides[0])\n",
"\n",
"# Simulate the cut with enzyme1\n",
"print('cutting with guide 1:', target_dseq.cut(enzyme))\n",
"\n",
"# Create an enzyme from the protospacer\n",
"enzyme2 = cas9(guides[1])\n",
"\n",
"# Simulate the cut with enzyme2\n",
"print('cutting with guide 2:', target_dseq.cut(enzyme2))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With these guides I would be able to generate a stable KO with a repair 60/90mer oligo."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"My repair oligo for this experiment : AGGTGAACACACTCTGATGTAGTGCAGTCCCTAAGTCCTTTGAAGTTACGGACTCCTCGACCGATGCCCTTGAGAGCCTTCAACCCAGTC \n",
"My repair oligo for this experiment length : 90 \n"
]
}
],
"source": [
"repair_oligo = target_dseq.cut(enzyme)[0][-45:]+target_dseq.cut(enzyme2)[-1][:45]\n",
"repair_oligo.name = 'My repair oligo for this experiment'\n",
"print(f'{repair_oligo.name} : {repair_oligo.seq} ')\n",
"print(f'{repair_oligo.name} length : {len(repair_oligo.seq)} ')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The final gene would look like this\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre>name|45\n",
" \\/\n",
" /\\\n",
" 45|My repair oligo for this experiment|45\n",
" \\/\n",
" /\\\n",
" 45|name</pre>"
],
"text/plain": [
"Contig(-469)"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pydna.assembly import Assembly\n",
"\n",
"my_KO = Assembly((target_dseq.cut(enzyme)[0],repair_oligo, target_dseq.cut(enzyme2)[-1]), limit = 20 )\n",
"my_assembly_KO, *rest = my_KO.assemble_linear()\n",
"my_assembly_KO"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 8ff1c76

Please sign in to comment.