Skip to content

Commit

Permalink
Merge pull request #84 from sanger-tol/check_ncbidatasets
Browse files Browse the repository at this point in the history
Check that the JSON coming from `datasets` contains an assembly
  • Loading branch information
muffato authored Oct 18, 2023
2 parents bdc772c + f06f8cf commit 33a8b4e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions bin/validate_datasets_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

import argparse
import json
import sys


def parse_args(args=None):
Description = "Verify the integrity of a JSON file coming from NCBI datasets"

parser = argparse.ArgumentParser(description=Description)
parser.add_argument("NCBI_SUMMARY_JSON", help="NCBI entry for this assembly (in JSON).")
parser.add_argument("--version", action="version", version="%(prog)s 1.0")
return parser.parse_args(args)


def check_json(ncbi_summary):
with open(ncbi_summary) as file_in:
data = json.load(file_in)

assert "reports" in data


def main(args=None):
args = parse_args(args)
check_json(args.NCBI_SUMMARY_JSON)


if __name__ == "__main__":
sys.exit(main())
2 changes: 2 additions & 0 deletions modules/local/ncbidatasets/summarygenome.nf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ process NCBIDATASETS_SUMMARYGENOME {
${args} \\
> ${prefix}.json
validate_datasets_json.py ${prefix}.json
cat <<-END_VERSIONS > versions.yml
"${task.process}":
ncbi-datasets-cli: \$(datasets --version | sed 's/^.*datasets version: //')
Expand Down

0 comments on commit 33a8b4e

Please sign in to comment.