aboutsummaryrefslogtreecommitdiff
path: root/bh20sequploader
diff options
context:
space:
mode:
Diffstat (limited to 'bh20sequploader')
-rw-r--r--bh20sequploader/bh20seq-schema.yml36
-rw-r--r--bh20sequploader/main.py7
-rw-r--r--bh20sequploader/qc_metadata.py26
3 files changed, 58 insertions, 11 deletions
diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml
new file mode 100644
index 0000000..6e0973a
--- /dev/null
+++ b/bh20sequploader/bh20seq-schema.yml
@@ -0,0 +1,36 @@
+$graph:
+
+- name: sampleInformationSchema
+ type: record
+ fields:
+ location: string
+ host: string
+ sequenceTechnology: string
+ assemblyMethod: string
+
+- name: InstituteInformationSchema
+ type: record
+ fields:
+ OriginatingLab: string
+ SubmittingLab: string
+
+- name: SubmitterInformationSchema
+ type: record
+ fields:
+ Submitter: string
+ submissionDate: string
+
+- name: VirusDetailSchema
+ type: record
+ fields:
+ VirusName: string
+ AccessionId: string
+
+- name: MainSchema
+ type: record
+ documentRoot: true
+ fields:
+ sampleInformation: sampleInformationSchema
+ InstituteInformation: InstituteInformationSchema
+ SubmitterInformation: SubmitterInformationSchema
+ VirusDetail: VirusDetailSchema
diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py
index d3ebc0c..8b8fefe 100644
--- a/bh20sequploader/main.py
+++ b/bh20sequploader/main.py
@@ -6,6 +6,7 @@ import json
import urllib.request
import socket
import getpass
+from .qc_metadata import qc_metadata
ARVADOS_API_HOST='lugli.arvadosapi.com'
ARVADOS_API_TOKEN='2fbebpmbo3rw3x05ueu2i6nx70zhrsb1p22ycu3ry34m4x4462'
@@ -19,6 +20,8 @@ def main():
api = arvados.api(host=ARVADOS_API_HOST, token=ARVADOS_API_TOKEN, insecure=True)
+ qc_metadata(args.metadata.name)
+
col = arvados.collection.Collection(api_client=api)
print("Reading FASTA")
@@ -29,8 +32,8 @@ def main():
f.write(r)
r = args.sequence.read(65536)
- print("Reading JSONLD")
- with col.open("metadata.jsonld", "w") as f:
+ print("Reading metadata")
+ with col.open("metadata.yaml", "w") as f:
r = args.metadata.read(65536)
print(r[0:20])
while r:
diff --git a/bh20sequploader/qc_metadata.py b/bh20sequploader/qc_metadata.py
index 0632777..78b31b2 100644
--- a/bh20sequploader/qc_metadata.py
+++ b/bh20sequploader/qc_metadata.py
@@ -1,13 +1,21 @@
-import yamale
+import schema_salad.schema
+import logging
+import pkg_resources
-## NOTE: this is just a DUMMY. Everything about this can and will change
def qc_metadata(metadatafile):
- print("Start metadata validation...")
- schema = yamale.make_schema('../example/dummyschema.yaml')
- data = yamale.make_data(metadatafile)
- # Validate data against the schema. Throws a ValueError if data is invalid.
- yamale.validate(schema, data)
- print("...complete!")
+ 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)
-#qc_metadata("../example/metadata.yaml")
+ 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:
+ return False