saketkc / pysradb

Package for fetching metadata and downloading data from SRA/ENA/GEO
https://saketkc.github.io/pysradb
BSD 3-Clause "New" or "Revised" License
303 stars 49 forks source link

[BUG] gse_to_srp problems #219

Closed binbinL closed 2 months ago

binbinL commented 2 months ago

Describe the bug I did the same code few weeks ago, it was ok. But now it broken down Code: from pysradb.sraweb import SRAweb db = SRAweb() srp = db.gse_to_srp('GSE243858') srp

run it on Jupyter

JSONDecodeError Traceback (most recent call last) File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/requests/models.py:971, in Response.json(self, kwargs) 970 try: --> 971 return complexjson.loads(self.text, kwargs) 972 except JSONDecodeError as e: 973 # Catch JSON-related errors and raise as requests.JSONDecodeError 974 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/json/init.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 343 if (cls is None and object_hook is None and 344 parse_int is None and parse_float is None and 345 parse_constant is None and object_pairs_hook is None and not kw): --> 346 return _default_decoder.decode(s) 347 if cls is None:

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/json/decoder.py:337, in JSONDecoder.decode(self, s, _w) 333 """Return the Python representation of s (a str instance 334 containing a JSON document). 335 336 """ --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end()

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx) 354 except StopIteration as err: --> 355 raise JSONDecodeError("Expecting value", s, err.value) from None 356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

JSONDecodeError Traceback (most recent call last) File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/pysradb/sraweb.py:270, in SRAweb.get_esummary_response(self, db, term, usehistory) 269 try: --> 270 esearch_response = request.json() 271 except JSONDecodeError:

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/requests/models.py:975, in Response.json(self, **kwargs) 972 except JSONDecodeError as e: 973 # Catch JSON-related errors and raise as requests.JSONDecodeError 974 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError --> 975 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

SystemExit Traceback (most recent call last) [... skipping hidden 1 frame]

Cell In[10], line 1 ----> 1 srp = db.gse_to_srp('GSE243858') 2 srp

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/pysradb/sraweb.py:775, in SRAweb.gse_to_srp(self, gse, kwargs) 774 gse = [gse] --> 775 gse_df = self.fetch_gds_results(gse, kwargs) 776 gse_df = gse_df.rename( 777 columns={"accession": "study_alias", "SRA": "study_accession"} 778 )

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/pysradb/sraweb.py:714, in SRAweb.fetch_gds_results(self, gse, kwargs) 713 def fetch_gds_results(self, gse, kwargs): --> 714 result = self.get_esummary_response("geo", gse) 716 try:

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/pysradb/sraweb.py:277, in SRAweb.get_esummary_response(self, db, term, usehistory) 272 sys.stderr.write( 273 "Unable to parse esummary response json: {}{}. Aborting.".format( 274 request.text, os.linesep 275 ) 276 ) --> 277 sys.exit(1) 279 # retry again

SystemExit: 1

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last) [... skipping hidden 1 frame]

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2121, in InteractiveShell.showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code) 2118 if exception_only: 2119 stb = ['An exception has occurred, use %tb to see ' 2120 'the full traceback.\n'] -> 2121 stb.extend(self.InteractiveTB.get_exception_only(etype, 2122 value)) 2123 else: 2125 def contains_exceptiongroup(val):

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/IPython/core/ultratb.py:710, in ListTB.get_exception_only(self, etype, value) 702 def get_exception_only(self, etype, value): 703 """Only print the exception type and message, without a traceback. 704 705 Parameters (...) 708 value : exception value 709 """ --> 710 return ListTB.structured_traceback(self, etype, value)

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/IPython/core/ultratb.py:568, in ListTB.structured_traceback(self, etype, evalue, etb, tb_offset, context) 565 chained_exc_ids.add(id(exception[1])) 566 chained_exceptions_tb_offset = 0 567 out_list = ( --> 568 self.structured_traceback( 569 etype, 570 evalue, 571 (etb, chained_exc_ids), # type: ignore 572 chained_exceptions_tb_offset, 573 context, 574 ) 575 + chained_exception_message 576 + out_list) 578 return out_list

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/IPython/core/ultratb.py:1435, in AutoFormattedTB.structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context) 1433 else: 1434 self.tb = etb -> 1435 return FormattedTB.structured_traceback( 1436 self, etype, evalue, etb, tb_offset, number_of_lines_of_context 1437 )

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/IPython/core/ultratb.py:1326, in FormattedTB.structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context) 1323 mode = self.mode 1324 if mode in self.verbose_modes: 1325 # Verbose modes need a full traceback -> 1326 return VerboseTB.structured_traceback( 1327 self, etype, value, tb, tb_offset, number_of_lines_of_context 1328 ) 1329 elif mode == 'Minimal': 1330 return ListTB.get_exception_only(self, etype, value)

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/IPython/core/ultratb.py:1173, in VerboseTB.structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context) 1164 def structured_traceback( 1165 self, 1166 etype: type, (...) 1170 number_of_lines_of_context: int = 5, 1171 ): 1172 """Return a nice text document describing the traceback.""" -> 1173 formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context, 1174 tb_offset) 1176 colors = self.Colors # just a shorthand + quicker name lookup 1177 colorsnormal = colors.Normal # used a lot

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/IPython/core/ultratb.py:1063, in VerboseTB.format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset) 1060 assert isinstance(tb_offset, int) 1061 head = self.prepare_header(str(etype), self.long_header) 1062 records = ( -> 1063 self.get_records(etb, number_of_lines_of_context, tb_offset) if etb else [] 1064 ) 1066 frames = [] 1067 skipped = 0

File /data/lwb/miniconda3/envs/LLPS/lib/python3.9/site-packages/IPython/core/ultratb.py:1131, in VerboseTB.get_records(self, etb, number_of_lines_of_context, tb_offset) 1129 while cf is not None: 1130 try: -> 1131 mod = inspect.getmodule(cf.tb_frame) 1132 if mod is not None: 1133 mod_name = mod.name

AttributeError: 'tuple' object has no attribute 'tb_frame'

To Reproduce Steps to reproduce the behavior: pysradb <command> SRPxxx

Desktop (please complete the following information):

Additional context it print: Unable to parse esummary response json: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

NCBI/eutils202 - WWW Error 500 Diagnostic

Server Error

Your request could not be processed due to a problem on our Web server. This could be a transient problem, please try the query again. If it doesn't clear up within a reasonable period of time, e-mail a short description of your query and the diagnostic information shown below to:

pubmed@nlm.nih.gov - for problems with PubMed
webadmin@ncbi.nlm.nih.gov - for problems with other services

Thank you for your assistance. We will try to fix the problem as soon as possible.


Diagnostic Information:

Error: 500
URL: h t t p : / / e x t - h t t p - e u t i l s . l i n k e r d . n c b i . n l m . n i h . g o v / e n t r e z / e u t i l s / e s e a r c h . f c g i ?
Client: 130.14.22.199
Server: eutils202
Time: Tue Jun 18 23:28:57 EDT 2024

NOTE: The above is an internal URL which may differ from the one you used to address the page.


Rev. 01/04/08

. Will retry once.Unable to parse esummary response json: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

NCBI/eutils202 - WWW Error 500 Diagnostic

Server Error

Your request could not be processed due to a problem on our Web server. This could be a transient problem, please try the query again. If it doesn't clear up within a reasonable period of time, e-mail a short description of your query and the diagnostic information shown below to:

pubmed@nlm.nih.gov - for problems with PubMed
webadmin@ncbi.nlm.nih.gov - for problems with other services

Thank you for your assistance. We will try to fix the problem as soon as possible.


Diagnostic Information:

Error: 500
URL: h t t p : / / e x t - h t t p - e u t i l s . l i n k e r d . n c b i . n l m . n i h . g o v / e n t r e z / e u t i l s / e s e a r c h . f c g i ?
Client: 130.14.18.65
Server: eutils202
Time: Tue Jun 18 23:29:00 EDT 2024

NOTE: The above is an internal URL which may differ from the one you used to address the page.


Rev. 01/04/08

. Aborting.

binbinL commented 2 months ago

error: RuntimeError: Failed to fetch esummary. API rate limit exceeded.

saketkc commented 2 months ago

NCBI seems to be having issues: https://ncbi.nlm.nih.gov/sra/?term=GSE243858 This should resolve on it's own in due course, but if not please feel free to reopen.