Coder Social home page Coder Social logo

chapplec / varsome-api-client-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saphetor/varsome-api-client-python

1.0 0.0 0.0 273 KB

Example client programs for Saphetor's VarSome annotation API

Home Page: https://api.varsome.com

License: Other

Python 100.00%

varsome-api-client-python's Introduction

Variant API Client

A basic api client implementation for api.varsome.com

This client is still in beta, but it is a good starting point for playing around with the API.

Installation

Either clone the repository from github and place the variantapi package within your code, or do

pip install https://github.com/saphetor/variant-api-client-python/archive/master.zip

API Documentation

Please visit the API documentation to learn how to use the API and what values it provides as a response to lookup requests

How to get an API key

You are generally not required to have an API key to use the API, but without one, though the number of requests you will be able to issue will be limited.

You will also not be able to perform batch requests without an API key.

To obtain an API key please contact us.

Using the client in your code

Using the API client is quite straightforward. Just install the API client package and use the following in your code:

from variantapi.client import VariantAPIClient
# API key is not required for single variant lookups
api_key = 'Your token'
api = VariantAPIClient(api_key)
# if you don't have an API key use
# api = VariantAPIClient()
# fetch information about a variant into a dictionary
result = api.lookup('chr19:20082943:1:G', params={'add-source-databases': 'gnomad-exomes,refseq-transcripts'}, ref_genome='hg19')
# access results e.g. the transcripts of the variant
transcripts = result['refseq_transcripts']
# fetch information for multiple variants
variants = ['chr19:20082943:1:G','chr22:39777823::CAA']
# results will be an array of dictionaries an api key will be required for this request
results = api.batch_lookup(variants, params={'add-source-databases': 'gnomad-exomes,gnomad-genomes'}, ref_genome='hg19')

If errors occur while using the client, an exception will be thrown. You may wish to catch this exception and proceed with your own code logic:

from variantapi.client import VariantAPIClient, VariantApiException
api = VariantAPIClient()
try:
   result = api.lookup('chr19:20082943:1:G', ref_genome='hg64')
except VariantApiException as e:
    # proceed with your code flow e.g.
    print(e) # 404 (invalid reference genome)

Example Usage

You may download and run the run.py python file after installing the package to test the API client directly e.g.:

./run.py -g hg19 -q 'chr19:20082943:1:G' -p add-all-data=1

For batch requests, you may pass multiple values after the -q flag, but you will need a token to do that. For example:

./run.py -k 'your token' -g hg19 -q 'rs113488022' 'chr19:20082943:1:G' -p add-source-databases=gnomad-exomes,gnomad-genomes

Run

./run.py -h

for a list of available options.

To view available request parameters (used by the params method parameter) refer to an example at api.varsome.com or the API documentation.

To understand how annotation properties are included in the JSON response, please refer to the relevant schema.

varsome-api-client-python's People

Contributors

chapplec avatar ckopanos avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.