codon

package
v0.14.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCodingRegions

func GetCodingRegions(sequence poly.Sequence) string

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

func Optimize(aminoAcids string, codonTable Table) (string, error)

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

func Translate(sequence string, codonTable Table) (string, error)

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

func WriteCodonJSON(codontable Table, path string)

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 AminoAcid

type AminoAcid struct {
	Letter string  `json:"letter"`
	Codons []Codon `json:"codons"`
}

AminoAcid holds information for an amino acid and related codons in a struct

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

func AddCodonTable(firstCodonTable Table, secondCodonTable Table) Table

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

func GetCodonTable(index int) Table

GetCodonTable takes the index of desired NCBI codon table and returns it.

func ParseCodonJSON

func ParseCodonJSON(file []byte) Table

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

func ReadCodonJSON(path string) Table

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

func (codonTable Table) OptimizeTable(sequence string) Table

OptimizeTable weights each codon in a codon table according to input string codon frequency. This function actually mutates the Table struct itself.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL