Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear friends,
I am trying to use the following module in a project of mine...
https://metacpan.org/pod/Bio::Graphics::DrawTransmembrane

It works fine, but I was wondering, is there a way that I can tilt the bars to have an angle, instead of being vertical?
My code, based on the module, which uses GD-graph, is the following:
use DrawTransmembrane; $topology_final = 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII +IIIIIIIII0IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII +IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIMMMMMMMMMOOOOO +OOOOOOOOOOMMMMMMMIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMM +MMMMMMIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMIIIIIIIMMMM +MMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMIIIMMMMMMMMMMMOOOO +OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMMMIIIIIMMMMMMMMMOOOOOOOM +MMMMMMMMMMIIIMMMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMM +MMMMMIIIIMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMMMMMMMMIIIMMM +MMMMMMMMOOOOOOOOOOOOOOMMMMMMMMMMMIIIIIMMMMMMMMMOOOOOOOOOOOOOOOOOOOOOO +OOOOOMMMMMMMMMMMIIIMMMMMMMOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOMMM +MMMMMM'; @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", -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); }

Any tips would be greatly appreciated... The goal should be to tilt the bars a bit, like, e.g. in:
http://bioinformatics.biol.uoa.gr/TMRPres2D/screens/big4.png

Replies are listed 'Best First'.
Re: Can you offer me some tips on this module?
by thanos1983 (Parson) on Aug 28, 2014 at 13:57 UTC

    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:

    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.

    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.

    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!
      Hello and many thanks for your trouble!
      Yes, first of all I should have written that one must download the module in order for the code to run... Other than that I didn't experience any problems, probably because I wrote the script quite plain (no stricts etc...).
      Your code works smoothly, but actually it doesn't do the main thing I wanted it to do, which is to tilt the bars to the side, and not be vertical. If you take a look at the image created by your code the bars are only vertical. So, any idea on how they can be tilted in a small angle maybe?
      Again many thanks!

        Hello Anonymous Monk,

        Hello and many thanks for your trouble!

        You are welcome, I think it would be easier for you to follow your threads if you where a registered member of the community.

        Moving on, about the code:

        Yes, first of all I should have written that one must download the module in order for the code to run... Other than that I didn't experience any problems, probably because I wrote the script quite plain (no stricts etc...).

        It is not about mentioning that in order to execute the code you need to download the module, it is about the module does not exist in CPAN. Based on your example you use: use DrawTransmembrane;, which when I use it says to me that it dose not exist. The module that exists on CPAN is Bio::Graphics::DrawTransmembrane. So my question was how your code compiles, when you use use DrawTransmembrane; and not use Bio::Graphics::DrawTransmembrane;, at least on my OS it complains that the module dose not exist.

        Moving on, about the answer to your question. Based on what I read on the Bio::Graphics::DrawTransmembrane there is no option to do that for you. So in this case you can try to contact the Author (Tim Nugent) or you can try alternative solutions such as Bio::Graphics::Glyph::pairplot which provide you the option -angle => 45. But as I said I have never used this modules before, so I am not an expert to give you a straight answer on that.

        I final note, I would modify the title of your current question and future questions to something more relevant. What I mean, most people in the forum here need to enter your question to see on which module you are referring to and what kind of tips you are looking for. Now imagine people who are using Google that might have the same question as you, how is it possible for them to find your question and possible an answer? Do not think so, or at least the possibilities are extremely small. So I would recommend to change the title something like (Bio::Graphics::DrawTransmembrane angle modification) or something that you feel closer to your question.

        Well I think I wrote too much, so I will stop somewhere here. I hope this new module is closer to what you are looking for.

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