Skip to main content

Create PCR primers optimized for length, tm, gc and free energy

Project description


This is a tool for making PCR primers for DNA sequences. primers' emphasis is on ease-of-use and DNA assembly. Adding additional sequence to 5' end of the FWD and REV primer, something common in creating fragments for Gibson assembly and Golden Gate cloning, is easy with primers. Finally, it has a permissive MIT license where other primer design tools don't.


pip install primers



from primers import primers

# add recognition sequences to FWD and REV primers
print(fwd.fwd)  # True
print(fwd.seq)  # GGTCTCAATGAGACAATAGCACACACA; 5' to 3'
print(   # 62.4; melting temp
print(fwd.tm_total)  # 68.6; melting temp with added seq (GGTCTC)
print(fwd.dg)   # -1.86; minimum free energy of the secondary structure

# add from a range of sequence to the FWD primer
fwd, rev = primers("AATGAGACAATAGCACACACAGCTAGGTCAGCATACGAAA", add_fwd="GGATCGAGCTTGA", add_fwd_len=(5, 12))
print(   # 62.2
print(fwd.tm_total)  # 70.0


  dir    tm   ttm     dg   pen  seq
  REV  62.8  67.4      0   4.8  GAAGACTTTCGTATGCTGACCTAG
$ primers --help
usage: primers [-h] [-f SEQ] [-fl INT INT] [-r SEQ] [-rl INT INT] [--version] SEQ

Create PCR primers for a DNA sequence.

Logs the FWD and REV primer with columns:
dir, tm, ttm, dg, pen, seq

dir = FWD or REV.
tm  = Melting temperature of the annealing/binding part of the primer (Celsius).
ttm = The total melting temperature of the primer with added seq (Celsius).
dg  = The minimum free energy of the primer (kcal/mol).
pen = The primer's penalty score. Lower is better.
seq = The sequence of the primer in the 5' to the 3' direction.

positional arguments:
  SEQ                   DNA sequence

optional arguments:
  -h, --help            show this help message and exit
  -f SEQ, --fwd SEQ     additional sequence to add to FWD primer (5' to 3')
  -fl INT INT, --flen INT INT
                        space separated min-max range for the length to add from 'add_fwd' (5' to 3')
  -r SEQ, --rev SEQ     additional sequence to add to REV primer (5' to 3')
  -rl INT INT, --rlen INT INT
                        space separated min-max range for the length to add from 'add_rev' (5' to 3')
  --version             show program's version number and exit


Selecting primers for a DNA sequence is non-trivial because it's a multi-objective optimization problem. Ideally, pairs of primers for PCR amplification would have similar, ideal tms, low gc%s, low free energies (dgs) and lack off-target binding sites.


In this module, the penalty for each possible primer, p, is calculated as:

    abs( - opt_tm) * penalty_tm +
    abs(p.gc - opt_gc) * penalty_gc +
    abs(len(p) - opt_len) * penalty_len +
    abs( - * penalty_tm_diff +
    abs(p.dg) * penalty_dg +
    p.offtargets * penalty_offtargets

Each of the optimal (opt_*) and penalty (penalty_*) parameters is adjustable through the primers.primers() function. The primer pair with the lowest combined penalty score is chosen.

Given this module's emphasis on DNA assembly, additional sequences added to the FWD and/or REV primer are considered in the PENALTY calculation.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for primers, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size primers-0.1.2-py3.8.egg (20.2 kB) File type Egg Python version 3.8 Upload date Hashes View
Filename, size primers-0.1.2-py3-none-any.whl (11.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size primers-0.1.2.tar.gz (10.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page