Skip to content

Instantly share code, notes, and snippets.

@ascatanach
Last active July 5, 2022 09:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ascatanach/7a562621b9c86c7b5e81973136e6419f to your computer and use it in GitHub Desktop.
Save ascatanach/7a562621b9c86c7b5e81973136e6419f to your computer and use it in GitHub Desktop.
MISA and primer3 input and output scripts with primer3 versions 2.2.3 and 2.3.5.

Use of uninitialized value $total in concatenation (.) or string at misa.pl line 224, chunk 99., means the conditions in the ini file are too stringent

Problem: MISA and the associated scripts from Thomas Thiel and available at http://pgrc.ipk-gatersleben.de/misa/ were written for use with early versions of primer3. These work with primer3 version 1.1.1 (and likely others), however, later versions (2.2.3 and 2.3.5 anyway) throw an error such as
Use of uninitialized value $count in concatenation (.) or string at ./p3_out.pl line 76, <SRC> chunk 11.
These come from later versions of primer3 using different input tags.

Solutions: 2.2.3 accepts the switch -io_version=3 which invokes the use of an old set of input tags and should fix the problem. 2.3.5 does not accept -io_version=3 so a more involved workaround is required. A primer3 settings file is required, called using the switch -p3_settings_file=<file>, which contains the following:

Primer3 File - http://primer3.sourceforge.net
P3_FILE_TYPE=settings

P3_FILE_ID=Description of the settings
PRIMER_THERMODYNAMIC_OLIGO_ALIGNMENT=0
=

Verbatim, spaces and the final = are required. Primer3 otherwise throws the error
PRIMER_ERROR=thermodynamic approach chosen, but path to thermodynamic parameters not specified

In addition need to use modified perl scripts p3_in_v2.pl and p3_out_v2.pl that use updated input tags.

#!/usr/bin/perl -w
# Author: Thomas Thiel
# Program name: primer3_in.pl
# Description: creates a PRIMER3 input file based on SSR search results
# Adjustments to input tags made for primer3 v.2.3.5
open (IN,"<$ARGV[0]") || die ("\nError: Couldn't open misa.pl results file (*.misa) !\n\n");
my $filename = $ARGV[0];
$filename =~ s/\.misa//;
open (SRC,"<$filename") || die ("\nError: Couldn't open source file containing original FASTA sequences !\n\n");
open (OUT,">$filename.p3in");
undef $/;
$in = <IN>;
study $in;
$/= ">";
my $count;
while (<SRC>)
{
next unless (my ($id,$seq) = /(.*?)\n(.*)/s);
$seq =~ s/[\d\s>]//g;#remove digits, spaces, line breaks,...
while ($in =~ /$id\t(\d+)\t\S+\t\S+\t(\d+)\t(\d+)/g)
{
my ($ssr_nr,$size,$start) = ($1,$2,$3);
$count++;
print OUT "SEQUENCE_ID=$id"."_$ssr_nr\nSEQUENCE_TEMPLATE=$seq\n";
print OUT "PRIMER_PRODUCT_SIZE_RANGE=100-280\n";
print OUT "SEQUENCE_TARGET=",$start-3,",",$size+6,"\n";
print OUT "PRIMER_MAX_END_STABILITY=250\n=\n"
};
};
print "\n$count records created.\n";
#!/usr/bin/perl -w
# Author: Thomas Thiel
# Program name: prim_output.pl
# Description: converts the Primer3 output into an table
# Adjustments to input tags made for primer3 v.2.3.5
open (SRC,"<$ARGV[0]") || die ("\nError: Couldn't open Primer3 results file (*.p3out) !\n\n");
my $filename = $ARGV[0];
$filename =~ s/\.p3out//;
open (IN,"<$ARGV[1]") || die ("\nError: Couldn't open source file containing MISA (*.misa) results !\n\n");
open (OUT,">$filename.results") || die ("nError: Couldn't create file !\n\n");
my ($seq_names_failed,$count,$count_failed);
print OUT "ID\tSSR nr.\tSSR type\tSSR\tsize\tstart\tend\t";
print OUT "FORWARD PRIMER1 (5'-3')\tTm(?C)\tsize\tREVERSE PRIMER1 (5'-3')\tTm(?C)\tsize\tPRODUCT1 size (bp)\tstart (bp)\tend (bp)\t";
print OUT "FORWARD PRIMER2 (5'-3')\tTm(?C)\tsize\tREVERSE PRIMER2 (5'-3')\tTm(?C)\tsize\tPRODUCT2 size (bp)\tstart (bp)\tend (bp)\t";
print OUT "FORWARD PRIMER3 (5'-3')\tTm(?C)\tsize\tREVERSE PRIMER3 (5'-3')\tTm(?C)\tsize\tPRODUCT3 size (bp)\tstart (bp)\tend (bp)\n";
undef $/;
my $in = <IN>;
study $in;
$/ = "=\n";
while (<SRC>)
{
# my ($id,$ssr_nr) = (/PRIMER_SEQUENCE_ID=(\S+)_(\d+)/);
my ($id,$ssr_nr) = (/SEQUENCE_ID=(\S+)_(\d+)/);
$in =~ /($id\t$ssr_nr\t.*)\n/;
my $misa = $1;
/PRIMER_LEFT_0_SEQUENCE=(.*)/ || do {$count_failed++;print OUT "$misa\n"; next};
my $info = "$1\t";
/PRIMER_LEFT_0_TM=(.*)/; $info .= "$1\t";
/PRIMER_LEFT_0=\d+,(\d+)/; $info .= "$1\t";
/PRIMER_RIGHT_0_SEQUENCE=(.*)/; $info .= "$1\t";
/PRIMER_RIGHT_0_TM=(.*)/; $info .= "$1\t";
/PRIMER_RIGHT_0=\d+,(\d+)/; $info .= "$1\t";
/PRIMER_PAIR_0_PRODUCT_SIZE=(.*)/; $info .= "$1\t";
/PRIMER_LEFT_0=(\d+),\d+/; $info .= "$1\t";
/PRIMER_RIGHT_0=(\d+),\d+/; $info .= "$1\t";
/PRIMER_LEFT_1_SEQUENCE=(.*)/; $info .= "$1\t";
/PRIMER_LEFT_1_TM=(.*)/; $info .= "$1\t";
/PRIMER_LEFT_1=\d+,(\d+)/; $info .= "$1\t";
/PRIMER_RIGHT_1_SEQUENCE=(.*)/; $info .= "$1\t";
/PRIMER_RIGHT_1_TM=(.*)/; $info .= "$1\t";
/PRIMER_RIGHT_1=\d+,(\d+)/; $info .= "$1\t";
/PRIMER_PAIR_PRODUCT_SIZE_1=(.*)/; $info .= "$1\t";
/PRIMER_LEFT_1=(\d+),\d+/; $info .= "$1\t";
/PRIMER_RIGHT_1=(\d+),\d+/; $info .= "$1\t";
/PRIMER_LEFT_2_SEQUENCE=(.*)/; $info .= "$1\t";
/PRIMER_LEFT_2_TM=(.*)/; $info .= "$1\t";
/PRIMER_LEFT_2=\d+,(\d+)/; $info .= "$1\t";
/PRIMER_RIGHT_2_SEQUENCE=(.*)/; $info .= "$1\t";
/PRIMER_RIGHT_2_TM=(.*)/; $info .= "$1\t";
/PRIMER_RIGHT_2=\d+,(\d+)/; $info .= "$1\t";
/PRIMER_PAIR_PRODUCT_SIZE_2=(.*)/; $info .= "$1\t";
/PRIMER_LEFT_2=(\d+),\d+/; $info .= "$1\t";
/PRIMER_RIGHT_2=(\d+),\d+/; $info .= "$1";
$count++;
print OUT "$misa\t$info\n"
};
print "\nPrimer modelling was successful for $count sequences.\n";
print "Primer modelling failed for $count_failed sequences.\n";
Primer3 File - http://primer3.sourceforge.net
P3_FILE_TYPE=settings
P3_FILE_ID=Description of the settings
PRIMER_THERMODYNAMIC_OLIGO_ALIGNMENT=0
=
@eilhan25
Copy link

Hi. I am steadly taking a message "Use of uninitialized value $count in concatenation (.) or string at p3_out_v2.pl line 79, chunk 371". Do you have a solution or a running MISA program?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment