diff options
author | Pjotr Prins | 2020-04-12 12:49:06 -0500 |
---|---|---|
committer | GitHub | 2020-04-12 12:49:06 -0500 |
commit | 23722a63682fdffe51efca55b40573fa27370973 (patch) | |
tree | 7628ccda2671fe9a3e9ff204918c965d4bb9e257 /bh20sequploader/qc_metadata.py | |
parent | 10ccb97cab69cb704c154387d544a74cd38d3cdf (diff) | |
parent | 92e1608b2d8b21f2001d7bf480301d314337fdc0 (diff) | |
download | bh20-seq-resource-23722a63682fdffe51efca55b40573fa27370973.tar.gz bh20-seq-resource-23722a63682fdffe51efca55b40573fa27370973.tar.lz bh20-seq-resource-23722a63682fdffe51efca55b40573fa27370973.zip |
Merge branch 'master' into patch-1
Diffstat (limited to 'bh20sequploader/qc_metadata.py')
-rw-r--r-- | bh20sequploader/qc_metadata.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bh20sequploader/qc_metadata.py b/bh20sequploader/qc_metadata.py new file mode 100644 index 0000000..e477f21 --- /dev/null +++ b/bh20sequploader/qc_metadata.py @@ -0,0 +1,26 @@ +import schema_salad.schema +import schema_salad.ref_resolver +import logging +import pkg_resources +import logging +import traceback + +def qc_metadata(metadatafile): + schema_resource = pkg_resources.resource_stream(__name__, "bh20seq-schema.yml") + cache = {"https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-schema.yml": schema_resource.read().decode("utf-8")} + (document_loader, + avsc_names, + schema_metadata, + metaschema_loader) = schema_salad.schema.load_schema("https://raw.githubusercontent.com/arvados/bh20-seq-resource/master/bh20sequploader/bh20seq-schema.yml", cache=cache) + + if not isinstance(avsc_names, schema_salad.avro.schema.Names): + print(avsc_names) + return False + + try: + doc, metadata = schema_salad.schema.load_and_validate(document_loader, avsc_names, metadatafile, True) + return True + except Exception as e: + traceback.print_exc() + logging.warn(e) + return False |