Je n'arrive pas à récupérer les valeurs :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
sub Output_file {
	my ($main, $ref_filetypes, $output_file) = @_;

Code complèt :
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/usr/bin/perl
 
use strict;
use warnings;
# use utf8;
 
use Bio::SeqIO;
use FileHandle;
use List::MoreUtils qw(any);
use File::Basename;
 
 
use Tk;
use Tk::BrowseEntry; 
 
 
 
# correspondances types de fichiers et extensions
my %correspondence = (
	abi => ['.ab', '.abi1'],
	ace => '.ace',
	agave => '.xml',
	alf => '.alf',
	bsml => '.bsml',
	bsml_sax => '.bsml', 
	chaosxml => '.xml',
	ctf => '.ctf',
	embl => ['.ebl', '.emb', '.dat'],
	excelx => '.exl', 
	exp => '.exp ',
	fasta => ['.fsa', '.fast', '.seq', '.fa', '.nt', '.aa'],
	fastq => '.fastq',
	flybase_chadoxml => '.xml',
	game => '.xml',
	gcg => '.gcg',
	genbank => ['.gbank', '.genbank'],
	interpro => '.xml',
	phd => '.phred',
	pir => '.pir',
	pln => '.pln',
	raw => '.txt',
	scf => '.scf',
	swiss => '.SwissProt',
	tab => '.txt',
	tigr => '.xml',
	tigrxml => '.xml',
	tigr => '.xml',
	ncbi => '.xml',
	ztr => '.ztr', 
);
 
my @filetypes;
foreach ( sort keys %correspondence ) {
  push @filetypes, [$_, $correspondence{$_} ];
}
push @filetypes, [ 'Tous les fichiers', '*' ];
 
my $main = MainWindow->new(
    -background => 'blue',
    -title      => 'Formatage de fichier',
);
$main->minsize( 250, 150 );
 
 
my $InFileLabel = $main->Label(
    -text       => "Fichier d'entrée : ",
    -background => 'blue',
    -foreground => 'white',
    -justify    => 'left',
);
 
 
my $input_file;
 
my $InputLabel = $main->Button(
    -text             => 'sélection',
    -activeforeground => 'red',
    -borderwidth      => 5,
    -command          => [ \&Input_file, $main, \@filetypes, \$input_file],
);
 
 
my $InTypeLabel = $main->Label(
    -text       => "Type du fichier d'entrée : ",
    -background => 'blue',
    -foreground => 'white',
);
 
my $in_format;
 
my $InTypeEntry = $main->BrowseEntry(-variable => \$in_format);
 
$InTypeEntry->insert("end", sort keys %correspondence);
 
 
 
 
 
my $OutTypeLabel = $main->Label(
    -text       => "Type du fichier de sortie : ",
    -background => 'blue',
    -foreground => 'white',
);
 
my $output_file;
 
my $OutputLabel = $main->Button(
    -text             => 'sélection',
    -activeforeground => 'red',
    -borderwidth      => 5,
    -command          => [ \&Output_file, $main, \@filetypes, \$output_file],
); 
 
my $OutFileLabel = $main->Label(
    -text       => "Fichier de sortie : ",
    -background => 'blue',
    -foreground => 'white',
    -justify    => 'left',
);
 
 
 
my $out_format;
 
my $OutTypeEntry = $main->BrowseEntry(-variable => \$out_format);
$OutTypeEntry->insert("end", sort keys %correspondence);
 
# bouton calculer
my $btn_execute = $main->Button(
    -text             => 'Formatage',
    -activeforeground => 'red',
    -borderwidth      => 5,
    -command          => [ \&Execute, $main, \$input_file, $in_format, \$output_file, $out_format],
);
 
# bouton quitter
my $btn_quitter = $main->Button(
    -text             => 'Quitter',
    -activeforeground => 'red',
    -borderwidth      => 5,
    -command          => \&Quitter,
);
 
# Effet clavier, touche entrée
$main->bind( 'Tk::Entry','<Return>', sub { $btn_execute->invoke(); } );
 
# Placement de mes widgets
 
$InFileLabel->grid( -row => 0, -column => 0, -sticky => 'w' );
$InputLabel->grid( -row => 0, -column => 1, -sticky => 'w', -pady => 20,);
 
$InTypeLabel->grid( -row => 1, -column => 0, -sticky => 'w' );
$InTypeEntry->grid( -row => 1, -column => 1, -sticky => 'w', -columnspan => 2);
 
$OutFileLabel->grid( -row => 2, -column => 0, -sticky => 'w');
$OutputLabel->grid( -row => 2, -column => 1, -sticky => 'w', -pady => 20,);
 
$OutTypeLabel->grid( -row => 3, -column => 0, -sticky => 'w' );
$OutTypeEntry->grid( -row => 3, -column => 1, -sticky => 'w', -columnspan => 2);
 
$btn_execute->grid( -row => 4, -column => 0, -pady => 20, );
$btn_quitter->grid( -row => 4, -column => 2, -pady => 20 );
 
 
 
MainLoop;
 
 
sub Quitter {
    exit(0);
}
 
sub Input_file {
	my ($main, $ref_filetypes, $input_file) = @_;
 
	${$input_file} = $main->getOpenFile(
	  -filetypes => $ref_filetypes,
	);
}
 
 
sub Output_file {
	my ($main, $ref_filetypes, $output_file) = @_;
 
	${$output_file} = $main->getSaveFile(
	  -filetypes => $ref_filetypes,
	);
}
 
 
sub Error {
 
	my ($main, $message) = @_;
 
        # fenêtre d'erreur
        #--------------------
        my $error_frame = $main->Toplevel(
            -title      => 'MESSAGE D\'ERREUR',
            -background => 'red',
        );
        $error_frame->minsize( 250, 50 );
 
        $error_frame->Label(
            -text =>
                "Le fichier $message est invalide",
            -background => 'red',
	    -font => "courrier 10 bold",
            -foreground => 'black',
        )->pack;
 
}
sub Execute {
 
	my ($main, $input_file, $in_format, $output_file, $out_format) = @_;
 
	if (! -e ${$input_file}){
		&Error ($main, "d'entrée :  $input_file");
	}
 
	if (! -e ${$output_file}){
		&Error ($main, "de sortie :  $output_file");	
	}
 
	# récupération des fichiers
	#----------------------------
 
	my ( $in_name, $in_dir, $in_ext ) = fileparse( ${$input_file}, qr/\.[^.]*/ );
 
	# extension choisie par l'utilisateur : $out_ext_cho
	my ( $out_name, $out_dir, $out_ext_cho ) = fileparse( ${$output_file}, qr/\.[^.]*/ );
 
 
 
	# vérification que $infile et $in_format correspondent
	# ne se fait automatiquement via Bio::SeqIO qui ne renvoie
	# pas de message d'erreur 
	if (defined $in_ext){
 
		# plusieurs possibilités d'extension
		if ( ref($correspondence{$in_format}) eq 'ARRAY' ){
			# si l'extension n'est pas valide, on affiche un message d'erreur
			unless (any { $in_format =~ m/$_/ } @{$correspondence{$in_format}}){
				&Error ($main, "d'entrée :  type $in_format ne correspond pas à l'extension $in_format\n");	
			}
		}
		# une seule possibilité d'extension
		elsif ($in_ext ne $correspondence{$in_format}){
			&Error ($main, "d'entrée :  type $in_format ne correspond pas à l'extension $in_format\n");		
		}		
	}
 
	# vérification que $in_format et $out_format soient différents
 
 
 
 
 
 
	# extension imposée : $out_ext (si l'extension choisie n'est pas valide)
	my $out_ext;
 
	# vérification que $out_ext_cho soit défini
	# vérification que l'extension choisie pour 
	# le fichier de sortie soit possible
	if (defined $out_ext_cho){
 
		# plusieurs possibilités d'extension
		if ( ref($correspondence{$out_format}) eq 'ARRAY' ){
			# si l'extension est valide, on garde le choix de l'utilisateur
			if (any { $out_format =~ m/$_/ } @{$correspondence{$out_format}}){
				$out_ext = $out_ext_cho;
			}
			# sinon, on prend la première de la liste
			else {
				$out_ext = $correspondence{$out_format}->[0];
			}
		}
		# une seule possibilité d'extension
		else{
				$out_ext = $correspondence{$out_format};
		}		
	}
	# aucune extension n'a été définie par l'utilisateur
	else{
 
		# recherche de l'extension du fichier de sortie
		# si plusieurs sont possibles, création d'une liste déroulante
		# permettant le choix à l'utilisateur
		if ( ref($correspondence{$out_format}) eq 'ARRAY' ){
 
			$out_ext = $correspondence{$out_format}->[0];
		}
		else{
			$out_ext = $correspondence{$out_format};
		}
	}
 
 
	# création des 2 objets Bio::SeqIO
	my $in  = Bio::SeqIO->new(-file => ${$input_file} , '-format' => $in_format);
	my $out = Bio::SeqIO->new(-file => '>'.${$output_file} , '-format' => $out_format);
 
	# récupération et formatage des données
	while ( my $seq = $in->next_seq() ) {
		$out->write_seq($seq);
	}
 
}
Où est mon erreur? Merci.