Précédent   Forum du club des développeurs et IT Pro > Autres langages > Perl > Interfaces Graphiques
Interfaces Graphiques Forum d'entraide pour les interfaces graphiques en Perl (TK, GTK, Tk-Zinc, 2D et 3D avec OpenGPL, ....). Avant de poster, veuillez consulter la FAQ Perl/Tk , les cours Perl.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 04/12/2012, 14h24   #1
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
Par défaut relier action clique bouton

Bonjour à tous,
Je suis en train d'essayer de faire une petite interface graphique avec Perl donc vous trouverez le code ci dessous(qui fonctionne mais qui ne fait rien !).
Les 2 fichiers (que je ne passe pas en argument) sont :
gene_trans_max_cx.txt
Code :
FBgn0002962	FBtr0083732
nanos.fasta
Code :
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
>FBgn0002962;FBtr0083732;nos-RA;2349
TTAGTTGGCGCGTAGCTTTACCACAAAATTCCTGGAATTGCCGTACGCTT
CGCAGTTGTTTCAAGTTGTCTAAGGGACATACGATTTTTTTTGCCTCTGC
GTCACGATTTTAACCCAAAAGCGAGTTTAGTTACATGTACATTATTATTA
GATAAAGAAGTATCGCGAATACTTCAGTTGAATAAACTGTGCTTGGTTTT
TGGGTGAGGATTTGTGGAAAGTAGAGTGCGCGATAACCGTAACTTTCGAC
CCGGATTTTCGCCATGTTCCGCAGCAACTTGGAGGGCAGTGGCGCAGCAG
CAGTAGGTGTTGCAAATCCCCCCTCGTTGGCTCAGTCTGGAAAGATTTTC
CAATTGCAGGATAACTTTTCTGCTTTTCACGCCAGAGGAGGGCTCAACAT
TCTGGGCCTGCAGGACATGTATTTGGATACCAGTGGGGCCAACTCGTCGG
CCACTTTGAGTCCGCCCATTACGCCGGTGACCCCTGACCCGTCGACGTCT
GCGCAGTCGACGCACTTCCCTTTTCTGGCCGACAGCGCAGCCACCGCCAA
TTCGCTCCTTATGCAGCGACAGTACCACTACCACTTGCTGCTCCAGCAGC
AGCAGCAACTGGCCATGGCGCAGCACCAATTGGCGCTGGCTGCATCAGCG
GCAGCGGCTAGTGCGAGTCACCAGCAAACGGACGAGATTGCGCGATCCTT
GAAAATCTTTGCGCAGGTGACGACGGGCGCAGCAGAAAATGCGGCTGGCT
CGATGCAGGATGTGATGCAGGAGTTCGCGACCAATGGCTATGCCAGCGAT
GATCTCGGTCGCATGTCCTACGGGAGTGCTCCGCCACAGGTGCAAATGCC
ACCGCAGCAGCAGCATCAGCAACAGCAGGGGCTGCACCTGCCACTGGGCC
GCAATCCTGCCCAGCTGCAGACCAATGGCGGCAACTTAATGCCCATTCCA
CTCGCCACCCACTGGCTGAACAACTACCGGGAGCATCTGAACAACGTGTG
GCGAAACATGTCGTATATACCAGCCGCTCCCAATACAATGGGTTTGCAGG
CCCAAACAGCGGCCACTGTGTCCACCAATCTCGGCGTGGGAATGGGTCTG
GGATTGCCCGTGCAGGGCGAACAGCTGCGCGGAGCTTCCAATTCCAGTAA
CAATAATAACAACAACAACAAGGTGTACAAGCGTTACAACAGCAAGGCCA
AAGAGATCAGCCGCCACTGCGTCTTTTGTGAGAATAACAACGAACCAGAG
GCGGTTATCAATAGCCACTCAGTGCGAGATAACTTTAACCGAGTGCTGTG
CCCCAAACTACGCACCTACGTGTGCCCCATCTGCGGGGCATCTGGGGACT
CGGCGCACACGATTAAGTACTGCCCCAAGAAGCCGATCATCACCATGGAG
GATGCGATCAAGGCGGAATCGTTCCGCCTAGCCAAGAGCAGTTACTACAA
GCAACAGATGAAGGTTTAGAGAGGGCGAATCCAGCTCTGGAGCAGAGGCT
CTGGCAGCTTTTGCAGCGTTTATATAACATGAAATATATATACGCATTCC
GATCAAAGCTGGGTTAACCAGATAGATAGATAGTAACGTTTAAATAGCGC
CTGGCGCGTTCGATTTTAAAGAGATTTAGAGCGTTATCCCGTGCCTATAG
ATCTTATAGTATAGACAACGAACGATCACTCAAATCCAAGTCAATAATTC
AAGAATTTATGTCTGTTTCTGTGAAAGGGAAACTAATTTTGTTAAAGAAG
Je souhaite que quand l'utilisateur entre le nom du gène dans Entry (dans l'exemple FBgn0002962), cela m'affiche la séquence quand j'appuie sur "Sequence". Mais je ne vois pas comment faire .... quelqu'un pourrait m'aider ?

Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::EntryCheck;
use Bio::SeqIO;
 
# sequence des transcripts
my $fasta_file ='nanos.fasta';
my $value;
 
my $in = Bio::SeqIO->new( -file => $fasta_file, '-format' => 'Fasta' );
open(my $trans_cx, "<", "gene_trans_max_cx.txt") ;
my $FBgn_entry;
my(%hash_cx,%hash_sequence);
 
# creation d'un hash avec FBgn => FBtr associé de façon a trouver le transcript du gène en entrée
while(<$trans_cx>){
	chomp;
	my($FBgn_cx,$FBtr_cx)=split /\t/,$_;
	$hash_cx{$FBgn_cx}->{'transcript'}=$FBtr_cx;
}
# creation d'un hash avec id transcript > sequence
while ( my $seq = $in->next_seq()){
	my $id = $seq->primary_id ;
	my($FBgn,$FBtr,$name,$length)=split /;/,$id;
 
	my $sequence = $seq->seq ;
	$hash_sequence{$FBtr}->{'sequence'} =$sequence;
 
}
 
my $fenetre_principale = MainWindow->new( -title => 'Tk::EntryCheck' );
$fenetre_principale->Label( -text => 'Gene (FBgn) : ')->pack();
my $entry = $fenetre_principale->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry,
)->pack(); 
 
# sequence du transcript
$fenetre_principale->Button( 
	-text => 'Sequence', 
	# que faire quand on appuie sur Afficher
	-command =>  sub { 
    print "$hash_cx{$FBgn_entry}->{'transcript'}\n";
},
)->pack();  
my $mycanvas = $fenetre_principale->Scrolled('Canvas',
	-scrollbars=>'oe',
)->pack();
 
my $widget_texte = $fenetre_principale->Scrolled('Text', 
	-scrollbars => 'oe',
	-setgrid=>'single',
)->pack();
 
$widget_texte->tagConfigure('ROUGE', 
  		-foreground => 'red',
  		-font       => 'arial',
);
$widget_texte->tagConfigure('YELLOW', 
  	-foreground => 'BLACK',
  	-font       => 'FontSequence',
	-underline => 1,
);
$widget_texte->tagConfigure('bold', 
	-font => "helvetica 10 bold"
);
 
 
MainLoop;
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/12/2012, 14h57   #2
djibril
Responsable Perl et Outils

 
Avatar de djibril
 
Homme
Inscription : avril 2004
Messages : 13 570
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 33
Localisation : France

Informations forums :
Inscription : avril 2004
Messages : 13 570
Points : 31 787
Points : 31 787
Bonjour,

À voir ton prog, il faut mettre FBtr0083732 dans le champ .
Ensuite, pour mettre la séquence dans le widget, c'est la méthode insert.
Essaye de lire la FAQ, j'y ai mis beaucoup d'exemples.

Exemple :
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::EntryCheck;
use Bio::SeqIO;
 
# sequence des transcripts
my $fasta_file ='nanos.fasta';
my $value;
 
my $in = Bio::SeqIO->new( -file => $fasta_file, '-format' => 'Fasta' );
open(my $trans_cx, "<", "gene_trans_max_cx.txt") ;
my $FBgn_entry;
my(%hash_cx,%hash_sequence);
 
# creation d'un hash avec FBgn => FBtr associé de façon a trouver le transcript du gène en entrée
while(<$trans_cx>){
	chomp;
	my($FBgn_cx,$FBtr_cx)=split /\t/,$_;
	$hash_cx{$FBgn_cx}->{'transcript'}=$FBtr_cx;
}
# creation d'un hash avec id transcript > sequence
while ( my $seq = $in->next_seq()){
	my $id = $seq->primary_id ;
	my($FBgn,$FBtr,$name,$length)=split /;/,$id;
 
	my $sequence = $seq->seq ;
	$hash_sequence{$FBtr}->{'sequence'} =$sequence;
 
}
 
my $fenetre_principale = MainWindow->new( -title => 'Tk::EntryCheck' );
$fenetre_principale->Label( -text => 'Gene (FBgn) : ')->pack();
my $entry = $fenetre_principale->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry,
); 
 
my $mycanvas = $fenetre_principale->Scrolled('Canvas',
	-scrollbars=>'oe',
);
 
my $widget_texte = $fenetre_principale->Scrolled('Text', 
	-scrollbars => 'oe',
	-setgrid=>'single',
);
 
# sequence du transcript
my $bouton = $fenetre_principale->Button( 
	-text => 'Sequence', 
	# que faire quand on appuie sur Afficher
	-command =>  sub { 
    print "$hash_cx{$FBgn_entry}->{'transcript'}\n";
    $widget_texte->insert('end', $hash_sequence{$FBgn_entry}->{'sequence'});
	},
);
 
$entry->pack();  
$bouton->pack();  
$mycanvas->pack();  
$widget_texte->pack();  
 
 
$widget_texte->tagConfigure('ROUGE', 
  		-foreground => 'red',
  		-font       => 'arial',
);
$widget_texte->tagConfigure('YELLOW', 
  	-foreground => 'BLACK',
  	-font       => 'FontSequence',
	-underline => 1,
);
$widget_texte->tagConfigure('bold', 
	-font => "helvetica 10 bold"
);
 
 
MainLoop;
__________________
Pas de questions technique par messagerie privée (lisez les règles du forum Perl) et pour les nouveaux !
djibril est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/12/2012, 15h09   #3
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
Oui en fait j'ai mis print "FBtr0083732", juste pour essayer ! Ce que je veux c'est mettre la séquence , j'avais essayé de cette façon, car en fait,en entrée je prends le FBgn, et il faut que je cherche le FBtr associé alors j'avais fait comme ceci :
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::EntryCheck;
use Bio::SeqIO;
 
# sequence des transcripts
my $fasta_file ='nanos.fasta';
my $value;
 
my $in = Bio::SeqIO->new( -file => $fasta_file, '-format' => 'Fasta' );
open(my $trans_cx, "<", "gene_trans_max_cx.txt") ;
my $FBgn_entry;
my(%hash_cx,%hash_sequence);
 
# creation d'un hash avec FBgn => FBtr associé de façon a trouver le transcript du gène en entrée
while(<$trans_cx>){
	chomp;
	my($FBgn_cx,$FBtr_cx)=split /\t/,$_;
	$hash_cx{$FBgn_cx}->{'transcript'}=$FBtr_cx;
}
# creation d'un hash avec id transcript > sequence
while ( my $seq = $in->next_seq()){
	my $id = $seq->primary_id ;
	my($FBgn,$FBtr,$name,$length)=split /;/,$id;
 
	my $sequence = $seq->seq ;
	$hash_sequence{$FBtr}->{'sequence'} =$sequence;
 
}
 
my $fenetre_principale = MainWindow->new( -title => 'Tk::EntryCheck' );
$fenetre_principale->Label( -text => 'Gene (FBgn) : ')->pack();
my $entry = $fenetre_principale->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry,
); 
 
my $current_FBtr= $hash_cx{$FBgn_entry}->{'transcript'};
 
my $mycanvas = $fenetre_principale->Scrolled('Canvas',
	-scrollbars=>'oe',
);
 
my $widget_texte = $fenetre_principale->Scrolled('Text', 
	-scrollbars => 'oe',
	-setgrid=>'single',
);
 
# sequence du transcript
my $bouton = $fenetre_principale->Button( 
	-text => 'Sequence', 
	# que faire quand on appuie sur Afficher
	-command =>  sub { 
    print "$hash_cx{$FBgn_entry}->{'transcript'}\n";
    $widget_texte->insert('end', $hash_sequence{$current_FBtr}->{'sequence'});
	},
);
 
$entry->pack();  
$bouton->pack();  
$mycanvas->pack();  
$widget_texte->pack();  
 
 
$widget_texte->tagConfigure('ROUGE', 
  		-foreground => 'red',
  		-font       => 'arial',
);
$widget_texte->tagConfigure('YELLOW', 
  	-foreground => 'BLACK',
  	-font       => 'FontSequence',
	-underline => 1,
);
$widget_texte->tagConfigure('bold', 
	-font => "helvetica 10 bold"
);
 
 
MainLoop;
Mais j'ai l'erreur :
Code :
1
2
3
Use of uninitialized value $FBgn_entry in hash element at test_entry.pl line 40, <GEN0> line 1.
FBtr0083732
Use of uninitialized value $current_FBtr in hash element at test_entry.pl line 57, <GEN0> line 1.
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/12/2012, 15h26   #4
Isabella83
Nouveau Membre du Club
 
Inscription : janvier 2010
Messages : 200
Détails du profil
Informations forums :
Inscription : janvier 2010
Messages : 200
Points : 35
Points : 35
En fait j'ai trouvé, je ne définissais pas $current_FBtr au bon endroit :
Code :
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::EntryCheck;
use Bio::SeqIO;
 
# sequence des transcripts
my $fasta_file ='nanos.fasta';
my $value;
 
my $in = Bio::SeqIO->new( -file => $fasta_file, '-format' => 'Fasta' );
open(my $trans_cx, "<", "gene_trans_max_cx.txt") ;
my $FBgn_entry;
my(%hash_cx,%hash_sequence);
 
# creation d'un hash avec FBgn => FBtr associé de façon a trouver le transcript du gène en entrée
while(<$trans_cx>){
	chomp;
	my($FBgn_cx,$FBtr_cx)=split /\t/,$_;
	$hash_cx{$FBgn_cx}->{'transcript'}=$FBtr_cx;
}
# creation d'un hash avec id transcript > sequence
while ( my $seq = $in->next_seq()){
	my $id = $seq->primary_id ;
	my($FBgn,$FBtr,$name,$length)=split /;/,$id;
 
	my $sequence = $seq->seq ;
	$hash_sequence{$FBtr}->{'sequence'} =$sequence;
 
}
 
my $fenetre_principale = MainWindow->new( -title => 'Tk::EntryCheck' );
$fenetre_principale->Label( -text => 'Gene (FBgn) : ')->pack();
my $entry = $fenetre_principale->Entry( 
	-background => 'white',
	-textvariable => \$FBgn_entry,
); 
 
my $mycanvas = $fenetre_principale->Scrolled('Canvas',
	-scrollbars=>'oe',
);
 
my $widget_texte = $fenetre_principale->Scrolled('Text', 
	-scrollbars => 'oe',
	-setgrid=>'single',
);
 
# sequence du transcript
my $bouton = $fenetre_principale->Button( 
	-text => 'Sequence', 
	# que faire quand on appuie sur Afficher
	-command =>  sub { 
	my $current_FBtr=$hash_cx{$FBgn_entry}->{'transcript'};
	#print "$hash_cx{$FBgn_entry}->{'transcript'}\n";
	$widget_texte->insert('end', $hash_sequence{$current_FBtr}->{'sequence'});
	# Mutation à mettre en rouge dans la séquence
	my @PositionsMutation = (10,25,30); 
	my @PositionPi =(55,56,57,58,59,60,61,62,63,64,65,66,1001,1002,1003,1004,1005,1006,1007);
	foreach my $position ( @PositionsMutation ) {
  		$widget_texte->tagAdd('ROUGE',"1.$position"); 
	}
 
	foreach my $value(@PositionPi){
		$widget_texte->tagAdd('bold',"1.$value");
 
	}
 
 
 
 
	},
);
 
$entry->pack();  
$bouton->pack();  
$mycanvas->pack();  
$widget_texte->pack();  
 
 
$widget_texte->tagConfigure('ROUGE', 
  		-foreground => 'red',
  		-font       => 'arial',
);
$widget_texte->tagConfigure('YELLOW', 
  	-foreground => 'BLACK',
  	-font       => 'FontSequence',
	-underline => 1,
);
$widget_texte->tagConfigure('bold', 
	-font => "helvetica 10 bold"
);
 
 
MainLoop;
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 22h18.


 
 
 
 
Partenaires

Hébergement Web