Created
May 5, 2010 10:29
-
-
Save dazoakley/390608 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
#! /usr/bin/perl | |
use strict; | |
use LWP; | |
use JSON; | |
# The I-DCC Search URL and default parameters | |
my $idcc_search_url = "http://www.sanger.ac.uk/mouseportal/solr/select"; | |
my $rows = 10; | |
my $start = 0; | |
my $wt = "json"; | |
# Our query term | |
my $query = "cbx"; | |
# Submit our search | |
my $time_begin = time(); | |
my $user_agent = LWP::UserAgent->new(); | |
my $response = $user_agent->post( | |
$idcc_search_url, | |
{ | |
q => $query, | |
rows => $rows, | |
start => $start, | |
wt => $wt | |
} | |
); | |
my $time_end = time(); | |
my $search_time = $time_end - $time_begin; | |
if ( $response->is_success ) { | |
my $json = JSON->new(); | |
my $search_result = $json->decode( $response->content() ); | |
print "--- I-DCC Search Test ---\n\n"; | |
print "Query String: $query\n"; | |
print "Search Time: ".$search_time."s\n"; | |
print "Total Number of Results: ".$search_result->{response}->{numFound}."\n\n"; | |
print "Genes on this page:\n\n"; | |
foreach my $gene ( @{ $search_result->{response}->{docs} } ) { | |
print $gene->{marker_symbol} . " - " . $gene->{marker_name} . "\n"; | |
} | |
print "\n"; | |
} else { | |
die "Unable to contact the search service"; | |
} | |
exit; |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<response> | |
<lst name="responseHeader"> | |
<int name="status">0</int> | |
<int name="QTime">0</int> | |
<lst name="params"> | |
<str name="q">cbx</str> | |
</lst> | |
</lst> | |
<result name="response" numFound="14" start="0"> | |
<doc> | |
<str name="chromosome">13</str> | |
<arr name="entrez_gene_id"> | |
<int>142983</int> | |
</arr> | |
<str name="marker_name">chromobox homolog 3 (Drosophila HP1 gamma), pseudogene 1</str> | |
<str name="marker_symbol">Cbx3-ps1</str> | |
<str name="mgi_accession_id">MGI:1890538</str> | |
<date name="timestamp">2009-03-18T09:06:02.256Z</date> | |
<str name="type">Pseudogene</str> | |
</doc> | |
<doc> | |
<str name="chromosome">13</str> | |
<arr name="entrez_gene_id"> | |
<int>142981</int> | |
</arr> | |
<str name="marker_name">chromobox homolog 3 (Drosophila HP1 gamma), pseudogene 2</str> | |
<str name="marker_symbol">Cbx3-ps2</str> | |
<str name="mgi_accession_id">MGI:1890539</str> | |
<date name="timestamp">2009-03-18T09:06:02.257Z</date> | |
<str name="type">Pseudogene</str> | |
</doc> | |
<doc> | |
<str name="chromosome">UN</str> | |
<arr name="entrez_gene_id"> | |
<int>108048</int> | |
</arr> | |
<str name="marker_name">chromobox related sequence 3 (Drosophila HP1 class)</str> | |
<str name="marker_symbol">Cbx-rs3</str> | |
<str name="mgi_accession_id">MGI:88287</str> | |
<date name="timestamp">2009-03-18T09:06:23.596Z</date> | |
<str name="type">Gene</str> | |
</doc> | |
... | |
... | |
... | |
</result> | |
</response> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment