[Bioperl-l] Displaying an alignment using Bio::Graphics

Jason Stajich jason at cgt.duhs.duke.edu
Tue Aug 10 09:34:30 EDT 2004


I think Lincoln wrote something recently - I don't remember where he put
it though.

I do it with HTML - this produces LARGE files though since every base gets
an html tag.  The number matching is for intron mapping stuff so wouldn't
be necessary for you.

$aln is an alignment
#consed colors
%COLOR = ('A' => 'green', 'T' => 'red','G'=> 'orange', 'C' => 'blue');
        my $str = IO::String->new();
        my $out = Bio::AlignIO->new(-format => 'clustalw',
                                    -linelength => 100,
                                    -fh     => $str);
        $out->write_aln($aln);
        $out->close();
        my $str2 = IO::String->new(${$str->string_ref});
        print $outfh "<pre>\n";
        while(<$str2>) {
            if( /^CLUSTAL|MUSCLE/ ) {
            } elsif( /^(\s*\S+\s+)(\S+)(\s*\d*\s*)$/ox ) {
                my ($pre,$seq,$post) = ($1,$2,$3);
                # add 'bold' tags
                $seq =~ s/(\d+)/<b>$1<\/b>/g;
                $seq =~ s/(A+)/<font color="$COLOR{'A'}">$1<\/font>/g;
                $seq =~ s/(C+)/<font color="$COLOR{'C'}">$1<\/font>/g;
                $seq =~ s/(G+)/<font color="$COLOR{'G'}">$1<\/font>/g;
                $seq =~ s/(T+)/<font color="$COLOR{'T'}">$1<\/font>/g;
                $_ = join('',$pre,$seq,$post);
            }
            print $outfh $_;
        }
        print $outfh "<\/pre>\n<\/html>\n";

Or for AA
# shapely color table from
#http://info.bio.cmu.edu/Courses/BiochemMols/RasFrames/SHAPELY.HTM
my %SHAPELYPEPCOLOR = ('D'    => 'A00042',  # dark red
                       'T'    => 'A00042',  # dark red
                       'E'    => '660000',  # red-brown
                       'C'    => 'FFFF70',  # bright yellow
                       'M'    => 'B8A042',  # dark yellow
                       'Y'    => 'B8A042',  # dark yellow
                       'K'    => '4747B8',  # blue
                       'R'    => '00007C',  # dark blue
                       'S'    => 'FF4C4C',  # orange
                       'Q'    => 'FF4C4C',  # orange
                       'F'    => '534C42',  # dark grey
                       'P'    => '534C42',  # dark grey
                       'W'    => '534C42',  # dark grey
                       'N'    => 'FF7C70',  # peach
                       'G'    => 'C8C8C8',  # grey
                       'V'    => 'C8C8C8',  # grey
                       'I'    => '004C00',  # dark green
                       'L'    => '455E45',  # grey-green
                       'A'    => '8CFF8C',  # light green
                       'H'    => '7070FF',  # pale blue
                       );
my %PEPCOLOR = %AMINOPEPCOLOR;
       # pep seqs
       $str = IO::String->new();
       $out = Bio::AlignIO->new(-format => 'clustalw',
                                 -linelength => 100,
                                 -fh     => $str);
        $out->write_aln($aln);
        $out->close();
        $str2 = IO::String->new(${$str->string_ref});
        print $outfhp "<pre>\n";
        $out->close();
        while(<$str2>) {
            if( /^CLUSTAL|MUSCLE/ ) {
            } elsif( /^(\s*\S+\s+)(\S+)(\s*\d*\s*)$/ox ) {
                my ($pre,$seq,$post) = ($1,$2,$3);
                # add 'bold' tags for intron phase
                $seq =~ s/(\d+)/<b>$1<\/b>/g;
                # base becomes base with font color tag
                $seq =~ s/([DTECMYKRSQFPWNGVILAH])/<font color="$PEPCOLOR{$1}">$1<\/font>/g;
                $_ = join('',$pre,$seq,$post);
            }
            print $outfhp $_;
        }
        print $outfhp "<\/pre>\n<\/html>\n";



On Tue, 10 Aug 2004, Iain Wallace wrote:

> Hi all,
>
> I was wondering if any one knows how to display a multiple sequence
> alignment using the Bio::Graphics modules.
> Ideally I would like to colour in certain columns depending on a mask that I
> have created ?
> (FYI The particular project is to colour in the columns of a test alignment
> which have corresponing columns in a reference alignment).
>
> thanks
>
> Iain Wallace
>
>
>
> ____________
> Virus checked by G DATA AntiVirusKit
> Version: AVK 12.0.594 from 19.09.2003
> Virus news: www.antiviruslab.com
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu


More information about the Bioperl-l mailing list