From 1f70caa4afa497c107a6bd85940b5188c0498c9d Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 17 Oct 2021 13:42:18 -0700 Subject: [PATCH] Refactoring docs to be more easily navigable. (#219) * updated doc.go. * refactored docs to render doc strings. * moved poly.go sequence structs to io subpackage. * moved codon tests to dedicated directory. --- checks/checks.go | 6 +- checks/checks_test.go | 14 +-- clone/clone.go | 34 ++++--- clone/clone_test.go | 81 ++++++++--------- cmd/poly/commands.go | 2 +- cmd/poly/commands_test.go | 2 +- cmd/poly/doc.go | 4 +- doc.go | 42 +++++---- io/example_test.go | 5 +- io/genbank/genbank.go | 5 +- io/genbank/genbank_test.go | 2 +- io/gff/gff.go | 5 +- io/gff/gff_test.go | 2 +- io/io_test.go | 4 +- poly.go => io/poly/poly.go | 14 +++ poly_test.go => io/poly/poly_test.go | 0 io/polyjson/polyjson.go | 8 +- io/polyjson/polyjson_test.go | 23 ++--- primers/primers.go | 19 ++++ primers/primers_test.go | 29 +++--- random/random.go | 3 + seqhash/example_test.go | 11 +++ seqhash/seqhash_test.go | 9 -- synthesis/codon/codon.go | 38 ++++---- synthesis/codon/codon_test.go | 121 ------------------------- synthesis/codon/example_test.go | 128 +++++++++++++++++++++++++++ synthesis/fix/example_test.go | 26 ++++++ synthesis/fix/synthesis_test.go | 22 ----- synthesis/fragment/example_test.go | 9 ++ synthesis/fragment/fragment_test.go | 9 -- transform/transform.go | 12 +++ transform/transform_test.go | 10 ++- transform/variants/variants.go | 8 ++ transform/variants/variants_test.go | 8 +- 34 files changed, 403 insertions(+), 312 deletions(-) rename poly.go => io/poly/poly.go (90%) rename poly_test.go => io/poly/poly_test.go (100%) create mode 100644 synthesis/codon/example_test.go diff --git a/checks/checks.go b/checks/checks.go index 77e94f78..86d6d147 100644 --- a/checks/checks.go +++ b/checks/checks.go @@ -1,8 +1,12 @@ +/* +Package checks provides utilities to check for certain properties of a sequence. +*/ package checks import ( - "github.com/TimothyStiles/poly/transform" "strings" + + "github.com/TimothyStiles/poly/transform" ) // IsPalindromic accepts a sequence of even length and returns if it is diff --git a/checks/checks_test.go b/checks/checks_test.go index 1eb69589..c73e2c06 100644 --- a/checks/checks_test.go +++ b/checks/checks_test.go @@ -1,21 +1,25 @@ -package checks +package checks_test -import "testing" +import ( + "testing" + + "github.com/TimothyStiles/poly/checks" +) // This also needs an example test. func TestIsPalindromic(t *testing.T) { - ecori := IsPalindromic("GAATTC") + ecori := checks.IsPalindromic("GAATTC") if ecori != true { t.Errorf("IsPalindromic failed to call EcoRI a palindrome") } - bsai := IsPalindromic("GGTCTC") + bsai := checks.IsPalindromic("GGTCTC") if bsai != false { t.Errorf("IsPalindromic failed call BsaI NOT a palindrome") } } func TestGcContent(t *testing.T) { - content := GcContent("GGTATC") + content := checks.GcContent("GGTATC") if content != 0.5 { t.Errorf("GcContent did not properly calculate GC content") } diff --git a/clone/clone.go b/clone/clone.go index 722d4bfc..9f73a317 100644 --- a/clone/clone.go +++ b/clone/clone.go @@ -1,21 +1,5 @@ -package clone - -import ( - "errors" - "regexp" - "sort" - "strings" - "sync" - - "github.com/TimothyStiles/poly/checks" - "github.com/TimothyStiles/poly/seqhash" - "github.com/TimothyStiles/poly/transform" -) - -/****************************************************************************** -Apr 22, 2021 - -Cloning stuff starts here. +/* +Package clone provides functions for cloning DNA sequences. Since 1973, the most common way to make recombinant DNA has been restriction enzyme cloning (though lately, homologous recombination based methods like @@ -54,8 +38,20 @@ Keoni PS: We do NOT (yet) handle restriction enzymes which recognize one site but cut in multiple places (Type IIG enzymes) such as BcgI. +*/ +package clone -******************************************************************************/ +import ( + "errors" + "regexp" + "sort" + "strings" + "sync" + + "github.com/TimothyStiles/poly/checks" + "github.com/TimothyStiles/poly/seqhash" + "github.com/TimothyStiles/poly/transform" +) // Part is a simple struct that can carry a circular or linear DNA sequence. // In the field of synthetic biology, the term "DNA Part" was popularized by diff --git a/clone/clone_test.go b/clone/clone_test.go index 68bd5fcb..7ac1eb7e 100644 --- a/clone/clone_test.go +++ b/clone/clone_test.go @@ -1,32 +1,33 @@ -package clone +package clone_test import ( "fmt" "testing" + "github.com/TimothyStiles/poly/clone" "github.com/TimothyStiles/poly/seqhash" ) // pOpen plasmid series (https://stanford.freegenes.org/collections/open-genes/products/open-plasmids#description). I use it for essentially all my cloning. -Keoni -var popen = Part{"TAACTATCGTCTTGAGTCCAACCCGGTAAGACACGACTTATCGCCACTGGCAGCAGCCACTGGTAACAGGATTAGCAGAGCGAGGTATGTAGGCGGTGCTACAGAGTTCTTGAAGTGGTGGCCTAACTACGGCTACACTAGAAGAACAGTATTTGGTATCTGCGCTCTGCTGAAGCCAGTTACCTTCGGAAAAAGAGTTGGTAGCTCTTGATCCGGCAAACAAACCACCGCTGGTAGCGGTGGTTTTTTTGTTTGCAAGCAGCAGATTACGCGCAGAAAAAAAGGATCTCAAGAAGGCCTACTATTAGCAACAACGATCCTTTGATCTTTTCTACGGGGTCTGACGCTCAGTGGAACGAAAACTCACGTTAAGGGATTTTGGTCATGAGATTATCAAAAAGGATCTTCACCTAGATCCTTTTAAATTAAAAATGAAGTTTTAAATCAATCTAAAGTATATATGAGTAAACTTGGTCTGACAGTTACCAATGCTTAATCAGTGAGGCACCTATCTCAGCGATCTGTCTATTTCGTTCATCCATAGTTGCCTGACTCCCCGTCGTGTAGATAACTACGATACGGGAGGGCTTACCATCTGGCCCCAGTGCTGCAATGATACCGCGAGAACCACGCTCACCGGCTCCAGATTTATCAGCAATAAACCAGCCAGCCGGAAGGGCCGAGCGCAGAAGTGGTCCTGCAACTTTATCCGCCTCCATCCAGTCTATTAATTGTTGCCGGGAAGCTAGAGTAAGTAGTTCGCCAGTTAATAGTTTGCGCAACGTTGTTGCCATTGCTACAGGCATCGTGGTGTCACGCTCGTCGTTTGGTATGGCTTCATTCAGCTCCGGTTCCCAACGATCAAGGCGAGTTACATGATCCCCCATGTTGTGCAAAAAAGCGGTTAGCTCCTTCGGTCCTCCGATCGTTGTCAGAAGTAAGTTGGCCGCAGTGTTATCACTCATGGTTATGGCAGCACTGCATAATTCTCTTACTGTCATGCCATCCGTAAGATGCTTTTCTGTGACTGGTGAGTACTCAACCAAGTCATTCTGAGAATAGTGTATGCGGCGACCGAGTTGCTCTTGCCCGGCGTCAATACGGGATAATACCGCGCCACATAGCAGAACTTTAAAAGTGCTCATCATTGGAAAACGTTCTTCGGGGCGAAAACTCTCAAGGATCTTACCGCTGTTGAGATCCAGTTCGATGTAACCCACTCGTGCACCCAACTGATCTTCAGCATCTTTTACTTTCACCAGCGTTTCTGGGTGAGCAAAAACAGGAAGGCAAAATGCCGCAAAAAAGGGAATAAGGGCGACACGGAAATGTTGAATACTCATACTCTTCCTTTTTCAATATTATTGAAGCATTTATCAGGGTTATTGTCTCATGAGCGGATACATATTTGAATGTATTTAGAAAAATAAACAAATAGGGGTTCCGCGCACCTGCACCAGTCAGTAAAACGACGGCCAGTAGTCAAAAGCCTCCGACCGGAGGCTTTTGACTTGGTTCAGGTGGAGTGGGAGTAgtcttcGCcatcgCtACTAAAagccagataacagtatgcgtatttgcgcgctgatttttgcggtataagaatatatactgatatgtatacccgaagtatgtcaaaaagaggtatgctatgaagcagcgtattacagtgacagttgacagcgacagctatcagttgctcaaggcatatatgatgtcaatatctccggtctggtaagcacaaccatgcagaatgaagcccgtcgtctgcgtgccgaacgctggaaagcggaaaatcaggaagggatggctgaggtcgcccggtttattgaaatgaacggctcttttgctgacgagaacagggGCTGGTGAAATGCAGTTTAAGGTTTACACCTATAAAAGAGAGAGCCGTTATCGTCTGTTTGTGGATGTACAGAGTGATATTATTGACACGCCCGGGCGACGGATGGTGATCCCCCTGGCCAGTGCACGTCTGCTGTCAGATAAAGTCTCCCGTGAACTTTACCCGGTGGTGCATATCGGGGATGAAAGCTGGCGCATGATGACCACCGATATGGCCAGTGTGCCGGTCTCCGTTATCGGGGAAGAAGTGGCTGATCTCAGCCACCGCGAAAATGACATCAAAAACGCCATTAACCTGATGTTCTGGGGAATATAAATGTCAGGCTCCCTTATACACAGgcgatgttgaagaccaCGCTGAGGTGTCAATCGTCGGAGCCGCTGAGCAATAACTAGCATAACCCCTTGGGGCCTCTAAACGGGTCTTGAGGGGTTTTTTGCATGGTCATAGCTGTTTCCTGAGAGCTTGGCAGGTGATGACACACATTAACAAATTTCGTGAGGAGTCTCCAGAAGAATGCCATTAATTTCCATAGGCTCCGCCCCCCTGACGAGCATCACAAAAATCGACGCTCAAGTCAGAGGTGGCGAAACCCGACAGGACTATAAAGATACCAGGCGTTTCCCCCTGGAAGCTCCCTCGTGCGCTCTCCTGTTCCGACCCTGCCGCTTACCGGATACCTGTCCGCCTTTCTCCCTTCGGGAAGCGTGGCGCTTTCTCATAGCTCACGCTGTAGGTATCTCAGTTCGGTGTAGGTCGTTCGCTCCAAGCTGGGCTGTGTGCACGAACCCCCCGTTCAGCCCGACCGCTGCGCCTTATCCGG", true} +var popen = clone.Part{"TAACTATCGTCTTGAGTCCAACCCGGTAAGACACGACTTATCGCCACTGGCAGCAGCCACTGGTAACAGGATTAGCAGAGCGAGGTATGTAGGCGGTGCTACAGAGTTCTTGAAGTGGTGGCCTAACTACGGCTACACTAGAAGAACAGTATTTGGTATCTGCGCTCTGCTGAAGCCAGTTACCTTCGGAAAAAGAGTTGGTAGCTCTTGATCCGGCAAACAAACCACCGCTGGTAGCGGTGGTTTTTTTGTTTGCAAGCAGCAGATTACGCGCAGAAAAAAAGGATCTCAAGAAGGCCTACTATTAGCAACAACGATCCTTTGATCTTTTCTACGGGGTCTGACGCTCAGTGGAACGAAAACTCACGTTAAGGGATTTTGGTCATGAGATTATCAAAAAGGATCTTCACCTAGATCCTTTTAAATTAAAAATGAAGTTTTAAATCAATCTAAAGTATATATGAGTAAACTTGGTCTGACAGTTACCAATGCTTAATCAGTGAGGCACCTATCTCAGCGATCTGTCTATTTCGTTCATCCATAGTTGCCTGACTCCCCGTCGTGTAGATAACTACGATACGGGAGGGCTTACCATCTGGCCCCAGTGCTGCAATGATACCGCGAGAACCACGCTCACCGGCTCCAGATTTATCAGCAATAAACCAGCCAGCCGGAAGGGCCGAGCGCAGAAGTGGTCCTGCAACTTTATCCGCCTCCATCCAGTCTATTAATTGTTGCCGGGAAGCTAGAGTAAGTAGTTCGCCAGTTAATAGTTTGCGCAACGTTGTTGCCATTGCTACAGGCATCGTGGTGTCACGCTCGTCGTTTGGTATGGCTTCATTCAGCTCCGGTTCCCAACGATCAAGGCGAGTTACATGATCCCCCATGTTGTGCAAAAAAGCGGTTAGCTCCTTCGGTCCTCCGATCGTTGTCAGAAGTAAGTTGGCCGCAGTGTTATCACTCATGGTTATGGCAGCACTGCATAATTCTCTTACTGTCATGCCATCCGTAAGATGCTTTTCTGTGACTGGTGAGTACTCAACCAAGTCATTCTGAGAATAGTGTATGCGGCGACCGAGTTGCTCTTGCCCGGCGTCAATACGGGATAATACCGCGCCACATAGCAGAACTTTAAAAGTGCTCATCATTGGAAAACGTTCTTCGGGGCGAAAACTCTCAAGGATCTTACCGCTGTTGAGATCCAGTTCGATGTAACCCACTCGTGCACCCAACTGATCTTCAGCATCTTTTACTTTCACCAGCGTTTCTGGGTGAGCAAAAACAGGAAGGCAAAATGCCGCAAAAAAGGGAATAAGGGCGACACGGAAATGTTGAATACTCATACTCTTCCTTTTTCAATATTATTGAAGCATTTATCAGGGTTATTGTCTCATGAGCGGATACATATTTGAATGTATTTAGAAAAATAAACAAATAGGGGTTCCGCGCACCTGCACCAGTCAGTAAAACGACGGCCAGTAGTCAAAAGCCTCCGACCGGAGGCTTTTGACTTGGTTCAGGTGGAGTGGGAGTAgtcttcGCcatcgCtACTAAAagccagataacagtatgcgtatttgcgcgctgatttttgcggtataagaatatatactgatatgtatacccgaagtatgtcaaaaagaggtatgctatgaagcagcgtattacagtgacagttgacagcgacagctatcagttgctcaaggcatatatgatgtcaatatctccggtctggtaagcacaaccatgcagaatgaagcccgtcgtctgcgtgccgaacgctggaaagcggaaaatcaggaagggatggctgaggtcgcccggtttattgaaatgaacggctcttttgctgacgagaacagggGCTGGTGAAATGCAGTTTAAGGTTTACACCTATAAAAGAGAGAGCCGTTATCGTCTGTTTGTGGATGTACAGAGTGATATTATTGACACGCCCGGGCGACGGATGGTGATCCCCCTGGCCAGTGCACGTCTGCTGTCAGATAAAGTCTCCCGTGAACTTTACCCGGTGGTGCATATCGGGGATGAAAGCTGGCGCATGATGACCACCGATATGGCCAGTGTGCCGGTCTCCGTTATCGGGGAAGAAGTGGCTGATCTCAGCCACCGCGAAAATGACATCAAAAACGCCATTAACCTGATGTTCTGGGGAATATAAATGTCAGGCTCCCTTATACACAGgcgatgttgaagaccaCGCTGAGGTGTCAATCGTCGGAGCCGCTGAGCAATAACTAGCATAACCCCTTGGGGCCTCTAAACGGGTCTTGAGGGGTTTTTTGCATGGTCATAGCTGTTTCCTGAGAGCTTGGCAGGTGATGACACACATTAACAAATTTCGTGAGGAGTCTCCAGAAGAATGCCATTAATTTCCATAGGCTCCGCCCCCCTGACGAGCATCACAAAAATCGACGCTCAAGTCAGAGGTGGCGAAACCCGACAGGACTATAAAGATACCAGGCGTTTCCCCCTGGAAGCTCCCTCGTGCGCTCTCCTGTTCCGACCCTGCCGCTTACCGGATACCTGTCCGCCTTTCTCCCTTCGGGAAGCGTGGCGCTTTCTCATAGCTCACGCTGTAGGTATCTCAGTTCGGTGTAGGTCGTTCGCTCCAAGCTGGGCTGTGTGCACGAACCCCCCGTTCAGCCCGACCGCTGCGCCTTATCCGG", true} func TestCutWithEnzymeByName(t *testing.T) { - _, err := CutWithEnzymeByName(popen, true, "EcoFake") + _, err := clone.CutWithEnzymeByName(popen, true, "EcoFake") if err == nil { t.Errorf("CutWithEnzymeByName should have failed when looking for fake restriction enzyme EcoFake") } } func TestCutWithEnzyme(t *testing.T) { - var seq Part + var seq clone.Part bsai := "GGTCTCAATGC" bsaiComplement := "ATGCAGAGACC" // test(1) // Test case of `<-bsaiComplement bsai-> <-bsaiComplement bsai->` where bsaI cuts off of a linear sequence. This tests the line: // if !seq.Circular && (overhangSet[len(overhangSet)-1].Position+enzyme.EnzymeSkip+enzyme.EnzymeOverhangLen > len(sequence)) - seq = Part{"ATATATA" + bsaiComplement + bsai + "ATGCATCGATCGACTAGCATG" + bsaiComplement + bsai[:8], false} - frag, err := CutWithEnzymeByName(seq, true, "BsaI") + seq = clone.Part{"ATATATA" + bsaiComplement + bsai + "ATGCATCGATCGACTAGCATG" + bsaiComplement + bsai[:8], false} + frag, err := clone.CutWithEnzymeByName(seq, true, "BsaI") if err != nil { t.Errorf("CutWithEnzyme should not have failed on test(1). Got error: %s", err) } @@ -40,7 +41,7 @@ func TestCutWithEnzyme(t *testing.T) { // test(2) // Now if we take the same sequence and circularize it, we get a different result seq.Circular = true - frag, err = CutWithEnzymeByName(seq, true, "BsaI") + frag, err = clone.CutWithEnzymeByName(seq, true, "BsaI") if err != nil { t.Errorf("CutWithEnzyme should not have failed on test(2). Got error: %s", err) } @@ -57,8 +58,8 @@ func TestCutWithEnzyme(t *testing.T) { // will give no fragments if you test for directionality, we set the // directionality flag to false. This tests the line: // if len(overhangs) == 1 && !directional && !seq.Circular - seq = Part{"ATATATATATATATAT" + bsai + "GCGCGCGCGCGCGCGCGCGC", false} - frag, err = CutWithEnzymeByName(seq, false, "BsaI") + seq = clone.Part{"ATATATATATATATAT" + bsai + "GCGCGCGCGCGCGCGCGCGC", false} + frag, err = clone.CutWithEnzymeByName(seq, false, "BsaI") if err != nil { t.Errorf("CutWithEnzyme should not have failed on test(3). Got error: %s", err) } @@ -74,7 +75,7 @@ func TestCutWithEnzyme(t *testing.T) { // tests the line: // if len(overhangs) == 2 && !directional && seq.Circular seq.Circular = true - frag, err = CutWithEnzymeByName(seq, false, "BsaI") + frag, err = clone.CutWithEnzymeByName(seq, false, "BsaI") if err != nil { t.Errorf("CutWithEnzyme should not have failed on test(4). Got error: %s", err) } @@ -88,7 +89,7 @@ func TestCutWithEnzyme(t *testing.T) { // test(5) // This tests if we have a fragment where we do not care about directionality // but have more than 1 cut site in our fragment. We can use pOpen for this. - frag, err = CutWithEnzymeByName(popen, false, "BbsI") + frag, err = clone.CutWithEnzymeByName(popen, false, "BbsI") if err != nil { t.Errorf("CutWithEnzyme should not have failed on test(5). Got error: %s", err) } @@ -100,9 +101,9 @@ func TestCutWithEnzyme(t *testing.T) { func TestCircularLigate(t *testing.T) { // The following tests for complementing overhangs. Specific, this line: // newSeed := Fragment{seedFragment.Sequence + seedFragment.ReverseOverhang + ReverseComplement(newFragment.Sequence), seedFragment.ForwardOverhang, ReverseComplement(newFragment.ForwardOverhang)} - fragment1 := Fragment{"AAAAAA", "GTTG", "CTAT"} - fragment2 := Fragment{"AAAAAA", "CAAC", "ATAG"} - outputConstructs, infiniteLoops, err := CircularLigate([]Fragment{fragment1, fragment2}) + fragment1 := clone.Fragment{"AAAAAA", "GTTG", "CTAT"} + fragment2 := clone.Fragment{"AAAAAA", "CAAC", "ATAG"} + outputConstructs, infiniteLoops, err := clone.CircularLigate([]clone.Fragment{fragment1, fragment2}) if err != nil { t.Errorf("Failed circular ligation with error: %s", err) } @@ -116,10 +117,10 @@ func TestCircularLigate(t *testing.T) { func TestGoldenGate(t *testing.T) { // Here we test if the enzyme we want to use in a GoldenGate reaction does not exist in our enzyme pool - fragment1 := Part{"GAAGTGCCATTCCGCCTGACCTGAAGACCAGGAGAAACACGTGGCAAACATTCCGGTCTCAAATGGAAAAGAGCAACGAAACCAACGGCTACCTTGACAGCGCTCAAGCCGGCCCTGCAGCTGGCCCGGGCGCTCCGGGTACCGCCGCGGGTCGTGCACGTCGTTGCGCGGGCTTCCTGCGGCGCCAAGCGCTGGTGCTGCTCACGGTGTCTGGTGTTCTGGCAGGCGCCGGTTTGGGCGCGGCACTGCGTGGGCTCAGCCTGAGCCGCACCCAGGTCACCTACCTGGCCTTCCCCGGCGAGATGCTGCTCCGCATGCTGCGCATGATCATCCTGCCGCTGGTGGTCTGCAGCCTGGTGTCGGGCGCCGCCTCCCTCGATGCCAGCTGCCTCGGGCGTCTGGGCGGTATCGCTGTCGCCTACTTTGGCCTCACCACACTGAGTGCCTCGGCGCTCGCCGTGGCCTTGGCGTTCATCATCAAGCCAGGATCCGGTGCGCAGACCCTTCAGTCCAGCGACCTGGGGCTGGAGGACTCGGGGCCTCCTCCTGTCCCCAAAGAAACGGTGGACTCTTTCCTCGACCTGGCCAGAAACCTGTTTCCCTCCAATCTTGTGGTTGCAGCTTTCCGTACGTATGCAACCGATTATAAAGTCGTGACCCAGAACAGCAGCTCTGGAAATGTAACCCATGAAAAGATCCCCATAGGCACTGAGATAGAAGGGATGAACATTTTAGGATTGGTCCTGTTTGCTCTGGTGTTAGGAGTGGCCTTAAAGAAACTAGGCTCCGAAGGAGAGGACCTCATCCGTTTCTTCAATTCCCTCAACGAGGCGACGATGGTGCTGGTGTCCTGGATTATGTGGTACGCGTCTTCAGGCTAGGTGGAGGCTCAGTG", false} - fragment2 := Part{"GAAGTGCCATTCCGCCTGACCTGAAGACCAGTACGTACCTGTGGGCATCATGTTCCTTGTTGGAAGCAAGATCGTGGAAATGAAAGACATCATCGTGCTGGTGACCAGCCTGGGGAAATACATCTTCGCATCTATATTGGGCCACGTCATTCATGGTGGTATCGTCCTGCCGCTGATTTATTTTGTTTTCACACGAAAAAACCCATTCAGATTCCTCCTGGGCCTCCTCGCCCCATTTGCGACAGCATTTGCTACGTGCTCCAGCTCAGCGACCCTTCCCTCTATGATGAAGTGCATTGAAGAGAACAATGGTGTGGACAAGAGGATCTCCAGGTTTATTCTCCCCATCGGGGCCACCGTGAACATGGACGGAGCAGCCATCTTCCAGTGTGTGGCCGCGGTGTTCATTGCGCAACTCAACAACGTAGAGCTCAACGCAGGACAGATTTTCACCATTCTAGTGACTGCCACAGCGTCCAGTGTTGGAGCAGCAGGCGTGCCAGCTGGAGGGGTCCTCACCATTGCCATTATCCTGGAGGCCATTGGGCTGCCTACTCATGATCTGCCTCTGATCCTGGCTGTGGACTGGATTGTGGACCGGACCACCACGGTGGTGAATGTGGAAGGGGATGCCCTGGGTGCAGGCATTCTCCACCACCTGAATCAGAAGGCAACAAAGAAAGGCGAGCAGGAACTTGCTGAGGTGAAAGTGGAAGCCATCCCCAACTGCAAGTCTGAGGAGGAAACCTCGCCCCTGGTGACACACCAGAACCCCGCTGGCCCCGTGGCCAGTGCCCCAGAACTGGAATCCAAGGAGTCGGTTCTGTGAAGAGCTTAGAGACCGACGACTGCCTAAGGACATTCGCTGCGTCTTCAGGCTAGGTGGAGGCTCAGTG", false} + fragment1 := clone.Part{"GAAGTGCCATTCCGCCTGACCTGAAGACCAGGAGAAACACGTGGCAAACATTCCGGTCTCAAATGGAAAAGAGCAACGAAACCAACGGCTACCTTGACAGCGCTCAAGCCGGCCCTGCAGCTGGCCCGGGCGCTCCGGGTACCGCCGCGGGTCGTGCACGTCGTTGCGCGGGCTTCCTGCGGCGCCAAGCGCTGGTGCTGCTCACGGTGTCTGGTGTTCTGGCAGGCGCCGGTTTGGGCGCGGCACTGCGTGGGCTCAGCCTGAGCCGCACCCAGGTCACCTACCTGGCCTTCCCCGGCGAGATGCTGCTCCGCATGCTGCGCATGATCATCCTGCCGCTGGTGGTCTGCAGCCTGGTGTCGGGCGCCGCCTCCCTCGATGCCAGCTGCCTCGGGCGTCTGGGCGGTATCGCTGTCGCCTACTTTGGCCTCACCACACTGAGTGCCTCGGCGCTCGCCGTGGCCTTGGCGTTCATCATCAAGCCAGGATCCGGTGCGCAGACCCTTCAGTCCAGCGACCTGGGGCTGGAGGACTCGGGGCCTCCTCCTGTCCCCAAAGAAACGGTGGACTCTTTCCTCGACCTGGCCAGAAACCTGTTTCCCTCCAATCTTGTGGTTGCAGCTTTCCGTACGTATGCAACCGATTATAAAGTCGTGACCCAGAACAGCAGCTCTGGAAATGTAACCCATGAAAAGATCCCCATAGGCACTGAGATAGAAGGGATGAACATTTTAGGATTGGTCCTGTTTGCTCTGGTGTTAGGAGTGGCCTTAAAGAAACTAGGCTCCGAAGGAGAGGACCTCATCCGTTTCTTCAATTCCCTCAACGAGGCGACGATGGTGCTGGTGTCCTGGATTATGTGGTACGCGTCTTCAGGCTAGGTGGAGGCTCAGTG", false} + fragment2 := clone.Part{"GAAGTGCCATTCCGCCTGACCTGAAGACCAGTACGTACCTGTGGGCATCATGTTCCTTGTTGGAAGCAAGATCGTGGAAATGAAAGACATCATCGTGCTGGTGACCAGCCTGGGGAAATACATCTTCGCATCTATATTGGGCCACGTCATTCATGGTGGTATCGTCCTGCCGCTGATTTATTTTGTTTTCACACGAAAAAACCCATTCAGATTCCTCCTGGGCCTCCTCGCCCCATTTGCGACAGCATTTGCTACGTGCTCCAGCTCAGCGACCCTTCCCTCTATGATGAAGTGCATTGAAGAGAACAATGGTGTGGACAAGAGGATCTCCAGGTTTATTCTCCCCATCGGGGCCACCGTGAACATGGACGGAGCAGCCATCTTCCAGTGTGTGGCCGCGGTGTTCATTGCGCAACTCAACAACGTAGAGCTCAACGCAGGACAGATTTTCACCATTCTAGTGACTGCCACAGCGTCCAGTGTTGGAGCAGCAGGCGTGCCAGCTGGAGGGGTCCTCACCATTGCCATTATCCTGGAGGCCATTGGGCTGCCTACTCATGATCTGCCTCTGATCCTGGCTGTGGACTGGATTGTGGACCGGACCACCACGGTGGTGAATGTGGAAGGGGATGCCCTGGGTGCAGGCATTCTCCACCACCTGAATCAGAAGGCAACAAAGAAAGGCGAGCAGGAACTTGCTGAGGTGAAAGTGGAAGCCATCCCCAACTGCAAGTCTGAGGAGGAAACCTCGCCCCTGGTGACACACCAGAACCCCGCTGGCCCCGTGGCCAGTGCCCCAGAACTGGAATCCAAGGAGTCGGTTCTGTGAAGAGCTTAGAGACCGACGACTGCCTAAGGACATTCGCTGCGTCTTCAGGCTAGGTGGAGGCTCAGTG", false} - _, _, err := GoldenGate([]Part{fragment1, fragment2, popen}, "EcoRFake") + _, _, err := clone.GoldenGate([]clone.Part{fragment1, fragment2, popen}, "EcoRFake") if err == nil { t.Errorf("GoldenGate should fail when using enzyme EcoRFake") } @@ -133,10 +134,10 @@ func ExampleGoldenGate() { // can occur. These two fragments are real DNA fragments used in the // FreeGenes Project. They are used because they were on my computer // - Keoni - fragment1 := Part{"GAAGTGCCATTCCGCCTGACCTGAAGACCAGGAGAAACACGTGGCAAACATTCCGGTCTCAAATGGAAAAGAGCAACGAAACCAACGGCTACCTTGACAGCGCTCAAGCCGGCCCTGCAGCTGGCCCGGGCGCTCCGGGTACCGCCGCGGGTCGTGCACGTCGTTGCGCGGGCTTCCTGCGGCGCCAAGCGCTGGTGCTGCTCACGGTGTCTGGTGTTCTGGCAGGCGCCGGTTTGGGCGCGGCACTGCGTGGGCTCAGCCTGAGCCGCACCCAGGTCACCTACCTGGCCTTCCCCGGCGAGATGCTGCTCCGCATGCTGCGCATGATCATCCTGCCGCTGGTGGTCTGCAGCCTGGTGTCGGGCGCCGCCTCCCTCGATGCCAGCTGCCTCGGGCGTCTGGGCGGTATCGCTGTCGCCTACTTTGGCCTCACCACACTGAGTGCCTCGGCGCTCGCCGTGGCCTTGGCGTTCATCATCAAGCCAGGATCCGGTGCGCAGACCCTTCAGTCCAGCGACCTGGGGCTGGAGGACTCGGGGCCTCCTCCTGTCCCCAAAGAAACGGTGGACTCTTTCCTCGACCTGGCCAGAAACCTGTTTCCCTCCAATCTTGTGGTTGCAGCTTTCCGTACGTATGCAACCGATTATAAAGTCGTGACCCAGAACAGCAGCTCTGGAAATGTAACCCATGAAAAGATCCCCATAGGCACTGAGATAGAAGGGATGAACATTTTAGGATTGGTCCTGTTTGCTCTGGTGTTAGGAGTGGCCTTAAAGAAACTAGGCTCCGAAGGAGAGGACCTCATCCGTTTCTTCAATTCCCTCAACGAGGCGACGATGGTGCTGGTGTCCTGGATTATGTGGTACGCGTCTTCAGGCTAGGTGGAGGCTCAGTG", false} - fragment2 := Part{"GAAGTGCCATTCCGCCTGACCTGAAGACCAGTACGTACCTGTGGGCATCATGTTCCTTGTTGGAAGCAAGATCGTGGAAATGAAAGACATCATCGTGCTGGTGACCAGCCTGGGGAAATACATCTTCGCATCTATATTGGGCCACGTCATTCATGGTGGTATCGTCCTGCCGCTGATTTATTTTGTTTTCACACGAAAAAACCCATTCAGATTCCTCCTGGGCCTCCTCGCCCCATTTGCGACAGCATTTGCTACGTGCTCCAGCTCAGCGACCCTTCCCTCTATGATGAAGTGCATTGAAGAGAACAATGGTGTGGACAAGAGGATCTCCAGGTTTATTCTCCCCATCGGGGCCACCGTGAACATGGACGGAGCAGCCATCTTCCAGTGTGTGGCCGCGGTGTTCATTGCGCAACTCAACAACGTAGAGCTCAACGCAGGACAGATTTTCACCATTCTAGTGACTGCCACAGCGTCCAGTGTTGGAGCAGCAGGCGTGCCAGCTGGAGGGGTCCTCACCATTGCCATTATCCTGGAGGCCATTGGGCTGCCTACTCATGATCTGCCTCTGATCCTGGCTGTGGACTGGATTGTGGACCGGACCACCACGGTGGTGAATGTGGAAGGGGATGCCCTGGGTGCAGGCATTCTCCACCACCTGAATCAGAAGGCAACAAAGAAAGGCGAGCAGGAACTTGCTGAGGTGAAAGTGGAAGCCATCCCCAACTGCAAGTCTGAGGAGGAAACCTCGCCCCTGGTGACACACCAGAACCCCGCTGGCCCCGTGGCCAGTGCCCCAGAACTGGAATCCAAGGAGTCGGTTCTGTGAAGAGCTTAGAGACCGACGACTGCCTAAGGACATTCGCTGCGTCTTCAGGCTAGGTGGAGGCTCAGTG", false} + fragment1 := clone.Part{"GAAGTGCCATTCCGCCTGACCTGAAGACCAGGAGAAACACGTGGCAAACATTCCGGTCTCAAATGGAAAAGAGCAACGAAACCAACGGCTACCTTGACAGCGCTCAAGCCGGCCCTGCAGCTGGCCCGGGCGCTCCGGGTACCGCCGCGGGTCGTGCACGTCGTTGCGCGGGCTTCCTGCGGCGCCAAGCGCTGGTGCTGCTCACGGTGTCTGGTGTTCTGGCAGGCGCCGGTTTGGGCGCGGCACTGCGTGGGCTCAGCCTGAGCCGCACCCAGGTCACCTACCTGGCCTTCCCCGGCGAGATGCTGCTCCGCATGCTGCGCATGATCATCCTGCCGCTGGTGGTCTGCAGCCTGGTGTCGGGCGCCGCCTCCCTCGATGCCAGCTGCCTCGGGCGTCTGGGCGGTATCGCTGTCGCCTACTTTGGCCTCACCACACTGAGTGCCTCGGCGCTCGCCGTGGCCTTGGCGTTCATCATCAAGCCAGGATCCGGTGCGCAGACCCTTCAGTCCAGCGACCTGGGGCTGGAGGACTCGGGGCCTCCTCCTGTCCCCAAAGAAACGGTGGACTCTTTCCTCGACCTGGCCAGAAACCTGTTTCCCTCCAATCTTGTGGTTGCAGCTTTCCGTACGTATGCAACCGATTATAAAGTCGTGACCCAGAACAGCAGCTCTGGAAATGTAACCCATGAAAAGATCCCCATAGGCACTGAGATAGAAGGGATGAACATTTTAGGATTGGTCCTGTTTGCTCTGGTGTTAGGAGTGGCCTTAAAGAAACTAGGCTCCGAAGGAGAGGACCTCATCCGTTTCTTCAATTCCCTCAACGAGGCGACGATGGTGCTGGTGTCCTGGATTATGTGGTACGCGTCTTCAGGCTAGGTGGAGGCTCAGTG", false} + fragment2 := clone.Part{"GAAGTGCCATTCCGCCTGACCTGAAGACCAGTACGTACCTGTGGGCATCATGTTCCTTGTTGGAAGCAAGATCGTGGAAATGAAAGACATCATCGTGCTGGTGACCAGCCTGGGGAAATACATCTTCGCATCTATATTGGGCCACGTCATTCATGGTGGTATCGTCCTGCCGCTGATTTATTTTGTTTTCACACGAAAAAACCCATTCAGATTCCTCCTGGGCCTCCTCGCCCCATTTGCGACAGCATTTGCTACGTGCTCCAGCTCAGCGACCCTTCCCTCTATGATGAAGTGCATTGAAGAGAACAATGGTGTGGACAAGAGGATCTCCAGGTTTATTCTCCCCATCGGGGCCACCGTGAACATGGACGGAGCAGCCATCTTCCAGTGTGTGGCCGCGGTGTTCATTGCGCAACTCAACAACGTAGAGCTCAACGCAGGACAGATTTTCACCATTCTAGTGACTGCCACAGCGTCCAGTGTTGGAGCAGCAGGCGTGCCAGCTGGAGGGGTCCTCACCATTGCCATTATCCTGGAGGCCATTGGGCTGCCTACTCATGATCTGCCTCTGATCCTGGCTGTGGACTGGATTGTGGACCGGACCACCACGGTGGTGAATGTGGAAGGGGATGCCCTGGGTGCAGGCATTCTCCACCACCTGAATCAGAAGGCAACAAAGAAAGGCGAGCAGGAACTTGCTGAGGTGAAAGTGGAAGCCATCCCCAACTGCAAGTCTGAGGAGGAAACCTCGCCCCTGGTGACACACCAGAACCCCGCTGGCCCCGTGGCCAGTGCCCCAGAACTGGAATCCAAGGAGTCGGTTCTGTGAAGAGCTTAGAGACCGACGACTGCCTAAGGACATTCGCTGCGTCTTCAGGCTAGGTGGAGGCTCAGTG", false} - Clones, _, _ := GoldenGate([]Part{fragment1, fragment2, popen}, "BbsI") + Clones, _, _ := clone.GoldenGate([]clone.Part{fragment1, fragment2, popen}, "BbsI") fmt.Println(seqhash.RotateSequence(Clones[0])) // Output: AAAAAAAGGATCTCAAGAAGGCCTACTATTAGCAACAACGATCCTTTGATCTTTTCTACGGGGTCTGACGCTCAGTGGAACGAAAACTCACGTTAAGGGATTTTGGTCATGAGATTATCAAAAAGGATCTTCACCTAGATCCTTTTAAATTAAAAATGAAGTTTTAAATCAATCTAAAGTATATATGAGTAAACTTGGTCTGACAGTTACCAATGCTTAATCAGTGAGGCACCTATCTCAGCGATCTGTCTATTTCGTTCATCCATAGTTGCCTGACTCCCCGTCGTGTAGATAACTACGATACGGGAGGGCTTACCATCTGGCCCCAGTGCTGCAATGATACCGCGAGAACCACGCTCACCGGCTCCAGATTTATCAGCAATAAACCAGCCAGCCGGAAGGGCCGAGCGCAGAAGTGGTCCTGCAACTTTATCCGCCTCCATCCAGTCTATTAATTGTTGCCGGGAAGCTAGAGTAAGTAGTTCGCCAGTTAATAGTTTGCGCAACGTTGTTGCCATTGCTACAGGCATCGTGGTGTCACGCTCGTCGTTTGGTATGGCTTCATTCAGCTCCGGTTCCCAACGATCAAGGCGAGTTACATGATCCCCCATGTTGTGCAAAAAAGCGGTTAGCTCCTTCGGTCCTCCGATCGTTGTCAGAAGTAAGTTGGCCGCAGTGTTATCACTCATGGTTATGGCAGCACTGCATAATTCTCTTACTGTCATGCCATCCGTAAGATGCTTTTCTGTGACTGGTGAGTACTCAACCAAGTCATTCTGAGAATAGTGTATGCGGCGACCGAGTTGCTCTTGCCCGGCGTCAATACGGGATAATACCGCGCCACATAGCAGAACTTTAAAAGTGCTCATCATTGGAAAACGTTCTTCGGGGCGAAAACTCTCAAGGATCTTACCGCTGTTGAGATCCAGTTCGATGTAACCCACTCGTGCACCCAACTGATCTTCAGCATCTTTTACTTTCACCAGCGTTTCTGGGTGAGCAAAAACAGGAAGGCAAAATGCCGCAAAAAAGGGAATAAGGGCGACACGGAAATGTTGAATACTCATACTCTTCCTTTTTCAATATTATTGAAGCATTTATCAGGGTTATTGTCTCATGAGCGGATACATATTTGAATGTATTTAGAAAAATAAACAAATAGGGGTTCCGCGCACCTGCACCAGTCAGTAAAACGACGGCCAGTAGTCAAAAGCCTCCGACCGGAGGCTTTTGACTTGGTTCAGGTGGAGTGGGAGAAACACGTGGCAAACATTCCGGTCTCAAATGGAAAAGAGCAACGAAACCAACGGCTACCTTGACAGCGCTCAAGCCGGCCCTGCAGCTGGCCCGGGCGCTCCGGGTACCGCCGCGGGTCGTGCACGTCGTTGCGCGGGCTTCCTGCGGCGCCAAGCGCTGGTGCTGCTCACGGTGTCTGGTGTTCTGGCAGGCGCCGGTTTGGGCGCGGCACTGCGTGGGCTCAGCCTGAGCCGCACCCAGGTCACCTACCTGGCCTTCCCCGGCGAGATGCTGCTCCGCATGCTGCGCATGATCATCCTGCCGCTGGTGGTCTGCAGCCTGGTGTCGGGCGCCGCCTCCCTCGATGCCAGCTGCCTCGGGCGTCTGGGCGGTATCGCTGTCGCCTACTTTGGCCTCACCACACTGAGTGCCTCGGCGCTCGCCGTGGCCTTGGCGTTCATCATCAAGCCAGGATCCGGTGCGCAGACCCTTCAGTCCAGCGACCTGGGGCTGGAGGACTCGGGGCCTCCTCCTGTCCCCAAAGAAACGGTGGACTCTTTCCTCGACCTGGCCAGAAACCTGTTTCCCTCCAATCTTGTGGTTGCAGCTTTCCGTACGTATGCAACCGATTATAAAGTCGTGACCCAGAACAGCAGCTCTGGAAATGTAACCCATGAAAAGATCCCCATAGGCACTGAGATAGAAGGGATGAACATTTTAGGATTGGTCCTGTTTGCTCTGGTGTTAGGAGTGGCCTTAAAGAAACTAGGCTCCGAAGGAGAGGACCTCATCCGTTTCTTCAATTCCCTCAACGAGGCGACGATGGTGCTGGTGTCCTGGATTATGTGGTACGTACCTGTGGGCATCATGTTCCTTGTTGGAAGCAAGATCGTGGAAATGAAAGACATCATCGTGCTGGTGACCAGCCTGGGGAAATACATCTTCGCATCTATATTGGGCCACGTCATTCATGGTGGTATCGTCCTGCCGCTGATTTATTTTGTTTTCACACGAAAAAACCCATTCAGATTCCTCCTGGGCCTCCTCGCCCCATTTGCGACAGCATTTGCTACGTGCTCCAGCTCAGCGACCCTTCCCTCTATGATGAAGTGCATTGAAGAGAACAATGGTGTGGACAAGAGGATCTCCAGGTTTATTCTCCCCATCGGGGCCACCGTGAACATGGACGGAGCAGCCATCTTCCAGTGTGTGGCCGCGGTGTTCATTGCGCAACTCAACAACGTAGAGCTCAACGCAGGACAGATTTTCACCATTCTAGTGACTGCCACAGCGTCCAGTGTTGGAGCAGCAGGCGTGCCAGCTGGAGGGGTCCTCACCATTGCCATTATCCTGGAGGCCATTGGGCTGCCTACTCATGATCTGCCTCTGATCCTGGCTGTGGACTGGATTGTGGACCGGACCACCACGGTGGTGAATGTGGAAGGGGATGCCCTGGGTGCAGGCATTCTCCACCACCTGAATCAGAAGGCAACAAAGAAAGGCGAGCAGGAACTTGCTGAGGTGAAAGTGGAAGCCATCCCCAACTGCAAGTCTGAGGAGGAAACCTCGCCCCTGGTGACACACCAGAACCCCGCTGGCCCCGTGGCCAGTGCCCCAGAACTGGAATCCAAGGAGTCGGTTCTGTGAAGAGCTTAGAGACCGACGACTGCCTAAGGACATTCGCTGAGGTGTCAATCGTCGGAGCCGCTGAGCAATAACTAGCATAACCCCTTGGGGCCTCTAAACGGGTCTTGAGGGGTTTTTTGCATGGTCATAGCTGTTTCCTGAGAGCTTGGCAGGTGATGACACACATTAACAAATTTCGTGAGGAGTCTCCAGAAGAATGCCATTAATTTCCATAGGCTCCGCCCCCCTGACGAGCATCACAAAAATCGACGCTCAAGTCAGAGGTGGCGAAACCCGACAGGACTATAAAGATACCAGGCGTTTCCCCCTGGAAGCTCCCTCGTGCGCTCTCCTGTTCCGACCCTGCCGCTTACCGGATACCTGTCCGCCTTTCTCCCTTCGGGAAGCGTGGCGCTTTCTCATAGCTCACGCTGTAGGTATCTCAGTTCGGTGTAGGTCGTTCGCTCCAAGCTGGGCTGTGTGCACGAACCCCCCGTTCAGCCCGACCGCTGCGCCTTATCCGGTAACTATCGTCTTGAGTCCAACCCGGTAAGACACGACTTATCGCCACTGGCAGCAGCCACTGGTAACAGGATTAGCAGAGCGAGGTATGTAGGCGGTGCTACAGAGTTCTTGAAGTGGTGGCCTAACTACGGCTACACTAGAAGAACAGTATTTGGTATCTGCGCTCTGCTGAAGCCAGTTACCTTCGGAAAAAGAGTTGGTAGCTCTTGATCCGGCAAACAAACCACCGCTGGTAGCGGTGGTTTTTTTGTTTGCAAGCAGCAGATTACGCGCAG @@ -145,18 +146,18 @@ func ExampleGoldenGate() { func TestSignalKilledGoldenGate(t *testing.T) { // This previously would crash from using too much RAM. - frag1 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATGGAGGGTCTCAAGGTGATCAAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTTTTGCCCTGTAAACGAAAAAACCACCTGGGTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - frag2 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATTGGGGAGGTGGTTTGATCGAAGGTTAAGTCAGTTGGGGAACTGCTTAACCGTGGTAACTGGCTTTCGCAGAGCACAGCAACCAAATCTGTTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - frag3 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATCTGTCCTTCCAGTGTAGCCGGACTTTGGCGCACACTTCAAGAGCAACCGCGTGTTTAGCTAAACAAATCCTCTGCGAACTCCCAGTTACCTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - frag4 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATTACCAATGGCTGCTGCCAGTGGCGTTTTACCGTGCTTTTCCGGGTTGGACTCAAGTGAACAGTTACCGGATAAGGCGCAGCAGTCGGGCTTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - frag5 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATGGCTGAACGGGGAGTTCTTGCTTACAGCCCAGCTTGGAGCGAACGACCTACACCGAGCCGAGATACCAGTGTGTGAGCTATGAGAAAGCGTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - frag6 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATAGCGCCACACTTCCCGTAAGGGAGAAAGGCGGAACAGGTATCCGGTAAACGGCAGGGTCGGAACAGGAGAGCGCAAGAGGGAGCGACCCGTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - frag7 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATCCCGCCGGAAACGGTGGGGATCTTTAAGTCCTGTCGGGTTTCGCCCGTACTGTCAGATTCATGGTTGAGCCTCACGGCTCCCACAGATGTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - frag8 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATGATGCACCGGAAAAGCGTCTGTTTATGTGAACTCTGGCAGGAGGGCGGAGCCTATGGAAAAACGCCACCGGCGCGGCCCTGCTGTTTTGCCTCACATGTTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - frag9 := Part{"AAAGCACTCTTAGGCCTCTGGAAGACATATGTTAGTCCCCTGCTTATCCACGGAATCTGTGGGTAACTTTGTATGTGTCCGCAGCGCAAAAAGAGACCCGCTTAGTCTTCGCATTTCTTAATCGGTGCCC", false} - fragments := []Part{popen, frag1, frag2, frag3, frag4, frag5, frag6, frag7, frag8, frag9} - - clones, loopingClones, err := GoldenGate(fragments, "BbsI") + frag1 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATGGAGGGTCTCAAGGTGATCAAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTTTTGCCCTGTAAACGAAAAAACCACCTGGGTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + frag2 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATTGGGGAGGTGGTTTGATCGAAGGTTAAGTCAGTTGGGGAACTGCTTAACCGTGGTAACTGGCTTTCGCAGAGCACAGCAACCAAATCTGTTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + frag3 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATCTGTCCTTCCAGTGTAGCCGGACTTTGGCGCACACTTCAAGAGCAACCGCGTGTTTAGCTAAACAAATCCTCTGCGAACTCCCAGTTACCTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + frag4 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATTACCAATGGCTGCTGCCAGTGGCGTTTTACCGTGCTTTTCCGGGTTGGACTCAAGTGAACAGTTACCGGATAAGGCGCAGCAGTCGGGCTTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + frag5 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATGGCTGAACGGGGAGTTCTTGCTTACAGCCCAGCTTGGAGCGAACGACCTACACCGAGCCGAGATACCAGTGTGTGAGCTATGAGAAAGCGTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + frag6 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATAGCGCCACACTTCCCGTAAGGGAGAAAGGCGGAACAGGTATCCGGTAAACGGCAGGGTCGGAACAGGAGAGCGCAAGAGGGAGCGACCCGTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + frag7 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATCCCGCCGGAAACGGTGGGGATCTTTAAGTCCTGTCGGGTTTCGCCCGTACTGTCAGATTCATGGTTGAGCCTCACGGCTCCCACAGATGTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + frag8 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATGATGCACCGGAAAAGCGTCTGTTTATGTGAACTCTGGCAGGAGGGCGGAGCCTATGGAAAAACGCCACCGGCGCGGCCCTGCTGTTTTGCCTCACATGTTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + frag9 := clone.Part{"AAAGCACTCTTAGGCCTCTGGAAGACATATGTTAGTCCCCTGCTTATCCACGGAATCTGTGGGTAACTTTGTATGTGTCCGCAGCGCAAAAAGAGACCCGCTTAGTCTTCGCATTTCTTAATCGGTGCCC", false} + fragments := []clone.Part{popen, frag1, frag2, frag3, frag4, frag5, frag6, frag7, frag8, frag9} + + clones, loopingClones, err := clone.GoldenGate(fragments, "BbsI") if err != nil { t.Errorf("GoldenGate should not fail with these fragments. Got error: %s", err) } @@ -173,14 +174,14 @@ func TestPanicGoldenGate(t *testing.T) { // This used to panic with the message: // panic: runtime error: slice bounds out of range [:-2] [recovered] // It was from the following sequence: GAAGACATAATGGTCTTC . There are 2 intercepting BbsI sites. - frag1 := Part{"AAACCGGAGCCATACAGTACGAAGACATGGAGGGTCTCAAATGAAAAAAATCATCGAAACCCAGCGTGCACCGGGAGCAATCGGACCGTACGTCCAGGGAGTCGACCTAGGATCAATGTAGTCTTCGCACTTGGCTTAGATGCAAC", false} - frag2 := Part{"AAACCGGAGCCATACAGTACGAAGACATAATGGTCTTCACCTCAGGACAGATCCCGGTCTGCCCGCAGACCGGAGAAATCCCGGCAGACGTCCAGGACCAGGCACGTCTATCACTAGATAGTCTTCGCACTTGGCTTAGATGCAAC", false} - frag3 := Part{"AAACCGGAGCCATACAGTACGAAGACATTAGAAAACGTCAAAGCAATCGTCGTCGCAGCAGGACTATCAGTCGGAGACATCATCAAAATGACCGTCTTCATCACCGACCTAAACGACTTAGTCTTCGCACTTGGCTTAGATGCAAC", false} - frag4 := Part{"AAACCGGAGCCATACAGTACGAAGACATGACTTCGCAACCATCAACGAAGTCTACAAACAGTTCTTCGACGAACACCAGGCAACCTACCCGACCCGTTCATGCGTCCAGGTCGCACGTCTACTAGTCTTCGCACTTGGCTTAGATGCAAC", false} - frag5 := Part{"AAACCGGAGCCATACAGTACGAAGACATCTACCGAAAGACGTCAAACTAGAAATCGAAGCAATCGCAGTCCGTTCAGCAAGAGCTTAGAGACCCGCTTAGTCTTCGCACTTGGCTTAGATGCAAC", false} - fragments := []Part{popen, frag1, frag2, frag3, frag4, frag5} - - _, _, err := GoldenGate(fragments, "BbsI") + frag1 := clone.Part{"AAACCGGAGCCATACAGTACGAAGACATGGAGGGTCTCAAATGAAAAAAATCATCGAAACCCAGCGTGCACCGGGAGCAATCGGACCGTACGTCCAGGGAGTCGACCTAGGATCAATGTAGTCTTCGCACTTGGCTTAGATGCAAC", false} + frag2 := clone.Part{"AAACCGGAGCCATACAGTACGAAGACATAATGGTCTTCACCTCAGGACAGATCCCGGTCTGCCCGCAGACCGGAGAAATCCCGGCAGACGTCCAGGACCAGGCACGTCTATCACTAGATAGTCTTCGCACTTGGCTTAGATGCAAC", false} + frag3 := clone.Part{"AAACCGGAGCCATACAGTACGAAGACATTAGAAAACGTCAAAGCAATCGTCGTCGCAGCAGGACTATCAGTCGGAGACATCATCAAAATGACCGTCTTCATCACCGACCTAAACGACTTAGTCTTCGCACTTGGCTTAGATGCAAC", false} + frag4 := clone.Part{"AAACCGGAGCCATACAGTACGAAGACATGACTTCGCAACCATCAACGAAGTCTACAAACAGTTCTTCGACGAACACCAGGCAACCTACCCGACCCGTTCATGCGTCCAGGTCGCACGTCTACTAGTCTTCGCACTTGGCTTAGATGCAAC", false} + frag5 := clone.Part{"AAACCGGAGCCATACAGTACGAAGACATCTACCGAAAGACGTCAAACTAGAAATCGAAGCAATCGCAGTCCGTTCAGCAAGAGCTTAGAGACCCGCTTAGTCTTCGCACTTGGCTTAGATGCAAC", false} + fragments := []clone.Part{popen, frag1, frag2, frag3, frag4, frag5} + + _, _, err := clone.GoldenGate(fragments, "BbsI") if err != nil { t.Errorf("GoldenGate should not fail with these fragments. Got error: %s", err) } diff --git a/cmd/poly/commands.go b/cmd/poly/commands.go index 369adc8f..6a862ad4 100644 --- a/cmd/poly/commands.go +++ b/cmd/poly/commands.go @@ -11,9 +11,9 @@ import ( "path/filepath" "sync" - "github.com/TimothyStiles/poly" "github.com/TimothyStiles/poly/io/genbank" "github.com/TimothyStiles/poly/io/gff" + "github.com/TimothyStiles/poly/io/poly" "github.com/TimothyStiles/poly/io/polyjson" "github.com/TimothyStiles/poly/seqhash" "github.com/urfave/cli/v2" diff --git a/cmd/poly/commands_test.go b/cmd/poly/commands_test.go index 471cd3d3..2562188d 100644 --- a/cmd/poly/commands_test.go +++ b/cmd/poly/commands_test.go @@ -7,8 +7,8 @@ import ( "path/filepath" "testing" - "github.com/TimothyStiles/poly" "github.com/TimothyStiles/poly/io/genbank" + "github.com/TimothyStiles/poly/io/poly" "github.com/TimothyStiles/poly/io/polyjson" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" diff --git a/cmd/poly/doc.go b/cmd/poly/doc.go index c0c6bb33..88a23476 100644 --- a/cmd/poly/doc.go +++ b/cmd/poly/doc.go @@ -1,6 +1,6 @@ /* -Poly command line utility installation instructions: +Poly command line utility installation instructions. Mac OSX @@ -13,6 +13,6 @@ Windows Coming soon... -Usage: please make good use of our `-h` help flag. Everything is up to date there and well tested. +Usage: please make good use of our `-h` help flag. Everything is up to date there and well tested. */ package main diff --git a/doc.go b/doc.go index 0f077294..54fe5aab 100644 --- a/doc.go +++ b/doc.go @@ -1,30 +1,34 @@ -/*Package poly is a go package for engineering organisms. +/* +Package poly is a Go package for engineering organisms. +Synthetic biology has a software problem. I.E almost all +of our field's software is slow, hard to maintain, +and even harder to deploy. +Poly solves that problem by providing a highly tested +suite of common functions for engineering organisms +through a simple interface in Go. -Poly can be used in two ways. +The reason why Go was choosen is that it's a highly popular +language with a simple sytax and a large ecosystem of packages +that makes it *extremely* easy to learn, use, and deploy. +It's also on average 25X faster and more energy efficient that +Python. - 1. As a Go library where you have finer control and can make magical things happen. - 2. As a command line utility where you can bash script your way to greatness and make DNA go brrrrrrrr. +Eventually we intend for poly to provide all the functionality +needed such that users can use it to engineer proteins which +they can then optimize and insert into their organisms of choice. +We've made great progress and are always looking for more support! -Installation +tl;dr +Poly is awesome. -These instructions assume that you already have a working go environment. If not see: - https://golang.org/doc/install +Throw money at Tim's github sponsors page: +https://github.com/sponsors/TimothyStiles - -Building Poly CLI and package from scratch: - - git clone https://github.com/TimothyStiles/poly.git && cd poly && go build ./... && go install ./... - - - -Installing latest release of poly as a go package: - go get github.com/TimothyStiles/poly - - -For CLI only instructions please checkout: https://pkg.go.dev/github.com/TimothyStiles/poly/poly +Browse our subpackages to find the functionality and documentation you need: +https://pkg.go.dev/github.com/TimothyStiles/poly#section-directories */ package poly diff --git a/io/example_test.go b/io/example_test.go index 633d47c0..06faf816 100644 --- a/io/example_test.go +++ b/io/example_test.go @@ -1,4 +1,4 @@ -package io +package io_test import ( "github.com/TimothyStiles/poly/io/fasta" @@ -19,7 +19,8 @@ func Example() { fastaInput := fasta.Read("fasta/data/base.fasta") jsonInput := polyjson.Read("../data/puc19static.json") - // Poly can also output these file formats though I wouldn't try doing gbk<->gff or anything like that unless it's JSON. + // Poly can also output these file formats though I wouldn't try doing gbk<->gff + // or anything like that but JSON <-> anything and back should work.that unless it's JSON. gff.Write(gffInput, "test.gff") genbank.Write(gbkInput, "test.gbk") diff --git a/io/genbank/genbank.go b/io/genbank/genbank.go index f329dbeb..b2217874 100644 --- a/io/genbank/genbank.go +++ b/io/genbank/genbank.go @@ -17,12 +17,13 @@ import ( "io" "io/ioutil" "log" - "lukechampine.com/blake3" "regexp" "strconv" "strings" - "github.com/TimothyStiles/poly" + "lukechampine.com/blake3" + + "github.com/TimothyStiles/poly/io/poly" "github.com/mitchellh/go-wordwrap" ) diff --git a/io/genbank/genbank_test.go b/io/genbank/genbank_test.go index b08d3518..eab4f7e8 100644 --- a/io/genbank/genbank_test.go +++ b/io/genbank/genbank_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/TimothyStiles/poly" + "github.com/TimothyStiles/poly/io/poly" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" ) diff --git a/io/gff/gff.go b/io/gff/gff.go index e7018e0a..acd7329c 100644 --- a/io/gff/gff.go +++ b/io/gff/gff.go @@ -15,13 +15,14 @@ import ( "bytes" "io/ioutil" "log" - "lukechampine.com/blake3" "regexp" "sort" "strconv" "strings" - "github.com/TimothyStiles/poly" + "lukechampine.com/blake3" + + "github.com/TimothyStiles/poly/io/poly" ) // Parse Takes in a string representing a gffv3 file and parses it into an Sequence object. diff --git a/io/gff/gff_test.go b/io/gff/gff_test.go index 4998d78d..8814ef7b 100644 --- a/io/gff/gff_test.go +++ b/io/gff/gff_test.go @@ -7,7 +7,7 @@ import ( "path/filepath" "testing" - "github.com/TimothyStiles/poly" + "github.com/TimothyStiles/poly/io/poly" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/pmezard/go-difflib/difflib" diff --git a/io/io_test.go b/io/io_test.go index b22fad7f..f1535048 100644 --- a/io/io_test.go +++ b/io/io_test.go @@ -1,10 +1,10 @@ -package io_test +package io import ( "testing" - "github.com/TimothyStiles/poly" "github.com/TimothyStiles/poly/io/genbank" + "github.com/TimothyStiles/poly/io/poly" "github.com/TimothyStiles/poly/io/polyjson" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" diff --git a/poly.go b/io/poly/poly.go similarity index 90% rename from poly.go rename to io/poly/poly.go index b0615b25..e0c04768 100644 --- a/poly.go +++ b/io/poly/poly.go @@ -1,3 +1,17 @@ +/* +Package poly provides the core Sequence struct and methods for working with DNA, RNA, and Amino Acid sequences in Poly. + +Each Sequence struct can be broken down into the following: + +Meta: Author, Date, Description, Name, Version, etc. +Features: A list of Feature structs containing feature locations and other information. +Sequece: The actual sequence string. + +As well as other info like source file checksums, etc. + +This package will likely be overhauled before 1.0 release to be more flexible and robust. +So be on the lookup for breaking changes in future releases. +*/ package poly import ( diff --git a/poly_test.go b/io/poly/poly_test.go similarity index 100% rename from poly_test.go rename to io/poly/poly_test.go diff --git a/io/polyjson/polyjson.go b/io/polyjson/polyjson.go index d53fcb0a..6fe47adf 100644 --- a/io/polyjson/polyjson.go +++ b/io/polyjson/polyjson.go @@ -1,10 +1,16 @@ +/* +Package polyjson provides utilities to read and write poly.Sequence structs as JSON. + +Poly's JSON schema is still in flux so be on the lookout for breaking changes as we +approach the 1.0 release. +*/ package polyjson import ( "encoding/json" "io/ioutil" - "github.com/TimothyStiles/poly" + "github.com/TimothyStiles/poly/io/poly" ) /****************************************************************************** diff --git a/io/polyjson/polyjson_test.go b/io/polyjson/polyjson_test.go index 68de473d..d0a55478 100644 --- a/io/polyjson/polyjson_test.go +++ b/io/polyjson/polyjson_test.go @@ -1,4 +1,4 @@ -package polyjson +package polyjson_test import ( "fmt" @@ -7,9 +7,10 @@ import ( "path/filepath" "testing" - "github.com/TimothyStiles/poly" "github.com/TimothyStiles/poly/io/genbank" "github.com/TimothyStiles/poly/io/gff" + "github.com/TimothyStiles/poly/io/poly" + "github.com/TimothyStiles/poly/io/polyjson" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -22,7 +23,7 @@ JSON related tests begin here. ******************************************************************************/ func ExampleRead() { - sequence := Read("../../data/sample.json") + sequence := polyjson.Read("../../data/sample.json") fmt.Println(sequence.Meta.Source) //output: Saccharomyces cerevisiae (baker's yeast) @@ -30,7 +31,7 @@ func ExampleRead() { func ExampleParse() { file, _ := ioutil.ReadFile("../../data/sample.json") - sequence := Parse(file) + sequence := polyjson.Parse(file) fmt.Println(sequence.Meta.Source) //output: Saccharomyces cerevisiae (baker's yeast) @@ -43,12 +44,12 @@ func ExampleWrite() { } defer os.RemoveAll(tmpDataDir) - sequence := Read("../../data/sample.json") + sequence := polyjson.Read("../../data/sample.json") tmpJSONFilePath := filepath.Join(tmpDataDir, "sample.json") - Write(sequence, tmpJSONFilePath) + polyjson.Write(sequence, tmpJSONFilePath) - testSequence := Read(tmpJSONFilePath) + testSequence := polyjson.Read(tmpJSONFilePath) fmt.Println(testSequence.Meta.Source) //output: Saccharomyces cerevisiae (baker's yeast) @@ -64,9 +65,9 @@ func TestGbkToJSON(t *testing.T) { testSequence := genbank.Read("../../data/puc19.gbk") tmpJSONFilePath := filepath.Join(tmpDataDir, "puc19.json") - Write(testSequence, tmpJSONFilePath) + polyjson.Write(testSequence, tmpJSONFilePath) - readTestSequence := Read(tmpJSONFilePath) + readTestSequence := polyjson.Read(tmpJSONFilePath) if diff := cmp.Diff(testSequence, readTestSequence, cmpopts.IgnoreFields(poly.Feature{}, "ParentSequence")); diff != "" { t.Errorf(" mismatch (-want +got):\n%s", diff) @@ -83,9 +84,9 @@ func TestGffToJSON(t *testing.T) { gffTestSequence := gff.Read("../../data/ecoli-mg1655-short.gff") tmpJSONFilePath := filepath.Join(tmpDataDir, "ecoli-mg1655-short.json") - Write(gffTestSequence, tmpJSONFilePath) + polyjson.Write(gffTestSequence, tmpJSONFilePath) - gffReadTestSequence := Read(tmpJSONFilePath) + gffReadTestSequence := polyjson.Read(tmpJSONFilePath) if diff := cmp.Diff(gffTestSequence, gffReadTestSequence, cmpopts.IgnoreFields(poly.Feature{}, "ParentSequence")); diff != "" { t.Errorf(" mismatch (-want +got):\n%s", diff) diff --git a/primers/primers.go b/primers/primers.go index 888905be..3e2b018a 100644 --- a/primers/primers.go +++ b/primers/primers.go @@ -1,3 +1,22 @@ +/* +Package primers provides utilities for creating primers and DNA barcodes. + +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 + +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. +*/ package primers import ( diff --git a/primers/primers_test.go b/primers/primers_test.go index 96624149..c5fb5726 100644 --- a/primers/primers_test.go +++ b/primers/primers_test.go @@ -1,4 +1,4 @@ -package primers +package primers_test import ( "fmt" @@ -6,12 +6,13 @@ import ( "strings" "testing" + "github.com/TimothyStiles/poly/primers" "github.com/TimothyStiles/poly/transform" ) func ExampleMarmurDoty() { sequenceString := "ACGTCCGGACTT" - meltingTemp := MarmurDoty(sequenceString) + meltingTemp := primers.MarmurDoty(sequenceString) fmt.Println(meltingTemp) // output: 31 @@ -20,7 +21,7 @@ func ExampleMarmurDoty() { func TestMarmurDoty(t *testing.T) { testSeq := "ACGTCCGGACTT" expectedTM := 31.0 - if calcTM := MarmurDoty(testSeq); expectedTM != calcTM { + if calcTM := primers.MarmurDoty(testSeq); expectedTM != calcTM { t.Errorf("MarmurDoty has changed on test. Got %f instead of %f", calcTM, expectedTM) } } @@ -32,7 +33,7 @@ func ExampleSantaLucia() { testCNa := 350e-3 // salt concentration testCMg := 0.0 // magnesium concentration expectedTM := 62.7 // roughly what we're expecting with a margin of error - meltingTemp, _, _ := SantaLucia(sequenceString, testCPrimer, testCNa, testCMg) + meltingTemp, _, _ := primers.SantaLucia(sequenceString, testCPrimer, testCNa, testCMg) withinMargin := math.Abs(expectedTM-meltingTemp)/expectedTM >= 0.02 // checking margin of error fmt.Println(withinMargin) @@ -44,7 +45,7 @@ func TestSantaLucia(t *testing.T) { testCNa := 350e-3 testCMg := 0.0 expectedTM := 62.7 - if calcTM, _, _ := SantaLucia(testSeq, testCPrimer, testCNa, testCMg); math.Abs(expectedTM-calcTM)/expectedTM >= 0.02 { + if calcTM, _, _ := primers.SantaLucia(testSeq, testCPrimer, testCNa, testCMg); math.Abs(expectedTM-calcTM)/expectedTM >= 0.02 { t.Errorf("SantaLucia has changed on test. Got %f instead of %f", calcTM, expectedTM) } } @@ -60,7 +61,7 @@ func TestSantaLuciaReverseComplement(t *testing.T) { testCNa := 350e-3 testCMg := 0.0 expectedTM := 47.428514 - if calcTM, _, _ := SantaLucia(testSeq, testCPrimer, testCNa, testCMg); math.Abs(expectedTM-calcTM)/expectedTM >= 0.02 { + if calcTM, _, _ := primers.SantaLucia(testSeq, testCPrimer, testCNa, testCMg); math.Abs(expectedTM-calcTM)/expectedTM >= 0.02 { t.Errorf("SantaLucia has changed on test. Got %f instead of %f", calcTM, expectedTM) } @@ -69,7 +70,7 @@ func TestSantaLuciaReverseComplement(t *testing.T) { func ExampleMeltingTemp() { sequenceString := "GTAAAACGACGGCCAGT" // M13 fwd expectedTM := 52.8 - meltingTemp := MeltingTemp(sequenceString) + meltingTemp := primers.MeltingTemp(sequenceString) withinMargin := math.Abs(expectedTM-meltingTemp)/expectedTM >= 0.02 fmt.Println(withinMargin) @@ -79,27 +80,27 @@ func ExampleMeltingTemp() { func TestMeltingTemp(t *testing.T) { testSeq := "GTAAAACGACGGCCAGT" // M13 fwd expectedTM := 52.8 - if calcTM := MeltingTemp(testSeq); math.Abs(expectedTM-calcTM)/expectedTM >= 0.02 { + if calcTM := primers.MeltingTemp(testSeq); math.Abs(expectedTM-calcTM)/expectedTM >= 0.02 { t.Errorf("MeltingTemp has changed on test. Got %f instead of %f", calcTM, expectedTM) } } func ExampleNucleobaseDeBruijnSequence() { - a := NucleobaseDeBruijnSequence(4) + a := primers.NucleobaseDeBruijnSequence(4) fmt.Println(a) // Output: AAAATAAAGAAACAATTAATGAATCAAGTAAGGAAGCAACTAACGAACCATATAGATACATTTATTGATTCATGTATGGATGCATCTATCGATCCAGAGACAGTTAGTGAGTCAGGTAGGGAGGCAGCTAGCGAGCCACACTTACTGACTCACGTACGGACGCACCTACCGACCCTTTTGTTTCTTGGTTGCTTCGTTCCTGTGTCTGGGTGGCTGCGTGCCTCTCGGTCGCTCCGTCCCGGGGCGGCCGCGCCCCAAA } func ExampleCreateBarcodesWithBannedSequences() { - barcodes := CreateBarcodesWithBannedSequences(20, 4, []string{"CTCTCGGTCGCTCC"}, []func(string) bool{}) + barcodes := primers.CreateBarcodesWithBannedSequences(20, 4, []string{"CTCTCGGTCGCTCC"}, []func(string) bool{}) fmt.Println(barcodes[0]) // Output: AAAATAAAGAAACAATTAAT } func ExampleCreateBarcodes() { - barcodes := CreateBarcodes(20, 4) + barcodes := primers.CreateBarcodes(20, 4) fmt.Println(barcodes[0]) // Output: AAAATAAAGAAACAATTAAT @@ -109,19 +110,19 @@ func TestCreateBarcode(t *testing.T) { testFunc := func(s string) bool { return !strings.Contains(s, "GGCCGCGCCCC") } - barcodes := CreateBarcodesWithBannedSequences(20, 4, []string{}, []func(string) bool{testFunc}) + barcodes := primers.CreateBarcodesWithBannedSequences(20, 4, []string{}, []func(string) bool{testFunc}) output := barcodes[len(barcodes)-1] if output != "CTCTCGGTCGCTCCGTCCCG" { t.Errorf("TestUniqueSequence function should return CTCTCGGTCGCTCCGTCCCG. Got:\n%s", output) } - barcodes = CreateBarcodesWithBannedSequences(20, 4, []string{"GGCCGCGCCCC"}, []func(string) bool{}) + barcodes = primers.CreateBarcodesWithBannedSequences(20, 4, []string{"GGCCGCGCCCC"}, []func(string) bool{}) output = barcodes[len(barcodes)-1] if output != "CTCTCGGTCGCTCCGTCCCG" { t.Errorf("TestUniqueSequence string should return CTCTCGGTCGCTCCGTCCCG. Got:\n%s", output) } - barcodes = CreateBarcodesWithBannedSequences(20, 4, []string{transform.ReverseComplement("GGCCGCGCCCC")}, []func(string) bool{}) + barcodes = primers.CreateBarcodesWithBannedSequences(20, 4, []string{transform.ReverseComplement("GGCCGCGCCCC")}, []func(string) bool{}) output = barcodes[len(barcodes)-1] if output != "CTCTCGGTCGCTCCGTCCCG" { t.Errorf("TestUniqueSequence string should return CTCTCGGTCGCTCCGTCCCG. Got:\n%s", output) diff --git a/random/random.go b/random/random.go index 44d9c68d..dc4e9ac1 100644 --- a/random/random.go +++ b/random/random.go @@ -1,3 +1,6 @@ +/* +Package random provides functions to generate randon DNA and protein sequences. +*/ package random import ( diff --git a/seqhash/example_test.go b/seqhash/example_test.go index e2aa0d13..981e7335 100644 --- a/seqhash/example_test.go +++ b/seqhash/example_test.go @@ -2,6 +2,8 @@ package seqhash_test import ( "fmt" + + "github.com/TimothyStiles/poly/io/genbank" "github.com/TimothyStiles/poly/seqhash" ) @@ -27,3 +29,12 @@ func ExampleHash() { fmt.Println(sequenceSeqhash) // Output: v1_DLD_f4028f93e08c5c23cbb8daa189b0a9802b378f1a1c919dcbcf1608a615f46350 } + +func ExampleRotateSequence() { + sequence := genbank.Read("../data/puc19.gbk") + sequenceLength := len(sequence.Sequence) + testSequence := sequence.Sequence[sequenceLength/2:] + sequence.Sequence[0:sequenceLength/2] + + fmt.Println(seqhash.RotateSequence(sequence.Sequence) == seqhash.RotateSequence(testSequence)) + // output: true +} diff --git a/seqhash/seqhash_test.go b/seqhash/seqhash_test.go index c4ff91d4..0f5c251d 100644 --- a/seqhash/seqhash_test.go +++ b/seqhash/seqhash_test.go @@ -66,15 +66,6 @@ func TestHash(t *testing.T) { } -func ExampleRotateSequence() { - sequence := genbank.Read("../data/puc19.gbk") - sequenceLength := len(sequence.Sequence) - testSequence := sequence.Sequence[sequenceLength/2:] + sequence.Sequence[0:sequenceLength/2] - - fmt.Println(RotateSequence(sequence.Sequence) == RotateSequence(testSequence)) - // output: true -} - func TestLeastRotation(t *testing.T) { sequence := genbank.Read("../data/puc19.gbk") var sequenceBuffer bytes.Buffer diff --git a/synthesis/codon/codon.go b/synthesis/codon/codon.go index e73ddb4d..6c42a7d1 100644 --- a/synthesis/codon/codon.go +++ b/synthesis/codon/codon.go @@ -1,3 +1,20 @@ +/* +Package codon is a package for optimizing codons for expression when synthesizing DNA. + +This package contains almost everything you need to do standard codon optimization. + +Biological context: certain cells favor certain codons and will reject or under +express sequences that don't use a similar ratio of codons. +This is called codon bias: https://en.wikipedia.org/wiki/Codon_usage_bias + +Furthermore, different ribosomes in different organisms will interpret codons differently. +What may be a start codon for one ribosome may be a stop in the other. +Heck, apparently nucleomorphs contain 4 different kinds of ribosomes. +https://en.wikipedia.org/wiki/Nucleomorph <- Thanks Keoni for mentioning this example! + +TTFN, +Tim +*/ package codon import ( @@ -8,7 +25,7 @@ import ( "strings" "time" - "github.com/TimothyStiles/poly" + "github.com/TimothyStiles/poly/io/poly" weightedRand "github.com/mroth/weightedrand" "encoding/json" @@ -33,28 +50,9 @@ File is structured as so: Optimize - given an amino acid sequence string and codon table it translates sequences to UPPERCASE nucleic acid sequences. -This file contains almost everything you need to do standard codon optimization. - -Biological context: certain cells favor certain codons and will reject or under -express sequences that don't use a similar ratio of codons. -This is called codon bias: https://en.wikipedia.org/wiki/Codon_usage_bias - -Furthermore, different ribosomes in different organisms will interpret codons differently. -What may be a start codon for one ribosome may be a stop in the other. -Heck, apparently nucleomorphs contain 4 different kinds of ribosomes. -https://en.wikipedia.org/wiki/Nucleomorph <- Thanks Keoni for mentioning this example! - Anywho, most of this file and Table's struct methods are meant to help overcome this codon bias. There's a default Table generator near the bottom of this file with a whole section on how it works and why it's gotta be that way. - -Like most codebases, best usage examples come from tests. You can check out -TestTranslate and TestOptimize in transformations_test.go for pretty solid -examples of what you can do with this code. - -TTFN, -Tim - ******************************************************************************/ var errEmtpyCodonTable error = errors.New("empty codon table") diff --git a/synthesis/codon/codon_test.go b/synthesis/codon/codon_test.go index 2b659a3b..b0d9e392 100644 --- a/synthesis/codon/codon_test.go +++ b/synthesis/codon/codon_test.go @@ -1,8 +1,6 @@ package codon import ( - "fmt" - "io/ioutil" "os" "strings" "testing" @@ -11,16 +9,6 @@ import ( "github.com/google/go-cmp/cmp" ) -func ExampleTranslate() { - - gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" - gfpDnaSequence := "ATGGCTAGCAAAGGAGAAGAACTTTTCACTGGAGTTGTCCCAATTCTTGTTGAATTAGATGGTGATGTTAATGGGCACAAATTTTCTGTCAGTGGAGAGGGTGAAGGTGATGCTACATACGGAAAGCTTACCCTTAAATTTATTTGCACTACTGGAAAACTACCTGTTCCATGGCCAACACTTGTCACTACTTTCTCTTATGGTGTTCAATGCTTTTCCCGTTATCCGGATCATATGAAACGGCATGACTTTTTCAAGAGTGCCATGCCCGAAGGTTATGTACAGGAACGCACTATATCTTTCAAAGATGACGGGAACTACAAGACGCGTGCTGAAGTCAAGTTTGAAGGTGATACCCTTGTTAATCGTATCGAGTTAAAAGGTATTGATTTTAAAGAAGATGGAAACATTCTCGGACACAAACTCGAGTACAACTATAACTCACACAATGTATACATCACGGCAGACAAACAAAAGAATGGAATCAAAGCTAACTTCAAAATTCGCCACAACATTGAAGATGGATCCGTTCAACTAGCAGACCATTATCAACAAAATACTCCAATTGGCGATGGCCCTGTCCTTTTACCAGACAACCATTACCTGTCGACACAATCTGCCCTTTCGAAAGATCCCAACGAAAAGCGTGACCACATGGTCCTTCTTGAGTTTGTAACTGCTGCTGGGATTACACATGGCATGGATGAGCTCTACAAATAA" - testTranslation, _ := Translate(gfpDnaSequence, GetCodonTable(11)) // need to specify which codons map to which amino acids per NCBI table - - fmt.Println(gfpTranslation == testTranslation) - // output: true -} - func TestTranslation(t *testing.T) { gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" gfpDnaSequence := "ATGGCTAGCAAAGGAGAAGAACTTTTCACTGGAGTTGTCCCAATTCTTGTTGAATTAGATGGTGATGTTAATGGGCACAAATTTTCTGTCAGTGGAGAGGGTGAAGGTGATGCTACATACGGAAAGCTTACCCTTAAATTTATTTGCACTACTGGAAAACTACCTGTTCCATGGCCAACACTTGTCACTACTTTCTCTTATGGTGTTCAATGCTTTTCCCGTTATCCGGATCATATGAAACGGCATGACTTTTTCAAGAGTGCCATGCCCGAAGGTTATGTACAGGAACGCACTATATCTTTCAAAGATGACGGGAACTACAAGACGCGTGCTGAAGTCAAGTTTGAAGGTGATACCCTTGTTAATCGTATCGAGTTAAAAGGTATTGATTTTAAAGAAGATGGAAACATTCTCGGACACAAACTCGAGTACAACTATAACTCACACAATGTATACATCACGGCAGACAAACAAAAGAATGGAATCAAAGCTAACTTCAAAATTCGCCACAACATTGAAGATGGATCCGTTCAACTAGCAGACCATTATCAACAAAATACTCCAATTGGCGATGGCCCTGTCCTTTTACCAGACAACCATTACCTGTCGACACAATCTGCCCTTTCGAAAGATCCCAACGAAAAGCGTGACCACATGGTCCTTCTTGAGTTTGTAACTGCTGCTGGGATTACACATGGCATGGATGAGCTCTACAAATAA" @@ -66,23 +54,6 @@ func TestTranslationLowerCase(t *testing.T) { } -func ExampleOptimize() { - - gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" - - sequence := genbank.Read("../../data/puc19.gbk") - codonTable := GetCodonTable(11) - codingRegions := GetCodingRegions(sequence) - - optimizationTable := codonTable.OptimizeTable(codingRegions) - - optimizedSequence, _ := Optimize(gfpTranslation, optimizationTable) - optimizedSequenceTranslation, _ := Translate(optimizedSequence, optimizationTable) - - fmt.Println(optimizedSequenceTranslation == gfpTranslation) - // output: true -} - func TestOptimize(t *testing.T) { gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" @@ -164,59 +135,12 @@ func TestGetCodonFrequency(t *testing.T) { } -func ExampleGetCodingRegions() { - - gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" - - sequence := genbank.Read("../../data/puc19.gbk") - codonTable := GetCodonTable(11) - - // GetCodingRegions returns a single concatenated string of all coding regions. - codingRegions := GetCodingRegions(sequence) - - optimizationTable := codonTable.OptimizeTable(codingRegions) - - optimizedSequence, _ := Optimize(gfpTranslation, optimizationTable) - optimizedSequenceTranslation, _ := Translate(optimizedSequence, optimizationTable) - - fmt.Println(optimizedSequenceTranslation == gfpTranslation) - // output: true - -} - /****************************************************************************** JSON related tests begin here. ******************************************************************************/ -func ExampleReadCodonJSON() { - codontable := ReadCodonJSON("../../data/bsub_codon_test.json") - - fmt.Println(codontable.AminoAcids[0].Codons[0].Weight) - //output: 28327 -} - -func ExampleParseCodonJSON() { - file, _ := ioutil.ReadFile("../../data/bsub_codon_test.json") - codontable := ParseCodonJSON(file) - - fmt.Println(codontable.AminoAcids[0].Codons[0].Weight) - //output: 28327 -} - -func ExampleWriteCodonJSON() { - codontable := ReadCodonJSON("../../data/bsub_codon_test.json") - WriteCodonJSON(codontable, "../../data/codon_test.json") - testCodonTable := ReadCodonJSON("../../data/codon_test.json") - - // cleaning up test data - os.Remove("../../data/codon_test.json") - - fmt.Println(testCodonTable.AminoAcids[0].Codons[0].Weight) - //output: 28327 -} - func TestWriteCodonJSON(t *testing.T) { testCodonTable := ReadCodonJSON("../../data/bsub_codon_test.json") WriteCodonJSON(testCodonTable, "../../data/codon_test1.json") @@ -236,29 +160,6 @@ func TestWriteCodonJSON(t *testing.T) { Codon Compromise + Add related tests begin here. ******************************************************************************/ - -func ExampleCompromiseCodonTable() { - sequence := genbank.Read("../../data/puc19.gbk") - codonTable := GetCodonTable(11) - codingRegions := GetCodingRegions(sequence) - optimizationTable := codonTable.OptimizeTable(codingRegions) - - sequence2 := genbank.Read("../../data/phix174.gb") - codonTable2 := GetCodonTable(11) - codingRegions2 := GetCodingRegions(sequence2) - optimizationTable2 := codonTable2.OptimizeTable(codingRegions2) - - finalTable, _ := CompromiseCodonTable(optimizationTable, optimizationTable2, 0.1) - for _, aa := range finalTable.AminoAcids { - for _, codon := range aa.Codons { - if codon.Triplet == "TAA" { - fmt.Println(codon.Weight) - } - } - } - //output: 2727 -} - func TestCompromiseCodonTable(t *testing.T) { sequence := genbank.Read("../../data/puc19.gbk") codonTable := GetCodonTable(11) @@ -279,25 +180,3 @@ func TestCompromiseCodonTable(t *testing.T) { t.Errorf("Compromise table should fail on 10.0") } } - -func ExampleAddCodonTable() { - sequence := genbank.Read("../../data/puc19.gbk") - codonTable := GetCodonTable(11) - codingRegions := GetCodingRegions(sequence) - optimizationTable := codonTable.OptimizeTable(codingRegions) - - sequence2 := genbank.Read("../../data/phix174.gb") - codonTable2 := GetCodonTable(11) - codingRegions2 := GetCodingRegions(sequence2) - optimizationTable2 := codonTable2.OptimizeTable(codingRegions2) - - finalTable := AddCodonTable(optimizationTable, optimizationTable2) - for _, aa := range finalTable.AminoAcids { - for _, codon := range aa.Codons { - if codon.Triplet == "GGC" { - fmt.Println(codon.Weight) - } - } - } - //output: 90 -} diff --git a/synthesis/codon/example_test.go b/synthesis/codon/example_test.go new file mode 100644 index 00000000..0bbe7f27 --- /dev/null +++ b/synthesis/codon/example_test.go @@ -0,0 +1,128 @@ +package codon_test + +import ( + "fmt" + "io/ioutil" + "os" + + "github.com/TimothyStiles/poly/io/genbank" + "github.com/TimothyStiles/poly/synthesis/codon" +) + +func ExampleTranslate() { + + gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" + gfpDnaSequence := "ATGGCTAGCAAAGGAGAAGAACTTTTCACTGGAGTTGTCCCAATTCTTGTTGAATTAGATGGTGATGTTAATGGGCACAAATTTTCTGTCAGTGGAGAGGGTGAAGGTGATGCTACATACGGAAAGCTTACCCTTAAATTTATTTGCACTACTGGAAAACTACCTGTTCCATGGCCAACACTTGTCACTACTTTCTCTTATGGTGTTCAATGCTTTTCCCGTTATCCGGATCATATGAAACGGCATGACTTTTTCAAGAGTGCCATGCCCGAAGGTTATGTACAGGAACGCACTATATCTTTCAAAGATGACGGGAACTACAAGACGCGTGCTGAAGTCAAGTTTGAAGGTGATACCCTTGTTAATCGTATCGAGTTAAAAGGTATTGATTTTAAAGAAGATGGAAACATTCTCGGACACAAACTCGAGTACAACTATAACTCACACAATGTATACATCACGGCAGACAAACAAAAGAATGGAATCAAAGCTAACTTCAAAATTCGCCACAACATTGAAGATGGATCCGTTCAACTAGCAGACCATTATCAACAAAATACTCCAATTGGCGATGGCCCTGTCCTTTTACCAGACAACCATTACCTGTCGACACAATCTGCCCTTTCGAAAGATCCCAACGAAAAGCGTGACCACATGGTCCTTCTTGAGTTTGTAACTGCTGCTGGGATTACACATGGCATGGATGAGCTCTACAAATAA" + testTranslation, _ := codon.Translate(gfpDnaSequence, codon.GetCodonTable(11)) // need to specify which codons map to which amino acids per NCBI table + + fmt.Println(gfpTranslation == testTranslation) + // output: true +} + +func ExampleOptimize() { + + gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" + + sequence := genbank.Read("../../data/puc19.gbk") + codonTable := codon.GetCodonTable(11) + codingRegions := codon.GetCodingRegions(sequence) + + optimizationTable := codonTable.OptimizeTable(codingRegions) + + optimizedSequence, _ := codon.Optimize(gfpTranslation, optimizationTable) + optimizedSequenceTranslation, _ := codon.Translate(optimizedSequence, optimizationTable) + + fmt.Println(optimizedSequenceTranslation == gfpTranslation) + // output: true +} + +func ExampleGetCodingRegions() { + + gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" + + sequence := genbank.Read("../../data/puc19.gbk") + codonTable := codon.GetCodonTable(11) + + // GetCodingRegions returns a single concatenated string of all coding regions. + codingRegions := codon.GetCodingRegions(sequence) + + optimizationTable := codonTable.OptimizeTable(codingRegions) + + optimizedSequence, _ := codon.Optimize(gfpTranslation, optimizationTable) + optimizedSequenceTranslation, _ := codon.Translate(optimizedSequence, optimizationTable) + + fmt.Println(optimizedSequenceTranslation == gfpTranslation) + // output: true + +} + +func ExampleReadCodonJSON() { + codontable := codon.ReadCodonJSON("../../data/bsub_codon_test.json") + + fmt.Println(codontable.AminoAcids[0].Codons[0].Weight) + //output: 28327 +} + +func ExampleParseCodonJSON() { + file, _ := ioutil.ReadFile("../../data/bsub_codon_test.json") + codontable := codon.ParseCodonJSON(file) + + fmt.Println(codontable.AminoAcids[0].Codons[0].Weight) + //output: 28327 +} + +func ExampleWriteCodonJSON() { + codontable := codon.ReadCodonJSON("../../data/bsub_codon_test.json") + codon.WriteCodonJSON(codontable, "../../data/codon_test.json") + testCodonTable := codon.ReadCodonJSON("../../data/codon_test.json") + + // cleaning up test data + os.Remove("../../data/codon_test.json") + + fmt.Println(testCodonTable.AminoAcids[0].Codons[0].Weight) + //output: 28327 +} + +func ExampleCompromiseCodonTable() { + sequence := genbank.Read("../../data/puc19.gbk") + codonTable := codon.GetCodonTable(11) + codingRegions := codon.GetCodingRegions(sequence) + optimizationTable := codonTable.OptimizeTable(codingRegions) + + sequence2 := genbank.Read("../../data/phix174.gb") + codonTable2 := codon.GetCodonTable(11) + codingRegions2 := codon.GetCodingRegions(sequence2) + optimizationTable2 := codonTable2.OptimizeTable(codingRegions2) + + finalTable, _ := codon.CompromiseCodonTable(optimizationTable, optimizationTable2, 0.1) + for _, aa := range finalTable.AminoAcids { + for _, codon := range aa.Codons { + if codon.Triplet == "TAA" { + fmt.Println(codon.Weight) + } + } + } + //output: 2727 +} + +func ExampleAddCodonTable() { + sequence := genbank.Read("../../data/puc19.gbk") + codonTable := codon.GetCodonTable(11) + codingRegions := codon.GetCodingRegions(sequence) + optimizationTable := codonTable.OptimizeTable(codingRegions) + + sequence2 := genbank.Read("../../data/phix174.gb") + codonTable2 := codon.GetCodonTable(11) + codingRegions2 := codon.GetCodingRegions(sequence2) + optimizationTable2 := codonTable2.OptimizeTable(codingRegions2) + + finalTable := codon.AddCodonTable(optimizationTable, optimizationTable2) + for _, aa := range finalTable.AminoAcids { + for _, codon := range aa.Codons { + if codon.Triplet == "GGC" { + fmt.Println(codon.Weight) + } + } + } + //output: 90 +} diff --git a/synthesis/fix/example_test.go b/synthesis/fix/example_test.go index 912e54ad..acda11d4 100644 --- a/synthesis/fix/example_test.go +++ b/synthesis/fix/example_test.go @@ -2,10 +2,14 @@ package fix_test import ( "fmt" + "sync" + "github.com/TimothyStiles/poly/synthesis/codon" "github.com/TimothyStiles/poly/synthesis/fix" ) +var dataDir string = "../../data/" + // This example shows basic usage of the synthesis package. In this example, // we will remove BsaI sites from the bla gene, commonly found in pUC plasmids. func Example_basic() { @@ -23,3 +27,25 @@ func Example_basic() { fmt.Println(fixedSeq) // Output: ATGAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGATCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA } + +func ExampleCds() { + bla := "ATGAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATACGGAAATGTTGAATACTCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGGTCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA" + + codonTable := codon.ReadCodonJSON(dataDir + "pichiaTable.json") + + fixedSeq, changes, _ := fix.Cds(bla, codonTable, []func(string, chan fix.DnaSuggestion, *sync.WaitGroup){fix.RemoveRepeat(20), fix.RemoveSequence([]string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC"}, "TypeIIS restriction enzyme site")}) + fmt.Printf("Changed position %d from %s to %s for reason: %s. Complete sequence: %s", changes[1].Position, changes[1].From, changes[1].To, changes[1].Reason, fixedSeq) + + // Output: Changed position 245 from GGG to GGA for reason: TypeIIS restriction enzyme site. Complete sequence: ATGAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATATGGAAATGTTGAATACTCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGATCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA +} + +func ExampleCdsSimple() { + bla := "ATGAAAAAAAAAAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGGTCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA" + + codonTable := codon.ReadCodonJSON(dataDir + "pichiaTable.json") + + fixedSeq, changes, _ := fix.CdsSimple(bla, codonTable, []string{"GGTCTC"}) + fmt.Printf("Changed position %d from %s to %s for reason: %s. Complete sequence: %s", changes[0].Position, changes[0].From, changes[0].To, changes[0].Reason, fixedSeq) + + // Output: Changed position 1 from AAA to AAG for reason: Homopolymers. Complete sequence: ATGAAGAAAAAAAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGATCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA +} diff --git a/synthesis/fix/synthesis_test.go b/synthesis/fix/synthesis_test.go index 30e24693..08b11162 100644 --- a/synthesis/fix/synthesis_test.go +++ b/synthesis/fix/synthesis_test.go @@ -18,28 +18,6 @@ Synthesis Fixer tests begin here var dataDir string = "../../data/" -func ExampleCds() { - bla := "ATGAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATACGGAAATGTTGAATACTCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGGTCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA" - - codonTable := codon.ReadCodonJSON(dataDir + "pichiaTable.json") - - fixedSeq, changes, _ := Cds(bla, codonTable, []func(string, chan DnaSuggestion, *sync.WaitGroup){RemoveRepeat(20), RemoveSequence([]string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC"}, "TypeIIS restriction enzyme site")}) - fmt.Printf("Changed position %d from %s to %s for reason: %s. Complete sequence: %s", changes[1].Position, changes[1].From, changes[1].To, changes[1].Reason, fixedSeq) - - // Output: Changed position 245 from GGG to GGA for reason: TypeIIS restriction enzyme site. Complete sequence: ATGAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATATGGAAATGTTGAATACTCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGATCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA -} - -func ExampleCdsSimple() { - bla := "ATGAAAAAAAAAAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGGTCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA" - - codonTable := codon.ReadCodonJSON(dataDir + "pichiaTable.json") - - fixedSeq, changes, _ := CdsSimple(bla, codonTable, []string{"GGTCTC"}) - fmt.Printf("Changed position %d from %s to %s for reason: %s. Complete sequence: %s", changes[0].Position, changes[0].From, changes[0].To, changes[0].Reason, fixedSeq) - - // Output: Changed position 1 from AAA to AAG for reason: Homopolymers. Complete sequence: ATGAAGAAAAAAAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGATCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA -} - func TestCdsWithAlteredCodonTable(t *testing.T) { bla := "ATGAAAAAAAAAAGTATTCAACATTTCCGTGTCGCCCTTATTCCCTTTTTTGCGGCATTTTGCCTTCCTGTTTTTGCTCACCCAGAAACGCTGGTGAAAGTAAAAGATGCTGAAGATCAGTTGGGTGCACGAGTGGGTTACATCGAACTGGATCTCAACAGCGGTAAGATCCTTGAGAGTTTTCGCCCCGAAGAACGTTTTCCAATGATGAGCACTTTTAAAGTTCTGCTATGTGGCGCGGTATTATCCCGTATTGACGCCGGGCAAGAGCAACTCGGTCGCCGCATACACTATTCTCAGAATGACTTGGTTGAGTACTCACCAGTCACAGAAAAGCATCTTACGGATGGCATGACAGTAAGAGAATTATGCAGTGCTGCCATAACCATGAGTGATAACACTGCGGCCAACTTACTTCTGACAACGATCGGAGGACCGAAGGAGCTAACCGCTTTTTTGCACAACATGGGGGATCATGTAACTCGCCTTGATCGTTGGGAACCGGAGCTGAATGAAGCCATACCAAACGACGAGCGTGACACCACGATGCCTGTAGCAATGGCAACAACGTTGCGCAAACTATTAACTGGCGAACTACTTACTCTAGCTTCCCGGCAACAATTAATAGACTGGATGGAGGCGGATAAAGTTGCAGGACCACTTCTGCGCTCGGCCCTTCCGGCTGGCTGGTTTATTGCTGATAAATCTGGAGCCGGTGAGCGTGGGTCTCGCGGTATCATTGCAGCACTGGGGCCAGATGGTAAGCCCTCCCGTATCGTAGTTATCTACACGACGGGGAGTCAGGCAACTATGGATGAACGAAATAGACAGATCGCTGAGATAGGTGCCTCACTGATTAAGCATTGGTAA" diff --git a/synthesis/fragment/example_test.go b/synthesis/fragment/example_test.go index 0d1ea359..15e558e8 100644 --- a/synthesis/fragment/example_test.go +++ b/synthesis/fragment/example_test.go @@ -2,6 +2,7 @@ package fragment_test import ( "fmt" + "github.com/TimothyStiles/poly/synthesis/fragment" ) @@ -14,3 +15,11 @@ func Example_basic() { fmt.Println(fragments) // Output: [ATGACCATGATTACGCCAAGCTTGCATGCCTGCAGGTCGACTCTAGAGGATCCCCGGGTACCGAGCTCGAATTCACTGGCCGTCGTTTTACAACGTCGTGACTGG CTGGGAAAACCCTGGCGTTACCCAACTTAATCGCCTTGCAGCACATCCCCCTTTCGCCAGCTGGCGTAATAGCGAAGAGGCCCGCACCGATCGCCCTTCCCAACA AACAGTTGCGCAGCCTGAATGGCGAATGGCGCCTGATGCGGTATTTTCTCCTTACGCATCTGTGCG TGCGGTATTTCACACCGCATATGGTGCACTCTCAGTACAATCTGCTCTGATGCCGCATAG] } + +func ExampleFragment() { + lacZ := "ATGACCATGATTACGCCAAGCTTGCATGCCTGCAGGTCGACTCTAGAGGATCCCCGGGTACCGAGCTCGAATTCACTGGCCGTCGTTTTACAACGTCGTGACTGGGAAAACCCTGGCGTTACCCAACTTAATCGCCTTGCAGCACATCCCCCTTTCGCCAGCTGGCGTAATAGCGAAGAGGCCCGCACCGATCGCCCTTCCCAACAGTTGCGCAGCCTGAATGGCGAATGGCGCCTGATGCGGTATTTTCTCCTTACGCATCTGTGCGGTATTTCACACCGCATATGGTGCACTCTCAGTACAATCTGCTCTGATGCCGCATAG" + fragments, efficiency, _ := fragment.Fragment(lacZ, 95, 105) + + fmt.Printf("%s : %f", fragments[1], efficiency) + // Output: CTGGGAAAACCCTGGCGTTACCCAACTTAATCGCCTTGCAGCACATCCCCCTTTCGCCAGCTGGCGTAATAGCGAAGAGGCCCGCACCGATCGCCCTTCCCAACA : 1.000000 +} diff --git a/synthesis/fragment/fragment_test.go b/synthesis/fragment/fragment_test.go index eaf51b45..c4f46a11 100644 --- a/synthesis/fragment/fragment_test.go +++ b/synthesis/fragment/fragment_test.go @@ -1,18 +1,9 @@ package fragment import ( - "fmt" "testing" ) -func ExampleFragment() { - lacZ := "ATGACCATGATTACGCCAAGCTTGCATGCCTGCAGGTCGACTCTAGAGGATCCCCGGGTACCGAGCTCGAATTCACTGGCCGTCGTTTTACAACGTCGTGACTGGGAAAACCCTGGCGTTACCCAACTTAATCGCCTTGCAGCACATCCCCCTTTCGCCAGCTGGCGTAATAGCGAAGAGGCCCGCACCGATCGCCCTTCCCAACAGTTGCGCAGCCTGAATGGCGAATGGCGCCTGATGCGGTATTTTCTCCTTACGCATCTGTGCGGTATTTCACACCGCATATGGTGCACTCTCAGTACAATCTGCTCTGATGCCGCATAG" - fragments, efficiency, _ := Fragment(lacZ, 95, 105) - - fmt.Printf("%s : %f", fragments[1], efficiency) - // Output: CTGGGAAAACCCTGGCGTTACCCAACTTAATCGCCTTGCAGCACATCCCCCTTTCGCCAGCTGGCGTAATAGCGAAGAGGCCCGCACCGATCGCCCTTCCCAACA : 1.000000 -} - func TestFragment(t *testing.T) { gene := "atgaaaaaatttaactggaagaaaatagtcgcgccaattgcaatgctaattattggcttactaggtggtttacttggtgcctttatcctactaacagcagccggggtatcttttaccaatacaacagatactggagtaaaaacggctaagaccgtctacaccaatataacagatacaactaaggctgttaagaaagtacaaaatgccgttgtttctgtcatcaattatcaagaaggttcatcttcagattctctaaatgacctttatggccgtatctttggcggaggggacagttctgattctagccaagaaaattcaaaagattcagatggtctacaggtcgctggtgaaggttctggagtcatctataaaaaagatggcaaagaagcctacatcgtaaccaataaccatgttgtcgatggggctaaaaaacttgaaatcatgctttcggatggttcgaaaattactggtgaacttgttggtaaagacacttactctgacctagcagttgtcaaagtatcttcagataaaataacaactgttgcagaatttgcagactcaaactcccttactgttggtgaaaaagcaattgctatcggtagcccacttggtaccgaatacgccaactcagtaacagaaggaatcgtttctagccttagccgtactataacgatgcaaaacgataatggtgaaactgtatcaacaaacgctatccaaacagatgcagccattaaccctggtaactctggtggtgccctagtcaatattgaaggacaagttatcggtattaattcaagtaaaatttcatcaacgtctgcagtcgctggtagtgctgttgaaggtatggggtttgccattccatcaaacgatgttgttgaaatcatcaatcaattagaaaaagatggtaaagttacacgaccagcactaggaatctcaatagcagatcttaatagcctttctagcagcgcaacttctaaattagatttaccagatgaggtcaaatccggtgttgttgtcggtagtgttcagaaaggtatgccagctgacggtaaacttcaagaatatgatgttatcactgagattgatggtaagaaaatcagctcaaaaactgatattcaaaccaatctttacagccatagtatcggagatactatcaaggtaaccttctatcgtggtaaagataagaaaactgtagatcttaaattaacaaaatctacagaagacatatctgattaa" diff --git a/transform/transform.go b/transform/transform.go index d7c19c20..a2c104ce 100644 --- a/transform/transform.go +++ b/transform/transform.go @@ -1,3 +1,15 @@ +/* +Package transform provides functions for transforming sequences. + +Complement takes the complement of a sequence. +(returns a sequence string where each nucleotide has been swapped with its complement A<->T, C<->G) + +Reverse takes the reverse of a sequence. +(literally just reverses a string. Exists in stdlib but hey why not have it here too?) + +ReverseComplement takes the reverse complement of a sequence. +(Reverses the sequence string and returns the complement of the reversed sequence.) +*/ package transform import "strings" diff --git a/transform/transform_test.go b/transform/transform_test.go index 693b7f42..266bcfcd 100644 --- a/transform/transform_test.go +++ b/transform/transform_test.go @@ -1,12 +1,14 @@ -package transform +package transform_test import ( "fmt" + + "github.com/TimothyStiles/poly/transform" ) func ExampleReverseComplement() { sequence := "GATTACA" - reverseComplement := ReverseComplement(sequence) + reverseComplement := transform.ReverseComplement(sequence) fmt.Println(reverseComplement) // Output: TGTAATC @@ -14,7 +16,7 @@ func ExampleReverseComplement() { func ExampleComplement() { sequence := "GATTACA" - complement := Complement(sequence) + complement := transform.Complement(sequence) fmt.Println(complement) // Output: CTAATGT @@ -22,7 +24,7 @@ func ExampleComplement() { func ExampleReverse() { sequence := "GATTACA" - reverse := Reverse(sequence) + reverse := transform.Reverse(sequence) fmt.Println(reverse) // Output: ACATTAG diff --git a/transform/variants/variants.go b/transform/variants/variants.go index ed208ff4..47c8d567 100644 --- a/transform/variants/variants.go +++ b/transform/variants/variants.go @@ -1,3 +1,11 @@ +/* +Package variants contains a function for generating all variants of a sequence. + +Sometimes sequencers will only give you an *estimate* of what the basepair at +a given position is. This package provides a function for generating all +possible deterministic variants of a sequence given a sequence +with ambiguous bases. +*/ package variants import ( diff --git a/transform/variants/variants_test.go b/transform/variants/variants_test.go index 41db3c7f..5f6f42db 100644 --- a/transform/variants/variants_test.go +++ b/transform/variants/variants_test.go @@ -1,16 +1,18 @@ -package variants +package variants_test import ( "fmt" "log" "sort" "testing" + + "github.com/TimothyStiles/poly/transform/variants" ) func TestIUPAC(t *testing.T) { testSeq := "ATN" testVariants := []string{"ATG", "ATA", "ATT", "ATC"} - testVariantsIUPAC, err := AllVariantsIUPAC(testSeq) + testVariantsIUPAC, err := variants.AllVariantsIUPAC(testSeq) if err != nil { log.Fatal(err) } @@ -30,7 +32,7 @@ func ExampleAllVariantsIUPAC() { // and returns all iupac variants as output mendelIUPAC := "ATGGARAAYGAYGARCTN" // ambiguous IUPAC codes for most of the sequences that code for the protein MENDEL - mendelIUPACvariants, _ := AllVariantsIUPAC(mendelIUPAC) + mendelIUPACvariants, _ := variants.AllVariantsIUPAC(mendelIUPAC) fmt.Println(mendelIUPACvariants) // Output: [ATGGAGAATGATGAGCTG ATGGAGAATGATGAGCTA ATGGAGAATGATGAGCTT ATGGAGAATGATGAGCTC ATGGAGAATGATGAACTG ATGGAGAATGATGAACTA ATGGAGAATGATGAACTT ATGGAGAATGATGAACTC ATGGAGAATGACGAGCTG ATGGAGAATGACGAGCTA ATGGAGAATGACGAGCTT ATGGAGAATGACGAGCTC ATGGAGAATGACGAACTG ATGGAGAATGACGAACTA ATGGAGAATGACGAACTT ATGGAGAATGACGAACTC ATGGAGAACGATGAGCTG ATGGAGAACGATGAGCTA ATGGAGAACGATGAGCTT ATGGAGAACGATGAGCTC ATGGAGAACGATGAACTG ATGGAGAACGATGAACTA ATGGAGAACGATGAACTT ATGGAGAACGATGAACTC ATGGAGAACGACGAGCTG ATGGAGAACGACGAGCTA ATGGAGAACGACGAGCTT ATGGAGAACGACGAGCTC ATGGAGAACGACGAACTG ATGGAGAACGACGAACTA ATGGAGAACGACGAACTT ATGGAGAACGACGAACTC ATGGAAAATGATGAGCTG ATGGAAAATGATGAGCTA ATGGAAAATGATGAGCTT ATGGAAAATGATGAGCTC ATGGAAAATGATGAACTG ATGGAAAATGATGAACTA ATGGAAAATGATGAACTT ATGGAAAATGATGAACTC ATGGAAAATGACGAGCTG ATGGAAAATGACGAGCTA ATGGAAAATGACGAGCTT ATGGAAAATGACGAGCTC ATGGAAAATGACGAACTG ATGGAAAATGACGAACTA ATGGAAAATGACGAACTT ATGGAAAATGACGAACTC ATGGAAAACGATGAGCTG ATGGAAAACGATGAGCTA ATGGAAAACGATGAGCTT ATGGAAAACGATGAGCTC ATGGAAAACGATGAACTG ATGGAAAACGATGAACTA ATGGAAAACGATGAACTT ATGGAAAACGATGAACTC ATGGAAAACGACGAGCTG ATGGAAAACGACGAGCTA ATGGAAAACGACGAGCTT ATGGAAAACGACGAGCTC ATGGAAAACGACGAACTG ATGGAAAACGACGAACTA ATGGAAAACGACGAACTT ATGGAAAACGACGAACTC]