@prefix this: . @prefix sub: . @prefix np: . @prefix grlc: . @prefix dct: . @prefix nt: . @prefix npx: . @prefix xsd: . @prefix rdfs: . @prefix orcid: . @prefix prov: . @prefix foaf: . sub:Head { this: a np:Nanopublication; np:hasAssertion sub:assertion; np:hasProvenance sub:provenance; np:hasPublicationInfo sub:pubinfo . } sub:assertion { sub:get-space-onehealth-coverage-svg a grlc:grlc-query; dct:description "Returns a single row holding an SVG diagram of how the projects of a space cover the three One Health domains: three overlapping circles for Human, Animal and Environment, each region showing the number of projects tagged with exactly that combination of domains via the ZonMw One Health vocabulary (zonmw/r/onehealth/domain), and each domain heading showing how many of the space's projects and how many datasets are tagged with it. Projects are the gen:Project spaces whose IRI extends the given space, tagged or not, which gives the 'of N' denominator; entities are anything under the space's IRI that carries a domain tag, classified as project (gen:Project), dataset (ff:Dataset) or other. The per-entity domain flags are computed once and every count is a conditional sum over that one set of rows, so the figures never multiply each other. Only tags asserted in nanopublications signed by a current admin, maintainer or member of the space or one of its sub-spaces count, with invalidated, superseded and example nanopublications skipped; the membership lookup is a federated sub-select sharing no variables with the rest of the query. The SVG uses explicit end tags and camelCase attributes and contains no data-derived text other than numbers, so it needs no escaping."; dct:license ; rdfs:label "Get a One Health coverage diagram for a space and its sub-spaces"; grlc:endpoint ; grlc:sparql """prefix np: prefix npa: prefix npx: prefix gen: prefix ff: prefix oh: select ?svg where { # One row: how many projects and datasets sit in each region of the Human / Animal / # Environment diagram, computed from one set of per-entity domain flags so that the # sums never multiply each other. { select (sum(if(?kind = \"project\" && ?h = 1 && ?a = 0 && ?e = 0, 1, 0)) as ?pH) (sum(if(?kind = \"project\" && ?h = 0 && ?a = 1 && ?e = 0, 1, 0)) as ?pA) (sum(if(?kind = \"project\" && ?h = 0 && ?a = 0 && ?e = 1, 1, 0)) as ?pE) (sum(if(?kind = \"project\" && ?h = 1 && ?a = 1 && ?e = 0, 1, 0)) as ?pHA) (sum(if(?kind = \"project\" && ?h = 1 && ?a = 0 && ?e = 1, 1, 0)) as ?pHE) (sum(if(?kind = \"project\" && ?h = 0 && ?a = 1 && ?e = 1, 1, 0)) as ?pAE) (sum(if(?kind = \"project\" && ?h = 1 && ?a = 1 && ?e = 1, 1, 0)) as ?pHAE) (sum(if(?kind = \"project\" && ?h = 1, 1, 0)) as ?pHt) (sum(if(?kind = \"project\" && ?a = 1, 1, 0)) as ?pAt) (sum(if(?kind = \"project\" && ?e = 1, 1, 0)) as ?pEt) (sum(if(?kind = \"project\", 1, 0)) as ?pTagged) (sum(if(?kind = \"dataset\" && ?h = 1, 1, 0)) as ?dHt) (sum(if(?kind = \"dataset\" && ?a = 1, 1, 0)) as ?dAt) (sum(if(?kind = \"dataset\" && ?e = 1, 1, 0)) as ?dEt) (sum(if(?kind = \"dataset\", 1, 0)) as ?dTagged) (sum(if(?kind = \"other\" && ?h = 1, 1, 0)) as ?oHt) (sum(if(?kind = \"other\" && ?a = 1, 1, 0)) as ?oAt) (sum(if(?kind = \"other\" && ?e = 1, 1, 0)) as ?oEt) where { { select ?entity ?kind (max(if(?domain = oh:Human, 1, 0)) as ?h) (max(if(?domain = oh:Animal, 1, 0)) as ?a) (max(if(?domain = oh:Environment, 1, 0)) as ?e) where { values ?_space_multi_iri {} { select (group_concat(distinct ?mpk; separator=\" \") as ?memberPubkeys) where { service { select ?mpk where { values ?_space_multi_iri {} graph npa:graph { npa:hasCurrentSpaceState ?stateG . } graph ?stateG { ?ri a gen:RoleInstantiation ; npa:forSpace ?sp ; npa:forAgent ?agent ; npa:hasRoleType ?rt . filter(?rt in (gen:AdminRole, gen:MaintainerRole, gen:MemberRole)) ?acct a npa:AccountState ; npa:agent ?agent ; npa:pubkey ?mpk . } filter(?sp = ?_space_multi_iri || strstarts(str(?sp), concat(str(?_space_multi_iri), \"/\"))) } } } } graph npa:graph { ?np npa:hasValidSignatureForPublicKeyHash ?npPubkey . filter not exists { ?invNp npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?npPubkey . } filter not exists { ?supNp npx:supersedes ?np . } filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . } ?np np:hasAssertion ?a0 . } filter(contains(?memberPubkeys, ?npPubkey)) graph ?a0 { ?entity oh:domain ?domain . } filter(strstarts(str(?entity), concat(str(?_space_multi_iri), \"/\"))) bind(if(exists { graph ?ta { ?entity a gen:Project } }, \"project\", if(exists { graph ?tb { ?entity a ff:Dataset } }, \"dataset\", \"other\")) as ?kind) } group by ?entity ?kind } } } # Denominator: every project space in the subtree, tagged or not. { select (count(distinct ?project) as ?pAll) where { values ?_space_multi_iri {} graph npa:graph { ?pnp np:hasAssertion ?pa . filter not exists { ?psup npx:supersedes ?pnp . } } graph ?pa { ?project a gen:Project . } filter(strstarts(str(?project), concat(str(?_space_multi_iri), \"/\"))) } } bind(if(?pAll > 0, ?pAll, ?pTagged) as ?pTotal) bind(concat( '', '', '', '', 'Human', '', str(?pHt), ' of ', str(?pTotal), ' projects, ', str(?dHt), ' datasets', 'Animal', '', str(?pAt), ' of ', str(?pTotal), ' projects, ', str(?dAt), ' datasets', 'Environment', '', str(?pEt), ' of ', str(?pTotal), ' projects, ', str(?dEt), ' datasets', ' 0, '#222', '#aaa'), '\">', str(?pH), '', ' 0, '#222', '#aaa'), '\">', str(?pA), '', ' 0, '#222', '#aaa'), '\">', str(?pE), '', ' 0, '#222', '#aaa'), '\">', str(?pHA), '', ' 0, '#222', '#aaa'), '\">', str(?pHE), '', ' 0, '#222', '#aaa'), '\">', str(?pAE), '', ' 0, '#222', '#aaa'), '\">', str(?pHAE), '', 'Numbers: projects per region (', str(?pTagged), ' of ', str(?pTotal), ' projects tagged, ', str(?dTagged), ' datasets)', '') as ?svg) }""" . } sub:provenance { sub:assertion prov:wasAttributedTo orcid:0000-0002-1267-0234 . } sub:pubinfo { orcid:0000-0002-1267-0234 foaf:name "Tobias Kuhn" . this: dct:created "2026-09-13T05:32:24Z"^^xsd:dateTime; dct:creator orcid:0000-0002-1267-0234; dct:license ; npx:embeds sub:get-space-onehealth-coverage-svg; rdfs:label "Get a One Health coverage diagram for a space and its sub-spaces"; nt:wasCreatedFromProvenanceTemplate ; nt:wasCreatedFromPubinfoTemplate , ; nt:wasCreatedFromTemplate . sub:sig npx:hasAlgorithm "RSA"; npx:hasPublicKey "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwUtewGCpT5vIfXYE1bmf/Uqu1ojqnWdYxv+ySO80ul8Gu7m8KoyPAwuvaPj0lvPtHrg000qMmkxzKhYknEjq8v7EerxZNYp5B3/3+5ZpuWOYAs78UnQVjbHSmDdmryr4D4VvvNIiUmd0yxci47dTFUj4DvfHnGd6hVe5+goqdcwIDAQAB"; npx:hasSignature "AYD3btJN+kkQKJvpMXgJW/WUcAdli1ctXlF7m/qLdpMAUczBZCbV7gXGERgd/w07RwUCMfWA5btJdEF8Us5dcIn7TovnxLKnUI4NgQLKAOrJhmOGNGFEtP5nUa06emfWuTgr82MipwphD1585Y3YOVpRaOGw5t7Nll+7Riuo1xY="; npx:hasSignatureTarget this:; npx:signedBy orcid:0000-0002-1267-0234 . }