IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces Graphiques Perl Discussion :

relier action clique bouton


Sujet :

Interfaces Graphiques Perl

  1. #1
    Membre régulier
    Inscrit en
    Janvier 2010
    Messages
    257
    Détails du profil
    Informations forums :
    Inscription : Janvier 2010
    Messages : 257
    Points : 81
    Points
    81
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    FBgn0002962	FBtr0083732
    nanos.fasta
    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
    >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 : 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
    #!/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;

  2. #2
    Responsable Perl et Outils

    Avatar de djibril
    Homme Profil pro
    Inscrit en
    Avril 2004
    Messages
    19 820
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 19 820
    Points : 498 771
    Points
    498 771
    Par défaut
    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 : 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
    #!/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;

  3. #3
    Membre régulier
    Inscrit en
    Janvier 2010
    Messages
    257
    Détails du profil
    Informations forums :
    Inscription : Janvier 2010
    Messages : 257
    Points : 81
    Points
    81
    Par défaut
    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 : 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
    #!/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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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.

  4. #4
    Membre régulier
    Inscrit en
    Janvier 2010
    Messages
    257
    Détails du profil
    Informations forums :
    Inscription : Janvier 2010
    Messages : 257
    Points : 81
    Points
    81
    Par défaut
    En fait j'ai trouvé, je ne définissais pas $current_FBtr au bon endroit :
    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
    #!/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;

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [FLASH MX2004 PRO] PB actions sur Boutons
    Par Mug13 dans le forum Flash
    Réponses: 7
    Dernier message: 01/03/2006, 12h54
  2. Action sur bouton de commande
    Par uloaccess dans le forum Access
    Réponses: 3
    Dernier message: 16/11/2005, 15h53
  3. Pouvoir gérer les actions des boutons dans une classe
    Par Cyborg289 dans le forum Composants
    Réponses: 2
    Dernier message: 08/07/2005, 12h08
  4. [FLASH MX] Action des boutons dans un menu déroulant
    Par zab_paris dans le forum Flash
    Réponses: 1
    Dernier message: 05/07/2005, 18h14
  5. Algorithme spécifier une action à un bouton
    Par KinF dans le forum Langages de programmation
    Réponses: 3
    Dernier message: 09/12/2004, 05h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo