Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCodingRegions ¶
GetCodingRegions is a helper function to pull coding regions out of an Sequence as input for optimizing codon tables.
Example ¶
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
func Optimize ¶
Optimize takes an amino acid sequence and Table and returns an optimized codon sequence
Example ¶
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 Translate ¶
Translate translates a codon sequence to an amino acid sequence
Example ¶
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 WriteCodonJSON ¶
WriteCodonJSON writes a Table struct out to JSON.
Example ¶
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
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 struct {
StartCodons []string `json:"start_codons"`
StopCodons []string `json:"stop_codons"`
AminoAcids []AminoAcid `json:"amino_acids"`
}
Table holds information for a codon table.
func AddCodonTable ¶
AddCodonTable takes 2 CodonTables and adds them together to create a new Table.
Example ¶
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
func CompromiseCodonTable ¶
func CompromiseCodonTable(firstCodonTable Table, secondCodonTable Table, cutOff float64) (Table, error)
CompromiseCodonTable takes 2 CodonTables and makes a new Table that is an equal compromise between the two tables.
Example ¶
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 GetCodonTable ¶
GetCodonTable takes the index of desired NCBI codon table and returns it.
func ParseCodonJSON ¶
ParseCodonJSON parses a Table JSON file.
Example ¶
file, _ := ioutil.ReadFile("../../data/bsub_codon_test.json")
codontable := ParseCodonJSON(file)
fmt.Println(codontable.AminoAcids[0].Codons[0].Weight)
Output: 28327
func ReadCodonJSON ¶
ReadCodonJSON reads a Table JSON file.
Example ¶
codontable := ReadCodonJSON("../../data/bsub_codon_test.json")
fmt.Println(codontable.AminoAcids[0].Codons[0].Weight)
Output: 28327
func (Table) OptimizeTable ¶
OptimizeTable weights each codon in a codon table according to input string codon frequency. This function actually mutates the Table struct itself.