Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: what's "plots are not rendered as ASCII art" ?

by Util (Priest)
on Apr 15, 2011 at 03:30 UTC ( [id://899554]=note: print w/replies, xml ) Need Help??


in reply to what's "plots are not rendered as ASCII art" ?

The chart (black picture) that is just above the text "Download PostScript file" is an interactive Java applet; notice that numbers in the legend (upper-right corner) change as you move your cursor across the chart.

Perhaps you could configure that applet to run locally, to achieve the same result after downloading the page? I am not sure what you intend, and this problem is not caused by Perl; you would get the same result with `wget` or `curl`.

Alternately, you could download the (non-interactive) chart as Encapsulated PostScript, and view it without an applet (although you will need the free Win32 Postscript programs GhostScript and GhostView.
This code works for me:

use strict; use warnings; use LWP; my $base_url = 'http://dis.embl.de'; my $protein = 'MSSSTPFDPYALSEHDEERPQNVQSKSRTAELQAEIDDTVGIMRDNINKVAERGE +RLTSI'; my $browser = LWP::UserAgent->new; $browser->env_proxy(); my $response = $browser->post( "$base_url/cgiDict.py", # That's the URL that the real form submits +to. [ key => 'process', SP_entry => '', sequence_string => $protein, smooth_frame => '8', peak_frame => '8', join_frame => '4', fold_coils => '1.20', fold_rem465 => '1.20', fold_hotloops => '1.40', plot_title => '', doApplet => 'true', tango_PH => 7.40, tango_T => 298.15, tango_I => 0.02, tango_TFE => 0.00, fold_tango => 1.00, ] ); die "Error: ", $response->status_line, "\n" unless $response->is_success; my $html = $response->content; my ($eps) = ( $html =~ m{<a href="([^"]+)">Download PostScript file</a +>} ) or die; $response = $browser->get("$base_url/$eps"); die "Error: ", $response->status_line, "\n" unless $response->is_success; my $out_path = 'tmp.eps'; open my $out_fh, '>', $out_path or die "Can't write-open out_file: $!"; print {$out_fh} $response->content; close $out_fh; system( 'C:/Program Files/Ghostgum/gsview/gsview32.exe', $out_path );

Replies are listed 'Best First'.
Re^2: what's "plots are not rendered as ASCII art" ?
by genbank (Novice) on Apr 15, 2011 at 05:09 UTC

    Yeah, it's not a simple picture. This script you provided is so great. However I want to show the webpage normally including the "black chart".


    what about the script as following?


    use strict; use LWP; my $protein = "MSSSTPFDPYALSEHDEERPQNVQSKSRTAELQAEIDDTVGIMRDNINKVAERGE +RLTSI"; my $browser = LWP::UserAgent->new; $browser->env_proxy(); my $response = $browser->post( 'http://dis.embl.de/cgiDict.py', # That's the URL that the real form submits to. [ 'key' => "process", 'SP_entry' => "", 'sequence_string' => $protein, 'smooth_frame' => "8", 'peak_frame' => "8", 'join_frame' => "4", 'fold_coils' => "1.20", 'fold_rem465' => "1.20", 'fold_hotloops' => "1.40", 'plot_title' => "", 'doApplet' => "true", 'tango_PH' => "7.40", 'tango_T' => "298.15", 'tango_I' => "0.02", 'tango_TFE' => "0.00", 'fold_tango' => "1.00", ] ); die "Error: ", $response->status_line, "\n" unless $response->is_success; open(FILE, '>D:\perl\tmp2.html') || die "Can't write-open out_file: $! +"; my $dat=$response->content; $dat=~s/"\//"http:\/\/dis.embl.de\//g; print FILE $dat; close FILE; system('C:\Program Files\Internet Explorer\IEXPLORE.EXE','D:\per +l\tmp2.html');

    This script can make the "black chart" correctly show up at the tmp2.html. The difference between the two script I post is "$dat=~s/"\//"http:\/\/dis.embl.de\//g;". But I don't know what's the function of "$dat=~s/"\//"http:\/\/dis.embl.de\//g;". Could you give me a explanation? Thanks a lot!

      But I don't know what's the function of "$dat=~s/"\//"http:\/\/dis.embl.de\//g;"

      It substitutes "/ with "http://dis.embl.de/, which presumably has the effect that IE will fetch URIs affected by the substitution remotely instead of trying to load them from your local disk (where tmp2.html resides).

      For example:

      my $dat = '<img src="/foo.jpg">'; $dat=~s/"\//"http:\/\/dis.embl.de\//g; print $dat; # <img src="http://dis.embl.de/foo.jpg">
        Wow, thank you very much! I have understood. Thanks again!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://899554]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-24 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found