my $num_species = @species;
+my @tables = $dbh->tables();
+my %table_hash;
+foreach my $table (@tables) {
+ my ($db,$table_name) = split ('`.`', $table);
+ $table_name =~ s/`$//;
+ $table_hash{$table_name} = $table_name;
+}
+
for (my $i=0; $i<$num_species-1; $i++) {
print "Working on species: $species[$i]\n";
# $species_2 = $spec_temp;
# print "non optimal order\n";
# }
-
-
+
+
# create the statement handler to pull the species-pair data
my $spec_table = "$species_1" . "_" . "$species_2";
my $safe_species_table = $dbh->quote_identifier($spec_table);
+
+ # Check to make sure table exists and skip if it doesn't
+ if(!defined($table_hash{$spec_table})) {
+ next;
+ }
+
+
my $sth = $dbh->prepare("select * from $safe_species_table");
+
+
my $id_prev = "";