aboutsummaryrefslogtreecommitdiff
path: root/workflows/pangenome-generate/merge-metadata.py
blob: 64275b11a7c6192e311f53ee42be180133a28088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import schema_salad.schema
import schema_salad.jsonld_context

metadataSchema = '$(inputs.metadataSchema.path)'
metadata = $(inputs.metadata)
subjects = $(inputs.subjects)

(document_loader,
 avsc_names,
 schema_metadata,
 metaschema_loader) = schema_salad.schema.load_schema(metadataSchema)

for i, m in enumerate(metadata):
    doc, metadata = schema_salad.schema.load_and_validate(document_loader, avsc_names, m["path"], True)
    doc["id"] = subjects[i]
    g = schema_salad.jsonld_context.makerdf(subjects[i], doc, document_loader.ctx)
    print(g.serialize(format="ntriples").decode("utf-8"))