diff options
Diffstat (limited to 'bh20sequploader/qc_metadata.py')
-rw-r--r-- | bh20sequploader/qc_metadata.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bh20sequploader/qc_metadata.py b/bh20sequploader/qc_metadata.py new file mode 100644 index 0000000..ebe4dfc --- /dev/null +++ b/bh20sequploader/qc_metadata.py @@ -0,0 +1,23 @@ +import schema_salad.schema +import logging +import pkg_resources +import logging + +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: + logging.warn(e) + return False |