Skip to content

Commit 916c92d

Browse files
renamed OptimizeSequence to just Optimize. (#407)
* renamed OptimizeSequence to just Optimize.
1 parent c9ba7f3 commit 916c92d

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

synthesis/codon/codon.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ File is structured as so:
4646
Key functions:
4747
TranslationTable.Translate - given a nucleic sequence string and codon table it translates sequences to UPPERCASE amino acid sequences.
4848
49-
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
49+
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
5050
5151
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.
5252
@@ -84,7 +84,7 @@ type AminoAcid struct {
8484
// Table is an interface encompassing what a potentially codon optimized Translation table can do
8585
type Table interface {
8686
GetWeightedAminoAcids() []AminoAcid
87-
OptimizeSequence(aminoAcids string, randomState ...int) (string, error)
87+
Optimize(aminoAcids string, randomState ...int) (string, error)
8888
Translate(dnaSeq string) (string, error)
8989
}
9090

@@ -137,9 +137,9 @@ func (table *TranslationTable) GetWeightedAminoAcids() []AminoAcid {
137137
return table.AminoAcids
138138
}
139139

140-
// OptimizeSequence will return a set of codons which can be used to encode the given amino acid sequence. The codons
140+
// Optimize will return a set of codons which can be used to encode the given amino acid sequence. The codons
141141
// picked are weighted according to the computed translation table's weights
142-
func (table *TranslationTable) OptimizeSequence(aminoAcids string, randomState ...int) (string, error) {
142+
func (table *TranslationTable) Optimize(aminoAcids string, randomState ...int) (string, error) {
143143
// Finding any given aminoAcid is dependent upon it being capitalized, so
144144
// we do that here.
145145
aminoAcids = strings.ToUpper(aminoAcids)

synthesis/codon/codon_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestOptimize(t *testing.T) {
7878

7979
codonTable := NewTranslationTable(11)
8080

81-
optimizedSequence, _ := table.OptimizeSequence(gfpTranslation)
81+
optimizedSequence, _ := table.Optimize(gfpTranslation)
8282
optimizedSequenceTranslation, _ := codonTable.Translate(optimizedSequence)
8383

8484
if optimizedSequenceTranslation != gfpTranslation {
@@ -100,8 +100,8 @@ func TestOptimizeSameSeed(t *testing.T) {
100100

101101
randomSeed := 10
102102

103-
optimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation, randomSeed)
104-
otherOptimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation, randomSeed)
103+
optimizedSequence, _ := optimizationTable.Optimize(gfpTranslation, randomSeed)
104+
otherOptimizedSequence, _ := optimizationTable.Optimize(gfpTranslation, randomSeed)
105105

106106
if optimizedSequence != otherOptimizedSequence {
107107
t.Error("Optimized sequence with the same random seed are not the same")
@@ -117,8 +117,8 @@ func TestOptimizeDifferentSeed(t *testing.T) {
117117
t.Error(err)
118118
}
119119

120-
optimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation)
121-
otherOptimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation)
120+
optimizedSequence, _ := optimizationTable.Optimize(gfpTranslation)
121+
otherOptimizedSequence, _ := optimizationTable.Optimize(gfpTranslation)
122122

123123
if optimizedSequence == otherOptimizedSequence {
124124
t.Error("Optimized sequence with different random seed have the same result")
@@ -127,7 +127,7 @@ func TestOptimizeDifferentSeed(t *testing.T) {
127127

128128
func TestOptimizeErrorsOnEmptyAminoAcidString(t *testing.T) {
129129
nonEmptyCodonTable := NewTranslationTable(1)
130-
_, err := nonEmptyCodonTable.OptimizeSequence("")
130+
_, err := nonEmptyCodonTable.Optimize("")
131131

132132
if err != errEmptyAminoAcidString {
133133
t.Error("Optimize should return an error if given an empty amino acid string")
@@ -137,7 +137,7 @@ func TestOptimizeErrorsOnInvalidAminoAcid(t *testing.T) {
137137
aminoAcids := "TOP"
138138
table := NewTranslationTable(1) // does not contain 'O'
139139

140-
_, optimizeErr := table.OptimizeSequence(aminoAcids)
140+
_, optimizeErr := table.Optimize(aminoAcids)
141141
assert.EqualError(t, optimizeErr, invalidAminoAcidError{'O'}.Error())
142142
}
143143

@@ -298,7 +298,7 @@ func TestCapitalizationRegression(t *testing.T) {
298298
t.Error(err)
299299
}
300300

301-
optimizedSequence, _ := optimizationTable.OptimizeSequence(gfpTranslation, 1)
301+
optimizedSequence, _ := optimizationTable.Optimize(gfpTranslation, 1)
302302
optimizedSequenceTranslation, _ := optimizationTable.Translate(optimizedSequence)
303303

304304
if optimizedSequenceTranslation != strings.ToUpper(gfpTranslation) {
@@ -375,7 +375,7 @@ func TestOptimizeSequence(t *testing.T) {
375375
t.Errorf("got %v, want %v", err, tt.wantUpdateWeightsErr)
376376
}
377377

378-
got, err := optimizationTable.OptimizeSequence(tt.sequenceToOptimise, 1)
378+
got, err := optimizationTable.Optimize(tt.sequenceToOptimise, 1)
379379
if !errors.Is(err, tt.wantOptimiseErr) {
380380
t.Errorf("got %v, want %v", err, tt.wantOptimiseErr)
381381
}

synthesis/codon/example_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ func ExampleTranslationTable_UpdateWeights() {
5757
fmt.Println("Could not update weights in example")
5858
}
5959

60-
optimizedSequence, _ := table.OptimizeSequence(gfpTranslation, 1)
60+
optimizedSequence, _ := table.Optimize(gfpTranslation, 1)
6161

6262
fmt.Println(optimizedSequence == sequenceWithCustomWeights)
6363
// output: true
6464
}
6565

66-
func ExampleTranslationTable_OptimizeSequence() {
66+
func ExampleTranslationTable_Optimize() {
6767
gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*"
6868

6969
sequence, _ := genbank.Read("../../data/puc19.gbk")
@@ -84,7 +84,7 @@ func ExampleTranslationTable_OptimizeSequence() {
8484
fmt.Println("Stop codons don't equal number of genes!")
8585
}
8686

87-
optimizedSequence, _ := codonTable.OptimizeSequence(gfpTranslation)
87+
optimizedSequence, _ := codonTable.Optimize(gfpTranslation)
8888
optimizedSequenceTranslation, _ := codonTable.Translate(optimizedSequence)
8989

9090
fmt.Println(optimizedSequenceTranslation == gfpTranslation)

synthesis/fix/synthesis_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func BenchmarkCds(b *testing.B) {
4040
var functions []func(string, chan DnaSuggestion, *sync.WaitGroup)
4141
functions = append(functions, RemoveSequence([]string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC"}, "TypeIIS restriction enzyme site."))
4242
for i := 0; i < b.N; i++ {
43-
seq, _ := codonTable.OptimizeSequence(phusion)
43+
seq, _ := codonTable.Optimize(phusion)
4444
optimizedSeq, changes, err := Cds(seq, codonTable, functions)
4545
if err != nil {
4646
b.Errorf("Failed to fix phusion with error: %s", err)
@@ -76,7 +76,7 @@ func TestCds(t *testing.T) {
7676
phusion := "MGHHHHHHHHHHSSGILDVDYITEEGKPVIRLFKKENGKFKIEHDRTFRPYIYALLRDDSKIEEVKKITGERHGKIVRIVDVEKVEKKFLGKPITVWKLYLEHPQDVPTIREKVREHPAVVDIFEYDIPFAKRYLIDKGLIPMEGEEELKILAFDIETLYHEGEEFGKGPIIMISYADENEAKVITWKNIDLPYVEVVSSEREMIKRFLRIIREKDPDIIVTYNGDSFDFPYLAKRAEKLGIKLTIGRDGSEPKMQRIGDMTAVEVKGRIHFDLYHVITRTINLPTYTLEAVYEAIFGKPKEKVYADEIAKAWESGENLERVAKYSMEDAKATYELGKEFLPMEIQLSRLVGQPLWDVSRSSTGNLVEWFLLRKAYERNEVAPNKPSEEEYQRRLRESYTGGFVKEPEKGLWENIVYLDFRALYPSIIITHNVSPDTLNLEGCKNYDIAPQVGHKFCKDIPGFIPSLLGHLLEERQKIKTKMKETQDPIEKILLDYRQKAIKLLANSFYGYYGYAKARWYCKECAESVTAWGRKYIELVWKELEEKFGFKVLYIDTDGLYATIPGGESEEIKKKALEFVKYINSKLPGLLELEYEGFYKRGFFVTKKRYAVIDEEGKVITRGLEIVRRDWSEIAKETQARVLETILKHGDVEEAVRIVKEVIQKLANYEIPPEKLAIYEQITRPLHEYKAIGPHVAVAKKLAAKGVKIKPGMVIGYIVLRGDGPISNRAILAEEYDPKKHKYDAEYYIENQVLPAVLRILEGFGYRKEDLRYQKTRQVGLTSWLNIKKSGTGGGGATVKFKYKGEEKEVDISKIKKVWRVGKMISFTYDEGGGKTGRGAVSEKDAPKELLQMLEKQKK*"
7777
var functions []func(string, chan DnaSuggestion, *sync.WaitGroup)
7878
functions = append(functions, RemoveSequence([]string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC"}, "TypeIIS restriction enzyme site."))
79-
seq, _ := codonTable.OptimizeSequence(phusion)
79+
seq, _ := codonTable.Optimize(phusion)
8080
optimizedSeq, _, err := Cds(seq, codonTable, functions)
8181
if err != nil {
8282
t.Errorf("Failed with error: %s", err)

0 commit comments

Comments
 (0)