Skip to content

Commit

Permalink
renamed OptimizeSequence to just Optimize. (#407)
Browse files Browse the repository at this point in the history
* renamed OptimizeSequence to just Optimize.
  • Loading branch information
TimothyStiles authored Nov 28, 2023
1 parent c9ba7f3 commit 916c92d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions synthesis/codon/codon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions synthesis/codon/codon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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())
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions synthesis/codon/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions synthesis/fix/synthesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 916c92d

Please sign in to comment.