Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial edge updates #76

Merged
merged 22 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 269 additions & 0 deletions examples/yeast_editing/edit-yeast-and-export-fasta.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "765587cd-3c78-4973-bfb2-06824e3a6f32",
"metadata": {},
"source": [
"In this notebook, we'll download the fasta for a yeast genome and edit it on the command line by replacing a short subsequence of NC_001138 with our own subsequence, ATCGATCG"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "b350d406-ea1d-41b4-b051-d5e79065ce2f",
"metadata": {},
"outputs": [],
"source": [
"# Clean up any lingering old files\n",
"!rm -rf .gen\n",
"!rm *.db"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c2cff742-e105-4eeb-9bb3-1c3ddc28aebb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2024-11-07 16:57:50-- http://sgd-archive.yeastgenome.org/sequence/S288C_reference/genome_releases/S288C_reference_genome_R64-1-1_20110203.tgz\n",
"Resolving sgd-archive.yeastgenome.org (sgd-archive.yeastgenome.org)... 52.92.229.203, 52.92.136.147, 52.218.218.50, ...\n",
"Connecting to sgd-archive.yeastgenome.org (sgd-archive.yeastgenome.org)|52.92.229.203|:80... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 17152288 (16M) [application/x-tar]\n",
"Saving to: ‘S288C_reference_genome_R64-1-1_20110203.tgz’\n",
"\n",
"S288C_reference_gen 100%[===================>] 16.36M 1.12MB/s in 18s \n",
"\n",
"2024-11-07 16:58:08 (945 KB/s) - ‘S288C_reference_genome_R64-1-1_20110203.tgz’ saved [17152288/17152288]\n",
"\n"
]
}
],
"source": [
"# Download yeast genome files\n",
"!wget http://sgd-archive.yeastgenome.org/sequence/S288C_reference/genome_releases/S288C_reference_genome_R64-1-1_20110203.tgz"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "318ef937-dc28-437e-a847-143bca61bf1a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x S288C_reference_genome_R64-1-1_20110203/\n",
"x S288C_reference_genome_R64-1-1_20110203/S288C_reference_sequence_R64-1-1_20110203.fsa\n",
"x S288C_reference_genome_R64-1-1_20110203/gene_association_R64-1-1_20110205.sgd\n",
"x S288C_reference_genome_R64-1-1_20110203/saccharomyces_cerevisiae_R64-1-1_20110208.gff\n",
"x S288C_reference_genome_R64-1-1_20110203/other_features_genomic_R64-1-1_20110203.fasta\n",
"x S288C_reference_genome_R64-1-1_20110203/rna_coding_R64-1-1_20110203.fasta\n",
"x S288C_reference_genome_R64-1-1_20110203/NotFeature_R64-1-1_20110203.fasta\n",
"x S288C_reference_genome_R64-1-1_20110203/orf_trans_all_R64-1-1_20110203.fasta\n",
"x S288C_reference_genome_R64-1-1_20110203/orf_coding_all_R64-1-1_20110203.fasta\n"
]
}
],
"source": [
"!tar -xzvf S288C_reference_genome_R64-1-1_20110203.tgz"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "15c93c14-de3d-4bfe-9ccd-38e6bc22e38b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Gen repository initialized.\n"
]
}
],
"source": [
"!gen init"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a890b7fd-7220-4888-b1d2-46da2ceb599b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Default database set to yeast.db\n",
"Default collection set to genome\n"
]
}
],
"source": [
"!gen defaults --database yeast.db --collection genome"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "1d23efeb-d239-43fb-a2ee-e00c7f0741c5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Created it\n"
]
}
],
"source": [
"!gen import --fasta S288C_reference_genome_R64-1-1_20110203\\/S288C_reference_sequence_R64-1-1_20110203.fsa"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "406421ff-4000-4418-b4f2-7a62c6087172",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rm: cassette-edit.fa: No such file or directory\n"
]
}
],
"source": [
"!rm cassette-edit.fa\n",
"# NOTE: The header doesn't matter, gen uses the --contig-name argument to know which contig to apply the change to\n",
"!echo \">foo\\n\" >> cassette-edit.fa\n",
"!echo \"ATCGATCG\\n\" >> cassette-edit.fa"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "2e2f6fd6-552e-43bb-af90-d7f3d566f5fe",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Updated with fasta file: cassette-edit.fa\n"
]
}
],
"source": [
"!gen update --fasta cassette-edit.fa --new-sample edited-sample --start 3 --end 5 --region-name ref\\|NC_001138\\|"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "2fc670e3-a9a6-4155-b0dc-0d313bb81311",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Exported to file edited-yeast-genome.fa\n"
]
}
],
"source": [
"!gen export --fasta edited-yeast-genome.fa --sample edited-sample"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "723c463a-6159-4257-b34d-bd878efea004",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"AAAATAAAGGTAGTAAGTAGCTTTTGGTTGAACATCCGGGTAAGAGACAACAGGGCTTGG\n",
"AGGAGACGTACATGAGGGCTATTTAGGGCTATTTAGGGCTATGTAGAAGTGCTGTAGGGC\n",
"TAAAGAACAGGGTTTCATTTTCATTTTTTTTTTT\n",
">ref|NC_001138| [org=Saccharomyces cerevisiae] [strain=S288C] [moltype=genomic] [chromosome=VI]\n",
"GATCTCGCAAGTGCATTCCTAGACTTAATTCATATCTGCTCCTCAACTGTCGATGATGCC\n",
"TGCTAAACTGCAGCTTGACGTACTGCGGACCCTGCAGTCCAGCGCTCGTCATGGAACGCA\n",
"AACGCTGAAAAACTCCAACTTTCTCGAGCGCTTCCACAAAGACCGTATCGTCTTTTGCCT\n"
]
}
],
"source": [
"!grep -C 3 NC_001138 S288C_reference_genome_R64-1-1_20110203\\/S288C_reference_sequence_R64-1-1_20110203.fsa"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "98c8c254-4304-495d-8a9e-3505d21cafe7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"TTTAGTGTTTGTTGCACGGCAGTAGCGAGAGACAAGTGGGAAAGAGTAGGATAAAAAGACAATCTATAAAAAGTAAACAT\n",
"AAAATAAAGGTAGTAAGTAGCTTTTGGTTGAACATCCGGGTAAGAGACAACAGGGCTTGGAGGAGACGTACATGAGGGCT\n",
"ATTTAGGGCTATTTAGGGCTATGTAGAAGTGCTGTAGGGCTAAAGAACAGGGTTTCATTTTCATTTTTTTTTTT\n",
">ref|NC_001138|\n",
"GATATCGATCGCGCAAGTGCATTCCTAGACTTAATTCATATCTGCTCCTCAACTGTCGATGATGCCTGCTAAACTGCAGC\n",
"TTGACGTACTGCGGACCCTGCAGTCCAGCGCTCGTCATGGAACGCAAACGCTGAAAAACTCCAACTTTCTCGAGCGCTTC\n",
"CACAAAGACCGTATCGTCTTTTGCCTCCCATTCTTCCCGGCACTTTTTCTCGTCCCAGTTCAAAAAGTACTGCAGCACCT\n"
]
}
],
"source": [
"!grep -C 3 NC_001138 edited-yeast-genome.fa\n",
"# Note that ATCGATCG appears starting after the third base pair, edit successful."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b499ed79-5705-400f-971d-4d7584efb4d3",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
2 changes: 2 additions & 0 deletions fixtures/aaaaaaaa.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>m123
AAAAAAAA
2 changes: 1 addition & 1 deletion fixtures/simple.fa
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
>m123
ATCGATCGATCGATCGATCGGGAACACACAGAGA
ATCGATCGATCGATCGATCGGGAACACACAGAGA
2 changes: 2 additions & 0 deletions fixtures/tttttttt.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>m123
TTTTTTTT
1 change: 1 addition & 0 deletions src/exports.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod fasta;
pub mod gfa;
Loading