Giter Club home page Giter Club logo

varsome-api-client-python's Issues

Create VERSION file

Hi there

It would be really nice if you can create a VERSION file and some certain of LOGCHANGE in order to keep a track of all the changes that you incorporate in this repo.
A good idea may be to use the "Releases" tool in github.

We ask for this feature because we use the API for python in a really sensitive environment and we need some kind of control for the versions for our dependencies.

Thank you very much

simpleVCFClient.py needs refactoring

simpleVCFClient.py has similar problems as run.py and batchRequestClient.py (fixed in #2).

  • reference genome is int, instead of str
  • has batching implemented which doesn't play well with the client, which itself batches by default
  • inconsistent line length, longest line is 144 char

Invalid token header

from varsome_api.client import VarSomeAPIClient
api_key = 'Your token'
api = VarSomeAPIClient(api_key, api_url="https://stable-api.varsome.com")
result = api.lookup('chr7-140453136-A-T',params={'add-source-databases':'gnomad-exomes,refseq-transcripts'},ref_genome='hg19')

HTTPError Traceback (most recent call last)
File ~/.local/lib/python3.8/site-packages/varsome_api/client.py:104, in VarSomeAPIClientBase._make_request(self, path, method, params, json_data)
103 self.logger.info("Content length %s" % len(r.content))
--> 104 r.raise_for_status()
105 return r

File /usr/lib/python3/dist-packages/requests/models.py:940, in Response.raise_for_status(self)
939 if http_error_msg:
--> 940 raise HTTPError(http_error_msg, response=self)

HTTPError: 401 Client Error: Unauthorized for url: https://stable-api.varsome.com/lookup/chr7-140453136-A-T/hg19?add-source-databases=gnomad-exomes%2Crefseq-transcripts

During handling of the above exception, another exception occurred:

VarSomeAPIException Traceback (most recent call last)
Cell In [16], line 4
2 api_key = 'Your token'
3 api = VarSomeAPIClient(api_key, api_url="https://stable-api.varsome.com/")
----> 4 result = api.lookup('chr7-140453136-A-T',params={'add-source-databases':'gnomad-exomes,refseq-transcripts'},ref_genome='hg19')

File ~/.local/lib/python3.8/site-packages/varsome_api/client.py:183, in VarSomeAPIClient.lookup(self, query, params, ref_genome)
181 if ref_genome is not None and not self.query_is_variant_id(query):
182 url = self.ref_genome_lookup_path % (query, ref_genome)
--> 183 return self.get(url, params=params)

File ~/.local/lib/python3.8/site-packages/varsome_api/client.py:124, in VarSomeAPIClientBase.get(self, path, params)
123 def get(self, path, params=None):
--> 124 response = self._make_request(path, "GET", params=params)
125 return response.json()

File ~/.local/lib/python3.8/site-packages/varsome_api/client.py:112, in VarSomeAPIClientBase._make_request(self, path, method, params, json_data)
110 if r.headers["Content-Type"] == "application/json":
111 error_message = response.json().get("detail", None)
--> 112 raise VarSomeAPIException(response.status_code, error_message)
113 raise VarSomeAPIException("", "Unknown http error %s" % e)
114 except Timeout as e:

VarSomeAPIException: 401 (Invalid token header. Token string should not contain spaces.)

The link generated in the output works if I copy and paste it in new browser

HTTPError: 401 Client Error: Unauthorized for url: https://stable-api.varsome.com/lookup/chr7-140453136-A-T/hg19?add-source-databases=gnomad-exomes%2Crefseq-transcripts

error 401 when running the example

Trying to run the example I got this error:

(venv) lab-cccnrc 13:04:51 >  varsome_api_run.py -g hg19 -q 'chr7-140453136-A-T' -p add-all-data=1

Traceback (most recent call last):
  File "/Users/cccnrc/Applications/varsome/venv/lib/python3.7/site-packages/varsome_api/client.py", line 87, in _make_request
    r.raise_for_status()
  File "/Users/cccnrc/Applications/varsome/venv/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.varsome.com/lookup/chr7-140453136-A-T/hg19?add-all-data=1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/cccnrc/Applications/varsome/venv/bin/varsome_api_run.py", line 127, in <module>
    annotate_variant(sys.argv[1:])
  File "/Users/cccnrc/Applications/varsome/venv/bin/varsome_api_run.py", line 70, in annotate_variant
    result = api.lookup(query[0], params=request_parameters, ref_genome=ref_genome)
  File "/Users/cccnrc/Applications/varsome/venv/lib/python3.7/site-packages/varsome_api/client.py", line 154, in lookup
    return self.get(url, params=params)
  File "/Users/cccnrc/Applications/varsome/venv/lib/python3.7/site-packages/varsome_api/client.py", line 105, in get
    response = self._make_request(path, "GET", params=params)
  File "/Users/cccnrc/Applications/varsome/venv/lib/python3.7/site-packages/varsome_api/client.py", line 95, in _make_request
    raise VarSomeAPIException(response.status_code, error_message)
varsome_api.client.VarSomeAPIException: 401 (Authentication credentials were not provided.)

schema() raises 404 Error

additionally, requesting 10190091015942290001 as per the api examples raises 404

Python 3.6.4 |Anaconda, Inc.| (default, Dec 21 2017, 15:39:08) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from variantapi.client import VariantAPIClient
>>> 
>>> with open('./varsome_api_key', 'r') as f:
...     key = f.read()
... 
>>> varsome_api = VariantAPIClient(key)
>>> 
>>> varsome_api.schema()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./variantapi/client.py", line 95, in schema
    return self.get(self.schema_lookup_path)
  File "./variantapi/client.py", line 77, in get
    response = self._make_request(path, "GET", params=params)
  File "./variantapi/client.py", line 65, in _make_request
    if r.headers['Content-Type'] == "application/json" else None)
variantapi.client.VariantApiException: 404 (Not Found: either you're requesting an invalid URI or the resource in question doesn't exist)
>>> 
>>> varsome_api.lookup('10190091015942290001')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./variantapi/client.py", line 106, in lookup
    return self.get(self.lookup_path % (query, ref_genome), params=params)
  File "./variantapi/client.py", line 77, in get
    response = self._make_request(path, "GET", params=params)
  File "./variantapi/client.py", line 65, in _make_request
    if r.headers['Content-Type'] == "application/json" else None)
variantapi.client.VariantApiException: 404 (Not Found: either you're requesting an invalid URI or the resource in question doesn't exist)

How could I input chr2:83300000:106000000:dup to get result In Varsome api?

Hi,

I have a problem about Varsome api in Linux use Like this

Varsome api support to find this format cnv? or What is correct input method ?

thanks!

``
(varsome) [luohaosen@P-01 Varsome_test]$ varsome_api_run.py -u https://stable-api.varsome.com -q chr2%3A83300000%3A106000000%3Adup -g hg19 -p add-all-data=1 expand-pubmed-articles=0 -o ./test.json
Traceback (most recent call last):
File "/ifs1/home/luohaosen/software/anaconda3/envs/varsome/lib/python3.9/site-packages/varsome_api/client.py", line 104, in _make_request
r.raise_for_status()
File "/ifs1/home/luohaosen/software/anaconda3/envs/varsome/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://stable-api.varsome.com/lookup/chr2%3A83300000%3A106000000%3Adup/hg19?add-all-data=1&expand-pubmed-articles=0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/ifs1/home/luohaosen/software/anaconda3/envs/varsome/bin/varsome_api_run.py", line 190, in
annotate_variant()
File "/ifs1/home/luohaosen/software/anaconda3/envs/varsome/bin/varsome_api_run.py", line 110, in annotate_variant
result = api.lookup(
File "/ifs1/home/luohaosen/software/anaconda3/envs/varsome/lib/python3.9/site-packages/varsome_api/client.py", line 183, in lookup
return self.get(url, params=params)
File "/ifs1/home/luohaosen/software/anaconda3/envs/varsome/lib/python3.9/site-packages/varsome_api/client.py", line 124, in get
response = self._make_request(path, "GET", params=params)
File "/ifs1/home/luohaosen/software/anaconda3/envs/varsome/lib/python3.9/site-packages/varsome_api/client.py", line 112, in _make_request
raise VarSomeAPIException(response.status_code, error_message)
varsome_api.client.VarSomeAPIException: 404 (Not found)
``

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.