X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=bin%2Fget_genecard_results;h=051e39da7e7d54dfcdda7cac17abcb8df8a3b1ba;hb=dd8ec1d4cecf282940831171ef0f796570d781fd;hp=634522700283854853b6fd7c8a0485cc1b154bea;hpb=d09b67e0af77d6f2818e41d6b4d648cff651c79d;p=function2gene.git diff --git a/bin/get_genecard_results b/bin/get_genecard_results index 6345227..051e39d 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 @@ -82,7 +82,7 @@ my %options = (debug => 0, 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_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)) {