Hello Anonymous Monk,

Final Update with solution is at the bottom.

I am not really familiar with the Bio::Graphics::DrawTransmembrane as you pointing out at your description but I decided to have a go and try to find out more about it.

By running your code the way that you have posted I came across with the following errors:

use DrawTransmembrane; Can't locate DrawTransmembrane.pm

When I tried to load it:

Warning: Cannot install DrawTransmembrane, don't know what it is. Try the command i /DrawTransmembrane/ to find objects with matching identifiers.

At this point I wonder how your code worked so far, but I decided to test it with the module Bio::Graphics::DrawTransmembrane and continue from there.

When I installed the module, and I added use strict; and use warnings; parameters I came across with these errors:

Global symbol "$topology_final" requires explicit package name at Draw +Transmembrane.pl line 6. Global symbol "@total_top" requires explicit package name at DrawTrans +membrane.pl line 8. Global symbol "$topology_final" requires explicit package name at Draw +Transmembrane.pl line 9. Global symbol "$topology_final" requires explicit package name at Draw +Transmembrane.pl line 11. Global symbol "@total_top" requires explicit package name at DrawTrans +membrane.pl line 18. Global symbol "@total_top" requires explicit package name at DrawTrans +membrane.pl line 19. Global symbol "@total_top" requires explicit package name at DrawTrans +membrane.pl line 28. Execution of DrawTransmembrane.pl aborted due to compilation errors.

If you are wondering why I am using strict and warnings, you can find more information here (Use strict and warnings).

When I fixed the errors, I came across with this error:

Can't locate object method "new" via package "DrawTransmembrane" (perh +aps you forgot to load "DrawTransmembrane"?)

Which makes sense since I can not find the DrawTransmembrane.pm so at this point again I am wondering is it really running your code???? But I changed the command: my $image = DrawTransmembrane->new ( to my $image = Bio::Graphics::DrawTransmembrane->new ( and I got this error:

Not a HASH reference at /usr/share/perl5/Bio/Graphics/DrawTransmembran +e.pm line 125.

Well at this point either your code has some serious errors or you are looking at the wrong direction. Please provide us with a sample of your output or operating code so we can try to assist you somehow.

The test code that I used, according to what you provide us:

#!/usr/bin/perl use strict; use warnings; #use DrawTransmembrane; use Bio::Graphics::DrawTransmembrane; my $topology_final = 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII +IIIIIIIIIIII0IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII +IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIMMMMMMMMMOO +OOOOOOOOOOOOOMMMMMMMIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO +MMMMMMMMMIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMIIIIIIIM +MMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMIIIMMMMMMMMMMMO +OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMIIIIIMMMMMMMMMOOOOO +OOMMMMMMMMMMMIIIMMMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMM +MMMMMMMMIIIIMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMIII +MMMMMMMMMMMOOOOOOOOOOOOOOMMMMMMMMMMMIIIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOO +OOOOOOOOMMMMMMMMMMMIIIMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO +MMMMMMMMM'; my @total_top = (); if($topology_final=~/M/) { while ($topology_final =~/(.)\1*/g) { if ($1 eq "M") { my $start_TM = $-[0] + 1; my $end_TM = $+[0]; push @total_top, $start_TM; push @total_top, $end_TM; } } #my $image = DrawTransmembrane->new( -title=>"topology prediction +image", my $image = Bio::Graphics::DrawTransmembrane->new( -title=>"topolo +gy prediction image", -n_terminal=>'in', -topology=>\@total_top, -bold_helices=> 1, -bold_labels=>1, -text_offset=>-25, -helix_label=>'b', -outside_label=>'Extracellular', -inside_label=>'Periplasm', -membrane_label=>'Membrane', -helix_width=>30, -vertical_padding=>150, -horizontal_padding=>120, -n_terminal_offset=>50, -n_terminal_height=>220, -c_terminal_offset=>30, -c_terminal_height=>220, -helix_label=>'Sheet', -colour_scheme=>'yellow' ); open (OUTPUT, '>', 'test.png'); binmode OUTPUT; print OUTPUT $image->png; close (OUTPUT); }

Ps: In case that some people will try to install the module, I found the process difficult in Linux OS. After some time, by trying to solve many problems I found that can also be installed through Dependencies. You can find more information here libbio-graphics-perl.

Update:

Sample of executable code taken by the Bio::Graphics::DrawTransmembrane, I just added this code in case someone in the future might want to experiment more.

#!/usr/bin/perl use strict; use warnings; use Bio::Graphics::DrawTransmembrane; ## Simple use - -topology is the only option that is required my @topology = (20,45,59,70,86,109,145,168,194,220); ## 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( -title => 'This is a cartoon displaying transmembrane helices.', -n_terminal=> 'out', -bold_helices=> 1, -labels=> \%labels, -text_offset=> -15, -outside_label=>'Lumen', -inside_label=>'Cytoplasm', -membrane_label=>'Membrane', -vertical_padding=> 155, -topology => \@topology, -bold_helices=> 1, ); ## Now write the image to a *.png file open(OUTPUT, ">output.png"); binmode OUTPUT; print OUTPUT $im->png; close OUTPUT;
Final Update With Answer:

After some experimentation with your code, I understood why it was not working. You forgot to load the \%labels. I am still wondering how your code was operating correctly without my small modifications.

Any way, just in case that you are still following this thread the complete answer with working example to your code is given under. You need to modify the label names, I just used the ones from the Bio::Graphics::DrawTransmembrane.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Bio::Graphics::DrawTransmembrane; my $topology_final = 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII +IIIIIIIIIIII0IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII +IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIMMMMMMMMMOO +OOOOOOOOOOOOOMMMMMMMIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO +MMMMMMMMMIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMIIIIIIIM +MMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMIIIMMMMMMMMMMMO +OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMIIIIIMMMMMMMMMOOOOO +OOMMMMMMMMMMMIIIMMMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMM +MMMMMMMMIIIIMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMIII +MMMMMMMMMMMOOOOOOOOOOOOOOMMMMMMMMMMMIIIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOO +OOOOOOOOMMMMMMMMMMMIIIMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO +MMMMMMMMM'; my @total_top = (); if($topology_final=~/M/) { while ($topology_final =~/(.)\1*/g) { if ($1 eq "M") { my $start_TM = $-[0] + 1; my $end_TM = $+[0]; push @total_top, $start_TM; push @total_top, $end_TM; } } } print Dumper(\@total_top); ## More advanced use my %labels = ( 176 => '5 - Sulphation Site', 206 => '1st Helix', 256 => '40 - Mutation', 276 => 'Voltage Sensor', 316 => '72 - Mutation 2', 392 => '73 - Mutation 3', 489 => '138 - Glycosylation Site', 539 => '170 - Phosphorylation Site', 747 => 'Last Helix' ); my $image = Bio::Graphics::DrawTransmembrane->new( -title=>"topology prediction image", -n_terminal=>'in', -topology=>\@total_top, -bold_helices=> 1, -labels=> \%labels, -bold_labels => 1, -text_offset=>-25, -helix_label=>'b', -outside_label=>'Extracellular', -inside_label=>'Periplasm', -membrane_label=>'Membrane', -helix_width=>30, -vertical_padding=>150, -horizontal_padding=>120, -n_terminal_offset=>50, -n_terminal_height=>220, -c_terminal_offset=>30, -c_terminal_height=>220, -helix_label=>'Sheet', -colour_scheme=>'yellow'); open (OUTPUT, '>', 'test.png'); binmode OUTPUT; print OUTPUT $image->png; close (OUTPUT);

I used also Data::Dumper to see your values in the array @total_top so I can determine the position of the labels. The rest of the experimentation I leave it up to you. I still can not figure it out though how your code was working. It still remains a mistery to me.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Can you offer me some tips on this module? by thanos1983
in thread Can you offer me some tips on this module? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.