X-Git-Url: https://git.donarmstrong.com/?p=function2gene.git;a=blobdiff_plain;f=bin%2Fget_genecard_results;h=017f1e1b2b76957fbb7c67e90fd7f0d075811ede;hp=634522700283854853b6fd7c8a0485cc1b154bea;hb=50e9739109c91b53ab620b462255f71a0b870f95;hpb=d09b67e0af77d6f2818e41d6b4d648cff651c79d diff --git a/bin/get_genecard_results b/bin/get_genecard_results index 6345227..017f1e1 100755 --- a/bin/get_genecard_results +++ b/bin/get_genecard_results @@ -68,8 +68,8 @@ BEGIN{ } use IO::File; -use URI::ParamMunge; -use LWP::UserAgent; +use URI; +use WWW::Mechanize; # XXX parse config file @@ -81,8 +81,8 @@ my %options = (debug => 0, dir => '.', name => '${search}_results_genecard', terms => '-', - genecard_site => 'http://bioinfo.weizmann.ac.il/cards-bin/', - genecard_search_url => 'cardsearch.pl?search_type=keyword%28s%29&search=complement', + genecard_site => 'http://www.genecards.org/cgi-bin/', + genecard_search_url => 'cardsearch.pl?search_type=kwd&mini=no&speed=fast&matches=999999', ); GetOptions(\%options,'format|f=s','database|b=s','name|n=s', @@ -106,24 +106,24 @@ else { $terms = new IO::File $options{terms}, 'r' or die "Unable to open file $options{terms}: $!"; } -my $ua = new LWP::UserAgent(agent=>"DA_get_harvester_results/$REVISION"); - #For every term while (<$terms>) { # Get uids to retrieve chomp; my $search = $_; - my $url = uri_param_munge($options{genecard_site}.$options{genecard_search_url}, - {search => $search, - }, - ); - my $request = HTTP::Request->new('GET', $url); - my $response = $ua->request($request); - $response = $response->content; - my @result_urls = $response =~ m#\s+Display\s*\s*
\s*the\s*complete#sg; - + my $uri = URI->new($options{genecard_site}.$options{genecard_search_url}); + $uri->query_form($uri->query_form(), + search => $search, + ); + my $url = $uri->as_string; + my $mech = WWW::Mechanize->new(agent=>"DA_get_harvester_results/$REVISION"); + $mech->get($url); + my $response = $mech->content(); + my @result_urls = $response =~ m##sg; my $dir_name = eval qq("$options{name}") or die $@; - mkdir("$options{dir}/$dir_name") or die "Unable to make directory $options{dir}/$dir_name $!"; + if (not -d "$options{dir}/$dir_name") { + mkdir("$options{dir}/$dir_name") or die "Unable to make directory $options{dir}/$dir_name $!"; + } # Get XML file my @current_urls; while (@current_urls = map{$options{genecard_site}.$_} splice(@result_urls,0,30)) {