If you already know the basic sequence i.e. the fixed regions in the primer; for e.g. the known nucleotides in the sequence - NGATWGCTSATNGC
, then you can implement your algorithm like this:
- Fix the max length of the primers. Lets say 20nt.
- Generate all combinations of primers (20nt): that is pretty straightforward. You will have
4N × 2(R+Y+S+W+K+M) × 3(B+D+V+H) number of combinations, where each alphabet denotes number of such instances. Chek this site for the nucleotide codes. - Calculate the Tm of the primer-template pairs. UNAfold has a nucleotide hybridization Tm calculator. You can specify parameters like salt concentration etc. There are other such tools too. These can be run on the commandline.
- Discard all primers have Tm below the acceptable limit.
- For those that exceed the acceptable Tm, keep dropping a base from the 3' until the Tm reaches within the range.
- If primer length goes below 14nt then discard the primer.
- Now with all these selected primers check for parameters like self hybridization, GC clamp etc (OPTIONAL). You can use primer3 for these purposes by running it on the
primer_check
mode. - Download the
nr/nt
BLAST database. - Adjust BLAST parameters for short nucleotide search: Decrease the word length, increase e-value cutoff etc (See this biostar post and BLAST help).
- BLAST your primers against the database in
plus-minus
mode. - Worry only about cases where there is significant alignment at the 3' of the primer as only these can cause extension.
These instructions can be automated using any language or shell script.
*Questions on script writing would be off-topic in this site. You can ask specific doubts about coding in stackoverflow.*