Bonjour,

J'aimerais savoir si il y a quelque chose à faire au niveau hardware afin d'améliorer la rapidité d'exécution d'un script.

Voici les informations matérielles
OS : Windows XP

Intel(R)
Pentium(R) 4 CPU 2.80 GHz
2.79 GHz, 1.99 Go de RAM


But du script : insertion dans une DB locale (MySQL) d'informations récupérées dans une banque de données publique (GenBank).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/local/bin/perl
 
use strict;
use warnings;
 
 
 
use DBI;
use Bio::DB::GenBank;
 
use Date::Calc qw(:all);
use Time::localtime;
 
use Devel::Size qw(total_size);
use Benchmark::Stopwatch;
 
 
 
my $stopwatch = Benchmark::Stopwatch->new->start;
 
 
 
# paramètre de temps
#-------------------------------
 
my ($start_hour,$start_min,$start_sec) = Now([+1]);
 
 
my $Depart = ctime();
my $Annee = localtime->year() + 1900;
my $Mois = localtime->mon() + 1;
my $Jour = localtime->mday();
my $Heure = localtime->hour();
my $Min = localtime->min();
my $Sec = localtime->sec();
 
# Date pour MySQL     (date du jour)
my $Date = sprintf("%04d",$Annee)."-".sprintf("%02d",$Mois)."-".sprintf("%02d",$Jour)." ".sprintf("%02d",$Heure).":".sprintf("%02d",$Min).":".sprintf("%02d",$Sec);
$Date = quotemeta($Date);
 
$stopwatch->lap('date');
 
 
 
 
# Connexion DB et création table
#-------------------------------
 
my $driver   = "mysql";
my $server   = "localhost";
my $database = "test";
my $url      = "DBI:$driver:$database:$server";
 
my $Table = "test_samson";
 
my ($user, $password ) = PASS();
 
my $DBconnect=DBI->connect( $url, $user, $password ) or die "Failure!\n";
 
 
# efface la table si elle existe déjà
my$sql0="drop table IF exists $Table;";
my$sth0 = $DBconnect->prepare($sql0) or print "prepare error\n";
$sth0->execute or die "Could not execute SQL0 statement ... maybe invalid?";
$sth0->finish;
 
 
# Créer la table
my$sql = "CREATE TABLE $Table  (Accession VARCHAR(30) PRIMARY KEY, GI INT(10), Organism VARCHAR(50), Taxon INT(10), Description TEXT, Seq_length SMALLINT(5),  Sequence LONGTEXT, Date DATE) ENGINE = InnoDB;";
my$sth = $DBconnect->prepare($sql) or print "prepare error\n";
$sth->execute or die "Could not execute SQL statement ... maybe invalid?";
$sth->finish;
 
print "\nTABLE $Table cree\n\n\n";
 
$stopwatch->lap('DB');
 
 
 
 
# Recherche dans Genbank
#--------------------------
 
my $gb = new Bio::DB::GenBank;
 
my $acc = 'AB113023'; 
print "\nAccession : $acc\n\n";
 
eval { $gb->get_Seq_by_acc($acc) };
if ($@) {
	print "ERREUR : pb accession $acc\n";
 
}
else{
	my $info = $gb->get_Seq_by_acc($acc);
 
	$stopwatch->lap('Info');
 
 
	my $total_size = total_size($info);
	print "\$total_size $total_size\n";
	#    23.000 chargement 2 sec to 54.000.000 chargement 3 min
 
	$stopwatch->lap('size');
 
 
	my $gi = $info->primary_id;
	my $desc = $info->description;
	my $seq = $info->seq();
	my $seq_length = length($seq);
 
	$stopwatch->lap('bases');
 
 
	my $organism = "";
	my $taxon = 0;
 
	my @Features = $info->get_SeqFeatures;
	my $FeaturesDNA = $Features[0];
 
 
	foreach my $k (keys %$FeaturesDNA){
 
		if ($k eq "annotation"){ 
 
			my $SousObjet1 = ($FeaturesDNA->{$k});
			my $SousObjet2 = ($SousObjet1->{"_annotation"});
			my $SousObjet3 = ($SousObjet2->{"organism"});
			$organism = ${$SousObjet3}[0];
 
			my $SousObjet4 = ($SousObjet2->{"db_xref"});
			$taxon = ${$SousObjet4}[0];
			$taxon =~ s/\D//g;
			last;
 
		} #if
 
	} # foreach my $k (keys %$FeaturesDNA)
 
	$stopwatch->lap('Features Obj');
 
	my $sql2 = "INSERT INTO $Table (Organism, Taxon, Accession, Gi, Description, Seq_length, Sequence, Date) VALUES ('$organism', '$taxon', '$acc', '$gi', '$desc', '$seq_length', '$seq', '$Date')";
	my $sth2 = $DBconnect->prepare($sql2) or print "prepare error\n";
	$sth2->execute or die "Could not execute SQL statement ... maybe invalid?";
	$sth2->finish;	
 
}
 
 
 
 
 
 
# DECONNEXION A LA BASE DE DONNEES
#-----------------------------------
$DBconnect->disconnect();
 
 
my ($end_hour,$end_min,$end_sec) = Now([+1]);
 
my ($D_y,$D_m,$D_d, $Dh,$Dm,$Ds) =
      Delta_YMDHMS(1, 1, 1, $start_hour, $start_min, $start_sec,
                   1, 1, 1, $end_hour,$end_min,$end_sec);
 
print "Temps d'exécution : ".$Dh." h ".$Dm." min ".$Ds." sec\n";      
 
 
print "\nBenchmark::Stopwatch\n";
print $stopwatch->stop->summary;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
sub PASS{
        my $password_file = "P:/Perl/InfoPass.txt";
        open (FILE, $password_file)  or die "Can't open file\n";
        my @line = <FILE>;
	close (FILE);
        chomp($line[0]);
        chomp($line[1]);
        return ( $line[0], $line[1]);
}

Résultat :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Accession : NC_012658
 
$total_size 53993371
Temps d'exécution : 0 h 3 min 10 sec
 
Benchmark::Stopwatch
NAME                        TIME        CUMULATIVE      PERCENTAGE
 date                        0.000       0.000           0.000%
 DB                          0.322       0.323           0.170%
 Info                        183.328     183.651         96.794%
 size                        3.281       186.933         1.733%
 bases                       0.007       186.939         0.004%
 Features Obj                0.037       186.977         0.020%
 _stop_                      2.425       189.402         1.280%
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Accession : AB113023
 
$total_size 22957
Temps d'exécution : 0 h 0 min 3 sec
 
Benchmark::Stopwatch
NAME                        TIME        CUMULATIVE      PERCENTAGE
 date                        0.000       0.000           0.008%
 DB                          0.531       0.531           15.486%
 Info                        2.844       3.375           82.940%
 size                        0.001       3.376           0.026%
 bases                       0.000       3.376           0.002%
 Features Obj                0.000       3.376           0.002%
 _stop_                      0.053       3.429           1.536%

Ce qui demande le plus de temps est la fonction
Code : Sélectionner tout - Visualiser dans une fenêtre à part
my $info = $gb->get_Seq_by_acc($acc);
provenant du module Bio:B::GenBank

get_Seq_by_acc

Title : get_Seq_by_acc
Usage : $seq = $db->get_Seq_by_acc($acc);
Function: Gets a Seq object by accession numbers
Returns : a Bio::Seq object
Args : the accession number as a string
Note : For GenBank, this just calls the same code for get_Seq_by_id()
Throws : "id does not exist" exception

Y a-t-il quelque chose à faire pour diminuer le temps de récupération de ces données? Apparemment c'est un problème de réseau. Soit une file d'attente à l'entrée de Genbank, soit un téléchargement des données trop lent ... 2.80 GHz est-ce bien?


SVP, je suis biologiste de formation et je ne connais pas grand chose en réseau et hardware, essayez d'utiliser des explications simples.


Merci pour votre aide,