Created
January 14, 2015 16:32
-
-
Save cybersiddhu/cdfe1784fd023ecf0de5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use LWP::UserAgent; | |
| use URI::Escape; | |
| use feature qw/say/; | |
| my $query = <<'SPARQL'; | |
| PREFIX up_core:<http://purl.uniprot.org/core/> | |
| PREFIX taxon:<http://purl.uniprot.org/taxonomy/> | |
| PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> | |
| SELECT ?taxonId ?scitName ?comName | |
| WHERE | |
| { | |
| ?taxonId a up_core:Taxon . | |
| ?taxonId rdfs:subClassOf+ taxon:554915 . | |
| ?taxonId up_core:scientificName ?scitName . | |
| OPTIONAL { | |
| ?taxonId up_core:commonName ?comName . | |
| } | |
| } LIMIT 2600 | |
| SPARQL | |
| my $agent = LWP::UserAgent->new(); | |
| my $url = 'http://beta.sparql.uniprot.org'; | |
| $query = uri_escape($query); | |
| my $rurl = $url.'?query='.$query; | |
| my $res = $agent->get($rurl, 'Accept' => 'application/sparql-results+xml'); | |
| if ($res->is_success) { | |
| say $res->decoded_content; | |
| } | |
| else { | |
| say sprintf "%s\t%s\n", $res->code, $res->status_line; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment