From 9b7d07ce5b4d9e748b238070f94b0959fe6af4fb Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 5 Sep 2024 10:46:34 -0700 Subject: [PATCH] Tutorial refactor (#443) * fixed typo. * updated comment * reorderd tutorial chapters. * created short tutorial on primer design * deleted dna parts tutorial wireframe. * explained PCR cycles and caveats. * renamed primer design tutorial. * disabled whitespace linting. * now using output of append. --- .golangci.yml | 1 - tutorials/001_input_output_test.go | 4 +- tutorials/002_dna_parts_test.go | 3 - tutorials/002_primer_design_test.go | 128 ++++++++++++++++++ ...test.go => 003_codon_optimization_test.go} | 0 tutorials/003_transforming_sequences_test.go | 3 - tutorials/005_primer_design_test.go | 3 - 7 files changed, 130 insertions(+), 12 deletions(-) delete mode 100644 tutorials/002_dna_parts_test.go create mode 100644 tutorials/002_primer_design_test.go rename tutorials/{004_codon_optimization_test.go => 003_codon_optimization_test.go} (100%) delete mode 100644 tutorials/003_transforming_sequences_test.go delete mode 100644 tutorials/005_primer_design_test.go diff --git a/.golangci.yml b/.golangci.yml index 53d8d62f8..fb6921ba2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -20,7 +20,6 @@ linters: - stylecheck - unconvert - unparam - - whitespace linters-settings: stylecheck: # https://staticcheck.io/docs/options#checks diff --git a/tutorials/001_input_output_test.go b/tutorials/001_input_output_test.go index 3c456b135..225f60029 100644 --- a/tutorials/001_input_output_test.go +++ b/tutorials/001_input_output_test.go @@ -47,7 +47,7 @@ Tim ******************************************************************************/ // if you're using VS-CODE you should see a DEBUG TEST button right below this -// comment. Please set break points and use it early and often. +// comment. Please set break points and use them early and often. func TestFileIOTutorial(t *testing.T) { // First we're going to read in a Genbank file for the well known plasmid // backbone puc19. Plasmids are super small rings of "Circular DNA" that are @@ -110,7 +110,7 @@ func TestFileIOTutorial(t *testing.T) { } // We'll go into more detail about features and DNA parts - // in the next tutorial but for now know that we can also + // later in this tutorial series but for now know that we can also // get the sequence of each feature using the GetSequence method. feature := puc19.Features[1] diff --git a/tutorials/002_dna_parts_test.go b/tutorials/002_dna_parts_test.go deleted file mode 100644 index 9d2d4144d..000000000 --- a/tutorials/002_dna_parts_test.go +++ /dev/null @@ -1,3 +0,0 @@ -package tutorials_test - -// TODO: Write a tutorial on DNA parts diff --git a/tutorials/002_primer_design_test.go b/tutorials/002_primer_design_test.go new file mode 100644 index 000000000..de8dc6fca --- /dev/null +++ b/tutorials/002_primer_design_test.go @@ -0,0 +1,128 @@ +package tutorials_test + +import ( + "fmt" + "log" + "testing" + + "github.com/bebop/poly/io/genbank" + "github.com/bebop/poly/primers/pcr" +) + +/****************************************************************************** +Sep, 12, 2022 + +== Designing Primers for Just About Anything == + +Now that you've learned what plasmids are you should probably know what primers +are as well. + +"Primers are short sequences of DNA that can be used to amplify DNA sequences +and they are the workhorse of modern molecular biology. + +Essentially primers are short pieces of single stranded DNA that can +bind to a target sequence of single stranded DNA. These primers serve as a +marker for polymerases (the enzyme Poly is named after!) to bind and start adding +free floating nucleotides (ACTGs) to a single strand piece of DNA to form a +double stranded piece of DNA. + +This is a crucial step in the process of PCR (polymerase chain reaction). +https://en.wikipedia.org/wiki/Polymerase_chain_reaction + +Here's also a video animation from Cold Spring Harbor's DNA Learning center explaining the process. +https://youtu.be/2KoLnIwoZKU?si=wqKs1NU5ZhU5O7Ui + +You can read more about that at the link above but just know that an absolute huge +number of protocols from diagnostics to plasmid cloning use these primers so they're +super important." + +- From the Poly's primer design package level documentation + + +Primers are the workhorse of modern molecular biology. They're involved in almost +every molecular biology experiment and are a crucial component in modern lab +diagnostics. + +In This tutorial we're going to design a large set of primers to help us extract and +isolate every protein coding region in the bacillus subtilis genome so we can express +and characterize each protein's structure individually in vivo (in the lab). + +We could also use these primers for RNA interference experiments to suppress +protein expression in vivo to better understand how these proteins interact. + +Point is that primers are incredibly versatile tools by automating their design +we can do some pretty interesting (and even potentially lucrative) experiments. + +TTFN, +Tim +******************************************************************************/ + +// if you're using VS-CODE you should see a DEBUG TEST button right below this +// comment. Please set break points and use them early and often. +func TestPrimersTutorial(t *testing.T) { + + // This is a struct that we'll use to store the results of our primer designs for cloning out each gene + type CloneOut struct { + CDS genbank.Feature + Sequence string + ForwardPrimer string + ReversePrimer string + } + + var reactions []CloneOut // <- declaring our list of primers so we can append to it + + // First let's get our annotated bacillus subtillus genome + bsub, err := genbank.Read("../data/bsub.gbk") + + if err != nil { + log.Fatal(err) + } + + // For each feature in the genome we're going to design a primer pair if the feature is a coding sequence + for _, feature := range bsub.Features { + if feature.Type == "CDS" { // CDS stands for coding sequence (which means that it codes for a protein in this case) + + var reaction CloneOut // initialize our reaction that will be appended + + // store the feature and its sequence in our reaction in case we need it later + reaction.CDS = feature + reaction.Sequence, _ = feature.GetSequence() + + // generate forward and reverse primers and store it in our struct + forward, reverse := pcr.DesignPrimers(reaction.Sequence, 56.0) // <- 56.0 is our melting temp. The temperature at which we want our primers to bind to double stranded DNA. Again. don't hardcode values like this in real life. Put it in a constant or something. + reaction.ForwardPrimer = forward + reaction.ReversePrimer = reverse + + // append our reaction to a our reactions slice (slice is essentially Go's version of a list, or vector) + reactions = append(reactions, reaction) + } + } + + fmt.Println("Total reactions:", len(reactions)) + // We've now just generated ~5000 primers. + // Notice how the only numerical parameter we give was "melting temp" this is the temp at which they'll anneal to denatured DNA. + // As mentioned in this Cold Spring Harbor video. PCR reactions are conducted in ~30 cycles of heating and cooling over 3 temperature stages. + + // Stage 1: We raise the temperature of our reaction to 95C to denature (split) our DNA such that our primers can bind to it. + // Stage 2: We lower the temperature of our reaction to 55C so that our primers can bind to complementary regions of newly accessible single stranded DNA. + // Stage 3: We raise the temperature of our reaction to ~72C (or whatever temperature is best for the polymerase we're using) to activate our polymerase + // Stage 3 (cont): to bind to our primers and begin constructing a brand new second strand to our denatured DNA. Then we go back to Stage 1. + + // For each cycle of the above stage we end up doubling the number of copies of the gene we want so after we have n^30 copies of our desired region. + + // What we've done is design a gigantic set of primers that share the same melting temp. This makes it possible to run all of these reactions + // concurrently within a single PCR run but we've ignored a lot of other design considerations. + + // This primers aren't particularly well designed. All pcr.DesignPrimers has done is figure out how long each primer should be so that they all bind + // at a specific temperature while assuming that they should bind at the very beginning and end of each given sequence. This is an extremely common + // use case but there are several caveats. + + // 1. The designed primers could be dimers (The primers could bind to each other and not to their target sequence) + // 2. One primer in a pair could be a "hairpin" that binds to itself (which is something the fold package can help detect) + // 3. Your primers may actually need a specific configuration to bind to the intended target (something the fold package may be able to help with) + + // Depending on your situation you may need to get creative. Lots of scientists design their primers to bind up or downstream of their gene of + // interest to avoid primer dimers or hairpins. Some scientists don't care if they copy the whole gene but just want to copy enough of the + // gene to verify that it's there. There's probably a million different way to design primers but I'd guess that poly itself covers about 95% + // of what most scientists would need on a daily basis. +} diff --git a/tutorials/004_codon_optimization_test.go b/tutorials/003_codon_optimization_test.go similarity index 100% rename from tutorials/004_codon_optimization_test.go rename to tutorials/003_codon_optimization_test.go diff --git a/tutorials/003_transforming_sequences_test.go b/tutorials/003_transforming_sequences_test.go deleted file mode 100644 index d7fc2ef69..000000000 --- a/tutorials/003_transforming_sequences_test.go +++ /dev/null @@ -1,3 +0,0 @@ -package tutorials_test - -// TODO: Write a tutorial on transforming sequences diff --git a/tutorials/005_primer_design_test.go b/tutorials/005_primer_design_test.go deleted file mode 100644 index 822e26d50..000000000 --- a/tutorials/005_primer_design_test.go +++ /dev/null @@ -1,3 +0,0 @@ -package tutorials_test - -//TODO: Write a tutorial on primer design