Skip to content

Commit

Permalink
Move Run accession regex to the schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed Aug 12, 2024
1 parent 75058d3 commit 6bed4a9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
3 changes: 2 additions & 1 deletion eva_sub_cli/etc/eva_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@
"runAccessions": {
"type": "array",
"items": {
"type": "string"
"type": "string",
"pattern": "^(E|D|S)RR[0-9]{6,}$"
},
"description": "List of run accessions linking to the raw data used in this analysis if applicable (e.g. SRR576651, SRR576652)"
}
Expand Down
6 changes: 1 addition & 5 deletions eva_sub_cli/semantic_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ def check_all_analysis_run_accessions(self):
json_path = f'/{ANALYSIS_KEY}/{idx}/{ANALYSIS_RUNS_KEY}'
if analysis[ANALYSIS_RUNS_KEY]:
for run_acc in analysis[ANALYSIS_RUNS_KEY]:
match = re.match('(E|D|S)RR[0-9]{6,}', run_acc)
if not match:
self.add_error(json_path, f'Invalid run accession format for {run_acc}')
else:
self.check_accession_in_ena(run_acc, 'Run', json_path)
self.check_accession_in_ena(run_acc, 'Run', json_path)

@retry(tries=4, delay=2, backoff=1.2, jitter=(1, 3))
def check_accession_in_ena(self, ena_accession, accession_type, json_path):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_semantic_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,9 @@ def test_check_all_analysis_run_accessions(self):
checker.check_all_analysis_run_accessions()
assert checker.errors == []

metadata["analysis"].append({'runAccessions': ['SRR00000A']})
metadata["analysis"].append({'runAccessions': ['SRR00000000001']})

checker.check_all_analysis_run_accessions()
assert checker.errors == [
{'property': '/analysis/1/runAccessions', 'description': 'Invalid run accession format for SRR00000A'},
{'property': '/analysis/2/runAccessions', 'description': 'Run SRR00000000001 does not exist in ENA or is private'}]
{'property': '/analysis/1/runAccessions', 'description': 'Run SRR00000000001 does not exist in ENA or is private'}]

0 comments on commit 6bed4a9

Please sign in to comment.