Documentation
¶
Overview ¶
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
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Optimize ¶
Optimize takes an amino acid sequence and codonTable and returns an optimized codon sequence. Takes an optional random seed as last argument.
Example ¶
package main
import (
"fmt"
"strings"
"github.com/TimothyStiles/poly/io/genbank"
"github.com/TimothyStiles/poly/synthesis/codon"
)
func main() {
gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*"
sequence, _ := genbank.Read("../../data/puc19.gbk")
codonTable := codon.GetCodonTable(11)
// a string builder to build a single concatenated string of all coding regions
var codingRegionsBuilder strings.Builder
// iterate through the features of the genbank file and if the feature is a coding region, append the sequence to the string builder
for _, feature := range sequence.Features {
if feature.Type == "CDS" {
sequence, _ := feature.GetSequence()
codingRegionsBuilder.WriteString(sequence)
}
}
// get the concatenated sequence string of the coding regions
codingRegions := codingRegionsBuilder.String()
// weight our codon optimization table using the regions we collected from the genbank file above
optimizationTable := codonTable.OptimizeTable(codingRegions)
optimizedSequence, _ := codon.Optimize(gfpTranslation, optimizationTable)
optimizedSequenceTranslation, _ := codon.Translate(optimizedSequence, optimizationTable)
fmt.Println(optimizedSequenceTranslation == gfpTranslation)
}
Output: true
func Translate ¶
Translate translates a codon sequence to an amino acid sequence
Example ¶
package main
import (
"fmt"
"github.com/TimothyStiles/poly/synthesis/codon"
)
func main() {
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 WriteCodonJSON ¶
WriteCodonJSON writes a codonTable struct out to JSON.
Example ¶
package main
import (
"fmt"
"os"
"github.com/TimothyStiles/poly/synthesis/codon"
)
func main() {
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.GetAminoAcids()[0].Codons[0].Weight)
}
Output: 28327
Types ¶
type Codon ¶
type Codon struct {
Triplet string `json:"triplet"`
Weight int `json:"weight"` // needs to be set to 1 for random chooser
}
Codon holds information for a codon triplet in a struct
type Table ¶
type Table interface {
Chooser() (map[string]weightedRand.Chooser, error)
GenerateTranslationTable() map[string]string
GetAminoAcids() []AminoAcid
GetStartCodons() []string
GetStopCodons() []string
IsEmpty() bool
OptimizeTable(string) Table
}
Table is an interface that specifies the functions that all table types must implement
func AddCodonTable ¶
AddCodonTable takes 2 CodonTables and adds them together to create a new codonTable.
Example ¶
package main
import (
"fmt"
"strings"
"github.com/TimothyStiles/poly/io/genbank"
"github.com/TimothyStiles/poly/synthesis/codon"
)
func main() {
sequence, _ := genbank.Read("../../data/puc19.gbk")
codonTable := codon.GetCodonTable(11)
// a string builder to build a single concatenated string of all coding regions
var codingRegionsBuilder strings.Builder
// iterate through the features of the genbank file and if the feature is a coding region, append the sequence to the string builder
for _, feature := range sequence.Features {
if feature.Type == "CDS" {
sequence, _ := feature.GetSequence()
codingRegionsBuilder.WriteString(sequence)
}
}
// get the concatenated sequence string of the coding regions
codingRegions := codingRegionsBuilder.String()
// weight our codon optimization table using the regions we collected from the genbank file above
optimizationTable := codonTable.OptimizeTable(codingRegions)
sequence2, _ := genbank.Read("../../data/phix174.gb")
codonTable2 := codon.GetCodonTable(11)
// a string builder to build a single concatenated string of all coding regions
var codingRegionsBuilder2 strings.Builder
// iterate through the features of the genbank file and if the feature is a coding region, append the sequence to the string builder
for _, feature := range sequence2.Features {
if feature.Type == "CDS" {
sequence, _ := feature.GetSequence()
codingRegionsBuilder2.WriteString(sequence)
}
}
// get the concatenated sequence string of the coding regions
codingRegions2 := codingRegionsBuilder2.String()
// weight our codon optimization table using the regions we collected from the genbank file above
optimizationTable2 := codonTable2.OptimizeTable(codingRegions2)
finalTable := codon.AddCodonTable(optimizationTable, optimizationTable2)
for _, aa := range finalTable.GetAminoAcids() {
for _, codon := range aa.Codons {
if codon.Triplet == "GGC" {
fmt.Println(codon.Weight)
}
}
}
}
Output: 90
func CompromiseCodonTable ¶
CompromiseCodonTable takes 2 CodonTables and makes a new codonTable that is an equal compromise between the two tables.
Example ¶
package main
import (
"fmt"
"strings"
"github.com/TimothyStiles/poly/io/genbank"
"github.com/TimothyStiles/poly/synthesis/codon"
)
func main() {
sequence, _ := genbank.Read("../../data/puc19.gbk")
codonTable := codon.GetCodonTable(11)
// a string builder to build a single concatenated string of all coding regions
var codingRegionsBuilder strings.Builder
// iterate through the features of the genbank file and if the feature is a coding region, append the sequence to the string builder
for _, feature := range sequence.Features {
if feature.Type == "CDS" {
sequence, _ := feature.GetSequence()
codingRegionsBuilder.WriteString(sequence)
}
}
// get the concatenated sequence string of the coding regions
codingRegions := codingRegionsBuilder.String()
// weight our codon optimization table using the regions we collected from the genbank file above
optimizationTable := codonTable.OptimizeTable(codingRegions)
sequence2, _ := genbank.Read("../../data/phix174.gb")
codonTable2 := codon.GetCodonTable(11)
// a string builder to build a single concatenated string of all coding regions
var codingRegionsBuilder2 strings.Builder
// iterate through the features of the genbank file and if the feature is a coding region, append the sequence to the string builder
for _, feature := range sequence2.Features {
if feature.Type == "CDS" {
sequence, _ := feature.GetSequence()
codingRegionsBuilder2.WriteString(sequence)
}
}
// get the concatenated sequence string of the coding regions
codingRegions2 := codingRegionsBuilder2.String()
// weight our codon optimization table using the regions we collected from the genbank file above
optimizationTable2 := codonTable2.OptimizeTable(codingRegions2)
finalTable, _ := codon.CompromiseCodonTable(optimizationTable, optimizationTable2, 0.1)
for _, aa := range finalTable.GetAminoAcids() {
for _, codon := range aa.Codons {
if codon.Triplet == "TAA" {
fmt.Println(codon.Weight)
}
}
}
}
Output: 2727
func GetCodonTable ¶
GetCodonTable takes the index of desired NCBI codon table and returns it.
func ParseCodonJSON ¶
ParseCodonJSON parses a codonTable JSON file.
Example ¶
package main
import (
"fmt"
"os"
"github.com/TimothyStiles/poly/synthesis/codon"
)
func main() {
file, _ := os.ReadFile("../../data/bsub_codon_test.json")
codontable := codon.ParseCodonJSON(file)
fmt.Println(codontable.GetAminoAcids()[0].Codons[0].Weight)
}
Output: 28327
func ReadCodonJSON ¶
ReadCodonJSON reads a codonTable JSON file.
Example ¶
package main
import (
"fmt"
"github.com/TimothyStiles/poly/synthesis/codon"
)
func main() {
codontable := codon.ReadCodonJSON("../../data/bsub_codon_test.json")
fmt.Println(codontable.GetAminoAcids()[0].Codons[0].Weight)
}
Output: 28327