diff --git a/synthesis/codon/codon.go b/synthesis/codon/codon.go index 5fd51de11..4bb883571 100644 --- a/synthesis/codon/codon.go +++ b/synthesis/codon/codon.go @@ -46,7 +46,7 @@ File is structured as so: Key functions: TranslationTable.Translate - given a nucleic sequence string and codon table it translates sequences to UPPERCASE amino acid sequences. - TranslationTable.OptimizeSequence - will return a set of codons which can be used to encode the given amino acid sequence. The codons picked are weighted according to the computed translation table's weights + TranslationTable.Optimize - will return a set of codons which can be used to encode the given amino acid sequence. The codons picked are weighted according to the computed translation table's weights TranslationTable.UpdateWeightsWithSequence - will look at the coding regions in the given genbank data, and use those to generate new weights for the codons in the translation table. The next time a sequence is optimised, it will use those updated weights. @@ -84,7 +84,7 @@ type AminoAcid struct { // Table is an interface encompassing what a potentially codon optimized Translation table can do type Table interface { GetWeightedAminoAcids() []AminoAcid - OptimizeSequence(aminoAcids string, randomState ...int) (string, error) + Optimize(aminoAcids string, randomState ...int) (string, error) Translate(dnaSeq string) (string, error) } @@ -137,9 +137,9 @@ func (table *TranslationTable) GetWeightedAminoAcids() []AminoAcid { return table.AminoAcids } -// OptimizeSequence will return a set of codons which can be used to encode the given amino acid sequence. The codons +// Optimize will return a set of codons which can be used to encode the given amino acid sequence. The codons // picked are weighted according to the computed translation table's weights -func (table *TranslationTable) OptimizeSequence(aminoAcids string, randomState ...int) (string, error) { +func (table *TranslationTable) Optimize(aminoAcids string, randomState ...int) (string, error) { // Finding any given aminoAcid is dependent upon it being capitalized, so // we do that here. aminoAcids = strings.ToUpper(aminoAcids) diff --git a/synthesis/codon/codon_test.go b/synthesis/codon/codon_test.go index c9607cd0f..9feafe708 100644 --- a/synthesis/codon/codon_test.go +++ b/synthesis/codon/codon_test.go @@ -78,7 +78,7 @@ func TestOptimize(t *testing.T) { codonTable := NewTranslationTable(11) - optimizedSequence, _ := table.OptimizeSequence(gfpTranslation) + optimizedSequence, _ := table.Optimize(gfpTranslation) optimizedSequenceTranslation, _ := codonTable.Translate(optimizedSequence) if optimizedSequenceTranslation != gfpTranslation { @@ -100,8 +100,8 @@ func TestOptimizeSameSeed(t *testing.T) { randomSeed := 10 - optimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation, randomSeed) - otherOptimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation, randomSeed) + optimizedSequence, _ := optimizationTable.Optimize(gfpTranslation, randomSeed) + otherOptimizedSequence, _ := optimizationTable.Optimize(gfpTranslation, randomSeed) if optimizedSequence != otherOptimizedSequence { t.Error("Optimized sequence with the same random seed are not the same") @@ -117,8 +117,8 @@ func TestOptimizeDifferentSeed(t *testing.T) { t.Error(err) } - optimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation) - otherOptimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation) + optimizedSequence, _ := optimizationTable.Optimize(gfpTranslation) + otherOptimizedSequence, _ := optimizationTable.Optimize(gfpTranslation) if optimizedSequence == otherOptimizedSequence { t.Error("Optimized sequence with different random seed have the same result") @@ -127,7 +127,7 @@ func TestOptimizeDifferentSeed(t *testing.T) { func TestOptimizeErrorsOnEmptyAminoAcidString(t *testing.T) { nonEmptyCodonTable := NewTranslationTable(1) - _, err := nonEmptyCodonTable.OptimizeSequence("") + _, err := nonEmptyCodonTable.Optimize("") if err != errEmptyAminoAcidString { t.Error("Optimize should return an error if given an empty amino acid string") @@ -137,7 +137,7 @@ func TestOptimizeErrorsOnInvalidAminoAcid(t *testing.T) { aminoAcids := "TOP" table := NewTranslationTable(1) // does not contain 'O' - _, optimizeErr := table.OptimizeSequence(aminoAcids) + _, optimizeErr := table.Optimize(aminoAcids) assert.EqualError(t, optimizeErr, invalidAminoAcidError{'O'}.Error()) } @@ -298,7 +298,7 @@ func TestCapitalizationRegression(t *testing.T) { t.Error(err) } - optimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation, 1) + optimizedSequence, _ := optimizationTable.Optimize(gfpTranslation, 1) optimizedSequenceTranslation, _ := optimizationTable.Translate(optimizedSequence) if optimizedSequenceTranslation != strings.ToUpper(gfpTranslation) { @@ -375,7 +375,7 @@ func TestOptimizeSequence(t *testing.T) { t.Errorf("got %v, want %v", err, tt.wantUpdateWeightsErr) } - got, err := optimizationTable.OptimizeSequence(tt.sequenceToOptimise, 1) + got, err := optimizationTable.Optimize(tt.sequenceToOptimise, 1) if !errors.Is(err, tt.wantOptimiseErr) { t.Errorf("got %v, want %v", err, tt.wantOptimiseErr) } diff --git a/synthesis/codon/example_test.go b/synthesis/codon/example_test.go index 0374a8f2a..6d7aee668 100644 --- a/synthesis/codon/example_test.go +++ b/synthesis/codon/example_test.go @@ -57,13 +57,13 @@ func ExampleTranslationTable_UpdateWeights() { fmt.Println("Could not update weights in example") } - optimizedSequence, _ := table.OptimizeSequence(gfpTranslation, 1) + optimizedSequence, _ := table.Optimize(gfpTranslation, 1) fmt.Println(optimizedSequence == sequenceWithCustomWeights) // output: true } -func ExampleTranslationTable_OptimizeSequence() { +func ExampleTranslationTable_Optimize() { gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*" sequence, _ := genbank.Read("../../data/puc19.gbk") @@ -84,7 +84,7 @@ func ExampleTranslationTable_OptimizeSequence() { fmt.Println("Stop codons don't equal number of genes!") } - optimizedSequence, _ := codonTable.OptimizeSequence(gfpTranslation) + optimizedSequence, _ := codonTable.Optimize(gfpTranslation) optimizedSequenceTranslation, _ := codonTable.Translate(optimizedSequence) fmt.Println(optimizedSequenceTranslation == gfpTranslation) diff --git a/synthesis/fix/synthesis_test.go b/synthesis/fix/synthesis_test.go index 7d6ceb99a..e86deb8c4 100644 --- a/synthesis/fix/synthesis_test.go +++ b/synthesis/fix/synthesis_test.go @@ -40,7 +40,7 @@ func BenchmarkCds(b *testing.B) { var functions []func(string, chan DnaSuggestion, *sync.WaitGroup) functions = append(functions, RemoveSequence([]string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC"}, "TypeIIS restriction enzyme site.")) for i := 0; i < b.N; i++ { - seq, _ := codonTable.OptimizeSequence(phusion) + seq, _ := codonTable.Optimize(phusion) optimizedSeq, changes, err := Cds(seq, codonTable, functions) if err != nil { b.Errorf("Failed to fix phusion with error: %s", err) @@ -76,7 +76,7 @@ func TestCds(t *testing.T) { phusion := "MGHHHHHHHHHHSSGILDVDYITEEGKPVIRLFKKENGKFKIEHDRTFRPYIYALLRDDSKIEEVKKITGERHGKIVRIVDVEKVEKKFLGKPITVWKLYLEHPQDVPTIREKVREHPAVVDIFEYDIPFAKRYLIDKGLIPMEGEEELKILAFDIETLYHEGEEFGKGPIIMISYADENEAKVITWKNIDLPYVEVVSSEREMIKRFLRIIREKDPDIIVTYNGDSFDFPYLAKRAEKLGIKLTIGRDGSEPKMQRIGDMTAVEVKGRIHFDLYHVITRTINLPTYTLEAVYEAIFGKPKEKVYADEIAKAWESGENLERVAKYSMEDAKATYELGKEFLPMEIQLSRLVGQPLWDVSRSSTGNLVEWFLLRKAYERNEVAPNKPSEEEYQRRLRESYTGGFVKEPEKGLWENIVYLDFRALYPSIIITHNVSPDTLNLEGCKNYDIAPQVGHKFCKDIPGFIPSLLGHLLEERQKIKTKMKETQDPIEKILLDYRQKAIKLLANSFYGYYGYAKARWYCKECAESVTAWGRKYIELVWKELEEKFGFKVLYIDTDGLYATIPGGESEEIKKKALEFVKYINSKLPGLLELEYEGFYKRGFFVTKKRYAVIDEEGKVITRGLEIVRRDWSEIAKETQARVLETILKHGDVEEAVRIVKEVIQKLANYEIPPEKLAIYEQITRPLHEYKAIGPHVAVAKKLAAKGVKIKPGMVIGYIVLRGDGPISNRAILAEEYDPKKHKYDAEYYIENQVLPAVLRILEGFGYRKEDLRYQKTRQVGLTSWLNIKKSGTGGGGATVKFKYKGEEKEVDISKIKKVWRVGKMISFTYDEGGGKTGRGAVSEKDAPKELLQMLEKQKK*" var functions []func(string, chan DnaSuggestion, *sync.WaitGroup) functions = append(functions, RemoveSequence([]string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC"}, "TypeIIS restriction enzyme site.")) - seq, _ := codonTable.OptimizeSequence(phusion) + seq, _ := codonTable.Optimize(phusion) optimizedSeq, _, err := Cds(seq, codonTable, functions) if err != nil { t.Errorf("Failed with error: %s", err)