MCPcopy Create free account
hub / github.com/bebop/poly / CompromiseCodonTable

Function CompromiseCodonTable

synthesis/codon/codon.go:617–702  ·  view source on GitHub ↗

****************************************************************************** Dec, 17, 2020 Compromise + Add codon table stuff begins here == Compromise tables == Basically, I want to codon optimize a protein for two or more organisms. In order to do that, I need to be able to generate a codon t

(firstCodonTable, secondCodonTable *TranslationTable, cutOff float64)

Source from the content-addressed store, hash-verified

615// CompromiseCodonTable takes 2 CodonTables and makes a new codonTable
616// that is an equal compromise between the two tables.
617func CompromiseCodonTable(firstCodonTable, secondCodonTable *TranslationTable, cutOff float64) (*TranslationTable, error) {
618 // Copy first table to base our merge on
619 //
620 // this take start and stop strings from first table
621 // and use them as start + stops in final codonTable
622 mergedTable, err := firstCodonTable.Copy()
623 if err != nil {
624 return nil, err
625 }
626
627 // Check if cutOff is too high or low (this is converted to a percent)
628 if cutOff < 0 {
629 return mergedTable, errors.New("cut off too low, cannot be less than 0")
630 }
631 if cutOff > 1 {
632 return mergedTable, errors.New("cut off too high, cannot be greater than 1")
633 }
634
635 // Initialize the finalAminoAcid list for the output codonTable
636 var finalAminoAcids []AminoAcid
637
638 // Loop over all AminoAcids represented in the first codonTable
639 for _, firstAa := range firstCodonTable.AminoAcids {
640 var firstTriplets []string
641 var firstWeights []int
642 var firstTotal int
643
644 var secondWeights []int
645 var secondTotal int
646 // For each amino acid in firstCodonTable, get list of all codons, and append triplets
647 // and weights to a list
648 for _, firstCodon := range firstAa.Codons {
649 firstTriplets = append(firstTriplets, firstCodon.Triplet)
650 firstWeights = append(firstWeights, firstCodon.Weight)
651 firstTotal = firstTotal + firstCodon.Weight
652 for _, secondAa := range secondCodonTable.AminoAcids {
653 if secondAa.Letter == firstAa.Letter {
654 for _, secondCodon := range secondAa.Codons {
655 // For each codon from firstCodonTable, get the
656 // corresponding triplet and weight from secondCodonTable
657 if secondCodon.Triplet == firstCodon.Triplet {
658 secondWeights = append(secondWeights, secondCodon.Weight)
659 secondTotal = secondTotal + secondCodon.Weight
660 }
661 }
662 }
663 }
664 }
665
666 var finalTriplets []string
667 var finalWeights []int
668 cutOffWeight := int(10000 * cutOff)
669
670 // For each of the Triplets in the amino acid, output a triplet weight
671 // for the first and second triplet, which is the percentage of Triplets
672 // coding for that amino acid multiplied by 10,000
673 for i, firstTriplet := range firstTriplets {
674 finalTriplets = append(finalTriplets, firstTriplet)

Callers 2

TestCompromiseCodonTableFunction · 0.85

Calls 2

CopyMethod · 0.80
UpdateWeightsMethod · 0.80

Tested by 2

TestCompromiseCodonTableFunction · 0.68