Skip to content

Commit

Permalink
Synthesis fixer panic (#210)
Browse files Browse the repository at this point in the history
* Updated synthesisFixer to not use SQL.

* Add comment to go to fixcdssimple

* Added developer docs

* Removed need for magic number

* increase code coverage to 100%

* Fixed if suggestion for fix is larger than the sequence itself

* Added 2 different fixes for particular sequence
  • Loading branch information
Koeng101 authored Sep 21, 2021
1 parent 87dbfca commit 1201768
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 2 additions & 8 deletions synthesis/synthesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@ func RemoveSequence(sequencesToRemove []string, reason string) func(string, chan
for _, location := range locations {
codonLength := 3
position := location[0] / codonLength
leftover := location[0] % codonLength
switch {
case leftover == 0:
c <- DnaSuggestion{position, (location[1] / codonLength), "NA", 1, reason}
case leftover != 0:
c <- DnaSuggestion{position, (location[1] / codonLength) - 1, "NA", 1, reason}
}
c <- DnaSuggestion{position, (location[1] / codonLength) - 1, "NA", 1, reason}
}
}
}
Expand Down Expand Up @@ -327,7 +321,7 @@ func FixCds(sequence string, codontable codon.Table, problematicSequenceFuncs []

// For each suggestion, get a list of potential changes that could fix the problem.
var potentialChanges []Change
for positionSelector := suggestion.Start; positionSelector <= suggestion.End; positionSelector++ {
for positionSelector := suggestion.Start; positionSelector <= suggestion.End && positionSelector < len(historicalMap); positionSelector++ {
codonList := historicalMap[positionSelector]
lastCodon := codonList[len(codonList)-1]
unavailableCodons := make(map[string]bool)
Expand Down
12 changes: 12 additions & 0 deletions synthesis/synthesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,15 @@ func TestBadCodonTable(t *testing.T) {
t.Errorf("TestBadCodonTable should fail with 'incomplete codon table'")
}
}

func TestPanicIndex(t *testing.T) {
// lastCodon := codonList[len(codonList)-1] used to fail here with a panic
// panic: runtime error: index out of range [-1]
// This was because there is a BbsI at the end of the gene and sometimes a
// synthesis fix would be requested at 825, out of the sequence range.

codonTable := codon.ReadCodonJSON(dataDir + "freqB.json")
gene := "ATGTCCGAAAAGAATCTGGAGCACAACCACGGTATCATCAAGGGTATCGATATTGCAGCGGAGGTGCGTAAAGACTTCCTGGAGTACAGCATGAGCGTCATCGTGAGCCGCGCACTGCCGGACCTGAAAGACGGTCTGAAACCGGTTCACCGTCGTATTATCTATGCGATGAACGACCTGGGTATCACCGCGGATAAGCCGCACAAGAAGAGCGCGCGTATCGTCGGTGAAGTTATTGGCAAGTATCACCCGCATGGTGACACCGCAGTTTATGATAGCATGGTTCGTATGGCGCAAGATTTTAGCTACCGCTATCCGCTGGTTGACGGCCACGGTAACTTTGGTAGCATCGACGGTGATGGCGCGGCGGCCATGCGTTACACCGAGGCGCGTTTGGCAAAAGTGTCCAATTTTATTATCAAGGACATCGATATGAATACCGTGCCGTTCGTGGACAACTACGACGCAAGCGAGCGTGAACCGGCTTACCTGACGGGCTATTTCCCGAATCTGCTGGCAAATGGTGCAATGGGTATCGCGGTCGGTATGGCTACCAGCATCCCGCCGCATAATCTGCGTGAGGTGATCTCCGCGATTCATGCATTTATCGATAACAAAGATATCACCATCGATGAGATCCTGGACAATCATATTATGGGTCCGGATTTCCCGACCGGTGCTCTGATGACCAACGGTATTCGTATGCGTGAGGGTTACAAAACGGGTCGCGGTGCGGTGACCATCCGCGCTAAAGTCGCACTGGAAGAGAATGATCGCCATGCGCGCTTCATCATTACGGAGATTCCGTATCAGACCAACAAGGCGAAACTGATTGAGCGCATCGCAGAGCTGGTCAAGACGAAGCAGCTGGAAGGTATCAGCGACATTCGTGACGAGAGCAATTATGAAGGTATTCGCATCGTTATCGAGCTGCGTCGCGACAGCAATCCGGACGTGGTCCTGAGCAAGCTGTACAAATTTACCAACTTGCAAACCACGTATAGCTTGAACCTGCTGAGCCTGCACAATAATATTCCGGTTCTGCTGGACCTGAAAAGCATCATCAAACACTACGTCGACTTTCAGATCAACGTTATTATCAAGCGCAGCATTTTTGAGAAGGATAAGATCGAAAAACGCTTCCACATCCTGGAAGCGCTGGATACCGCGCTGGACAATATCGACGCGATTGTCAACATTCTGCGTAACAGCCCGGAGAGCAACGAGGCTAAAATGAAGCTGACCGAAGCGTTCGGCTTCGATGAAGAACAAAATAAAGCGATCCTGGATATGCGTCTGCAACGTTTGGTCGGTCTGGAACGTGGCAAAATCCAGCAGGAGATGGCGCAGATCAAAGAGCGTATTGACTACCTGACCCTGCTGATTAGCGATGAAACCGAACAGAACAATGTTCTGAAGAACCAGCTGAGCGAAATTGCTGAGAAATTCGGTGACAACCGTCGCACGGAGACGATTGACGAGGGTCTGATGGATATCGAGGATGAGGAACTGATTCCGGACGTGAAGACGATGATTCTGCTGAGCGACGAAGGCTATATTCGTCGTGTGGATCCGGAGGAATTTCGCGTCCAAAAGCGCGGTGGTCGCGGTGTGAGCGTGAACTCCAGCAATGAGGACCCGATTGTTATCGCGACGATGGGTAAGATGCGTGACTGGGTCCTGTTTTTCACGAATAGCGGTAAGGTCTTCCGCACCAAAGCCTACAACATTCGCCAATACAGCCGTACCGCGCGCGGCCTGCCGATCGTGAATTTTCTGAACGGTCTGACCGCGGGCGACAAGATTACCGCGATTCTGCCGCTGCGTAATGTGAAAGAGAAAATGAATTATTTGACCTTTATTACCGAGAAGGGTATGATTAAGAAAACCGATATTAGCCTGTTTGACAATATCAACAAAAACGGTAAAATCGCGATTAACTTGAAAGAGGACGACCAACTGGTGACCGTTTTCGCGACCACGGGCGAGGATACCATCTTTGTGGCAAACAAGAGCGGTAAAGTTATCCGTATTCAGGAAAACATCGTCCGCCCGTTGTCTCGTACGGCATCTGGTGTGAAAGCGATTAAGTTGGACGAGAACGATGTGGTGGTGGGTGCAGTTACGAGCTTCGGTATTGAGAACATTACGACCATTTCCTCCAAGGGTAGCTTCAAAAAGACGAACATCGATGAGTATCGTATCAGCGGCCGTAATGGTAAAGGCATCAAAGTCATGAATCTGAACGAAAAGACCGGTGATTTCAAAAGCATCATTGCGGCACGCGAAACCGATCTGGTTTGTATTATTAGCACGGACGGCAATCTGATTAAGACCAAAGCGAGCGATATCCCGGTGCTGGGCCGTGCGGCTGCCGGCGTGCGTGGTATTCGCCTGTCCGAGGGTAATAAGATTCAGGCCGTTATGCTGGAGTACCGTAAACACGGTGAAGAGAACCAGGAATTCGAGGAAGAC"
_, _, _ = FixCdsSimple(gene, codonTable, []string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC", "CGTCTC"})

}

0 comments on commit 1201768

Please sign in to comment.