Skip to content

Commit

Permalink
Separated minimums between design and simulate (#447)
Browse files Browse the repository at this point in the history
* Separated minimums between design and simulate

* Added check on primer length when using simulate

* Added CHANGELOG.md
  • Loading branch information
whitead authored Oct 21, 2024
1 parent 529ccc7 commit 2c103ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Made it possible to simulate primers shorter than design minimum.

## [0.31.1] - 2024-01-31

### Added
Expand Down
19 changes: 14 additions & 5 deletions primers/pcr/pcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,24 @@ import (
)

// https://doi.org/10.1089/dna.1994.13.75
var minimalPrimerLength int = 15
const minimalPrimerLength int = 7

// what we want for designs
const designedMinimalPrimerLength int = 15

// DesignPrimersWithOverhangs designs two primers to amplify a target sequence,
// adding on an overhang to the forward and reverse strand. This overhang can
// contain additional DNA needed for assembly, like Gibson assembly overhangs
// or GoldenGate restriction enzyme sites.
func DesignPrimersWithOverhangs(sequence, forwardOverhang, reverseOverhang string, targetTm float64) (string, string) {
sequence = strings.ToUpper(sequence)
forwardPrimer := sequence[0:minimalPrimerLength]
forwardPrimer := sequence[0:designedMinimalPrimerLength]
for additionalNucleotides := 0; primers.MeltingTemp(forwardPrimer) < targetTm; additionalNucleotides++ {
forwardPrimer = sequence[0 : minimalPrimerLength+additionalNucleotides]
forwardPrimer = sequence[0 : designedMinimalPrimerLength+additionalNucleotides]
}
reversePrimer := transform.ReverseComplement(sequence[len(sequence)-minimalPrimerLength:])
reversePrimer := transform.ReverseComplement(sequence[len(sequence)-designedMinimalPrimerLength:])
for additionalNucleotides := 0; primers.MeltingTemp(reversePrimer) < targetTm; additionalNucleotides++ {
reversePrimer = transform.ReverseComplement(sequence[len(sequence)-(minimalPrimerLength+additionalNucleotides):])
reversePrimer = transform.ReverseComplement(sequence[len(sequence)-(designedMinimalPrimerLength+additionalNucleotides):])
}

// Add overhangs to primer
Expand Down Expand Up @@ -168,6 +171,12 @@ func SimulateSimple(sequences []string, targetTm float64, circular bool, primerL
// in your reaction, which can lead to confusing results. The variable
// `circular` is for if the target template is circular, like a plasmid.
func Simulate(sequences []string, targetTm float64, circular bool, primerList []string) ([]string, error) {
// make sure no primers are too short
for _, primer := range primerList {
if len(primer) < minimalPrimerLength {
return nil, errors.New("Primers are too short.")
}
}
initialAmplification := SimulateSimple(sequences, targetTm, circular, primerList)
subsequentAmplification := SimulateSimple(sequences, targetTm, circular, append(primerList, initialAmplification...))
if len(initialAmplification) != len(subsequentAmplification) {
Expand Down

0 comments on commit 2c103ec

Please sign in to comment.