1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
#!/usr/bin/perl -w
use strict;
use GD;
[...]
## Generation d'une image
# create a new image
my $img = new GD::Image(550,2400);
# allocate some colors
my $white = $img->colorAllocate(255,255,255);
my $black = $img->colorAllocate(0,0,0);
my $red = $img->colorAllocate(255,0,0);
my $green = $img->colorAllocate(0,255,0);
# Ecriture de la legende en haut de l'image :
$img -> string(gdMediumBoldFont, 2,10, "Liste des situations : ",$black);
$img -> string(gdSmallFont, 10,20, "S1 : SAGE_Embryonic_stem_cell_H1_normal_p31_CL_SHE17",$black);
$img -> string(gdSmallFont, 10,30, "S2 : SAGE_Embryonic_stem_cell_H1_normal_p54_CL_SHE16",$black);
$img -> string(gdSmallFont, 10,40, "S3 : SAGE_Embryonic_stem_cell_H9_normal_p38_CL_SHES2",$black);
$img -> string(gdSmallFont, 10,50, "S4 : SAGE_Embryonic_stem_cell_HES3_normal_p16_CL_SHE10",$black);
$img -> string(gdSmallFont, 10,60, "S5 : SAGE_Embryonic_stem_cell_HES4_normal_p36_CL_SHE11",$black);
$img -> string(gdSmallFont, 10,75, "Les lignes commencant par une etoile correspondent aux genes cibles de TEAD2",$black);
# Ecriture de la ligne de titre du tableau gene_cibles
$img -> string(gdGiantFont, 5, 100, "Genes cibles de TEAD2", $black);
$img -> string(gdMediumBoldFont, 100, 130, " S1", $black);
$img -> string(gdMediumBoldFont, 120, 130, " S2", $black);
$img -> string(gdMediumBoldFont, 140, 130, " S3", $black);
$img -> string(gdMediumBoldFont, 160, 130, " S4", $black);
$img -> string(gdMediumBoldFont, 180, 130, " S5", $black);
# Ecriture de la ligne de titre du tableau gene_non_cibles
$img -> string(gdGiantFont, 250, 100, "Autres genes des concepts", $black);
$img -> string(gdMediumBoldFont, 350, 130, " S1", $black);
$img -> string(gdMediumBoldFont, 370, 130, " S2", $black);
$img -> string(gdMediumBoldFont, 390, 130, " S3", $black);
$img -> string(gdMediumBoldFont, 410, 130, " S4", $black);
$img -> string(gdMediumBoldFont, 430, 130, " S5", $black);
my ($y1,$y2) = (145,165);
my ($x1, $x2);
foreach my $tag (keys(%infos_cible))
{
my $S1 = $infos_cible{$tag}->{'SAGE_Embryonic_stem_cell_H1_normal_p31_CL_SHE17'};
my $S2 = $infos_cible{$tag}->{'SAGE_Embryonic_stem_cell_H1_normal_p54_CL_SHE16'};
my $S3 = $infos_cible{$tag}->{'SAGE_Embryonic_stem_cell_H9_normal_p38_CL_SHES2'};
my $S4 = $infos_cible{$tag}->{'SAGE_Embryonic_stem_cell_HES3_normal_p16_CL_SHE10'};
my $S5 = $infos_cible{$tag}->{'SAGE_Embryonic_stem_cell_HES4_normal_p36_CL_SHE11'};
($x1, $x2) = (100, 120);
&draw_line($tag, $S1, $S2, $S3, $S4, $S5, 'left');
($y1,$y2) = ($y1+20, $y2+20);
}
($y1,$y2) = (145,165);
foreach my $tag (keys(%infos_non_cible))
{
my $S1 = $infos_non_cible{$tag}->{'SAGE_Embryonic_stem_cell_H1_normal_p31_CL_SHE17'};
my $S2 = $infos_non_cible{$tag}->{'SAGE_Embryonic_stem_cell_H1_normal_p54_CL_SHE16'};
my $S3 = $infos_non_cible{$tag}->{'SAGE_Embryonic_stem_cell_H9_normal_p38_CL_SHES2'};
my $S4 = $infos_non_cible{$tag}->{'SAGE_Embryonic_stem_cell_HES3_normal_p16_CL_SHE10'};
my $S5 = $infos_non_cible{$tag}->{'SAGE_Embryonic_stem_cell_HES4_normal_p36_CL_SHE11'};
($x1, $x2) = (350, 370);
&draw_line($tag, $S1, $S2, $S3, $S4, $S5, 'right');
($y1,$y2) = ($y1+20, $y2+20);
}
# make sure we are writing to a binary stream
binmode STDOUT;
# Convert the image to PNG and print it on standard output
print $img->png;
sub draw_line
{
my ($tag, $S1, $S2, $S3, $S4, $S5, $col) = @_;
if($col eq 'left')
{
$img -> string(gdSmallFont, 5, $y1, "* $tag", $black);
}
else
{
$img -> string(gdSmallFont, 250, $y1, " $tag", $black);
}
if($S1 == 1)
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$red);
}
else
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$green);
}
($x1, $x2) = ($x1 + 20, $x2 + 20);
if($S2 == 1)
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$red);
}
else
{
$img -> filledRectangle($x1,$y1,$x2,$y2, $green);
}
($x1, $x2) = ($x1 + 20, $x2 + 20);
if($S3 == 1)
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$red);
}
else
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$green);
}
($x1, $x2) = ($x1 + 20, $x2 + 20);
if($S4 == 1)
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$red);
}
else
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$green);
}
($x1, $x2) = ($x1 + 20, $x2 + 20);
if($S5 == 1)
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$red);
}
else
{
$img -> filledRectangle($x1,$y1,$x2,$y2,$green);
}
} |
Partager