Skip to content

Commit

Permalink
Fix PCR bug (issue #279). (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
carreter authored Sep 26, 2023
1 parent d2ae0de commit 41a9515
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion primers/pcr/pcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func Simulate(sequences []string, targetTm float64, circular bool, primerList []

func generatePcrFragments(sequence string, forwardLocation int, reverseLocation int, forwardPrimerIndxs []int, reversePrimerIndxs []int, minimalPrimers []string, primerList []string) []string {
var pcrFragments []string
for forwardPrimerIndex := range forwardPrimerIndxs {
for _, forwardPrimerIndex := range forwardPrimerIndxs {
minimalPrimer := minimalPrimers[forwardPrimerIndex]
fullPrimerForward := primerList[forwardPrimerIndex]
for _, reversePrimerIndex := range reversePrimerIndxs {
Expand Down
17 changes: 17 additions & 0 deletions primers/pcr/pcr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package pcr

import (
"testing"

"github.com/google/go-cmp/cmp"
)

// gene is a gene for testing PCR
Expand Down Expand Up @@ -72,3 +74,18 @@ func TestSimulateConcatemerization(t *testing.T) {
t.Errorf("Should have gotten concatemerization")
}
}

// Test to catch bug discovered by @Koeng101, see issue #279.
func TestIssue279PCRBug(t *testing.T) {
gene := "aataattacaccgagataacacatcatggataaaccgatactcaaagattctatgaagctatttgaggcacttggtacgatcaagtcgcgctcaatgtttggtggcttcggacttttcgctgatgaaacgatgtttgcactggttgtgaatgatcaacttcacatacgagcagaccagcaaacttcatctaacttcgagaagcaagggctaaaaccgtacgtttataaaaagcgtggttttccagtcgttactaagtactacgcgatttccgacgacttgtgggaatccagtgaacgcttgatagaagtagcgaagaagtcgttagaacaagccaatttggaaaaaaagcaacaggcaagtagtaagcccgacaggttgaaagacctgcctaacttacgactagcgactgaacgaatgcttaagaaagctggtataaaatcagttgaacaacttgaagagaaaggtgcattgaatgcttacaaagcgatacgtgactctcactccgcaaaagtaagtattgagctactctgggctttagaaggagcgataaacggcacgcactggagcgtcgttcctcaatctcgcagagaagagctggaaaatgcgctttcttaa"

fragments, err := Simulate([]string{gene}, 55.0, false, []string{"TATATGGTCTCTTCATTTAAGAAAGCGCATTTTCCAGC", "TTATAGGTCTCATACTAATAATTACACCGAGATAACACATCATGG", "CTGCAGGTCGACTCTAG"})
if err != nil {
t.Fatalf("unexpected error during PCR simulation: %v", err)
}

want := "TTATAGGTCTCATACTAATAATTACACCGAGATAACACATCATGGATAAACCGATACTCAAAGATTCTATGAAGCTATTTGAGGCACTTGGTACGATCAAGTCGCGCTCAATGTTTGGTGGCTTCGGACTTTTCGCTGATGAAACGATGTTTGCACTGGTTGTGAATGATCAACTTCACATACGAGCAGACCAGCAAACTTCATCTAACTTCGAGAAGCAAGGGCTAAAACCGTACGTTTATAAAAAGCGTGGTTTTCCAGTCGTTACTAAGTACTACGCGATTTCCGACGACTTGTGGGAATCCAGTGAACGCTTGATAGAAGTAGCGAAGAAGTCGTTAGAACAAGCCAATTTGGAAAAAAAGCAACAGGCAAGTAGTAAGCCCGACAGGTTGAAAGACCTGCCTAACTTACGACTAGCGACTGAACGAATGCTTAAGAAAGCTGGTATAAAATCAGTTGAACAACTTGAAGAGAAAGGTGCATTGAATGCTTACAAAGCGATACGTGACTCTCACTCCGCAAAAGTAAGTATTGAGCTACTCTGGGCTTTAGAAGGAGCGATAAACGGCACGCACTGGAGCGTCGTTCCTCAATCTCGCAGAGAAGAGCTGGAAAATGCGCTTTCTTAAATGAAGAGACCATATA"
if diff := cmp.Diff(fragments[0], want); diff != "" {
t.Errorf("incorrect PCR output (-want,+got): %s", diff)
}
}

0 comments on commit 41a9515

Please sign in to comment.