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 03/12/2012, 10h20   #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 Afficher chaine avec différentes couleurs

Bonjour,
J'écris dans ce post car j'ai un problème similaire.
J'ai en fait une séquence, et je souhaiterai colorer seulement certaines lettres.
Par exemple :
Code :
AGTAATTGTAGTTCATTAGTGTCAGAAAATATCAGAAAAAGAGCATAAAGTGCTTAATTCCGTGAGACAAAAATGGTTGTTGGCACAGCCACAATGCCCCCGGAAATATTGCAAGTGCCCGCGATAAAAAAAGAGCACTCGGAGCTGCTGGAAAACCCTGCGAACTCTAAACCTTGTGATCCCGACGAAACTGCTGAGGAGGG
et je voudrais colorer en rouge les lettres en rouge sur l'exemple sachant que pour chaque séquence que j'aurais, ce ne sera jamais la même place ... J'ai un fichier à part m'indiquant la position de la lettre (nucléotide) dans la séquence.
Comment puis je réaliser cela ?
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/12/2012, 10h24   #2
djibril
Responsable Perl et Outils

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

Informations forums :
Inscription : avril 2004
Messages : 13 536
Points : 31 724
Points : 31 724
Bonjour,

Montre nous ce que tu as fais.
Si tu écris dans un Widget Text, c'est à toi au moment de l'affichage de ta séquence de jouer avec les tags.
__________________
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 03/12/2012, 10h35   #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
Pour le moment j'ai fait quelque chose de très basique
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl
use strict;
use warnings;
 
use Tk;
 
my $phrase ='CGGAAATATTGCAAGTGCCCGCGATAAAAAAAGAGCACTCGGAGCTGCTGGAAAACCCTGCGAACTCTAAACCTTGTGATCCCGACGAAACTGCTGAGGAGGGCGGAAATATTGCAAGTGCCCGCGATAAAAAAAGAGCACTCGGAGCTGCTGGAAAACCCTGCGAACTCTAAACCTTGTGATCCCGACGAAACTGCTGAGGAGGG';
 
my $fenetre_principale = MainWindow->new( -title => 'Text' );
my $widget_texte = $fenetre_principale->Text( )->pack( );
 
$widget_texte->insert('end', $phrase);
 
 
 
MainLoop;
Juste pour écrire la séquence ...
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/12/2012, 11h08   #4
djibril
Responsable Perl et Outils

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

Informations forums :
Inscription : avril 2004
Messages : 13 536
Points : 31 724
Points : 31 724
Du moment où tu as les positions, il devient simple de jouer avec les tags.

Tu te crées un tag rouge par exemple et tu l'applique sur ta séquence au bon index. Voici un exemple de programme :

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
#!/usr/bin/perl
use warnings;
use strict;
use Tk;  
 
my $sequence ='CGCGATAAAAAAAGAGCACTCGGAGCTGCTGGAAAACCCTGCGAACTCTAAACCTTGTGATCCCGACGAAACTGCTGAGGAGGG';
 
my $fenetre_principale = MainWindow->new( -title => 'Text' );
$fenetre_principale->fontCreate( 'FontSequence', 
  -family =>'helvetica', 
  -size   =>'14', 
  -weight =>'bold'
);
 
my $widget_texte = $fenetre_principale->Scrolled('Text', 
  -scrollbars => 's',
  -wrap => 'none',
  -font       => 'FontSequence',
)->pack( qw/ -expand 1 -fill both /);
 
$widget_texte->tagConfigure('ROUGE', 
  -background => '#E3E3E3',
  -foreground => 'red',
  -font       => 'FontSequence',
);
 
$widget_texte->insert('end', $sequence);
 
# Mutation à mettre en rouge dans la séquence
my @PositionsMutation = (10,25,30); 
foreach my $position ( @PositionsMutation ) {
  $widget_texte->tagAdd('ROUGE',"1.$position"); 
}
 
MainLoop;
Je te recommande de lire la documentation de Tk::Text.
__________________
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 03/12/2012, 11h21   #5
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
Merci beaucoup,
Ce scroll est très pratique car j'ai des séquences de tailles variables, mais est il possible de créer un fichier .ps ? Car en fait j'ai énormément de séquences et le plus pratique pour les biologistes est de créer des .ps ou .txt (1 pour chaque séquence) qu'ils puissent ouvrir et regarder pour chacune de leur séquences d’intérêt ...
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/12/2012, 14h36   #6
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
J'ai modifié le script avec ce que je souhaite faire, mais lorsque j’essaie de le sauvegarder dans un fichier, cela me retourne l'erreur suivante :

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
#!/usr/bin/perl
use strict;
use warnings;
use Carp qw(confess);
 
use Getopt::Long;
use Tk;
use Bio::SeqIO;
 
my $fasta_file;
GetOptions("fasta=s" => \$fasta_file);
 
my $in = Bio::SeqIO->new( -file => $fasta_file, '-format' => 'Fasta' );
 
 
 
 # récupération de la séquence
 
while ( my $seq = $in->next_seq()){
 
	my $sequence = $seq->seq ;
	my $fenetre_principale = MainWindow->new( -title => 'Text' );
	$fenetre_principale->resizable( 0, 0 );
	$fenetre_principale->fontCreate( 'FontSequence', 
  		-family =>'helvetica', 
  		-size   =>'14', 
  		-weight =>'bold'
	);
	my $widget_texte = $fenetre_principale->Text( -padx=>70, -pady=>70 )->pack( );
 
	$widget_texte->tagConfigure('ROUGE', 
  		-foreground => 'red',
  		-font       => 'arial',
	);
	$widget_texte->tagConfigure('YELLOW', 
  		-foreground => 'YELLOW',
  		-font       => 'arial',
		-underline => 1,
	);
 
 
	$widget_texte->insert('end', $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('YELLOW',"1.$value");
 
	}
 
 	my $postscript = $fenetre_principale->postscript();
 
	$fenetre_principale->postscript(-file => "tmp.ps",-width => "1000" , -height => "500");
	#MainLoop;
 
 
 
}
Code :
Failed to AUTOLOAD 'MainWindow::postscript' at test_tmp.pl line 51.
Le fichier contient la séquence
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
 
>nos
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
ACTTACAATATCGTAATACTTGTTCAATCGTCGTGGCCGATAGAAATATC
TTACAATCCGAAAGTTGATGAATGGAATTGGTCTGCAACTGGTCGCCTTC
ATTTCGTAAAATGTTCGCTTGCGGCCGAAAAATTTCGATATATCTACAAT
TGATCTACAATCTTTACTAAATTTTGAAAAAGGAACACTTTGAATTTCGA
ACTGTCAATCGTATCATTAGAATTTAATCTAAATTTAAATCTTGCTAAAG
GAAATAGCAAGGAACACTTTCGTCGTCGGCTACGCATTCATTGTAAAATT
TTAAATTTTGACATTCCGCACTTTTTGATAGATAAGCGAAGAGTATTTTT
ATTACATGTATCGCAAGTATTCATTTCAACACACATATCTATATATATAT
ATATATATATATATATATATATATATATATATGTTATATATTTATTCAAT
:
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/12/2012, 14h39   #7
djibril
Responsable Perl et Outils

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

Informations forums :
Inscription : avril 2004
Messages : 13 536
Points : 31 724
Points : 31 724
La méthode postscript ne s'applique uniquement que pour les Widgets CANVAS.
__________________
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 03/12/2012, 14h40   #8
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
D'accord, y a t'il une autre façon de procéder ?
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/12/2012, 15h34   #9
djibril
Responsable Perl et Outils

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

Informations forums :
Inscription : avril 2004
Messages : 13 536
Points : 31 724
Points : 31 724
Non. Pour avoir un postscript, il faut faire du Canvas, donc dessiner et ça devient plus compliqué.
__________________
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 03/12/2012, 15h37   #10
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 je ne peux même pas générer une image ou autre ?
Isabella83 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 00h43.


 
 
 
 
Partenaires

Hébergement Web