This is the perl code …
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Date;
my $taxon = $ARGV[0]; # Taxonomy identifier of organism.
my $query = "http://www.uniprot.org/uniprot/?query=organism:$taxon&format=fasta&include=yes";
my $file = $taxon . '.fasta';
my $agent = LWP::UserAgent->new;
my $response = $agent->mirror($query, $file);
if ($response->is_success) {
my $results = $response->header('X-Total-Results');
my $release = $response->header('X-UniProt-Release');
my $date = sprintf("%4d-%02d-%02d", HTTP::Date::parse_date($response->header('Last-Modified')));
print "Downloaded $results entries of UniProt release $release ($date) to file $file\n";
}
elsif ($response->code == HTTP::Status::RC_NOT_MODIFIED) {
print "Data for taxon $taxon is up-to-date.\n";
}
else {
die 'Failed, got ' . $response->status_line .
' for ' . $response->request->uri . "\n";
}
I have tried converting this to php…
there are still lines of codes that are in errors: in the else if statement..
If you spotted other errors please comment it here…
Here is what I have tried so far
$taxon = $ARGV[0]; # Taxonomy identifier of organism.
$query = "http://www.uniprot.org/uniprot/?query=organism:$taxon&format=fasta&include=yes";
$file = $taxon . '.fasta';
$response = $agent->mirror($query, $file);
if ($response->is_success) {
$results = $response->header('X-Total-Results');
$release = $response->header('X-UniProt-Release');
$date = sprintf("%4d-%02d-%02d", date_parse($response->header('Last-Modified')));
print "Downloaded $results entries of UniProt release $release ($date) to file $file\n";
}
elsif ($response->code == HTTP::Status::RC_NOT_MODIFIED) {
print "Data for taxon $taxon is up-to-date.\n";
}
else {
die ('Failed, got ' . $response->status_line .
' for ' . $response->request->uri . "\n");
}
Using this WebGet class.