[Bioperl-l] coloring subseq

Andreas Kahari ak at ebi.ac.uk
Fri Mar 26 08:52:46 EST 2004

On Fri, Mar 26, 2004 at 01:14:10PM +0100, KHOUEIRY pierre wrote:
> Hello,
> Anybody can help me to color a subseq in Bioperl.. Per example, I have a 
> subseq of "NPYCEWKCPVHNYIPNWLKLA" in wich i like to color
> H and C in blue and P and K in red...
> Any suggestions would be appreciated
> Thanks...

This would be colors in a Unix console window, in HTML, in a PNG
file, or where?

Here's a short way of doing it by applying HTML <font> tags with
a color attribute (I'm not sure this is the correct usage of the
tag in HTML, but it shouldn't be hard to modify):


$seq =~ s/([NC])/<font color="blue">\1<\/font>/g;
$seq =~ s/([PK])/<font color="red">\1<\/font>/g;

print "$seq\n";

|(==)| Andreas Kähäri      EMBL, European Bioinformatics Institute
|=)(=|                     Wellcome Trust Genome Campus
|(==)| DAS Project Leader  Hinxton, Cambridgeshire, CB10 1SD
|=)(=| Ensembl Developer   United Kingdom

More information about the Bioperl-l mailing list