my $link = "error.html";
my $count =0;
my @poss_numbers;
$plot = plot_graph (\@temps, \@new, $well_no, $maxx, $maxx2);
push @graph_links, $plot . ' ';
push @existing_wells, $well_no . ' ';
my $graph_links = join ('', @graph_links);
@graph_links = split (/\s+/, $graph_links);
my @graph_links2;
my $m = 1;
foreach my $a (@graph_links) {
my ($n);
if ($a =~ m/(\w{4})(.{1})(\d{1,2})(.{1})(\w{3})/) {
$n = $3;
}
while ($n > $m) {
push @graph_links2, "error.html";
$m++;
}
push @graph_links2, $a;
$m++;
}
my @coords = ( undef, [53,46,22], [92,45,24],[131,48,21], [171,47,22], [211,47,22],[248,47,22], [289,47,21],[327,47,21],[366,48,21],[406,46,23], [444,47,20],[485,48,21],[52,86,22],[92,86,22], [131,86,22],[171,86,22],[210,85,22],[249,86,22],[288,86,23], [327,85,24],[366,86,22],[406,86,22], [445,86,22],[483,85,23],[54,125,22],[93,125,23], [131,124,23],[170,125,22], [210,125,22],[249,125,23],[288,125,22],[327,124,23], [367,125,24],[445,320,22],[483,320,21]);
my $img;
my $pos =0;
for my $counter (1 .. 97) {
if (defined $existing_wells[$pos] and $existing_wells[$pos] == $counter) {
# print "Use image: $counter \n";
$img = $graph_links[$counter-1];
$pos++;
}
else {
# print "Use error image $counter\n";
$img = "error.html";
}
# print $img;
my $coords = join ',', @{$coords[$counter]};
print qq();
}
#----------------------
sub plot_graph {
my ($temps, $numbers, $well_no, $maxx, $maxx2) = @_;
my @graph_data = (\@$temps, \@$numbers);
my $graph = GD::Graph::lines->new (650, 400);
$graph->set_legend("Melting temps: PEAK 1 - $maxx PEAK 2 - $maxx2");
$graph->set_legend_font(GD::gdMediumBoldFont);
$graph->set(
x_label => 'Temperature degrees C',
y_label => 'Fluorescence Derivative',
x_max_value =>95,
y_max_value =>0.7,
title => "The derivative melting curve for well $well_no",
legend_placement => 'BC',
x_label_position =>1/2,
x_tick_number =>20,
y_tick_number =>10
) or die $graph->error;
$graph->set (dclrs=> [qw(green red blue)]);
my $gb = $graph->plot(\@graph_data) or die $graph->error;
open (IMG , ">temp/$well_no.png") or die $!;
binmode IMG;
print IMG $gb->png;
close IMG;
my $plot = "temp/$well_no.png";
return $plot;
}