---
name: "Bio::Align::Graphics"
section: "3pm"
platform: "linux"
package: "libbio-perl-perl"
version: "1.7.2-3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/Bio::Align::Graphics"
---

# Bio::Align::Graphics(3pm)

Graphic Rendering of Bio::Align::AlignI Objects

## NAME

Bio::Align::Graphics - Graphic Rendering of Bio::Align::AlignI Objects

## SYNOPSIS

```
  use Bio::Align::Graphics;
  #Get an AlignI object, usually by using Bio::AlignIO
  my $file=shift @ARGV;
  my $in=new Bio::AlignIO(-file=>$file, -format=>'clustalw');
  my $aln=$in->next_aln();
  #Create a new Graphics object
  my $print_align = new Bio::Align::Graphics(align => $aln);
  #Draw the alignment
  $print_align->draw();
```

## DESCRIPTION

Bio::Align::Graphics is a module designed to create image files out of Bio::Align::AlignI objects.  An alignment may be manipulated with various  formatting and highlighting options.

An example:

```
        #!/usr/bin/perl -w
        use Bio::AlignIO;
        use Bio::Align::Graphics;
        use strict;

        #Get an alignment file
        my $file = shift @ARGV;

        #Create an AlignI object using AlignIO
        my $in=new Bio::AlignIO(-file=>$file, -format=>'clustalw');
        #Read the alignment
        my $aln=$in->next_aln();
        #Create some domains for highlighting
        my @domain_start = ( 25 , 50, 80 );
        my @domain_end = ( 40 , 60 , 100 );
        my @domain_color = ( 'red' , 'cyan' , 'green' );

        #Create Labels for the domains
        my @dml = ("CARD", "Proline Rich", "Transmembrane");
        my @dml_start = (25, 50, 80);
        my @dml_end = (40, 60, 100);
        my @dml_color = ("lightpink", "lightblue", "lightgreen");

        #Create individual labels
        my %labels = ( 145 => "Hep-c target");

        my $print_align = new Bio::Align::Graphics( align => $aln,
                                        pad_bottom => 5,
                                        domain_start => \@domain_start,
                                        domain_end => \@domain_end,
                                        dm_color => \@domain_color,
                                        dm_labels => \@dml,
                                        dm_label_start => \@dml_start,
                                        dm_label_end => \@dml_end,
                                        dm_label_color => \@dml_color,
                                        labels => \%labels,
                                        out_format => "png");

        $print_align->draw();
```

## METHODS

This section describes the class and object methods for Bio::Align::Graphics.

Typically you will begin by creating a Bio::Align::Graphics  object, passing it an alignment object created using Bio::AlignIO. The Bio::Align::Graphics-\>*new()* method has a number of  configuration variables that allow you to control the appearance of the final image.

You will then call the *draw()* method to output the final image.

## CONSTRUCTORS

*new()* is the constructor for Bio::Align::Graphics:

- $print\_align = Bio::Align::Graphics-\>new(@options)

  The *new()* method creates a new graphics object.  The options are a set of tag/value pairs as follows:

  ```
    Option         Value                                  Default
    ------         -----                                  -------
    align          Bio::AlignI object                     None, must be
                                                          supplied to draw
                                                          an alignment
    output         Filename to print image to             STDOUT
    out_format     png, jpeg, gif, gd                     png
    font           Size of font, ranging from 1 to 5      2
                   and equal to the standard GD fonts
                   ranging from gdTinyFont to
                   gdGiantFont
    x_label        Draws a scale numbering alignment      true
                   bases along top of image, every x
                   bases are numbered, where x is the
                   block_size option
    y_label        Draws sequence ids of alignment        true
                   along left side of image
    bg_color       Background color of the image          white
    font_color     Color of the font used for drawing     black
                   the alignment characters
    x_label_color  Color of the font used for drawing     red
                   the base scale characters
    y_label_color  Color of the font used for drawing     blue
                   the sequence id characters
    p_color        Colors protein bases according to      false
                   a coloring scheme proposed by W.R.
                   Taylor(Protein Engineering, vol 10
                   no 7, 1997), only works with
                   protein alignments
    pad_top        Additional whitespace characters       5
                   between top of image and x-label
    pad_bottom     Additional whitespace characters       5
                   between bottom of image and
                   alignment
    pad_left       Additional whitespace characters       5
                   between left side of image and
                   y-label
    pad_right      Additional whitespace characters       5
                   between right side of image and
                   alignment
    x_label_space  Additional whitespace characters       1
                   between x_label and alignment
    y_label_space  Additional whitespace characters       1
                   between y_label and alignment
    reference      Characters which are identical to      false
                   the reference sequence are replaced
                   with the match character
    reference_id   Sequence id of the sequence to use     First sequence
                   as the reference                       supplied in alignment
    match_char     Character to replace identical bases   .
                   in aligned sequences
    block_size     Number of bases to group together      10
                   when printing alignment, groups are
                   separated by whitespace
    block_space    Amount of character whitespace to      2
                   separate groups of bases by
    labels         A hash containing labels to be         none
                   printed beneath the alignment,
                   where the keys are the bases to
                   print the values at
    dm_start       An array containing start bases        none
                   for highlighting of segments of
                   the alignment, paired with dm_end
                   option
    dm_end         An array containing end bases          none
                   for highlighting of segments of
                   the alignment, paired with dm_start
                   options
    dm_color       An array containing colors for         silver
                   highlighting segments of bases
                   denoted by the coordinates
                   located in the dm_start and dm_end
                   options
    dml_start      An array containing start bases        none
                   for addition of domain labels
                   underneath the alignment, paired
                   with dml_end
    dml_end        An array containing end bases          none
                   for addition of domain labels
                   underneath the alignment, paired
                   with dml_start
    dml_color      An array containing colors for         silver
                   the domain labels denoted by the
                   coordinates located in the
                   dml_start and dml_end options
    dm_labels      An array containing labels to be       none
                   printed underneath specified
                   domains, each label should
                   correspond with the base position
                   located in the dml_start option

    show_nonsynonymous  Boolean value to turn option      false
                   on or off. If 0 (or undef), option
                   is off. If 1 (or non-0), option is on.
                   Only valid for nucleotide alignments.
                   Output images are wider with this option on.
  ```

  Note that all arrays and hashes must be passed by reference.

## OBJECT METHODS

- $draw\_align-\>*draw()*;

  The *draw()* method draws the image with the options that were specified with *new()*.

- $draw\_align-\>*width()*;

  Get the width of the image created with *new()*, in pixels.

- $draw\_align-\>*height()*;

  Get the height of the image created with *new()*, in pixels.

- $draw\_align-\>*aln\_length()*;

  Get the length of the alignment submitted to *new()*.

- $draw\_align-\>*aln\_format()*;

  Get the format of the alignment submitted to *new()*.

- $draw\_align-\>*no\_sequences()*;

  Get the number of sequences in the alignment submitted to *new()*.

## AUTHORS AND CONTRIBUTORS

William McCaig, \<wmccaig@gmail.com\>

Mikhail Bekarev, \<mbekarev@hunter.cuny.edu\>

Yoezen Hernandez, \<yzhernand@gmail.com\>

Weigang Qiu (Corresponding Developer), \<weigang@genectr.hunter.cuny.edu\>

## COPYRIGHT AND LICENSE

Copyright (C) 2006-2008 by William McCaig

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.

## SEE ALSO

Bio::Align::AlignI, Bio::AlignIO, GD, GD::Simple
