[Bioperl-l] PDB Parser

neeti somaiya neetisomaiya at gmail.com
Wed Aug 22 06:06:38 EDT 2007


Thanks a lot. It worked for me.

use LWP::UserAgent;
use HTTP::Cookies;

$ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt",
                                     autosave => 1));

$request = HTTP::Request->new('GET', '
http://www.pdb.org/pdb/search/smartSubquery.do?smartSearchSubtype=HoldingsQuery&moleculeType=ignore&experimentalMethod=ignore'
);

$response = $ua->request($request);

if ($response->is_success)
{
        print "\nSuccessfully connected to url
http://www.pdb.org/pdb/search/smartSubquery.do?smartSearchSubtype=HoldingsQuery&moleculeType=ignore&experimentalMethod=ignore\n
";

        $request = HTTP::Request->new('GET', '
http://www.pdb.org/pdb/results/tabularForm.do');

        $response = $ua->request($request);

        if ($response->is_success)
        {
                print "\nSuccessfully connected to url
http://www.pdb.org/pdb/results/tabularForm.do\n";

                $request = HTTP::Request->new('GET', '
http://www.pdb.org/pdb/results/tabularReport.do?reportTitle=CustomReport&customReportColumns=
VStructureSummary.structureId~VCitation.title&format=csv');

                $response = $ua->request($request);

                if ($response->is_success)
                {
                        print "\nSuccessfully connected to url
http://www.pdb.org/pdb/results/tabularReport.do?reportTitle=CustomReport&customReportColumns=
VStructureSummary.structureId~VCitation.title&format=csv\n";
                       open(FH,">tabularResults.csv");
                        print FH $response->content;
                        close(FH);
                }
                else
                {
                        die $response->status_line;
                }
        }
        else
        {
                die $response->status_line;
        }
}
else
{
  die $response->status_line;
}


On 8/22/07, Sendu Bala <bix at sendu.me.uk> wrote:
>
> neeti somaiya wrote:
> > Hi,
> >
> > I wanted to automate my pdb script, right from downloading of data. As
> per
> > the solution given by RCSB about custom report for pdb ids and titles
> only,
> > I was trying something like the code below, but it doesnt seem to work
> :-
> >
> > my $url = '
> >
> http://www.pdb.org/pdb/results/tabularReport.do?reportTitle=CustomReport&customReportColumns=
> > VStructureSummary.structureId~VCitation.title&format=csv';
> > use LWP::Simple;
> > my $content = get $url;
> > die "Couldn't get $url" unless defined $content;
> >
> > Can anyone tell how I can do it, if there is any other way to do it, or
> if I
> > am going wrong somewhere, or if it is't possible for this case at all.
>
> Use LWP::UserAgent so you can see what's going on.
>
> my $ua = LWP::UserAgent->new;
> $ua->timeout(10);
> my $response = $ua->get($url);
> if ($response->is_success) {
>    print $response->content;
> }
> else {
>    die $response->status_line;
> }
>
>
> Gives:
> 500 Internal Server Error
>
> Most likely the server is expecting some kind of cookie and falls over
> when you try to visit that url without it. So start where they told you
> to and grab pages successively, keeping any cookies.
>



-- 
-Neeti
Even my blood says, B positive


More information about the Bioperl-l mailing list