Question: Download all SRA of one species
0
gravatar for nhaituan
22 months ago by
nhaituan0
nhaituan0 wrote:

I try to run the code below

!/usr/bin/python2.7

import json, urllib

query = '"Vibrio cholerae O1"[Organism]"'

params = {'db':'sra', 'term':query, 'usehistory':'y', 'retmode':'json',}
url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi' stream = urllib.urlopen(url, urllib.urlencode(params)) answer = json.loads(stream.read()) webenv = answer["esearchresult"]["webenv"] query_key = answer["esearchresult"]["querykey"]

params = {'db':'sra', 'save':'efetch', 'rettype':'runinfo', 'WebEnv':webenv, 'query_key':query_key,} url = 'http://trace.ncbi.nlm.nih.gov/Traces/sra/sra.cgi' outfile = 'runinfo.csv' urllib.urlretrieve(url, data=urllib.urlencode(params), filename=outfile)

#

Up to line answer = json.loads(stream.read()) It prompts error :

answer = json.loads(stream.read()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded

Is there any solution or suggestion, it would be highly appreciated.

software error • 591 views
ADD COMMENTlink modified 22 months ago • written 22 months ago by nhaituan0
0
gravatar for nhaituan
22 months ago by
nhaituan0
nhaituan0 wrote:

url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi'

change to

url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi'

Than I can get it works

ADD COMMENTlink written 22 months ago by nhaituan0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1636 users visited in the last hour