Python SDK for WeGene
$ pip install wegene
To query data from WeGene, one need a valid OAuth2 access token authorized by the user.
import wegene
wegene.Configuration.o_auth_access_token = '<A Valid Access Token with Proper Scope>'
Use wegene.WeGeneUser().get_user()
to get user data
profile_id = ''
try:
user = wegene.WeGeneUser().get_user()
print(user.profiles[0].id)
print(user.profiles[0].format)
print(user.profiles[0].name)
except Exception as e:
print(e.response_body)
Use wegene.Allele().get_allele(profile_id, locations)
to get allele data
try:
allele = wegene.Allele().get_allele(profile_id, ['rs182549'])
print(allele)
except Exception as e:
print(e.response_body)
Use wegene.Athletigen().get_athletigen(profile_id, report_id)
to get athletigen data
try:
athletigen = wegene.Athletigen().get_athletigen(profile_id, 1487)
print(athletigen.caseid)
print(athletigen.description)
print(athletigen.rank)
print(athletigen.genotypes.data[0].rsid)
print(athletigen.genotypes.data[0].genotype)
except Exception as e:
print(e.response_body)
Use wegene.Skin().get_skin(profile_id, report_id)
to get skin data
try:
skin = wegene.Skin().get_skin(profile_id, 1522)
print(skin.caseid)
print(skin.description)
print(skin.rank)
print(skin.genotypes.data[0].rsid)
print(skin.genotypes.data[0].genotype)
except Exception as e:
print(e.response_body)
Use wegene.Psychology().get_psychology(profile_id, report_id)
to get psychology data
try:
psychology = wegene.Psychology().get_psychology(profile_id, 1557)
print(psychology.caseid)
print(psychology.description)
print(psychology.rank)
print(psychology.genotypes.data[0].rsid)
print(psychology.genotypes.data[0].genotype)
except Exception as e:
print(e.response_body)
Use wegene.Risk().get_risk(profile_id, report_id)
to get health risk data
try:
risk = wegene.Risk().get_risk(profile_id, 88)
print(risk.caseid)
print(risk.description)
print(risk.risk)
print(risk.genotypes.data[0].rsid)
except Exception as e:
print(e.response_body)
Use wegene.Health().get_metabolism(profile_id, report_id)
to get health metabolism info
Use wegene.Health().get_traits(profile_id, report_id)
to get genetic traits info
Use wegene.Health().get_drug(profile_id, report_id)
to get drug response info
Use wegene.Health().get_carrier(profile_id, report_id)
to get disease carrier info
try:
carrier = wegene.Health().get_drug(profile_id, 184)
print(carrier.caseid)
print(carrier.description)
print(carrier.genotypes.data[0].rsid)
for allele in carrier.genotypes.data:
print(allele.genotype)
print(allele.tsummary)
except Exception as e:
print(e.response_body)
Use wegene.Ancestry().get_ancestry(profile_id)
to get user ancestry composition
try:
ancestry = wegene.Ancestry().get_ancestry(profile_id)
print(ancestry.block.chinese_nation)
print(ancestry.area.han_southern)
except Exception as e:
print(e.response_body)
Use wegene.Haplogroups().get_haplogroups(profile_id)
to get user haplogroups
try:
haplogroups = wegene.Haplogroups().get_haplogroups(profile_id)
print(haplogroups.y)
print(haplogroups.mt)
except Exception as e:
print(e.response_body)
Use wegene.Demographics().get_demographics(profile_id)
to get user demographics
try:
demographics = wegene.Demographics().get_demographics(profile_id)
print(demographics.surname)
print(demographics.population)
except Exception as e:
print(e.response_body)
- The SDK is modified on top of the code auto-generated using APIMATIC. Huge thanks to the team as this is a real life saver!!
(The MIT License)
Copyright (c) 2016 Eddie Wu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.