Technical development: Difference between revisions
Amy Suo Wu (talk | contribs) No edit summary |
Amy Suo Wu (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
==pulling categories from mediawiki(SNPedia)== | ==CGI Extravaganza! pulling categories from mediawiki(SNPedia)== | ||
* | *local cgi with Fako & Natasha (feb,15th). From the terminal (local host), this script pulls categories (default on 10) from SNPedia. | ||
<source lang="python"> | <source lang="python"> |
Revision as of 22:38, 15 February 2011
CGI Extravaganza! pulling categories from mediawiki(SNPedia)
- local cgi with Fako & Natasha (feb,15th). From the terminal (local host), this script pulls categories (default on 10) from SNPedia.
#!/usr/bin/python
import json, urllib2
search = u'Rs1001179' # quotes are string.
url = u'http://www.snpedia.com/api.php?action=query&format=json&redirects=true&generator=categories&titles=' + search
request = urllib2.Request(url)
response = urllib2.urlopen(request)
result = response.read()
f = json.loads(result)
print type(f)
g = json.dumps(f) # dump makes back into a string
print type(g)
for page in f['query']['pages'].itervalues():
print page['title']
Meaning that rsid number Rs1001179 is found in 10 categories in following results (terminal):
<type 'dict'>
<type 'str'>
Category:On chip Illumina Human 1M
Category:SNPs on chromosome 11
Category:In dbSNP
Category:Is a snp
Category:On chip 23andMe v3
Category:On chip HumanOmni1Quad
Category:On chip 23andMe v2
Category:Has population
Category:On chip 23andMe v1
Category:Has genotype