From 07bc4c65535437b8e9e0744f08da8cea541d0116 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Tue, 7 Apr 2020 15:28:42 -0400 Subject: Add metadata validation with schema-salad --- bh20sequploader/bh20seq-schema.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bh20sequploader/bh20seq-schema.yml (limited to 'bh20sequploader/bh20seq-schema.yml') 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 -- cgit v1.2.3 From d7498093d0f5e0db052ef88815d57c2648d09425 Mon Sep 17 00:00:00 2001 From: lltommy Date: Thu, 9 Apr 2020 14:34:54 +0200 Subject: Updating schema and examples. This is still work in progress but we get there --- bh20sequploader/bh20seq-schema.yml | 60 ++++++++++++++++++++++++++------------ example/metadata.yaml | 49 ++++++++++++++++++++++--------- example/minimal_example.yaml | 14 +++++++++ 3 files changed, 91 insertions(+), 32 deletions(-) create mode 100644 example/minimal_example.yaml (limited to 'bh20sequploader/bh20seq-schema.yml') diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index 6e0973a..38cfb48 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -1,36 +1,60 @@ $graph: -- name: sampleInformationSchema +- name: hostSchema type: record fields: - location: string - host: string - sequenceTechnology: string - assemblyMethod: string + host_id: string + host_species: string + host_common_name: string? + host_sex: string? + host_age: int? + host_age_unit: string? + host_health_status: string? + host_treatment: string? + additional_host_information: string? -- name: InstituteInformationSchema +- name: sampleSchema type: record fields: - OriginatingLab: string - SubmittingLab: string + collector_name: string + collecting_institution: string + specimen_source: string? + collection_date: string? + collection_location: string? + sample_storage_conditions: string? + additional_collection_information: string? -- name: SubmitterInformationSchema +- name: virusSchema type: record fields: - Submitter: string - submissionDate: string + virus_species: string? + virus_strain: string? -- name: VirusDetailSchema +- name: technologySchema type: record fields: - VirusName: string - AccessionId: string + sample_sequencing_technology: string + sequence_assembly_method: string? + sequencing_coverage: string? + +- name: submitterSchema + type: record + fields: + submitter_name: string + submitter_address: string? + originating_lab: string + lab_address: string? + provider_sample_id: string? + submitter_sample_id: string? + authors: string? + submitter_id: string? - name: MainSchema type: record documentRoot: true fields: - sampleInformation: sampleInformationSchema - InstituteInformation: InstituteInformationSchema - SubmitterInformation: SubmitterInformationSchema - VirusDetail: VirusDetailSchema + host: hostSchema + sample: sampleSchema + virus: virusSchema? + technology: technologySchema + submitter: submitterSchema \ No newline at end of file diff --git a/example/metadata.yaml b/example/metadata.yaml index 587d0be..8a93379 100644 --- a/example/metadata.yaml +++ b/example/metadata.yaml @@ -1,17 +1,38 @@ -sampleInformation: - location: "USA" - host : "Homo Sapiens" - sequenceTechnology: "Sanger" - assemblyMethod: "CLC Genomics" +host: + host_id: XX1 + host_species: string + host_common_name: string + host_sex: string + host_age: 20 + host_age_unit: string + host_health_status: string + host_treatment: string + additional_host_information: string -InstituteInformation: - OriginatingLab: "Erik's kitchen" - SubmittingLab: "National Institute for Viral Disease Control and Prevention, China CDC" +sample: + collector_name: XXX + collecting_institution: XXX + specimen_source: XXX + collection_date: XXX + collection_location: XXX + sample_storage_conditions: XXX + additional_collection_information: XXX -SubmitterInformation: - Submitter: "National Institute for Viral Disease Control and Prevention, China CDC" - submissionDate: "04-04-2020" +virus: + virus_species: XX + virus_strain: XX -VirusDetail: - VirusName: "hCoV-19/USA/identifer/2020" - AccessionId: "EPI_ISL_Random" +technology: + sample_sequencing_technology: XX + sequence_assembly_method: XX + sequencing_coverage: 70x + +submitter: + submitter_name: tester + submitter_address: testerAdd + originating_lab: testLab + lab_address: labAdd + provider_sample_id: string + submitter_sample_id: string + authors: testAuthor + submitter_id: X12 \ No newline at end of file diff --git a/example/minimal_example.yaml b/example/minimal_example.yaml new file mode 100644 index 0000000..201b080 --- /dev/null +++ b/example/minimal_example.yaml @@ -0,0 +1,14 @@ +host: + host_id: XX + host_species: string + +sample: + collector_name: XXX + collecting_institution: XXX + +technology: + sample_sequencing_technology: XX + +submitter: + submitter_name: tester + originating_lab: testLab \ No newline at end of file -- cgit v1.2.3 From deedb2ed7046bbe81136b8d9d1edc353984d356b Mon Sep 17 00:00:00 2001 From: lltommy Date: Thu, 9 Apr 2020 20:38:55 +0200 Subject: Adding functionality of turning keys into ontology terms (URI). This is work in progress - of course! --- bh20sequploader/bh20seq-schema.yml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'bh20sequploader/bh20seq-schema.yml') diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index 38cfb48..fd9e854 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -3,14 +3,20 @@ $graph: - name: hostSchema type: record fields: + host_species: + type: string + jsonldPredicate: + _id: http://www.ebi.ac.uk/efo/EFO_0000532 host_id: string - host_species: string host_common_name: string? host_sex: string? host_age: int? host_age_unit: string? host_health_status: string? - host_treatment: string? + host_treatment: + type: string? + jsonldPredicate: + _id: http://www.ebi.ac.uk/efo/EFO_0000727 additional_host_information: string? - name: sampleSchema @@ -20,7 +26,10 @@ $graph: collecting_institution: string specimen_source: string? collection_date: string? - collection_location: string? + collection_location: + type: string? + jsonldPredicate: + _id: https://schema.org/fromLocation sample_storage_conditions: string? additional_collection_information: string? @@ -33,9 +42,18 @@ $graph: - name: technologySchema type: record fields: - sample_sequencing_technology: string - sequence_assembly_method: string? - sequencing_coverage: string? + sample_sequencing_technology: + type: string + jsonldPredicate: + _id: http://www.ebi.ac.uk/efo/EFO_0000532 + sequence_assembly_method: + type: string? + jsonldPredicate: + _id: http://www.ebi.ac.uk/efo/EFO_0002699 + sequencing_coverage: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/FLU_0000848 - name: submitterSchema type: record -- cgit v1.2.3 From dbe094a150d6c969b3d69f112b3538e6a87a74a2 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 9 Apr 2020 15:59:46 -0400 Subject: Add "sequencefile" for the metadata subject. --- bh20sequploader/bh20seq-schema.yml | 13 ++++++++++++- example/metadata.yaml | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'bh20sequploader/bh20seq-schema.yml') diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index fd9e854..5c962d1 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -1,3 +1,8 @@ +$base: http://biohackathon.org/bh20-seq-schema +$namespaces: + sch: https://schema.org/ + efo: http://www.ebi.ac.uk/efo/ + obo: http://purl.obolibrary.org/obo/ $graph: - name: hostSchema @@ -75,4 +80,10 @@ $graph: sample: sampleSchema virus: virusSchema? technology: technologySchema - submitter: submitterSchema \ No newline at end of file + submitter: submitterSchema + sequencefile: + doc: The subject (eg the fasta/fastq file) that this metadata describes + type: string? + jsonldPredicate: + _id: "@id" + _type: "@id" diff --git a/example/metadata.yaml b/example/metadata.yaml index 8a93379..41ff93e 100644 --- a/example/metadata.yaml +++ b/example/metadata.yaml @@ -35,4 +35,4 @@ submitter: provider_sample_id: string submitter_sample_id: string authors: testAuthor - submitter_id: X12 \ No newline at end of file + submitter_id: X12 -- cgit v1.2.3 From ddabd9390d2b221786ef58a6d85200eecf82ca2f Mon Sep 17 00:00:00 2001 From: lltommy Date: Fri, 10 Apr 2020 15:39:56 +0200 Subject: Updating schema and examples, including URIs --- bh20sequploader/bh20seq-schema.yml | 145 ++++++++++++++++++++++++++++++------- example/metadata.yaml | 4 + example/minimal_example.yaml | 6 +- 3 files changed, 128 insertions(+), 27 deletions(-) (limited to 'bh20sequploader/bh20seq-schema.yml') diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index 5c962d1..cf9b015 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -3,6 +3,10 @@ $namespaces: sch: https://schema.org/ efo: http://www.ebi.ac.uk/efo/ obo: http://purl.obolibrary.org/obo/ + sio: http://semanticscience.org/resource/ + edam: http://edamontology.org/ + evs: http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl# + $graph: - name: hostSchema @@ -12,37 +16,93 @@ $graph: type: string jsonldPredicate: _id: http://www.ebi.ac.uk/efo/EFO_0000532 - host_id: string - host_common_name: string? - host_sex: string? - host_age: int? - host_age_unit: string? - host_health_status: string? + host_id: + type: string + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_000115 + host_common_name: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/NOMEN_0000037 + host_sex: + type: string + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/PATO_0000047 + host_age: + type: int? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/PATO_0000011 + host_age_unit: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/UO_0000036 + host_health_status: + type: string? + jsonldPredicate: http://purl.obolibrary.org/obo/NCIT_C25688 host_treatment: type: string? jsonldPredicate: _id: http://www.ebi.ac.uk/efo/EFO_0000727 - additional_host_information: string? + host_vaccination: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/VO_0000001 + additional_host_information: + type: string? + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_001167 - name: sampleSchema type: record fields: - collector_name: string - collecting_institution: string - specimen_source: string? - collection_date: string? + collector_name: + type: string + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/OBI_0001895 + collecting_institution: + type: string + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_001167 + specimen_source: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/OBI_0001479 + collection_date: + type: string? + jsonldPredicate: + _id: http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C25164 collection_location: type: string? jsonldPredicate: - _id: https://schema.org/fromLocation - sample_storage_conditions: string? - additional_collection_information: string? + _id: http://purl.obolibrary.org/obo/GAZ_00000448 + sample_storage_conditions: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/OBI_0001472 + additional_collection_information: + type: string? + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_001167 + sample_id: + type: string + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_000115 + source_database_accession: + type: string? + jsonldPredicate: + _id: http://edamontology.org/data_2091 - name: virusSchema type: record fields: - virus_species: string? - virus_strain: string? + virus_species: + type: string? + jsonldPredicate: + _id: http://edamontology.org/data_1875 + virus_strain: + type: string? + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_010055 - name: technologySchema type: record @@ -50,7 +110,7 @@ $graph: sample_sequencing_technology: type: string jsonldPredicate: - _id: http://www.ebi.ac.uk/efo/EFO_0000532 + _id: http://purl.obolibrary.org/obo/OBI_0600047 sequence_assembly_method: type: string? jsonldPredicate: @@ -63,14 +123,42 @@ $graph: - name: submitterSchema type: record fields: - submitter_name: string - submitter_address: string? - originating_lab: string - lab_address: string? - provider_sample_id: string? - submitter_sample_id: string? - authors: string? - submitter_id: string? + submitter_name: + type: string + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_000116 + submitter_date: + type: string + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/NCIT_C94162 + submitter_address: + type: string? + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_000172 + originating_lab: + type: string + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/NCIT_C37984 + lab_address: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/OBI_0600047 + provider_sample_id: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/NCIT_C37900 + submitter_sample_id: + type: string? + jsonldPredicate: + _id: http://www.ebi.ac.uk/efo/EFO_0001741 + authors: + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/NCIT_C42781 + submitter_id: + type: string? + jsonldPredicate: + _id: http://semanticscience.org/resource/SIO_000115 - name: MainSchema type: record @@ -81,9 +169,14 @@ $graph: virus: virusSchema? technology: technologySchema submitter: submitterSchema + submission: + type: string + jsonldPredicate: + _id: "@id" + #_type: "@id" sequencefile: doc: The subject (eg the fasta/fastq file) that this metadata describes type: string? jsonldPredicate: _id: "@id" - _type: "@id" + _type: "@id" \ No newline at end of file diff --git a/example/metadata.yaml b/example/metadata.yaml index 41ff93e..a2f6e57 100644 --- a/example/metadata.yaml +++ b/example/metadata.yaml @@ -1,3 +1,5 @@ +submission: publicSequenceResource + host: host_id: XX1 host_species: string @@ -10,6 +12,7 @@ host: additional_host_information: string sample: + sample_id: XXX collector_name: XXX collecting_institution: XXX specimen_source: XXX @@ -36,3 +39,4 @@ submitter: submitter_sample_id: string authors: testAuthor submitter_id: X12 + submitter_date: Subdate diff --git a/example/minimal_example.yaml b/example/minimal_example.yaml index 201b080..f312ab7 100644 --- a/example/minimal_example.yaml +++ b/example/minimal_example.yaml @@ -1,8 +1,11 @@ +submission: publicSequenceResource + host: host_id: XX host_species: string sample: + sample_id: XXX collector_name: XXX collecting_institution: XXX @@ -11,4 +14,5 @@ technology: submitter: submitter_name: tester - originating_lab: testLab \ No newline at end of file + originating_lab: testLab + submitter_date: Subdate \ No newline at end of file -- cgit v1.2.3 From a6ba9a5203a568611a94c043fd13e2ec50f071da Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 10 Apr 2020 15:12:08 -0400 Subject: Validate & propagate metadata --- bh20seqanalyzer/main.py | 45 ++++++++++++++++++++++++++++++++------ bh20sequploader/bh20seq-schema.yml | 6 ++--- bh20sequploader/main.py | 2 +- bh20sequploader/qc_metadata.py | 29 +++++++++++++++++++++++- 4 files changed, 70 insertions(+), 12 deletions(-) (limited to 'bh20sequploader/bh20seq-schema.yml') diff --git a/bh20seqanalyzer/main.py b/bh20seqanalyzer/main.py index 2030c1e..1fb51b5 100644 --- a/bh20seqanalyzer/main.py +++ b/bh20seqanalyzer/main.py @@ -8,6 +8,8 @@ import json import logging import ruamel.yaml from bh20sequploader.qc_metadata import qc_metadata +import pkg_resources +from schema_salad.sourceline import add_lc_filename logging.basicConfig(format="[%(asctime)s] %(levelname)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S", level=logging.INFO) @@ -24,8 +26,14 @@ def validate_upload(api, collection, validated_project, logging.warn("Upload '%s' missing metadata.yaml", collection["name"]) valid = False else: - metadata_content = ruamel.yaml.round_trip_load(col.open("metadata.yaml")) - #valid = qc_metadata(metadata_content) and valid + try: + metadata_content = ruamel.yaml.round_trip_load(col.open("metadata.yaml")) + metadata_content["id"] = "keep:%s/metadata.yaml" % collection["portable_data_hash"] + add_lc_filename(metadata_content, metadata_content["id"]) + valid = qc_metadata(metadata_content) and valid + except Exception as e: + logging.warn(e) + valid = False if not valid: logging.warn("Failed metadata qc") @@ -52,9 +60,10 @@ def validate_upload(api, collection, validated_project, "owner_uuid": validated_project, "name": "%s (%s)" % (collection["name"], time.asctime(time.gmtime()))}).execute() else: + pass # It is invalid, delete it. - logging.warn("Deleting '%s'" % collection["name"]) - api.collections().delete(uuid=collection["uuid"]).execute() + #logging.warn("Deleting '%s'" % collection["name"]) + #api.collections().delete(uuid=collection["uuid"]).execute() return valid @@ -107,12 +116,17 @@ def start_fastq_to_fasta(api, collection, def start_pangenome_analysis(api, analysis_project, pangenome_workflow_uuid, - validated_project): + validated_project, + schema_ref): validated = arvados.util.list_all(api.collections().list, filters=[["owner_uuid", "=", validated_project]]) inputobj = { "inputReads": [], "metadata": [], - "subjects": [] + "subjects": [], + "metadataSchema": { + "class": "File", + "location": schema_ref + } } for v in validated: inputobj["inputReads"].append({ @@ -166,12 +180,26 @@ def move_fastq_to_fasta_results(api, analysis_project, uploader_project): api.groups().update(uuid=p["uuid"], body={"properties": p["properties"]}).execute() +def upload_schema(api, workflow_def_project): + schema_resource = pkg_resources.resource_stream('bh20sequploader.qc_metadata', "bh20seq-schema.yml") + c = arvados.collection.Collection() + with c.open("schema.yml", "wb") as f: + f.write(schema_resource.read()) + pdh = c.portable_data_hash() + wd = api.collections().list(filters=[["owner_uuid", "=", workflow_def_project], + ["portable_data_hash", "=", pdh]]).execute() + if len(wd["items"]) == 0: + c.save_new(owner_uuid=workflow_def_project, name="Metadata schema", ensure_unique_name=True) + return "keep:%s/schema.yml" % pdh + + def main(): parser = argparse.ArgumentParser(description='Analyze collections uploaded to a project') parser.add_argument('--uploader-project', type=str, default='lugli-j7d0g-n5clictpuvwk8aa', help='') parser.add_argument('--pangenome-analysis-project', type=str, default='lugli-j7d0g-y4k4uswcqi3ku56', help='') parser.add_argument('--fastq-project', type=str, default='lugli-j7d0g-xcjxp4oox2u1w8u', help='') parser.add_argument('--validated-project', type=str, default='lugli-j7d0g-5ct8p1i1wrgyjvp', help='') + parser.add_argument('--workflow-def-project', type=str, default='lugli-j7d0g-5hswinmpyho8dju', help='') parser.add_argument('--pangenome-workflow-uuid', type=str, default='lugli-7fd4e-mqfu9y3ofnpnho1', help='') parser.add_argument('--fastq-workflow-uuid', type=str, default='lugli-7fd4e-2zp9q4jo5xpif9y', help='') @@ -183,6 +211,8 @@ def main(): logging.info("Starting up, monitoring %s for uploads" % (args.uploader_project)) + schema_ref = upload_schema(api, args.workflow_def_project) + while True: move_fastq_to_fasta_results(api, args.fastq_project, args.uploader_project) @@ -198,7 +228,8 @@ def main(): start_pangenome_analysis(api, args.pangenome_analysis_project, args.pangenome_workflow_uuid, - args.validated_project) + args.validated_project, + schema_ref) copy_most_recent_result(api, args.pangenome_analysis_project, diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index cf9b015..a072bd7 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -174,9 +174,9 @@ $graph: jsonldPredicate: _id: "@id" #_type: "@id" - sequencefile: - doc: The subject (eg the fasta/fastq file) that this metadata describes + id: + doc: The subject (eg the fasta/fastq file) that the metadata describes type: string? jsonldPredicate: _id: "@id" - _type: "@id" \ No newline at end of file + _type: "@id" diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py index bfb8c51..2032508 100644 --- a/bh20sequploader/main.py +++ b/bh20sequploader/main.py @@ -22,7 +22,7 @@ def main(): api = arvados.api(host=ARVADOS_API_HOST, token=ARVADOS_API_TOKEN, insecure=True) - if not qc_metadata(args.metadata.name): + if not bh20sequploader.qc_metadata.qc_metadata(args.metadata.name): print("Failed metadata qc") exit(1) diff --git a/bh20sequploader/qc_metadata.py b/bh20sequploader/qc_metadata.py index ebe4dfc..38edcaa 100644 --- a/bh20sequploader/qc_metadata.py +++ b/bh20sequploader/qc_metadata.py @@ -1,12 +1,25 @@ import schema_salad.schema +import schema_salad.ref_resolver import logging import pkg_resources import logging +import traceback + +class CustomFetcher(schema_salad.ref_resolver.DefaultFetcher): + def check_exists(sup, url): + if url.startswith("keep:"): + return True + else: + return super().check_exists(url) + + def supported_schemes(self): # type: () -> List[str] + return ["file", "http", "https", "mailto", "keep"] + 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, + (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) @@ -15,9 +28,23 @@ def qc_metadata(metadatafile): print(avsc_names) return False + document_loader = schema_salad.ref_resolver.Loader( + loader.ctx, + schemagraph=loader.graph, + foreign_properties=loader.foreign_properties, + idx=loader.idx, + cache=loader.cache, + fetcher_constructor=CustomFetcher, + skip_schemas=loader.skip_schemas, + url_fields=loader.url_fields, + allow_attachments=loader.allow_attachments, + session=loader.session, + ) + 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 -- cgit v1.2.3 From ffad8c21f08aca1cf65809c398f3613846e7c8ba Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 10 Apr 2020 16:47:31 -0400 Subject: Propagating metadata to output works now. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- bh20seqanalyzer/main.py | 4 ++-- bh20sequploader/bh20seq-schema.yml | 5 ----- bh20sequploader/qc_metadata.py | 26 +------------------------- example/metadata.yaml | 2 -- 4 files changed, 3 insertions(+), 34 deletions(-) (limited to 'bh20sequploader/bh20seq-schema.yml') diff --git a/bh20seqanalyzer/main.py b/bh20seqanalyzer/main.py index 63ff067..193a268 100644 --- a/bh20seqanalyzer/main.py +++ b/bh20seqanalyzer/main.py @@ -29,7 +29,7 @@ def validate_upload(api, collection, validated_project, else: try: metadata_content = ruamel.yaml.round_trip_load(col.open("metadata.yaml")) - metadata_content["id"] = "keep:%s/metadata.yaml" % collection["portable_data_hash"] + metadata_content["id"] = "http://arvados.org/keep:%s/metadata.yaml" % collection["portable_data_hash"] add_lc_filename(metadata_content, metadata_content["id"]) valid = qc_metadata(metadata_content) and valid except Exception as e: @@ -146,7 +146,7 @@ def start_pangenome_analysis(api, "class": "File", "location": "keep:%s/metadata.yaml" % v["portable_data_hash"] }) - inputobj["subjects"].append("keep:%s/sequence.fasta" % v["portable_data_hash"]) + inputobj["subjects"].append("http://arvados.org/keep:%s/sequence.fasta" % v["portable_data_hash"]) run_workflow(api, analysis_project, pangenome_workflow_uuid, "Pangenome analysis", inputobj) diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index a072bd7..8a22db1 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -169,11 +169,6 @@ $graph: virus: virusSchema? technology: technologySchema submitter: submitterSchema - submission: - type: string - jsonldPredicate: - _id: "@id" - #_type: "@id" id: doc: The subject (eg the fasta/fastq file) that the metadata describes type: string? diff --git a/bh20sequploader/qc_metadata.py b/bh20sequploader/qc_metadata.py index 38edcaa..e477f21 100644 --- a/bh20sequploader/qc_metadata.py +++ b/bh20sequploader/qc_metadata.py @@ -5,21 +5,10 @@ import pkg_resources import logging import traceback -class CustomFetcher(schema_salad.ref_resolver.DefaultFetcher): - def check_exists(sup, url): - if url.startswith("keep:"): - return True - else: - return super().check_exists(url) - - def supported_schemes(self): # type: () -> List[str] - return ["file", "http", "https", "mailto", "keep"] - - 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")} - (loader, + (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) @@ -28,19 +17,6 @@ def qc_metadata(metadatafile): print(avsc_names) return False - document_loader = schema_salad.ref_resolver.Loader( - loader.ctx, - schemagraph=loader.graph, - foreign_properties=loader.foreign_properties, - idx=loader.idx, - cache=loader.cache, - fetcher_constructor=CustomFetcher, - skip_schemas=loader.skip_schemas, - url_fields=loader.url_fields, - allow_attachments=loader.allow_attachments, - session=loader.session, - ) - try: doc, metadata = schema_salad.schema.load_and_validate(document_loader, avsc_names, metadatafile, True) return True diff --git a/example/metadata.yaml b/example/metadata.yaml index a2f6e57..c780921 100644 --- a/example/metadata.yaml +++ b/example/metadata.yaml @@ -1,5 +1,3 @@ -submission: publicSequenceResource - host: host_id: XX1 host_species: string -- cgit v1.2.3 From 4f4229a61e63649730e7120c764f364078860f0f Mon Sep 17 00:00:00 2001 From: lltommy Date: Sat, 11 Apr 2020 02:44:04 +0200 Subject: Adding descriptions to the yml schema, slight changes to the yml schema --- bh20sequploader/bh20seq-schema.yml | 45 ++++++++++++++++++++++++++++++++------ example/metadata.yaml | 5 +++-- example/minimal_example.yaml | 6 ++--- 3 files changed, 44 insertions(+), 12 deletions(-) (limited to 'bh20sequploader/bh20seq-schema.yml') diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index 8a22db1..c259f16 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -13,41 +13,51 @@ $graph: type: record fields: host_species: + doc: Host species as defined in NCBITaxon (e.g. http://purl.obolibrary.org/obo/NCBITaxon_9606 for Homo sapiens) type: string jsonldPredicate: _id: http://www.ebi.ac.uk/efo/EFO_0000532 host_id: + doc: Identifer for the host. If you submit multiple samples from the same host, use the same host_id for those samples type: string jsonldPredicate: _id: http://semanticscience.org/resource/SIO_000115 host_common_name: + doc: Text label for the host species (e.g. homo sapiens) type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/NOMEN_0000037 host_sex: + doc: Sex of the host as define in NCIT, IRI expected (http://purl.obolibrary.org/obo/C20197 (Male), http://purl.obolibrary.org/obo/NCIT_C27993 (Female) or unkown (http://purl.obolibrary.org/obo/NCIT_C17998)) type: string jsonldPredicate: _id: http://purl.obolibrary.org/obo/PATO_0000047 host_age: + doc: Age of the host as number (e.g. 50) type: int? jsonldPredicate: _id: http://purl.obolibrary.org/obo/PATO_0000011 host_age_unit: + doc: Unit of host age.... this field is unstable as of now (might be removed) type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/UO_0000036 host_health_status: + doc: A condition or state at a particular time type: string? jsonldPredicate: http://purl.obolibrary.org/obo/NCIT_C25688 host_treatment: + doc: Process in which the act is intended to modify or alter type: string? jsonldPredicate: _id: http://www.ebi.ac.uk/efo/EFO_0000727 host_vaccination: + doc: Field is unstable type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/VO_0000001 additional_host_information: + doc: Field for additional host information type: string? jsonldPredicate: _id: http://semanticscience.org/resource/SIO_001167 @@ -56,38 +66,47 @@ $graph: type: record fields: collector_name: + doc: Name of the person that took the sample type: string jsonldPredicate: _id: http://purl.obolibrary.org/obo/OBI_0001895 collecting_institution: + doc: Institute that was responsible of sampeling type: string jsonldPredicate: _id: http://semanticscience.org/resource/SIO_001167 specimen_source: + doc: A specimen that derives from an anatomical part or substance arising from an organism, e.g. tissue, organ type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/OBI_0001479 collection_date: + doc: Date when the sample was taken type: string? jsonldPredicate: _id: http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C25164 collection_location: + doc: Geographical location where the sample was collected as Gazetteer (https://www.ebi.ac.uk/ols/ontologies/gaz) reference, e.g. http://purl.obolibrary.org/obo/GAZ_00002845 (China) type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/GAZ_00000448 sample_storage_conditions: + doc: Information aboout storage of a specified type, e.g. frozen specimen, paraffin, fresh .... type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/OBI_0001472 additional_collection_information: + doc: Add additional comment about the circumstances that a sample was taken type: string? jsonldPredicate: _id: http://semanticscience.org/resource/SIO_001167 sample_id: + doc: Id of the sample as defined by the submitter type: string jsonldPredicate: _id: http://semanticscience.org/resource/SIO_000115 source_database_accession: + doc: If data is deposit at a public resource (e.g. Genbank, ENA) enter the Accession Id here type: string? jsonldPredicate: _id: http://edamontology.org/data_2091 @@ -96,10 +115,12 @@ $graph: type: record fields: virus_species: + doc: The name of a taxon from the NCBI taxonomy database type: string? jsonldPredicate: _id: http://edamontology.org/data_1875 virus_strain: + doc: Name of the virus strain type: string? jsonldPredicate: _id: http://semanticscience.org/resource/SIO_010055 @@ -108,14 +129,17 @@ $graph: type: record fields: sample_sequencing_technology: + doc: Technology that was used to sequence this sample (e.g Sanger, Nanopor MiniION) type: string jsonldPredicate: _id: http://purl.obolibrary.org/obo/OBI_0600047 sequence_assembly_method: + doc: Protocol which provides instructions on the alignment of sequencing reads to reference genome type: string? jsonldPredicate: _id: http://www.ebi.ac.uk/efo/EFO_0002699 sequencing_coverage: + doc: Sequence coverage defined as the average number of reads representing a given nucleotide (e.g. 100x) type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/FLU_0000848 @@ -124,22 +148,22 @@ $graph: type: record fields: submitter_name: + doc: Name of the submitter type: string jsonldPredicate: _id: http://semanticscience.org/resource/SIO_000116 - submitter_date: - type: string - jsonldPredicate: - _id: http://purl.obolibrary.org/obo/NCIT_C94162 submitter_address: + doc: Address of the submitter type: string? jsonldPredicate: _id: http://semanticscience.org/resource/SIO_000172 originating_lab: + doc: Name of the laboratory that took the sample type: string jsonldPredicate: _id: http://purl.obolibrary.org/obo/NCIT_C37984 lab_address: + doc: Address of the laboratory where the sample was taken type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/OBI_0600047 @@ -152,10 +176,17 @@ $graph: jsonldPredicate: _id: http://www.ebi.ac.uk/efo/EFO_0001741 authors: + doc: Name of the author(s) type: string? jsonldPredicate: _id: http://purl.obolibrary.org/obo/NCIT_C42781 - submitter_id: + publication: + doc: Reference to publication of this sample (e.g. DOI, pubmed ID, ...) + type: string? + jsonldPredicate: + _id: http://purl.obolibrary.org/obo/NCIT_C19026 + submitter_orchid: + doc: ORCHID of the submitter type: string? jsonldPredicate: _id: http://semanticscience.org/resource/SIO_000115 @@ -171,7 +202,7 @@ $graph: submitter: submitterSchema id: doc: The subject (eg the fasta/fastq file) that the metadata describes - type: string? + type: string jsonldPredicate: _id: "@id" - _type: "@id" + #_type: "@id" # Error (contains undefined reference) if I keep this file but we need a toplevel id to tie things together diff --git a/example/metadata.yaml b/example/metadata.yaml index c780921..d9e8e92 100644 --- a/example/metadata.yaml +++ b/example/metadata.yaml @@ -1,3 +1,5 @@ +id: placeholder + host: host_id: XX1 host_species: string @@ -36,5 +38,4 @@ submitter: provider_sample_id: string submitter_sample_id: string authors: testAuthor - submitter_id: X12 - submitter_date: Subdate + submitter_orchid: X12 diff --git a/example/minimal_example.yaml b/example/minimal_example.yaml index f312ab7..160d1d4 100644 --- a/example/minimal_example.yaml +++ b/example/minimal_example.yaml @@ -1,8 +1,9 @@ -submission: publicSequenceResource +id: placeholder host: host_id: XX host_species: string + host_sex: string sample: sample_id: XXX @@ -14,5 +15,4 @@ technology: submitter: submitter_name: tester - originating_lab: testLab - submitter_date: Subdate \ No newline at end of file + originating_lab: testLab \ No newline at end of file -- cgit v1.2.3 From 31686ba2e1b2edec29229ab5adb28b366893f17b Mon Sep 17 00:00:00 2001 From: lltommy Date: Sat, 11 Apr 2020 04:02:55 +0200 Subject: Adding noLinkCheck to root --- bh20sequploader/bh20seq-schema.yml | 4 +++- bh20sequploader/rdf-mappings.ttl | 0 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 bh20sequploader/rdf-mappings.ttl (limited to 'bh20sequploader/bh20seq-schema.yml') diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index c259f16..81a7f22 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -13,6 +13,7 @@ $graph: type: record fields: host_species: + ## autocomplete # NCBITAXON doc: Host species as defined in NCBITaxon (e.g. http://purl.obolibrary.org/obo/NCBITaxon_9606 for Homo sapiens) type: string jsonldPredicate: @@ -205,4 +206,5 @@ $graph: type: string jsonldPredicate: _id: "@id" - #_type: "@id" # Error (contains undefined reference) if I keep this file but we need a toplevel id to tie things together + _type: "@id" + noLinkCheck: true diff --git a/bh20sequploader/rdf-mappings.ttl b/bh20sequploader/rdf-mappings.ttl new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3