Skip to content

Commit

Permalink
Add NdeI fixing plus regression (#314)
Browse files Browse the repository at this point in the history
* Add NdeI fixing plus regression

* add comment in code itself
  • Loading branch information
Koeng101 authored Jun 30, 2023
1 parent 763ad3a commit 5e9d809
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion synthesis/fix/synthesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ func RemoveSequence(sequencesToRemove []string, reason string) func(string, chan
return func(sequence string, c chan DnaSuggestion, waitgroup *sync.WaitGroup) {
var sequencesToRemoveForReverse []string
for _, seq := range sequencesToRemove {
sequencesToRemoveForReverse = []string{seq, transform.ReverseComplement(seq)}
reverseComplementToRemove := transform.ReverseComplement(seq)
// Palindromes only have to be fixed once, so add a check here
// for palindromes.
if reverseComplementToRemove == seq {
sequencesToRemoveForReverse = []string{seq}
} else {
sequencesToRemoveForReverse = []string{seq, reverseComplementToRemove}
}
for _, site := range sequencesToRemoveForReverse {
re := regexp.MustCompile(site)
locations := re.FindAllStringIndex(sequence, -1)
Expand Down
16 changes: 16 additions & 0 deletions synthesis/fix/synthesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,19 @@ func TestPanicIndex(t *testing.T) {
_, _, _ = CdsSimple(gene, codonTable, []string{"GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC", "CGTCTC"})

}

func TestNdeIFix(t *testing.T) {
// The following used to fail with "Too many fixes required. Number of potential fixes: 0 , number of required fixes: 1"
// This was because of an internal NdeI site at a `HM` aa intersection, which is a palindrome.
// This would previously cause the palindrome to be found twice, which would add 2 suggested changes
// to the change log. Since NdeI cuts at a methionine, only the His can be changed, which is then
// frozen. Since the palindrome has two requested fixes, and only 1 can be applied, the problem fails
// to fix the sequence. I now added a check if a sequence is a palindrome, and if it is, only search
// for a single copy of it.
codonTable := codon.ReadCodonJSON(dataDir + "freqB.json")
gene := "ATGCGTTTCTTCGAATGCAGCTGCAGCCCGTTCCCGAGCCAGCTGAGCAGCTTTCTGACCCATCTGCTGATCCTGTACACCCTGAGCAGCAGCGTTGAAGCGAGCAGCCGTAATAATTACCAATGGAGCTACGATAGCGATGTCTTTGGTGGCCCGGACTTCTGGGGCCTGGTGGAGAAAGACTGGTGGATGTGCCGTAAAGGTCGTTTGCAAAGCCCGATCGATATTCAACCGGACCGTCTGCTGTTCGATGCGAGCGTCAAACCGGTGCGTCTGGATAAATTGCCGGTGCTGAGCGAATTCGTGAATACCGGCCAGATGGTGCGTATTCGTATTGGTTATAGCACCAAGAAGCCGAGCGTGAACATTACCAACGGTCCGCTGTATGGTTACCGTTACCGTGTTCAGCGCATCGACTTCCATATGGGTCGTGGTAAGGAGAATGGCTCCGAGCATACCATTAACGGCCGCCGCTTTCCGATGGAAGTTCAACTGGTGGCTTTCAATACGGACCTGTATCCGAACTTCACCGCAGCTTCCAAGAGCCCGCACGGCATCGCCATTCTGAGCGTTCTGGTCGATTTCGGTGCACAGACCAACCAGGAGTTGACCAAATTGACCATCGCAACCGCTAGCATCAGCTATAAGGACCAGCGTGTTCAGATGGCCGATTTTGAGCCGTGGCGCTTGTTGCCGTTCACGCGTGACATCATCACCTACGAGGGCAGCCTGACGTCTCCGGGTTGCCACGAGACCGTCACGTGGATCATCCTGAATCAGCCGATCTTCATCACCCGTGAACACTTCGAAGAGTGGAGCCACCTGTACCACACGATGGAAGGCGCAGAGAAAGTCCCGGTGGCCCCGAATTACCGTAAGATTCAGGAGACCAACAATCGCCTGGTGCGCACCAACATTCAGCATAAGGTT"
_, _, err := CdsSimple(gene, codonTable, []string{"CTCGAG", "CATATG", "GAAGAC", "GGTCTC", "GCGATG", "CGTCTC", "GCTCTTC", "CACCTGC", "CGTCTC"})
if err != nil {
t.Errorf("Failed to NdeIFix with error: %s", err)
}
}

0 comments on commit 5e9d809

Please sign in to comment.