aboutsummaryrefslogtreecommitdiff
path: root/bh20sequploader/qc_metadata.py
diff options
context:
space:
mode:
authorPjotr Prins2020-04-09 15:34:06 -0500
committerPjotr Prins2020-04-09 15:34:06 -0500
commit0670ac0644c1e7366952e254bdee2db62e673275 (patch)
treeaed056a1ca4208cf30993da3e96bbb4fb08dbe52 /bh20sequploader/qc_metadata.py
parent146cf2f5d1be9a5dd9d6cd65ce9c760853d014f8 (diff)
parentdbe094a150d6c969b3d69f112b3538e6a87a74a2 (diff)
downloadbh20-seq-resource-0670ac0644c1e7366952e254bdee2db62e673275.tar.gz
bh20-seq-resource-0670ac0644c1e7366952e254bdee2db62e673275.tar.lz
bh20-seq-resource-0670ac0644c1e7366952e254bdee2db62e673275.zip
Merge branch 'master' of github.com:arvados/bh20-seq-resource
Diffstat (limited to 'bh20sequploader/qc_metadata.py')
-rw-r--r--bh20sequploader/qc_metadata.py23
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