Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] Annotator Help Request

Harish Vutukuru harish.vutukuru at gmail.com
Wed Jul 6 17:48:27 PDT 2011


Hello,

I am trying to use the OBO webservice for annotation and I constantly get
"500 Internal Server Error" while running the sample perl script. at Wed
Jul  6 17:42:29 2011".  I did include my apikey but that did not help. Are
there any known outages with the service?

I am running this script from a Windows XP machine. I am also including the
script with this email.

Thanks
Harish

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
use strict;
use LWP::UserAgent;
use URI::Escape;
use XML::LibXML;

$|=1;

my $AnnotatorURL = 'http://rest.bioontology.org/obs/annotator';

# Sample text
my $text = uri_escape("Diffuse thickening of the aortic valve cusps with
mildly reduced excursion.");

# create a user agent
my $ua = new LWP::UserAgent;
$ua->agent('Annotator Client Example - Perl');
$ua->from('example\@example.org');

# create a parse to handle the output
my $parser = XML::LibXML->new();



# create a POST request
my $req = new HTTP::Request POST => "$AnnotatorURL";
   $req->content_type('application/x-www-form-urlencoded');

my $apikey  = "a5e7cc71-6439-4bd2-91ee-8a687b71d497";
# Set parameters
# Check docs for extra parameters
$req->content("longestOnly=true&"
             ."wholeWordOnly=true&"
             ."withContext=true&"
             ."filterNumber=true&"
             ."stopWords=&"
             ."withDefaultStopWords=false&"
             ."isStopWordsCaseSenstive=false&"
             ."minTermSize=3&"
             ."scored=true&"
             ."withSynonyms=true"
             ."ontologiesToExpand=&"
             ."ontologiesToKeepInResult=&"
             ."isVirtualOntologyId=true&"  #Suggest to set to true and use
ontology virtual id
             ."semanticTypes=&"
             ."levelMax=0&"
             ."mappingTypes=null&"
             ."textToAnnotate=$text&"
             ."apikey=$apikey&"
             ."format=xml&"  #Possible values: xml, tabDelimited, text
             ."email=harish.vutukuru\@gmail.com"); #Please change to include
your email address - thanks!


# send request and get response.
my $res = $ua->request($req);


# Check the outcome of the response
if ($res->is_success) {
    my $time = localtime();
    print "Call successful at $time\n";

      print $res->decoded_content;  # this line prints out unparsed response

    # Parse the response
     my ($M_ConceptREF, $M_PhraseREF) = parse_annotator_response($res,
$parser);

    # Print something for the user
    print scalar (keys %{$M_ConceptREF}), " concepts found\n";
    foreach my $c (keys %{$M_ConceptREF}){
        print $c,"\t",
$$M_ConceptREF{$c},"\t","matched\t","$$M_PhraseREF{$c}","\n";
    }
}
else {
    my $time = localtime();
    print $res->status_line, " at $time\n";
    print "Harish Testing :1 \n";
}


###################
# parse response
# TODO: Add clause to not run XML parse subroutine
# if text or tabDelimited format is selected
###################
sub parse_annotator_response {
    my ($res, $parser) = @_;
        my $dom = $parser->parse_string($res->decoded_content);
    my $root = $dom->getDocumentElement();
    my %MatchedConcepts;
    my %MatchedPhrase;

    my $results =
$root->findnodes('/success/data/annotatorResultBean/annotations/annotationBean/concept');
    foreach my $c_node ($results->get_nodelist){
                # Sample XPATH to extract concept info if needed
        print "ID = ", $c_node->findvalue('localConceptId'),"\n";
        print "Name = ", $c_node->findvalue('preferredName'),"\n";
        print "Type = ",
$c_node->findvalue('./semanticTypes/semanticTypeBean[1]/localSemanticTypeId'),"\n";
        print "Type name = ",
$c_node->findvalue('./semanticTypes/semanticTypeBean[1]/name'),"\n\n";

        $MatchedConcepts{$c_node->findvalue('localConceptId')} =
$c_node->findvalue('preferredName');
    }

    my $results =
$root->findnodes('/success/data/annotatorResultBean/annotations/annotationBean/context');
    foreach my $c_node ($results->get_nodelist){
                # Sample XPATH to extract concept info if needed
        print "ID = ", $c_node->findvalue('./term/localConceptId'),"\n";
        print "Match = ", $c_node->findvalue('./term/name'),"\n";
        print "From = ", $c_node->findvalue('from'),"\n";
        print "To = ", $c_node->findvalue('to'),"\n";

        $MatchedPhrase{$c_node->findvalue('./term/localConceptId')} =
$c_node->findvalue('./term/name');
    }
    return (\%MatchedConcepts, \%MatchedPhrase);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20110706/050b3fed/attachment.html>


More information about the bioontology-support mailing list