Scroll to navigation

Bio::Graphics::DrawTransmembrane(3pm) User Contributed Perl Documentation Bio::Graphics::DrawTransmembrane(3pm)


Bio::Graphics::DrawTransmembrane - draw a cartoon of an Alpha-helical transmembrane protein.


  use Bio::Graphics::DrawTransmembrane;
  my @topology = (20,45,59,70,86,109,145,168,194,220);
  ## Simple use - -topology is the only option that is required
  my $im = Bio::Graphics::DrawTransmembrane->new(
      -title => 'This is a cartoon displaying transmembrane helices.',
      -topology => \@topology);
  ## More advanced use
  my %labels = (5 => '5 - Sulphation Site',
                21 => '1st Helix',
                47 => '40 - Mutation',
                60 => 'Voltage Sensor',
                72 => '72 - Mutation 2',
                73 => '73 - Mutation 3',
                138 => '138 - Glycosylation Site',
                170 => '170 - Phosphorylation Site',
                200 => 'Last Helix');
  my $im = Bio::Graphics::DrawTransmembrane->new(-n_terminal=> 'out',
                                  -topology => \@topology,
                                  -bold_helices=> 1,
                                  -labels=> \%labels,
                                  -text_offset=> -15,
                                  -vertical_padding=> 155);
  ## Parse Tmhmm data
  use Bio::Tools::Tmhmm;
  my $im = Bio::Graphics::DrawTransmembrane->new(
      -title=>'Let\'s parse some Tmhmm output...',
      -bold_helices=> 1);
  open(FILE, 'tmhmm.out');
  my $parser = new Bio::Tools::Tmhmm(-fh => \*FILE );
  while(my $tmhmm_feat = $parser->next_result ) {
        ## Load features into DrawTransmembrane object
  close FILE;
  ## Now write the image to a .png file
  open(OUTPUT, ">output.png");
  binmode OUTPUT;
  print OUTPUT $im->png;
  close OUTPUT;


A module to draw a cartoon of an alpha-helical transmembrane protein. It uses GD and allows the image to be written to a .png file.

The options are a set of tag/value pairs as follows:

  Option              Value                                         Default
  ------              -----                                         -------
  -topology           Array containing transmembrane helix          none
                      boundaries. This is the only option that 
                      is required
  -topology_string    Alternative to -topology, provide a string    none
                      containing the topology data in the form
  -n_terminal         Location of the N-terminal of the sequence,   out
                      either 'in' or 'out'
  -title              Title to add to the image                     none
  -inside_label       Label for the inside of the membrane          Cytoplasmic
  -outside_label      Label for the outside of the membrane         Extracellular
  -membrane_label     Label for the membrane                        Plasma Membrane
  -colour_scheme      Colour scheme to use. Current choices are     blue
                      blue, yellow, red, green, pink or white. 
  -labels             Label loops and helices using data from a     none
                      hash, e.g.
                      %labels = (138 => 'Glycosylation Site',
                                 190 => 'Binding Site');
                      The hash key must be numeric, ranges are 
                      not allowed.
  -bold_helices       Draws black boxes round helices               1
  -bold_labels        Draws black boxes round labels                0
  -text_offset        Shift the text labeling the loops. Use a      0 
                      negative value to shift it left, a positive
                      value to shift it right
  -helix_height       Transmembrane helix height                    130
  -helix_width        Transmembrane helix width                     50
  -loop_width         Loop width                                    20
  -vertical_padding   Vertical padding                              140
  -horizontal_padding Horizontal Padding                            150
  -membrane_offset    Offest between helix end and membrane         6
  -short_loop_height  Height of short loops                         90
  -medium_loop_height Height of medium loops                        120
  -long_loop_height   Height of long loops                          150
  -short_loop_limit   Length in residues below which a loop is      15
                      classed as short
  -long_loop_limit    Length in residues above which a loop is      30
                      classed as long
  -loop_heights       Explicitly set heights of each loop, e.g.
                      %loop_heights = (1 => 45,
                                       2 => 220,
                                       3 => 50,
                                       4 => 220,
                                       9 => 70);
                      The key corresponds to the loop number. Both
                      key and value must be numeric. If you use
                      -loop_height and there is a defined height
                      for the current loop then other height values
                      will be overridden
  -n_terminal_height  Height of N-terminal                          150
  -c_terminal_height  Height of C-terminal                          80
  -n_terminal_offset  Shift the N-terminal left by this amount      0
  -c_terminal_offset  Shift the C-terminal right by this amount     0
  -helix_label        Change the 'S' label on each helix. Only 1    S
                      character is allowed
  -show_labels        Display text labels                           on
  -draw_cytosol       Show the cytosol                              false
  -draw_bilayer       Show the membrane                             true
  -draw_loops         Show the loops                                true
  -draw_terminai      Show the terminai                             true
  -draw_helices       Show the helices                              true
  -dontsort           Don't automatically sort the topology array   0
  -ttf_font           Path to TTF font, e.g.                        none 
  -ttf_font_size      Default size for TTF font. Use 7-9 with       8
                      Arial for best results

Height, width, padding and other numerical values can gernerally be left alone. They are useful if your labels consists of a lot of text as this may lead to them overlapping. In this case try increasing the loop_width or helix_width options. -text_offset is also very useful for avoiding overlapping.


Tim Nugent <>

2019-11-25 perl v5.30.0