saphetor / varsome-api-client-python Goto Github PK
View Code? Open in Web Editor NEWExample client programs for Saphetor's VarSome annotation API
Home Page: https://api.varsome.com
License: Apache License 2.0
Example client programs for Saphetor's VarSome annotation API
Home Page: https://api.varsome.com
License: Apache License 2.0
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
passing argv to main() is not necessary, since argparse implements sys.argv directly
from the latest push it appears as though the batch size is 200. I have implemented a batch size of 10,000, as per recommendation from Andreas Massouras. Should I switch back to 200?
Running PyVCF-0.6.8/setup.py -q bdist_egg --dist-dir /tmp/easy_install-g03wy5kq/PyVCF-0.6.8/egg-dist-tmp-dtk0mpp9
error: Setup script exited with error in PyVCF setup command: use_2to3 is invalid.
Current workaround: jamescasbon/PyVCF#331 (comment)
Or switching to the faster and maintained cyvcf2
simpleVCFClient.py
has similar problems as run.py
and batchRequestClient.py
(fixed in #2).
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
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.)
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)
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)
``
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.