Skip to content

Commit 583449b

Browse files
committed
Handle errors in SRA metadata
1 parent 5f5313c commit 583449b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

rnaseq_pipeline/sources/sra.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ def read_xml_metadata(path, include_invalid_runs=False) -> List[SraRunMetadata]:
117117
:return:
118118
"""
119119
root = ET.parse(path)
120+
121+
errors = root.find('ERROR')
122+
if errors is not None:
123+
raise RuntimeError(errors.text)
124+
120125
runs = root.findall('EXPERIMENT_PACKAGE/RUN_SET/RUN')
126+
121127
result = []
122128
for run in runs:
123129
srr = run.attrib['accession']

tests/test_sra.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ def test_SRX29529383():
355355
# FIXME: this should be [R1, R2], but it is mislabelled as single-end in SRA
356356
assert run.layout == [R1, I1]
357357

358+
def test_SRX835000():
359+
"""This dataset was not publicly released at the time of writing, so we're making sure we can handle the <ERROR> tag"""
360+
with pytest.raises(RuntimeError, match='SRA Experiment SRX835000 is not public'):
361+
read_xml_metadata(join(test_data_dir, 'SRX835000.xml'))
362+
358363
def test_read_runinfo():
359364
meta = read_runinfo(join(test_data_dir, 'SRX26261721.runinfo'))
360365
assert len(meta) == 2

0 commit comments

Comments
 (0)