@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix grlc: <https://w3id.org/kpxl/grlc/> .

<https://w3id.org/np/RAaQHF8pXj2Y4UeWChdkLxM9g5webS68YaZjYPtAlhe2Q/get-rocrate-nanopubs>
  a grlc:grlc-query;
  dct:description "This query returns all RO-Crate nanopubs. Including the old and new type.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all RO-Crate nanopubs";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix kpxl: <https://w3id.org/kpxl/gen/terms/>

# find all ro-crates, with old and new nanopub type
select distinct ?rocrate ?date ?np where { 
  graph npa:graph {
    {?np npx:hasNanopubType kpxl:RoCrateNanopub .} union {?np npx:hasNanopubType npx:RoCrateNanopub .}
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkeyhash .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkeyhash . }
    ?np dct:created ?date .
    ?np npx:introduces ?rocrate .
    ?np npx:signedBy ?agent_iri .
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RACIjwEYXjz60_kM3Yzp-5WdmgHBi__FKzsMa_3zWGfLU/find-gofair-qualified-things-valid>
  a grlc:grlc-query;
  dct:description "This query allows for searching for resources (FERs etc.) together with the info about whether GO FAIR qualified them.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Find GO FAIR qualified things (only valid entries)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix prov: <http://www.w3.org/ns/prov#>

select distinct ?thing ?label ?description ?np ?date ?pubkey ?qualifier ?qualification_np (group_concat(distinct ?recommender; separator=\" \") as ?recommenders) (group_concat(distinct ?recommendation_np; separator=\" \") as ?recommendation_nps) (count(distinct ?recommender) as ?recommender_count) (sample(?fairAssessmentLevel) as ?fairAssessmentLevel) (sample(?fairAssessmentLevelNp) as ?fairAssessmentLevelNp) where {
  graph npa:graph {
    <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> npa:hasValidSignatureForPublicKey ?curators_np_pk .
    ?latest_curators_np npa:hasValidSignatureForPublicKey ?curators_np_pk .
    filter not exists { ?latest_curators_npx npx:invalidates ?latest_curators_np ; npa:hasValidSignatureForPublicKey ?curators_np_pk . }
    ?latest_curators_np np:hasAssertion ?latest_curators_assertion .
  }
  graph npa:networkGraph {
    ?latest_curators_np (npx:supersedes)* <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> .
    filter not exists { ?latest_curators_npxx npx:supersedes ?latest_curators_np }
  }
  
  graph npa:graph {
    ?np npx:hasNanopubType ?__type_iri .
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?retraction npx:retracts ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    filter not exists { ?newversion npx:supersedes ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np (npx:introduces|npx:describes) ?thing .
    ?np rdfs:label ?label .
    ?np dct:description ?description .
    ?np dct:created ?date .
    filter(str(?date) > \"2022\")
  }
  bind(concat(\" \",lcase(str(?label)),\" \",lcase(str(?description)),\" \") as ?text)
  filter( contains(?text, lcase(str(?_searchterm))) )
  
  optional {
    graph npa:graph {
      ?disapproval npa:hasValidSignatureForPublicKey ?dpubkey .
    }
    graph ?latest_curators_assertion {
      ?dpubkeys npx:hasPublicKey ?dpubkey .
    }
    graph npa:graph {
      filter not exists { ?disapproval_x npx:invalidates ?disapproval ; npa:hasValidSignatureForPublicKey ?dpubkey . }
      ?disapproval np:hasAssertion ?da .
    }
    graph ?da {
      ?dsomebody ( npx:disapproves-of | npx:disapprovesOf ) ?np .
    }
  } filter(!bound(?disapproval))  # Faster than \"filter not exists\" for some reason

  optional {
    graph npa:graph {
      ?recommendation_np npx:hasNanopubType fip:recommended-by .
      ?recommendation_np npa:hasValidSignatureForPublicKey ?rpubkey .
      filter not exists { ?recommendation_np_x npx:invalidates ?recommendation_np ; npa:hasValidSignatureForPublicKey ?rpubkey . }
      ?recommendation_np np:hasAssertion ?ra .
      ?recommendation_np np:hasProvenance ?rp .
    }
    graph ?ra {
      ?thing fip:recommended-by ?recommender .
    }
    graph ?rp {
      ?ra prov:wasDerivedFrom ?rfip_np .
    }
    graph npa:graph {
      ?rfip_np npx:hasNanopubType fip:Reference-FAIR-Implementation-Profile .
      ?rfip_np npa:hasValidSignatureForPublicKey ?rfip_pubkey .
      ?latest_rfip_np npa:hasValidSignatureForPublicKey ?rfip_pubkey .
      filter not exists { ?latest_rfip_npx npx:invalidates ?latest_rfip_np ; npa:hasValidSignatureForPublicKey ?rfip_pubkey . }
    }
    graph npa:networkGraph {
      ?latest_rfip_np (npx:supersedes)* ?rfip_np .
    }
    graph ?rfip_qa {
      ?rfip_qualifier npx:qualifies ?latest_rfip_np .
    }
    graph npa:graph {
      ?rfip_qualification_np np:hasAssertion ?rfip_qa .
      ?rfip_qualification_np npx:hasNanopubType npx:qualifies .
      ?rfip_qualification_np npa:hasValidSignatureForPublicKey ?rfip_qpubkey .
      filter not exists { ?rfip_qualification_np_x npx:invalidates ?rfip_qualification_np ; npa:hasValidSignatureForPublicKey ?rfip_qpubkey . }
    }
    graph ?latest_curators_assertion {
      ?rfip_qpubkeys npx:hasPublicKey ?rfip_qpubkey .
    }
  }
  optional {
    graph npa:graph {
      ?qualification_np npx:hasNanopubType npx:qualifies .
      ?qualification_np npa:hasValidSignatureForPublicKey ?qpubkey .
    }
    graph ?latest_curators_assertion {
      ?qpubkeys npx:hasPublicKey ?qpubkey .
    }
    graph npa:graph {
      filter not exists { ?qualification_np_x npx:invalidates ?qualification_np ; npa:hasValidSignatureForPublicKey ?qpubkey . }
      ?qualification_np np:hasAssertion ?qa .
    }
    graph ?qa {
      ?qualifier npx:qualifies ?np .
    }
  }

  optional {
    graph npa:graph {
      ?fairAssessmentLevelNp npx:hasNanopubType fip:has-FAIR-assessment .
      ?fairAssessmentLevelNp npa:hasValidSignatureForPublicKey ?lpubkey .
    }
    graph ?latest_curators_assertion {
      ?lpubkeys npx:hasPublicKey ?lpubkey .
    }
    graph npa:graph {
      filter not exists { ?fairAssessmentLevelNp_x npx:invalidates ?fairAssessmentLevelNp ; npa:hasValidSignatureForPublicKey ?lpubkey . }
      ?fairAssessmentLevelNp np:hasAssertion ?la .
    }
    graph ?la {
      ?thing fip:has-FAIR-assessment ?fairAssessmentLevel .
    }
  } filter(!bound(?levelNp))  # Faster than \"filter not exists\" for some reason

}
group by ?thing ?label ?description ?np ?date ?pubkey ?retraction ?newversion ?qualifier ?qualification_np
order by desc(?recommender_count) asc(?label)""" .

<https://w3id.org/np/RADoFDqAnBoTNbcMOpVks8a5XvMJIy7PQqvJMEY6JquIc/get-all-rocrate-nanopubs>
  a grlc:grlc-query;
  dct:description "This query returns all RO-Crate nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all RO-Crate Nanopubs (new type)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/a94355158beda26c5d1533e079a7f76e827b9037dc594fac440e0cf3a2a153d1>;
  grlc:sparql "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix dct: <http://purl.org/dc/terms/> prefix np: <http://www.nanopub.org/nschema#> prefix npa: <http://purl.org/nanopub/admin/> prefix npx: <http://purl.org/nanopub/x/> prefix kpxl: <https://w3id.org/kpxl/gen/terms/>  select distinct ?rocrate ?date (?__agent_iri as ?agent) ?np (?__pubkeyhash as ?pubkey) where {   graph npa:graph {     ?np npx:hasNanopubType kpxl:RoCrateNanopub .     ?np npa:hasValidSignatureForPublicKeyHash ?__pubkeyhash .     filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?__pubkeyhash . }     ?np dct:created ?date .     ?np npx:introduces ?rocrate .     ?np npx:signedBy ?__agent_iri .   } } order by desc(?date)" .

<https://w3id.org/np/RAZZqZF32-571vr8dVlRfgwUdweOogVr20HL_vWae5FLY/get-all-rocrate-nanopubs>
  a grlc:grlc-query;
  dct:description "This query returns all RO-Crate nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all RO-Crate Nanopubs (new type)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/a94355158beda26c5d1533e079a7f76e827b9037dc594fac440e0cf3a2a153d1>;
  grlc:sparql "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix dct: <http://purl.org/dc/terms/> prefix np: <http://www.nanopub.org/nschema#> prefix npa: <http://purl.org/nanopub/admin/> prefix npx: <http://purl.org/nanopub/x/> prefix kpxl: <https://w3id.org/kpxl/gen/terms/>  select distinct ?rocrate ?date (?__agent_iri as ?agent) ?np (?__pubkeyhash as ?pubkey) where {   graph npa:graph {     ?np npx:hasNanopubType kpxl:RoCrateNanopub .     ?np npa:hasValidSignatureForPublicKeyHash ?__pubkeyhash .     filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?__pubkeyhash . }     ?np dct:created ?date .     ?np npx:introduces ?rocrate .     ?np npx:signedBy ?__agent_iri .   } } order by desc(?date)" .

<https://w3id.org/np/RAhN5_UrRfgNdm3lHUxpTB8XX7AcDvRu-SWN5BvbxEDZM/get-all-rocrate-nanopubs>
  a grlc:grlc-query;
  dct:description "This query returns all RO-Crate nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all RO-Crate Nanopubs (old type)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/a94355158beda26c5d1533e079a7f76e827b9037dc594fac440e0cf3a2a153d1>;
  grlc:sparql "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>prefix dct: <http://purl.org/dc/terms/>prefix np: <http://www.nanopub.org/nschema#>prefix npa: <http://purl.org/nanopub/admin/>prefix npx: <http://purl.org/nanopub/x/>select distinct ?rocrate ?date ?np where {  graph npa:graph {    ?np npx:hasNanopubType npx:RoCrateNanopub .    filter not exists { ?npx npx:invalidates ?np }    ?np dct:created ?date .    ?np npx:introduces ?rocrate .  }}order by desc(?date)" .

<https://w3id.org/np/RA6jejfdtvpwzvBHTijU1TlpAU8qXjc4TNt43qzlmxLm0/get-all-rocrate-nanopubs>
  a grlc:grlc-query;
  dct:description "This query returns all RO-Crate nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all RO-Crate Nanopubs (old type)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/a94355158beda26c5d1533e079a7f76e827b9037dc594fac440e0cf3a2a153d1>;
  grlc:sparql "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>prefix dct: <http://purl.org/dc/terms/>prefix np: <http://www.nanopub.org/nschema#>prefix npa: <http://purl.org/nanopub/admin/>prefix npx: <http://purl.org/nanopub/x/>select distinct ?rocrate ?date ?np where {  graph npa:graph {    ?np npx:hasNanopubType npx:RoCrateNanopub .    filter not exists { ?npx npx:invalidates ?np }    ?np dct:created ?date .    ?np npx:introduces ?rocrate .  }}order by desc(?date)" .

<https://w3id.org/np/RAxwaV0932wEXtFMeYPIOaZ0KzxVZvNVHpoM01xRcffz0/get-all-rocrate-nanopubs>
  a grlc:grlc-query;
  dct:description "This query returns all RO-Crate nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all RO-Crate Nanopubs (old type)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/a94355158beda26c5d1533e079a7f76e827b9037dc594fac440e0cf3a2a153d1>;
  grlc:sparql "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>prefix dct: <http://purl.org/dc/terms/>prefix np: <http://www.nanopub.org/nschema#>prefix npa: <http://purl.org/nanopub/admin/>prefix npx: <http://purl.org/nanopub/x/>select distinct ?rocrate ?date ?np where {  graph npa:graph {    ?np npx:hasNanopubType npx:RoCrateNanopub .    filter not exists { ?npx npx:invalidates ?np }    ?np dct:created ?date .    ?np npx:introduces ?rocrate .  }}order by desc(?date)" .

<https://w3id.org/np/RAFfcfnIIX_2yNybt_Kx1PmlDmgZvSLsogDDsi5eAtG74/get-faqs> a grlc:grlc-query;
  dct:description "This query returns the FAQ entries (questions and answers) of an entity, including source nanopub and date. When several nanopubs declare the same FAQ entry, only the most recent one is returned.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get FAQ entries of an entity";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/88a3271eb4f952262a674b6765824830ecb6c5a9ae10f1fd8caa4fc21cdccad7>;
  grlc:sparql """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <http://schema.org/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?title ?content ?date ?faq ?np where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?faq rdf:type schema:Question .
    ?faq rdfs:label ?title .
    ?faq gen:hasContent ?content .
    values ?_resource_multi_iri {}
    ?faq dct:isPartOf ?_resource_multi_iri .
    optional { ?faq gen:hasPositionString ?position }
  }
  filter not exists {
    graph npa:graph {
      ?np2 npa:hasValidSignatureForPublicKeyHash ?pubkey2 .
      filter not exists { ?npx2 npx:invalidates ?np2 ; npa:hasValidSignatureForPublicKeyHash ?pubkey2 . }
      ?np2 dct:created ?date2 .
      ?np2 np:hasAssertion ?a2 .
      filter (?date2 > ?date)
    }
    graph ?a2 {
      ?faq rdf:type schema:Question .
    }
  }
}
order by ?position ?title""" .

<https://w3id.org/np/RALx4mcnF84op6E-q-voMr19X80Sy_Khy2I1dMmachJ3o/get-fip-decl-in-index>
  a grlc:grlc-query;
  dct:description "This query returns all FIP declarations that are part of the most recent versions of the FIP indexes, as these nanopubs are produced by the FIP Wizard.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get FIP declarations in indexes";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix dct: <http://purl.org/dc/terms/>
prefix dce: <http://purl.org/dc/elements/1.1/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix np: <http://www.nanopub.org/nschema#>
prefix prov: <http://www.w3.org/ns/prov#>

select ?fip_index ?fip_title ?fip_source ?decl_np where {
  graph npa:graph {
    ?fip_index npx:hasNanopubType npx:NanopubIndex .
    ?fip_index npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?index_np_x npx:invalidates ?fip_index ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?fip_index np:hasAssertion ?index_a .
    ?fip_index np:hasPublicationInfo ?index_i .
    ?fip_index rdfs:label ?fip_title .
    ?fip_index dct:created ?index_date .
    ?decl_np npa:hasValidSignatureForPublicKey ?decl_pubkey .
    filter not exists { ?decl_np_x npx:invalidates ?decl_np ; npa:hasValidSignatureForPublicKey ?decl_pubkey . }
    ?decl_np npx:hasNanopubType fip:FIP-Declaration .
    ?decl_np dct:created ?date .
  }
  graph ?index_a {
    ?fip_index npx:includesElement ?decl_np .
  }
  graph ?index_i {
    ?fip_index prov:wasDerivedFrom ?fip_source .
  }
  filter not exists {
    graph npa:graph { # Moving this to a separate graph for performance reasons with RDF4J LMDB engine
      # Matching on the title string is an ugly hack:
      ?fip_newer_index rdfs:label ?fip_title .
    }
    graph npa:graph {
      ?fip_newer_index npa:hasValidSignatureForPublicKey ?pubkey .
      filter not exists { ?fip_newer_index_x npx:invalidates ?fip_newer_index ; npa:hasValidSignatureForPublicKey ?pubkey . }
      ?fip_newer_index dct:created ?newer_date .
    }
    filter(?newer_date > ?index_date).
  }
}""" .

<https://w3id.org/np/RAsW9bmHY-TvpycMw0KweAE0g5i_M5eyVKFOAuvXWs1BQ/get-annotated-entities>
  a grlc:grlc-query;
  dct:description "Lists all entities that have been annotated by nanopubs containing oa:Annotation, ordered by the number of annotation nanopubs targeting each entity.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get annotated entities";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix oa: <http://www.w3.org/ns/oa#>

select ?entity (count(?np) as ?annotation_count)
  (group_concat(str(?np); separator=\" \") as ?nps_multi_iri)
  (group_concat(\"^\"; separator=\"\\n\") as ?nps_label_multi)
where {
  {
    select distinct ?entity ?np where {
      graph npa:graph {
        ?np np:hasAssertion ?a .
        ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
        filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
      }
      graph ?a {
        ?annotation a oa:Annotation ;
          oa:hasTarget ?target .
        ?target oa:hasSource ?entity .
      }
    }
  }
}
group by ?entity
order by desc(?annotation_count)""" .

<https://w3id.org/np/RA6xFhuP00MiS7MvgFwxgIENkLSpvHMPsgTqQ1WpxCsjw/get-papers-for-team>
  a grlc:grlc-query;
  dct:description "This query returns the papers co-authored by team members of a given Space.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get papers for team";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix fabio: <http://purl.org/spar/fabio/>
prefix bibo: <http://purl.org/ontology/bibo/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select distinct ?paper ?paper_label ?journal ?journal_label ?publication_date ?np (\"^\" as ?np_label) where {
  values ?_space_multi_iri {}
  graph npa:graph {
    ?mnp npa:hasValidSignatureForPublicKeyHash ?mpubkey .
    filter not exists { ?mnpx npx:invalidates ?mnp ; npa:hasValidSignatureForPublicKeyHash ?mpubkey . }
    ?mnp np:hasAssertion ?ma .
  }
  graph ?ma {
    ?_space_multi_iri gen:hasTeamMember ?author .
  }
  graph npa:graph {
    ?np npx:hasNanopubType fabio:ScholarlyWork .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?paper .
  }
  graph ?a {
    ?paper dct:title ?paper_label .
    ?paper bibo:authorList ?author_list .
    ?paper dct:date ?publication_date .
    ?author_list ?rdfseqpred ?author .
    filter(strstarts(str(?rdfseqpred), \"http://www.w3.org/1999/02/22-rdf-syntax-ns#_\"))
    optional {
      ?paper dct:isPartOf ?journal .
      ?journal dct:title ?journal_label .
    }
  }
}
order by desc(?publication_date)""" .

<https://w3id.org/np/RAPmq6S_b-med8V0SHm0qOd4XvlCbxZ-FXaqohaOWoOnY/get-3pff-events-html>
  a grlc:grlc-query;
  dct:description "Returns a list of all events related to the Three Point FAIRification Framework (3PFF), with multi-value fields pre-rendered as HTML anchor strings. Variant of get-3pff-events intended for consumption by clients (e.g. nanopub-table with data-bind-html) that cannot split space-separated URI lists on their own.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get 3PFF Events (HTML)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/1c6aa07996de9244076dbdbf96515ae280fb28a8a0cc49f7b0b8c819bc8d54cf>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix tpff: <https://w3id.org/fair/3pff/>
prefix schema: <http://schema.org/>

select
  (?event as ?Event_ID)
  (?eventShortName as ?Event_ID__label)
  (?eventLongName as ?Event_Name)
  (?eventDate as ?Date)
  (group_concat(distinct concat(
    \"<a href=\\\"\", str(?eventOrganizer), \"\\\">\",
    replace(str(?eventOrganizer), \"^.*[/#]\", \"\"),
    \"</a>\"
  ); separator=\", \") as ?Organizers)
  (group_concat(distinct concat(
    \"<a href=\\\"\", str(?eventFacilitator), \"\\\">\",
    replace(str(?eventFacilitator), \"^.*[/#]\", \"\"),
    \"</a>\"
  ); separator=\", \") as ?Facilitators)
  (group_concat(distinct concat(
    \"<a href=\\\"\", str(?eventMoreInfoLink), \"\\\">\",
    replace(str(?eventMoreInfoLink), \"^.*[/#]\", \"\"),
    \"</a>\"
  ); separator=\", \") as ?More_Info)
  (?np as ?Source)
where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np dct:created ?npDate .
    ?np dct:creator ?npCreator .
    ?np np:hasAssertion ?assertion .
    ?np npx:introduces ?event .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
  }
  graph ?assertion {
    ?event a tpff:3PFF-event .
    ?event rdfs:label ?eventName .

    # Date Handling: Check for both predicates
    optional { ?event dct:date ?dateDct . }
    optional { ?event schema:startDate ?dateSchema . }
    bind(coalesce(?dateDct, strBefore(str(?dateSchema), \"T\")) as ?eventDate)

    bind(replace(str(?eventName), ' ?\\\\|.*$', '') as ?eventShortName)
    bind(replace(str(?eventName), '^([A-Z0-9]{2,3}).*$', '$1') as ?eventSeries)
    bind(replace(str(?eventName), '^.*\\\\| ?(.*)$', '$1') as ?eventLongName)

    optional {
      ?event tpff:has-event-organizer ?eventOrganizer .
    }
    optional {
      ?event tpff:has-event-facilitator ?eventFacilitator .
    }
    optional {
      ?event rdfs:seeAlso ?eventMoreInfoLink .
    }
  }
}
group by ?event ?eventShortName ?eventLongName ?eventDate ?np
order by desc(?eventDate)""" .

<https://w3id.org/np/RAydXkXhyL-uFqfW6F9DoM6Eu4x0bjux2JsdzQwy9stJM/find-fdo-subclasses>
  a grlc:grlc-query;
  dct:description "Full-text search over classes that have been declared as FAIR Digital Object (FDO) subclasses in nanopublications. Suitable as an autocomplete lookup source in Nanodash guided-choice placeholders.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Full-text search on FDO subclasses";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/f82fa5e467e6ba40c5d14402c3590f2ad8ed9a13e982133ab26ef1a889b34ebd>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>
prefix fdof: <https://w3id.org/fdof/ontology#>

select distinct ?thing ?label ?description ?np ?pubkey ?date where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np dct:created ?date .
    ?np npx:introduces|npx:describes|npx:embeds ?thing .
    ?np rdfs:label ?label .
    optional { ?np dct:description ?description . }
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?thing rdfs:subClassOf fdof:FAIRDigitalObject .
  }
  filter(contains(lcase(str(?label)), lcase(?_query)))
}
order by desc(?date)
limit 10""" .

<https://w3id.org/np/RAx19vZVg2X9P-GQlVaWtcNCqbOruRHIIJhBCUrinBDRQ/get-pinned-templates-for-resource>
  a grlc:grlc-query;
  dct:description "Returns the pinned templates for the given resource (Space, agent, or other resource), formatted for list display.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get pinned templates for resource";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/5061d4f8ce945becd54000fab7645326faad3024f83998d8613ecc5e92c595e5>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix nt: <https://w3id.org/np/o/ntemplate/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?label ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np npx:hasNanopubType gen:hasPinnedTemplate .
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np np:hasPublicationInfo ?pi .
  }
  graph ?a {
    values ?_resource_multi_iri {}
    ?_resource_multi_iri gen:hasPinnedTemplate ?template .
  }
  optional { graph ?pi { ?template nt:hasLabelFromApi ?api_label } }
  bind(if(bound(?api_label),
    if(contains(?api_label, \" - \"), strbefore(?api_label, \" - \"), ?api_label),
    str(?template)) as ?rawlabel)
  bind(concat(\"<span><a href=\\\"/publish?template=\", encode_for_uri(str(?template)), \"\\\">\", ?rawlabel, \"</a></span>\") as ?label)
} order by desc(?date)""" .

<https://w3id.org/np/RAWd7JXEAoMqP-5FlsLJCH2VI85inDDb7whiegnDsCkT8/get-pinned-queries-for-resource>
  a grlc:grlc-query;
  dct:description "Returns the pinned queries for the given resource (Space, agent, or other resource), formatted for list display.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get pinned queries for resource";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/2f015fe8a76203b3802178d9104416bd39d2592618810fc070af54351971bed0>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix nt: <https://w3id.org/np/o/ntemplate/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?label ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np npx:hasNanopubType gen:hasPinnedQuery .
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np np:hasPublicationInfo ?pi .
  }
  graph ?a {
    values ?_resource_multi_iri {}
    ?_resource_multi_iri gen:hasPinnedQuery ?query .
  }
  optional { graph ?pi { ?query nt:hasLabelFromApi ?api_label } }
  bind(if(bound(?api_label),
    if(contains(?api_label, \" - \"), strbefore(?api_label, \" - \"), ?api_label),
    str(?query)) as ?rawlabel)
  bind(replace(str(?query), \"https://w3id.org/np/\", \"\") as ?spec_path)
  bind(concat(\"<span><a href=\\\"/query?id=\", ?spec_path, \"\\\">\", ?rawlabel, \"</a></span>\") as ?label)
} order by desc(?date)""" .

<https://w3id.org/np/RA2zssMBdXlBkp6X-2P-oEAV3_qrr24ETFjVRIzRMuQX4/get-queries-by-user>
  a grlc:grlc-query;
  dct:description "Returns the grlc query nanopublications created by the given user.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get queries by given user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix grlc: <https://w3id.org/kpxl/grlc/>

select ?label ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:signedBy ?_user_iri .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkeyhash .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkeyhash . }
    ?np npx:hasNanopubType grlc:grlc-query .
    ?np npx:introduces|npx:embeds ?query .
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?query grlc:endpoint ?endpoint .
    filter(strstarts(str(?endpoint), \"https://w3id.org/np/l/nanopub-query\"))
    optional { ?query rdfs:label ?rawlabel }
  }
  bind(replace(str(?query), \"https://w3id.org/np/\", \"\") as ?spec_path)
  bind(concat(\"<span><a href=\\\"/query?id=\", ?spec_path, \"\\\">\", coalesce(?rawlabel, str(?query)), \"</a></span>\") as ?label)
} order by desc(?date)""" .

<https://w3id.org/np/RAS7TYM9bUPRh21GQ58dkxDM0Nv3rLGoMkHa29QW3sFCA/get-templates-by-user>
  a grlc:grlc-query;
  dct:description "Returns the assertion templates created by the given user.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get templates by given user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/79342356d3a68063a627e83ac34b376479e438abb8a4c4b27d49f845f537dc8d>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix nt: <https://w3id.org/np/o/ntemplate/>

select ?label ?tag ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:signedBy ?_user_iri .
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np npx:hasNanopubType nt:AssertionTemplate .
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?a rdfs:label ?rawlabel .
    optional { ?a nt:hasTag ?tag . }
    filter not exists { ?a a nt:UnlistedTemplate }
  }
  bind(concat(\"<span><a href=\\\"/publish?template=\", encode_for_uri(str(?np)), \"\\\">\", ?rawlabel, \"</a></span>\") as ?label)
} order by desc(?date)""" .

<https://w3id.org/np/RA2heUumpDFaDxWu98tBNbmHAuz5k3YI37Fw3Yi0hte_s/find-gofair-qualified-vocab-onto>
  a grlc:grlc-query;
  dct:description "This query allows for searching for resources (FERs etc.) together with the info about whether GO FAIR qualified them.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Find GO FAIR qualified vocabularies/ontologies";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix prov: <http://www.w3.org/ns/prov#>

select distinct ?thing ?label ?types ?description ?np ?date ?pubkey ?retraction ?newversion ?qualifier ?qualification_np (group_concat(distinct ?recommender; separator=\" \") as ?recommenders) (group_concat(distinct ?recommendation_np; separator=\" \") as ?recommendation_nps) (count(distinct ?recommender) as ?recommender_count) (sample(?fairAssessmentLevel) as ?fairAssessmentLevel) (sample(?fairAssessmentLevelNp) as ?fairAssessmentLevelNp) where {
  
  {
    SELECT ?np (GROUP_CONCAT(DISTINCT ?filteredType; separator=\" \") AS ?types) WHERE {
      GRAPH npa:graph {
        VALUES ?filteredType { fip:Semantic-model fip:Structured-vocabulary }
        ?np npx:hasNanopubType ?filteredType .
      }
    } GROUP BY ?np
  }
  
  graph npa:graph {
    <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> npa:hasValidSignatureForPublicKey ?curators_np_pk .
    ?latest_curators_np npa:hasValidSignatureForPublicKey ?curators_np_pk .
    filter not exists { ?latest_curators_npx npx:invalidates ?latest_curators_np ; npa:hasValidSignatureForPublicKey ?curators_np_pk . }
    ?latest_curators_np np:hasAssertion ?latest_curators_assertion .
  }
  graph npa:networkGraph {
    ?latest_curators_np (npx:supersedes)* <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> .
    filter not exists { ?latest_curators_npxx npx:supersedes ?latest_curators_np }
  }
  
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    optional { ?retraction npx:retracts ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    optional { ?newversion npx:supersedes ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np (npx:introduces|npx:describes) ?thing .
    ?np rdfs:label ?label .
    ?np dct:description ?description .
    ?np dct:created ?date .
    filter(str(?date) > \"2022\")
  }
  bind(concat(\" \",lcase(str(?label)),\" \",lcase(str(?description)),\" \") as ?text)
  filter( contains(?text, lcase(str(?_searchterm))) )

  optional {
    graph npa:graph {
      ?disapproval npa:hasValidSignatureForPublicKey ?dpubkey .
    }
    graph ?latest_curators_assertion {
      ?dpubkeys npx:hasPublicKey ?dpubkey .
    }
    graph npa:graph {
      filter not exists { ?disapproval_x npx:invalidates ?disapproval ; npa:hasValidSignatureForPublicKey ?dpubkey . }
      ?disapproval np:hasAssertion ?da .
    }
    graph ?da {
      ?dsomebody ( npx:disapproves-of | npx:disapprovesOf ) ?np .
    }
  } filter(!bound(?disapproval))  # Faster than \"filter not exists\" for some reason

  optional {
  optional {
    graph npa:graph {
      ?recommendation_np npx:hasNanopubType fip:recommended-by .
      ?recommendation_np npa:hasValidSignatureForPublicKey ?rpubkey .
      filter not exists { ?recommendation_np_x npx:invalidates ?recommendation_np ; npa:hasValidSignatureForPublicKey ?rpubkey . }
      ?recommendation_np np:hasAssertion ?ra .
      ?recommendation_np np:hasProvenance ?rp .
    }
    graph ?ra {
      ?thing fip:recommended-by ?recommender .
    }
    graph ?rp {
      ?ra prov:wasDerivedFrom ?rfip_np .
    }
    graph npa:graph {
      ?rfip_np npx:hasNanopubType fip:Reference-FAIR-Implementation-Profile .
      ?rfip_np npa:hasValidSignatureForPublicKey ?rfip_pubkey .
      ?latest_rfip_np npa:hasValidSignatureForPublicKey ?rfip_pubkey .
      filter not exists { ?latest_rfip_npx npx:invalidates ?latest_rfip_np ; npa:hasValidSignatureForPublicKey ?rfip_pubkey . }
    }
    graph npa:networkGraph {
      ?latest_rfip_np (npx:supersedes)* ?rfip_np .
    }
    graph ?rfip_qa {
      ?rfip_qualifier npx:qualifies ?latest_rfip_np .
    }
    graph npa:graph {
      ?rfip_qualification_np np:hasAssertion ?rfip_qa .
      ?rfip_qualification_np npx:hasNanopubType npx:qualifies .
      ?rfip_qualification_np npa:hasValidSignatureForPublicKey ?rfip_qpubkey .
      filter not exists { ?rfip_qualification_np_x npx:invalidates ?rfip_qualification_np ; npa:hasValidSignatureForPublicKey ?rfip_qpubkey . }
    }
    graph ?latest_curators_assertion {
      ?rfip_qpubkeys npx:hasPublicKey ?rfip_qpubkey .
    }
  }
    graph npa:graph {
      ?qualification_np npx:hasNanopubType npx:qualifies .
      ?qualification_np npa:hasValidSignatureForPublicKey ?qpubkey .
    }
    graph ?latest_curators_assertion {
      ?qpubkeys npx:hasPublicKey ?qpubkey .
    }
    graph npa:graph {
      filter not exists { ?qualification_np_x npx:invalidates ?qualification_np ; npa:hasValidSignatureForPublicKey ?qpubkey . }
      ?qualification_np np:hasAssertion ?qa .
    }
    graph ?qa {
      ?qualifier npx:qualifies ?np .
    }
  }

  optional {
    graph npa:graph {
      ?fairAssessmentLevelNp npx:hasNanopubType fip:has-FAIR-assessment .
      ?fairAssessmentLevelNp npa:hasValidSignatureForPublicKey ?lpubkey .
    }
    graph ?latest_curators_assertion {
      ?lpubkeys npx:hasPublicKey ?lpubkey .
    }
    graph npa:graph {
      filter not exists { ?fairAssessmentLevelNp_x npx:invalidates ?fairAssessmentLevelNp ; npa:hasValidSignatureForPublicKey ?lpubkey . }
      ?fairAssessmentLevelNp np:hasAssertion ?la .
    }
    graph ?la {
      ?thing fip:has-FAIR-assessment ?fairAssessmentLevel .
    }
  } filter(!bound(?levelNp))  # Faster than \"filter not exists\" for some reason

}
group by ?thing ?label ?types ?description ?np ?date ?pubkey ?retraction ?newversion ?qualifier ?qualification_np
order by desc(?recommender_count) asc(?label)""" .

<https://w3id.org/np/RA7ZVUBsunF1SvM67wE-PzjiwuAc2IO53ympEWIZtmowE/get-llm-kg-papers-summary>
  a grlc:grlc-query;
  dct:description "This query summarises statistics for the assessed LLM-KG integration papers, returning the average number of described and discussed methods, along with the % of papers that have the source code link in the text.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get summary statistics for assessed LLM-KG papers";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/793278d29da42e9607b0870e3d4f4a43c9be03f9a5f909b59844d1deb725f400>;
  grlc:sparql """PREFIX np: <http://www.nanopub.org/nschema#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX cito: <http://purl.org/spar/cito/>
PREFIX fabio: <http://purl.org/spar/fabio/>
PREFIX npx: <http://purl.org/nanopub/x/>

SELECT 
(STR(ROUND(AVG(?describedCount) * 100) / 100) AS ?AvgDescribedMethods)
(STR(ROUND(AVG(?discussedCount) * 100) / 100) AS ?AvgDiscussedMethods)
  (CONCAT(STR(ROUND((SUM(?hasUrl) / COUNT(?paper)) * 100)), \"%\") AS ?PercentPapersWithSourceCodeURL)
WHERE {
  {
    SELECT ?paper 
      (COUNT(DISTINCT ?desc) AS ?describedCount) 
      (COUNT(DISTINCT ?disc) AS ?discussedCount)

      (MAX(IF(BOUND(?methodUrl), 1, 0)) AS ?hasUrl)
    WHERE {
      ?np a np:Nanopublication ; 
          np:hasAssertion ?assertion .
      
      FILTER NOT EXISTS {
    		?newerNp npx:supersedes ?np .
  		}
      
      GRAPH ?assertion {
        ?paper a prov:Entity .
        
        OPTIONAL { 
          ?paper cito:describes ?desc . 
          OPTIONAL { ?desc fabio:hasURL ?methodUrl . }
        }

        OPTIONAL { ?paper cito:discusses ?disc . }
      }
    }
    GROUP BY ?paper
  }
}""" .

<https://w3id.org/np/RAoTk2RB6fztwEdg3xYaJzAFP8RwaKmVtzYXGL0kZEDW4/get-llm-kg-category-count>
  a grlc:grlc-query;
  dct:description "This query returns the distribution of unique research papers across the two-tier hierarchy of LLM-KG integration, excluding all superseded assessments.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get counts of assessed LLM-KG papers per assigned category";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/793278d29da42e9607b0870e3d4f4a43c9be03f9a5f909b59844d1deb725f400>;
  grlc:sparql """PREFIX npx: <http://purl.org/nanopub/x/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX np: <http://www.nanopub.org/nschema#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX cito: <http://purl.org/spar/cito/>

SELECT ?TopCategory ?Category (STR(COUNT(DISTINCT ?paper)) AS ?PaperCount) (SAMPLE(?np) AS ?Example)
WHERE {
  ?np a np:Nanopublication ;
      np:hasAssertion ?assertionGraph .
  
  FILTER NOT EXISTS {
    ?newerNp npx:supersedes ?np .
  }
  
  GRAPH ?assertionGraph {
    ?paper a prov:Entity ;
           cito:describes ?method .

    ?method dct:subject ?catUri ;
            <https://neverblink.eu/ontologies/llm-kg/hasTopCategory> ?topUri .

    BIND(REPLACE(STR(?topUri), \"^.*#\", \"\") AS ?TopCategory)
    BIND(REPLACE(STR(?catUri), \"^.*#\", \"\") AS ?Category)
  }
}
GROUP BY ?TopCategory ?Category
ORDER BY ?TopCategory""" .

<https://w3id.org/np/RA9sKk0x5Zwy4p7rur0qSWkIfIR3fdxI_phsuQMeFXqK0/get-testimonials-by-project-leads>
  a grlc:grlc-query;
  dct:description "This query returns the testimonials (about any entity) authored by any of the project leads of the given project.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get testimonials by project leads";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <https://schema.org/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?author ?author_label ?about ?about_label ?text ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?lead_np np:hasAssertion ?lead_a .
    ?lead_np npa:hasValidSignatureForPublicKeyHash ?lead_pubkey .
    filter not exists { ?lead_npx npx:invalidates ?lead_np ; npa:hasValidSignatureForPublicKeyHash ?lead_pubkey . }
  }
  graph ?lead_a {
    ?_project_iri gen:hasProjectLead ?author .
  }
  graph npa:graph {
    ?np npx:hasNanopubType gen:Testimonial .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx2 npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np npx:introduces ?testimonial .
    ?np np:hasAssertion ?a .
    ?np dct:created ?date .
  }
  graph ?a {
    ?testimonial dct:description ?text .
    ?testimonial schema:author ?author .
    optional { ?testimonial schema:about ?about . }
    optional { ?author rdfs:label ?author_label . }
    optional { ?about rdfs:label ?about_label . }
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RA7BDm_AJfuwtYKLXgfJGKEyrpD33ZSMDQeL5ltfGuDGo/get-classes-of-ontology>
  a grlc:grlc-query;
  dct:description "This query returns all classes that specify to be part of a given ontology.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the classes of an ontology";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/e8cc5bb29ec5597303f8f101c65c545dc124ee0df68ce733764b03adc3237184>;
  grlc:sparql """prefix owl: <http://www.w3.org/2002/07/owl#>
  prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>                                                                                                            
  prefix dct: <http://purl.org/dc/terms/>                                                                                                                         
  prefix np: <http://www.nanopub.org/nschema#>                                                                                                                    
  prefix npa: <http://purl.org/nanopub/admin/>                                                                                                                    
  prefix npx: <http://purl.org/nanopub/x/>                                                                                                                        
  prefix skos: <http://www.w3.org/2004/02/skos/core#>                                                                                                             
                                                                                                                                                                  
  select ?class ?class_label (?definition as ?description)
         (group_concat(distinct str(?superclass); separator=\" \") as ?superclasses_multi_iri)                                                                      
         (group_concat(distinct replace(replace(coalesce(?superclass_lbl, str(?superclass)), \"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\"), \"[\\r\\n]+\", \"\\\\\\\\n\"); separator=\"\\n\") as         
  ?superclasses_label_multi)                                                                                                                                      
         ?np (\"^\" as ?np_label) where {                                                                                                                                              
    values ?_ontology_multi_iri {}                                                                                                                                
    graph npa:graph {                                                                                                                                             
      ?np npx:hasNanopubType owl:Class .
      ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .                                                                                                         
      filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }                                                            
      ?np dct:created ?date .
      ?np npx:introduces ?class .                                                                                                                                 
      ?np np:hasAssertion ?a .
    }                                                                                                                                                             
    graph ?a {    
      ?class dct:partOf ?_ontology_multi_iri .
      optional { ?class rdfs:label ?class_label . }                                                                                                               
      optional { ?class skos:definition ?definition . }
      optional {                                                                                                                                                  
        ?class rdfs:subClassOf ?superclass .
        filter(isIRI(?superclass))                                                                                                                                
        optional { ?superclass rdfs:label ?superclass_lbl . }
      }                                                                                                                                                           
    }             
  }                                                                                                                                                               
  group by ?class ?class_label ?definition ?np
  order by ?class_label""" .

<https://w3id.org/np/RABGqv3aRClMqv7w2Icc9z0IS_CLe0MQPOtVPvjHzPaOM/get-classes-of-ontology>
  a grlc:grlc-query;
  dct:description "This query returns all classes that specify to be part of a given ontology.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the classes of an ontology";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/e8cc5bb29ec5597303f8f101c65c545dc124ee0df68ce733764b03adc3237184>;
  grlc:sparql """prefix owl: <http://www.w3.org/2002/07/owl#>                                                                                                                    
  prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>       
  prefix dct: <http://purl.org/dc/terms/>                                                                                                                         
  prefix np: <http://www.nanopub.org/nschema#>                                                                                                                    
  prefix npa: <http://purl.org/nanopub/admin/>                                                                                                                    
  prefix npx: <http://purl.org/nanopub/x/>                                                                                                                        
  prefix skos: <http://www.w3.org/2004/02/skos/core#>                                                                                                             
                                                                                                                                                                  
  select ?class ?class_label (?definition as ?description)
         (group_concat(distinct str(?superclass); separator=\" \") as ?superclasses_multi_iri)                                                                      
         (group_concat(distinct replace(replace(coalesce(?superclass_lbl, str(?superclass)), \"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\"), \"[\\r\\n]+\", \"\\\\\\\\n\"); separator=\"\\n\") as         
  ?superclasses_label_multi)                                                                                                                                      
         ?np (\"^\" as ?np_label)                                                                                                                                   
  where {                                                                                                                                                         
    values ?_ontology_multi_iri {}
    graph npa:graph {                                                                                                                                             
      ?np npx:hasNanopubType owl:Class .
      ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .                                                                                                         
      filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }                                                            
      ?np dct:created ?date .
      ?np npx:introduces ?class .                                                                                                                                 
      ?np np:hasAssertion ?a .
    }                                                                                                                                                             
    graph ?a {    
      ?class dct:partOf ?_ontology_multi_iri .
      optional { ?class rdfs:label ?class_label . }                                                                                                               
      optional { ?class skos:definition ?definition . }
      optional {                                                                                                                                                  
        ?class rdfs:subClassOf ?superclass .
        filter(isIRI(?superclass))                                                                                                                                
        optional { ?superclass rdfs:label ?superclass_lbl . }
      }                                                                                                                                                           
    }             
  }                                                                                                                                                               
  group by ?class ?class_label ?definition ?np
  order by ?class_label""" .

<https://w3id.org/np/RA7HCpPKDuU9MlnakZE7QHomIFsj-Nk5GwnConWniI2js/get-all-templates>
  a grlc:grlc-query;
  dct:description "Returns all assertion templates with their label, tag, creator and date, ordered by descending date";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all templates";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/79342356d3a68063a627e83ac34b376479e438abb8a4c4b27d49f845f537dc8d>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix nt: <https://w3id.org/np/o/ntemplate/>

select ?template_iri ?template_iri_label ?tag ?creator ?date where {
  graph npa:graph {
    ?template_iri npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?npx npx:invalidates ?template_iri ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?template_iri npx:hasNanopubType nt:AssertionTemplate .
    ?template_iri dct:created ?date .
    ?template_iri np:hasAssertion ?a .
    optional { ?template_iri npx:signedBy ?creator . }
  }
  optional { graph ?a { ?a rdfs:label ?template_iri_label } }
  optional { graph ?a { ?a nt:hasTag ?tag . } }
  filter not exists { graph ?a { ?a a nt:UnlistedTemplate } }
} order by desc(?date)""" .

<https://w3id.org/np/RAz-5JLrXHfS9LInO8L8Mw64PSGJwojVemL-V3pqqIisc/get-most-used-templates-last30d>
  a grlc:grlc-query;
  dct:description "This query returns the most used assertion templates of the last 30 days, considering the latest versions of these templates.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the most used templates of the last 30 days";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/last30d>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix nt: <https://w3id.org/np/o/ntemplate/>
prefix dct: <http://purl.org/dc/terms/>

select ?template_np ?template_np_label (sum(?npcount) as ?overallcount) {
  { select ?used_template_np (count(distinct ?np) as ?npcount) where {
    graph npa:graph {
      ?np npa:hasValidSignatureForPublicKey ?pubkey .
      filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
      ?np np:hasPublicationInfo ?i .
    }
    graph ?i {
      ?np nt:wasCreatedFromTemplate ?used_template_np .
    }
  } group by ?used_template_np }
  bind(uri(concat(\"https://w3id.org/np/l/nanopub-query-1.1/repo/type/\", sha256(str(nt:AssertionTemplate)))) as ?atservice)
  { service ?atservice {
    graph npa:networkGraph {
      ?template_np npx:supersedes* ?used_template_np .
    }
    graph npa:graph {
      ?used_template_np npa:hasValidSignatureForPublicKey ?pubkey .
      ?template_np npa:hasValidSignatureForPublicKey ?pubkey .
      filter not exists { ?template_npx npx:invalidates ?template_np ; npa:hasValidSignatureForPublicKey ?pubkey . }
      ?used_template_np np:hasAssertion ?a .
    }
    graph ?a {
      ?a rdfs:label ?template_np_label .
    } 
  } }
} group by ?template_np ?template_np_label order by desc(?overallcount) limit 10""" .

<https://w3id.org/np/RApT0O5Trs4SmBIKkhx7WsTktpeO3rNnD-yQSrRx0dJgk/get-nanopubs-by-user>
  a grlc:grlc-query;
  dct:description "Returns the latest nanopublications signed by or created by a given user (signed via npx:signedBy, or created via dct:creator if no npx:signedBy is present).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get latest nanopublications by user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>

select ?np ?date where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np dct:created ?date .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    filter not exists { ?np npx:hasNanopubType npx:retracts . }
  }
  {
    graph npa:graph {
      ?np npx:signedBy ?_userid_iri .
    }
  } union {
    filter not exists {
      graph npa:graph { ?np npx:signedBy ?anyuser . }
    }
    graph npa:graph {
      ?np dct:creator ?_userid_iri .
    }
  }
}
order by desc(?date)
limit 100""" .

<https://w3id.org/np/RA7xslzACOXMiNX-EJXDdGVE3AvoSJvDKq12mUJO0xl1g/get-nanopubs-by-user>
  a grlc:grlc-query;
  dct:description "Returns the latest nanopublications signed by or created by a given user (signed via npx:signedBy, or created via dct:creator if no npx:signedBy is present).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get latest nanopublications by user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>

select ?np ?date where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np dct:created ?date .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    filter not exists { ?np npx:hasNanopubType npx:retracts . }
  }
  {
    graph npa:graph {
      ?np npx:signedBy ?_userid_iri .
    }
  } union {
    filter not exists {
      graph npa:graph { ?np npx:signedBy ?_userid_iri . }
    }
    graph npa:graph {
      ?np dct:creator ?_userid_iri .
    }
  }
}
order by desc(?date)
limit 100""" .

<https://w3id.org/np/RAtsYQxGyxlXsZSMab67T5gm_-Eg8QiFg9mjR3NMXQtug/get-latest-users-v2>
  a grlc:grlc-query;
  dct:description "Returns the latest users who have introduced themselves, with the user IRI in the user_iri column for display.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get latest users v2";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/77757cabf6184c51c20b8b0fe5dc5e1365b7f628448335184ad54319a0affdfc>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npx: <http://purl.org/nanopub/x/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix dct: <http://purl.org/dc/terms/>

select ?user_iri where {
  {
    select ?user_iri (min(?date) as ?mindate) where {
      graph npa:graph {
        ?intronp npa:hasValidSignatureForPublicKey ?introPubkey .
        filter not exists { ?intronpx npx:retracts ?intronp ; npa:hasValidSignatureForPublicKey ?pubkey . }
        filter not exists { ?intronp npx:supersedes ?intronpx . }
        ?intronp dct:created ?date .
        ?intronp np:hasAssertion ?a .
      }
      graph ?a {
        ?keydeclaration npx:declaredBy ?user_iri .
        ?keydeclaration npx:hasPublicKey ?pubkey .
      }
    }
    group by ?user_iri
  }
}
order by desc(?mindate)
limit 100""" .

<https://w3id.org/np/RACtrpz5w6egoLdx61qRMVza82Rc7wThen-RMyG_5NC1k/get-suggested-templates-to-get-started>
  a grlc:grlc-query;
  dct:description "This query returns a list of suggested templates to get started, so it can be shown e.g. on Nanodash.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get suggested templates to get started";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>

select ?template_iri ?template_iri_label where {
  graph npa:graph {
    ?np npx:hasNanopubType <https://w3id.org/kpxl/gen/terms/SuggestedTemplateToGetStarted> .
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter(?pubkey = \"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD4Wj537OijfOWVtsHMznuXKISqBhtGDQZfdO6pbb4hg9EHMcUFGTLbWaPrP783PHv8HMAAPjvEkHLaOHMIknqhaIa5236lfBO3r+ljVdYBElBcLvROmwG+ZGtmPNZf7lMhI15xf5TfoaSa84AFRd5J2EXekK6PhaFQhRm1IpSYtwIDAQAB\")
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?template_iri a <https://w3id.org/kpxl/gen/terms/SuggestedTemplateToGetStarted> .
  }
  optional {
    graph npa:graph {
      ?template_iri rdfs:label ?raw_label .
    }
    bind(replace(str(?raw_label), \"^Template: \", \"\") as ?template_iri_label)
  }
} order by desc(?date)""" .

<https://w3id.org/np/RA5DOQEw4Nelu2XGVZFNFA07xm-RR_LPMplJanO4Y0KOs/get-suggested-templates-to-get-started>
  a grlc:grlc-query;
  dct:description "This query returns a list of suggested templates to get started, so it can be shown e.g. on Nanodash.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get suggested templates to get started";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/pubkey/1162349fdeaf431e71ab55898cb2a425b971d466150c2aa5b3c1beb498045a37>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>

select ?template_iri ?template_iri_label where {
  graph npa:graph {
    ?np npx:hasNanopubType <https://w3id.org/kpxl/gen/terms/SuggestedTemplateToGetStarted> .
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?template_iri a <https://w3id.org/kpxl/gen/terms/SuggestedTemplateToGetStarted> .
    optional { ?template_iri rdfs:label ?template_iri_label . }
  }
} order by desc(?date)""" .

<https://w3id.org/np/RAvMdZmdceXtXS8zyQ6vda-7gC2HsUuQ6WFyZMGuVdfXc/get-top-creators-last30d>
  a grlc:grlc-query;
  dct:description "This query returns the 10 creators who created most nanopublications during the last 30 days.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the top-10 creators of the last 30 days";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/last30d>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix foaf: <http://xmlns.com/foaf/0.1/>

select ?user_iri where {
  { graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np dct:creator ?user_iri .
  } }
  union
  {
    graph npa:graph {
      ?np npa:hasValidSignatureForPublicKey ?pubkey .
      ?np np:hasAssertion ?assertion .
      ?np np:hasProvenance ?prov .
    }
    graph ?prov {
      ?assertion prov:wasAttributedTo ?user_iri .
    }
  }
  filter(?user_iri != <https://orcid.org/1234-1234-1234-1234>)
  filter(?user_iri != <https://orcid.org/0000-0000-0000-0000>)
  filter(!regex(str(?user_iri), '[^A-Za-z0-9-_]RA[A-Za-z0-9-_]{43}$'))
}
group by ?user_iri
order by desc(count(distinct ?np))
limit 10""" .

<https://w3id.org/np/RAcJ4wQzfXPm05Ki00SECq5hyx7yo181Xzu933euBNApU/get-testimonials-about>
  a grlc:grlc-query;
  dct:description "This query returns the testimonials about the given entity.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get testimonials about entity";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <https://schema.org/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?author ?author_label ?text ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType gen:Testimonial .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np npx:introduces ?testimonial .
    ?np np:hasAssertion ?a .
    ?np dct:created ?date .
  }
  graph ?a {
    ?testimonial dct:description ?text .
    values ?_subject_multi_iri {}
    ?testimonial schema:about ?_subject_multi_iri .
    ?testimonial schema:author ?author .
    optional { ?author rdfs:label ?author_label . }
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RAwFxFTxlhf09GL93BrZCxVTf-FOxqNT16qVR9M9DIDvY/get-testimonials-by-author>
  a grlc:grlc-query;
  dct:description "This query returns the testimonials by the given author.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get testimonials by author";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <https://schema.org/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?about ?text ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType gen:Testimonial .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np npx:introduces ?testimonial .
    ?np np:hasAssertion ?a .
    ?np dct:created ?date .
  }
  graph ?a {
    ?testimonial dct:description ?text .
    ?testimonial schema:author ?_author_iri .
    optional { ?testimonial schema:about ?about . }
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RAoyVY3PFKl2LgnV4O4JmyepekSn8jxCGq0T2CsXv6AMs/get-fip-decl-details>
  a grlc:grlc-query;
  dct:description "This query returns the details of all FIP declarations, including schema:version for R-FIP declarations.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get FIP declaration details";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/4ad845e860a6db3a69160adb7aec894e622280ff9881e41a600756ad1abcfa23>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix dct: <http://purl.org/dc/terms/>
prefix dce: <http://purl.org/dc/elements/1.1/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix np: <http://www.nanopub.org/nschema#>
prefix dcat: <https://www.w3.org/ns/dcat#>
prefix schema: <https://schema.org/>

select ?decl_np ?community ?c ?question ?q ?sort ?nochoice ?decl ?rel ?resource_id_used ?startdate ?enddate ?date ?version where {
  graph npa:graph {
    ?decl_np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?decl_np_x npx:invalidates ?decl_np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?decl_np npx:hasNanopubType fip:FIP-Declaration .
    ?decl_np dct:created ?date .
    ?decl_np np:hasAssertion ?assertion .
  }
  graph ?assertion {
    ?decl a fip:FIP-Declaration .
    ?decl fip:refers-to-question ?question .
    {
      { ?decl fip:declares-current-use-of ?resource_id_used . bind(fip:declares-current-use-of as ?rel) }
      union
      { ?decl fip:declares-planned-use-of ?resource_id_used . bind(fip:declares-planned-use-of as ?rel) }
      union
      { ?decl fip:declares-planned-replacement-of ?resource_id_used . bind(fip:declares-planned-replacement-of as ?rel) }
      union
      { ?decl fip:declares-replacement-from ?resource_id_used . bind(fip:declares-replacement-from as ?rel) }
      union
      { ?decl fip:declares-replacement-to ?resource_id_used . bind(fip:declares-replacement-to as ?rel) }
    }
    # grlc gives an error for some reason if these two optional statements are at the end of the graph block:
    optional { ?decl dcat:startDate ?startdate . }
    optional { ?decl dcat:endDate ?enddate . }
    ?decl fip:declared-by ?community .
    optional { ?decl schema:version ?version . }
  }
  bind (replace(str(?community), \".*#\", \"\") as ?c)
  bind (replace(str(?supercommunity), \".*#\", \"\") as ?sc)
  bind (replace(str(?question), \"^.*-([^-MD]+(-[MD]+)?)$\", \"$1\") as ?q)
  bind (concat(replace(?q, \"F|M\", \"0\"), \"x\") as ?sort)
  bind (\"\" as ?nochoice)
}""" .

<https://w3id.org/np/RAWdDgH8EfNe5cuKLMaYAJWKAvTz0YHlZ4KxKaI-liDVs/get-rfip-decl-in-context>
  a grlc:grlc-query;
  dct:description "Returns R-FIP declarations: FIP declarations whose community has a Reference-FAIR-Implementation-Profile, matched with the latest R-FIP profile for that community.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get R-FIP declarations in context";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix dct: <http://purl.org/dc/terms/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix np: <http://www.nanopub.org/nschema#>
prefix schema: <https://schema.org/>

select ?fip_index ?fip_title ?decl_np where {
  # Find R-FIP profiles (latest per community)
  graph npa:graph {
    ?fip_index npx:hasNanopubType fip:Reference-FAIR-Implementation-Profile .
    ?fip_index npa:hasValidSignatureForPublicKeyHash ?pkh .
    filter not exists { ?inv npx:invalidates ?fip_index ; npa:hasValidSignatureForPublicKeyHash ?pkh . }
    ?fip_index np:hasAssertion ?rfip_a .
    ?fip_index npx:introduces ?rfip .
    ?fip_index dct:created ?rfip_date .
  }
  graph ?rfip_a {
    ?rfip rdfs:label ?fip_title .
    ?rfip fip:declared-by ?community .
  }
  # Keep only the latest R-FIP profile per community
  filter not exists {
    graph npa:graph {
      ?newer_rfip npx:hasNanopubType fip:Reference-FAIR-Implementation-Profile .
      ?newer_rfip npa:hasValidSignatureForPublicKeyHash ?nkh .
      filter not exists { ?ninv npx:invalidates ?newer_rfip ; npa:hasValidSignatureForPublicKeyHash ?nkh . }
      ?newer_rfip np:hasAssertion ?nra .
      ?newer_rfip dct:created ?newer_date .
    }
    graph ?nra {
      ?nrfip fip:declared-by ?community .
    }
    filter(?newer_date > ?rfip_date)
  }

  # Find FIP declarations from these R-FIP communities that have schema:version
  graph npa:graph {
    ?decl_np npx:hasNanopubType fip:FIP-Declaration .
    ?decl_np npa:hasValidSignatureForPublicKey ?dpk .
    filter not exists { ?dinv npx:invalidates ?decl_np ; npa:hasValidSignatureForPublicKey ?dpk . }
    ?decl_np np:hasAssertion ?decl_a .
  }
  graph ?decl_a {
    ?decl fip:declared-by ?community .
    ?decl schema:version ?version .
  }
}""" .

<https://w3id.org/np/RANapstDVfQjfmmEtnLKyNv_qGdGvwfc2TmAqmDNmafeo/get-relevant-resources>
  a grlc:grlc-query;
  dct:description "This query returns the relevant resources for a given entity (e.g. a Space).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get relevant resources";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/1bf3710b89b36c56df4a23aaf137406d1d268c0ed35aaf874359d9d215b72ccf>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?resource ?resource_label ?comment ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType gen:isRelevantFor .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    optional { ?np rdfs:label ?label }
  }
  values ?_entity_multi_iri {}
  graph ?a {
    ?resource gen:isRelevantFor ?_entity_multi_iri .
    optional { ?resource rdfs:label ?resource_label . }
    optional { ?resource rdfs:comment ?comment . }
  }
}""" .

<https://w3id.org/np/RAHhVKUA6GgNS0KE2gbOSrDynLHFBWg3ZoM9x0LbsMBjk/get-paragraphs>
  a grlc:grlc-query;
  dct:description "This query returns the paragraphs of an entity (e.g. a space) with their title and content, including source nanopub and date.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get paragraphs of an entity";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <http://schema.org/>
prefix schemas: <https://schema.org/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?title ?content ?date ?np where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np dct:creator ?user .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?paragraph schema:title|schemas:title ?title .
    ?paragraph rdf:type gen:Paragraph .
    ?paragraph gen:hasContent ?content .
    values ?_resource_multi_iri {}
    ?paragraph schema:isPartOf|schemas:isPartOf|schema:about|schemas:about ?_resource_multi_iri .
    optional { ?paragraph gen:hasPositionString ?position }
  }
}
order by ?position ?title""" .

<https://w3id.org/np/RAqmmNSxQaRNWRYH0o4Da3GSOwvoFLObhXfAGUCOqEtfw/get-newer-versions-of-np>
  a grlc:grlc-query;
  dct:description "This query returns all newer versions of a given nanopublication, including those that since have been superseded or retracted.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all newer versions of this nanopublication";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/meta>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>

select ?newerVersion ?date ?retractedBy ?supersededBy where {
  graph npa:graph {
    ?_np_iri npa:hasValidSignatureForPublicKey ?pubkey .
  }
  graph npa:networkGraph {
    ?newerVersion (npx:supersedes)* ?_np_iri .
  }
  graph npa:graph {
    ?newerVersion npa:hasValidSignatureForPublicKey ?pubkey .
  }
  optional { graph npa:graph { ?newerVersion dct:created ?date . } }
  optional { graph npa:graph { ?retractedBy npx:retracts ?newerVersion ; npa:hasValidSignatureForPublicKey ?pubkey . } }
  optional { graph npa:graph { ?supersededBy npx:supersedes ?newerVersion ; npa:hasValidSignatureForPublicKey ?pubkey . } }
}
order by desc(?date) ?newerVersion""" .

<https://w3id.org/np/RAU0jUrzNYI94ypHwHTz_ergyrEV30eqgLVgGjxocgUc0/get-reads-by-reader>
  a grlc:grlc-query;
  dct:description "This query returns the items a given user has read, covering both schema:ReadAction and paperclub:hasRead nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get reads by reader";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/0545e3be5c488e5c1735567ae3ed698812cc1f6c5dce0aee5a3e0113b136670a>;
  grlc:sparql """prefix schema: <http://schema.org/>
prefix pc: <http://purl.org/petapico/o/paperclub#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

select distinct ?item ?item_label ?date ?comment ?np (\"^\" as ?np_label) where {
  {
    graph npa:graph {
      ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
      filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
      ?np np:hasAssertion ?a .
      ?np dct:created ?created .
    }
    graph ?a {
      ?ra a schema:ReadAction ;
        schema:agent ?_reader_iri ;
        schema:object ?item .
      optional { ?item rdfs:label ?item_label }
      optional { ?ra schema:endTime ?d }
      optional { ?ra rdfs:comment ?comment }
    }
    bind(coalesce(?d, substr(str(?created), 1, 10)) as ?date)
  }
  union
  {
    bind(iri(concat(\"https://w3id.org/np/l/nanopub-query-1.1/repo/type/\", sha256(str(pc:hasRead)))) as ?hasread_repo)
    service ?hasread_repo {
      graph npa:graph {
        ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
        filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
        ?np np:hasAssertion ?a .
        ?np npx:signedBy ?_reader_iri .
        ?np dct:created ?created .
      }
      graph ?a {
        ?_reader_iri pc:hasRead ?item .
        optional { ?item rdfs:comment ?comment }
      }
    }
    bind(substr(str(?created), 1, 10) as ?date)
  }
} order by desc(?date)""" .

<https://w3id.org/np/RAPUS6U6B4FvT0gIckKl44q96inQps0JPGVNhR8tnc-Gw/get-thanks> a grlc:grlc-query;
  dct:description "This query returns all thanks, possibly restricted by thanker, thanked, and/or thank reason.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get thanks";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/f5d900d50df7a37bd33ebe0063e99b49c1d869c8ebfc2e794d69b2699feec563>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix thank: <https://w3id.org/spaces/nanopub/r/thank/>

select (?__thanker_iri as ?thanker) (?__thanked_iri as ?thanked) (?__thankReason_iri as ?thank_reason) ?comment ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np npx:signedBy ?__thanker_iri .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?thanks a thank:Thanks .
    ?thanks thank:hasThanked ?__thanked_iri .
    ?thanks thank:hasThanker ?__thanker_iri .
    ?thanks thank:thanksFor ?__thankReason_iri .
    optional { ?thanks rdfs:comment ?comment . }
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RA0z2ybDd78hG_Y7UNnDmrUTJS0zHKrdOI_NqrNkhzrxw/get-3pff-events-for-user>
  a grlc:grlc-query;
  dct:description "Returns all 3PFF events for a given user, including the role they had in each event.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get 3PFF events for user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>
prefix tpff: <https://w3id.org/fair/3pff/>
prefix schema: <http://schema.org/>

select ?event ?event_label (sample(?ev_name) as ?event_name) (sample(?ev_date) as ?event_date) ?roles_multi_iri ?roles_label_multi ?np_multi_iri ?np_label_multi where {
  {
    select ?event (replace(str(?event), \"^.*/\", \"\") as ?event_label) (group_concat(str(?role); separator=\" \") as ?roles_multi_iri) (group_concat(?role_label; separator=\"\\n\") as ?roles_label_multi) (group_concat(str(?latest_np); separator=\" \") as ?np_multi_iri) (group_concat(\"^\"; separator=\"\\n\") as ?np_label_multi) where {
      {
        select ?event ?role ?role_label (sample(?np) as ?latest_np) where {
          values (?role ?role_label) {
            (tpff:participatedAsParticipantIn \"Participant\")
            (tpff:participatedAsFacilitatorIn \"Facilitator\")
            (tpff:participatedAsTrainerIn \"Trainer\")
            (tpff:participatedAsFacilitatorAssistantIn \"Facilitator Assistant\")
            (tpff:participatedAsTrainerAssistantIn \"Trainer Assistant\")
            (tpff:participatedAsImplementerIn \"Implementer\")
            (tpff:participatedAsImplementerAspirantIn \"Implementer Aspirant\")
          }
          graph npa:graph {
            ?np npx:hasNanopubType ?role .
            ?np dct:creator ?_user_iri .
            ?np npa:hasValidSignatureForPublicKeyHash ?pk .
            filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pk . }
            ?np np:hasAssertion ?a .
            ?np dct:created ?date .
          }
          graph ?a {
            ?_user_iri ?role ?event .
          }
          filter not exists {
            graph npa:graph {
              ?np2 npx:hasNanopubType ?role .
              ?np2 dct:creator ?_user_iri .
              ?np2 npa:hasValidSignatureForPublicKeyHash ?pk2 .
              filter not exists { ?npx2 npx:invalidates ?np2 ; npa:hasValidSignatureForPublicKeyHash ?pk2 . }
              ?np2 np:hasAssertion ?a2 .
              ?np2 dct:created ?date2 .
              filter(?date2 > ?date)
            }
            graph ?a2 {
              ?_user_iri ?role ?event .
            }
          }
        }
        group by ?event ?role ?role_label
      }
    }
    group by ?event
  }
  graph npa:graph {
    ?enp npx:introduces ?event .
    ?enp npa:hasValidSignatureForPublicKeyHash ?epk .
    filter not exists { ?enpx npx:invalidates ?enp ; npa:hasValidSignatureForPublicKeyHash ?epk . }
    ?enp np:hasAssertion ?ea .
  }
  graph ?ea {
    ?event a tpff:3PFF-event .
    ?event rdfs:label ?ename .
    optional { ?event dct:date ?dateDct . }
    optional { ?event schema:startDate ?dateSchema . }
  }
  bind(coalesce(?dateDct, strBefore(str(?dateSchema), \"T\")) as ?ev_date)
  bind(replace(?ename, \"^[^|]*\\\\| ?\", \"\") as ?ev_name)
}
group by ?event ?event_label ?roles_multi_iri ?roles_label_multi ?np_multi_iri ?np_label_multi
order by desc(sample(?ev_date))""" .

<https://w3id.org/np/RAz49FfxC9XaYITrhz_BgNbMO0TVihAFCGv8QpQoizJFg/get-past-event-participations>
  a grlc:grlc-query;
  dct:description "This query returns the past events the given user has participated in.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get past event participations";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/c57ab33a5dd555f386714db4cfff523b9fbdaa3b2cdd448e1ed810317280308c>;
  grlc:sparql """prefix wd: <http://www.wikidata.org/entity/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix schema: <http://schema.org/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

select distinct ?event ?event_label ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?_user_iri wd:P1344 ?event .
  }
  optional {
    bind(iri(concat(\"https://w3id.org/np/l/nanopub-query-1.1/repo/type/\", sha256(str(gen:Space)))) as ?space_repo)
    service ?space_repo {
      graph npa:graph {
        ?nps npx:introduces ?event .
        ?nps npa:hasValidSignatureForPublicKeyHash ?pks .
        filter not exists { ?npsx npx:invalidates ?nps ; npa:hasValidSignatureForPublicKeyHash ?pks . }
        ?nps np:hasAssertion ?as .
      }
      graph ?as {
        ?event rdfs:label ?el .
        optional {
          ?event schema:startDate ?datetime .
        }
      }
    }
  }
  bind(xsd:date(substr(str(?datetime), 0, 11)) as ?date)
  bind(?el as ?event_label)
  filter(?date < xsd:date(substr(str(now()), 0, 11)))
} order by desc(?date)""" .

<https://w3id.org/np/RA-SYwh12YqSOePu9OX9VD94KVuoG69ddkE4XET_zJShY/get-papers-for-author>
  a grlc:grlc-query;
  dct:description "This query returns the papers for a given author.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get papers for author";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix fabio: <http://purl.org/spar/fabio/>
prefix bibo: <http://purl.org/ontology/bibo/>

select ?paper ?paper_label ?journal ?journal_label ?publication_date ?np (\"^\" as ?np_label) where {
  values ?_author_multi_iri {}
  graph npa:graph {
    ?np npx:hasNanopubType fabio:ScholarlyWork .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?paper .
  }
  graph ?a {
    ?paper dct:title ?paper_label .
    ?paper bibo:authorList ?author_list .
    ?paper dct:date ?publication_date .
    ?author_list ?rdfseqpred ?_author_multi_iri .
    filter(strstarts(str(?rdfseqpred), \"http://www.w3.org/1999/02/22-rdf-syntax-ns#_\"))
    optional {
      ?paper dct:isPartOf ?journal .
      ?journal dct:title ?journal_label .
    }
  }
}
order by desc(?publication_date)""" .

<https://w3id.org/np/RAnywWCyBJfe4Ebk3Pvn453ihrj8N4sFcEQsR7zDeztQs/get-personal-urls>
  a grlc:grlc-query;
  dct:description "This query returns the personal URLs for a given user.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get personal URLs";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/12ad4f9c57edaccb015e17da7dbbe8759305d12df328d02ba66e7d799cb8bf4f>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>

select ?urllink ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType rdfs:seeAlso .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?_user_iri rdfs:seeAlso ?url .
    ?url rdfs:label ?url_label .
  }
  bind(concat(\"<span><a target=\\\"_blank\\\" href=\\\"\", str(?url), \"\\\">\", ?url_label, \"</a></span>\") as ?urllink)
} order by ?url_label""" .

<https://w3id.org/np/RARbQh51JW7ufDVdSdJEFEMiWiFo8WtBJ070RuPDRyLW0/get-gofair-qualified-things>
  a grlc:grlc-query;
  dct:description "This query returns resources (FERs etc.) together with the info about whether GO FAIR qualified them.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get GO FAIR qualified things";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix prov: <http://www.w3.org/ns/prov#>

select distinct ?thing ?label ?np ?date ?qualification_np where {
  graph npa:graph {
    <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> npa:hasValidSignatureForPublicKey ?curators_np_pk .
    ?latest_curators_np npa:hasValidSignatureForPublicKey ?curators_np_pk .
    filter not exists { ?latest_curators_npx npx:invalidates ?latest_curators_np ; npa:hasValidSignatureForPublicKey ?curators_np_pk . }
    ?latest_curators_np np:hasAssertion ?latest_curators_assertion .
  }
  graph npa:networkGraph {
    ?latest_curators_np (npx:supersedes)* <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> .
    filter not exists { ?latest_curators_npxx npx:supersedes ?latest_curators_np }
  }
  
  graph npa:graph {
    ?np npx:hasNanopubType ?__type_iri .
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np (npx:introduces|npx:describes) ?thing .
    ?np rdfs:label ?label .
    ?np dct:description ?description .
    ?np dct:created ?date .
    filter(str(?date) > \"2022\")
  }

  optional {
    graph npa:graph {
      ?disapproval npa:hasValidSignatureForPublicKey ?dpubkey .
    }
    graph ?latest_curators_assertion {
      ?dpubkeys npx:hasPublicKey ?dpubkey .
    }
    graph npa:graph {
      filter not exists { ?disapproval_x npx:invalidates ?disapproval ; npa:hasValidSignatureForPublicKey ?dpubkey . }
      ?disapproval np:hasAssertion ?da .
    }
    graph ?da {
      ?dsomebody ( npx:disapproves-of | npx:disapprovesOf ) ?np .
    }
  } filter(!bound(?disapproval))  # Faster than \"filter not exists\" for some reason

  optional {
  optional {
    graph npa:graph {
      ?recommendation_np npx:hasNanopubType fip:recommended-by .
      ?recommendation_np npa:hasValidSignatureForPublicKey ?rpubkey .
      filter not exists { ?recommendation_np_x npx:invalidates ?recommendation_np ; npa:hasValidSignatureForPublicKey ?rpubkey . }
      ?recommendation_np np:hasAssertion ?ra .
      ?recommendation_np np:hasProvenance ?rp .
    }
    graph ?ra {
      ?thing fip:recommended-by ?recommender .
    }
    graph ?rp {
      ?ra prov:wasDerivedFrom ?rfip_np .
    }
    graph npa:graph {
      ?rfip_np npx:hasNanopubType fip:Reference-FAIR-Implementation-Profile .
      ?rfip_np npa:hasValidSignatureForPublicKey ?rfip_pubkey .
      ?latest_rfip_np npa:hasValidSignatureForPublicKey ?rfip_pubkey .
      filter not exists { ?latest_rfip_npx npx:invalidates ?latest_rfip_np ; npa:hasValidSignatureForPublicKey ?rfip_pubkey . }
    }
    graph npa:networkGraph {
      ?latest_rfip_np (npx:supersedes)* ?rfip_np .
    }
    graph ?rfip_qa {
      ?rfip_qualifier npx:qualifies ?latest_rfip_np .
    }
    graph npa:graph {
      ?rfip_qualification_np np:hasAssertion ?rfip_qa .
      ?rfip_qualification_np npx:hasNanopubType npx:qualifies .
      ?rfip_qualification_np npa:hasValidSignatureForPublicKey ?rfip_qpubkey .
      filter not exists { ?rfip_qualification_np_x npx:invalidates ?rfip_qualification_np ; npa:hasValidSignatureForPublicKey ?rfip_qpubkey . }
    }
    graph ?latest_curators_assertion {
      ?rfip_qpubkeys npx:hasPublicKey ?rfip_qpubkey .
    }
  }
    graph npa:graph {
      ?qualification_np npx:hasNanopubType npx:qualifies .
      ?qualification_np npa:hasValidSignatureForPublicKey ?qpubkey .
    }
    graph ?latest_curators_assertion {
      ?qpubkeys npx:hasPublicKey ?qpubkey .
    }
    graph npa:graph {
      filter not exists { ?qualification_np_x npx:invalidates ?qualification_np ; npa:hasValidSignatureForPublicKey ?qpubkey . }
      ?qualification_np np:hasAssertion ?qa .
    }
    graph ?qa {
      ?qualifier npx:qualifies ?np .
    }
  }

  optional {
    graph npa:graph {
      ?fairAssessmentLevelNp npx:hasNanopubType fip:has-FAIR-assessment .
      ?fairAssessmentLevelNp npa:hasValidSignatureForPublicKey ?lpubkey .
    }
    graph ?latest_curators_assertion {
      ?lpubkeys npx:hasPublicKey ?lpubkey .
    }
    graph npa:graph {
      filter not exists { ?fairAssessmentLevelNp_x npx:invalidates ?fairAssessmentLevelNp ; npa:hasValidSignatureForPublicKey ?lpubkey . }
      ?fairAssessmentLevelNp np:hasAssertion ?la .
    }
    graph ?la {
      ?thing fip:has-FAIR-assessment ?fairAssessmentLevel .
    }
  } filter(!bound(?levelNp))  # Faster than \"filter not exists\" for some reason

}
group by ?thing ?label ?description ?np ?date ?pubkey ?retraction ?newversion ?qualifier ?qualification_np
order by desc(?recommender_count) asc(?label)""" .

<https://w3id.org/np/RABc2867Nx_w-zMtQleYNDKZfdgyswjoEzX1EuMSQT2g8/get-type-counts>
  a grlc:grlc-query;
  dct:description "This query returns the number of nanopubs per type.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get nanopub type counts";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>

select (count(?np) as ?count) ?type where {
 graph npa:graph {
 ?np npx:hasNanopubType ?type .
 }
} group by ?type order by desc(?count)""" .

<https://w3id.org/np/RAvP8141ilUn0IJGPeKHG7cXjMH4gNTW54YsT5ofnrMWU/get-weekly-nanopub-count>
  a grlc:grlc-query;
  dct:description "Returns the number of nanopublications published per week (Mon-Sun).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get weekly nanopub count";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>

select ?week (substr(str(min(?date)), 0, 11) as ?firstday) (count(?np) as ?nanopubcount) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np dct:created ?date .
  }

  bind(if(month(?date) <= 2, year(?date) - 1, year(?date)) as ?y)
  bind(if(month(?date) <= 2, month(?date) + 9, month(?date) - 3) as ?m)
  bind(365*?y + xsd:integer(?y/4) - xsd:integer(?y/100) + xsd:integer(?y/400) + xsd:integer((153*?m + 2)/5) + day(?date) as ?daynum)
  bind(?daynum + 1 - xsd:integer((?daynum + 1) / 7) * 7 as ?dow)
  bind(xsd:integer((?daynum - ?dow) / 7) as ?week)
}
group by ?week
order by desc(?week)""" .

<https://w3id.org/np/RAOMMFrJj4SyF4vlvJhr_AQH0jRL2jI9RUAroP5ZKe0D8/get-news-content>
  a grlc:grlc-query;
  dct:description "This query returns the content (body) of the news entries.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get news content";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <http://schema.org/>
prefix schemas: <https://schema.org/>

select ?headline ?body ?datePublished ?link ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np dct:creator ?user .
    ?np np:hasAssertion ?a .
  }
  values ?_resource_multi_iri {}
  { graph ?a {
    ?newsItem schema:headline ?headline .
    ?newsItem rdf:type schema:NewsArticle .
    ?newsItem schema:articleBody ?body .
    optional { ?newsItem schema:datePublished ?datePublished . }
    optional { ?newsItem schema:url ?link . }
    ?newsItem schema:isPartOf ?_resource_multi_iri .
  } } union { graph ?a {
    ?newsItem schemas:headline ?headline .
    ?newsItem rdf:type schemas:NewsArticle .
    ?newsItem schemas:articleBody ?body .
    optional { ?newsItem schemas:datePublished ?datePublished . }
    optional { ?newsItem schemas:url ?link . }
    ?newsItem schemas:isPartOf ?_resource_multi_iri .
  } }
} order by desc(?datePublished)""" .

<https://w3id.org/np/RADmJFgPaoDmz-surpx6Jpq_abBtkc6H0WTeslF7byEK4/get-news-content>
  a grlc:grlc-query;
  dct:description "This query returns the content (body) of the news entries.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get news content";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <http://schema.org/>

select ?headline ?body ?datePublished ?link where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np dct:creator ?user .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?newsItem schema:headline ?headline .
    ?newsItem rdf:type schema:NewsArticle .
    ?newsItem schema:articleBody ?body .
    optional { ?newsItem schema:datePublished ?datePublished . }
    optional { ?newsItem schema:url ?link . }
    values ?_resource_multi_iri {}
    ?newsItem schema:isPartOf ?_resource_multi_iri .
  }
} order by desc(?datePublished)""" .

<https://w3id.org/np/RAHhKP76OK5VYDcEUaij2_NrO-f5VhylvchupmhbOsbvk/get-users-with-profile>
  a grlc:grlc-query;
  dct:description "This query returns all users who have set up their profile by declaring at least one view to be displayed on their profile page, sorted by date of first view display publication (most recent first).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get users with profile";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npx: <http://purl.org/nanopub/x/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix dct: <http://purl.org/dc/terms/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix foaf: <http://xmlns.com/foaf/0.1/>

select ?user (sample(?name) as ?user_label) (min(?date) as ?date) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?display a gen:ViewDisplay .
    ?display gen:isDisplayFor ?user .
  }
  graph npa:graph {
    ?intronp npa:hasValidSignatureForPublicKeyHash ?intropubkey .
    filter not exists { ?intronpx npx:invalidates ?intronp ; npa:hasValidSignatureForPublicKeyHash ?intropubkey . }
    ?intronp np:hasAssertion ?introa .
  }
  graph ?introa {
    ?keydecl npx:declaredBy ?user .
    optional { ?user foaf:name ?name . }
  }
}
group by ?user
order by desc(?date)""" .

<https://w3id.org/np/RAPkmPk1FT2RzZZL4bQu_4Ghfogn-xbk969p8sMiuC8lk/get-replication-study-definition>
  a grlc:grlc-query;
  dct:description "This query returns the definition relations of a replication study.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get replication study definition";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/3ebd75ffc866d7fe53f05b3189bd2258cc8eaea56b8a5de74b64846708547fc8>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>

select ?relation ?relation_label                                                                                                                                                                               
    (group_concat(replace(replace(str(?value), \"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\"), \"[\\r\\n]{1,2}\", \"\\\\\\\\n\"); separator=\"\\n\") as ?value_multi_val)
    (group_concat(replace(replace(coalesce(?valueLabel, \"\"), \"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\"), \"[\\r\\n]{1,2}\", \"\\\\\\\\n\"); separator=\"\\n\") as ?value_label_multi)                                                                
    ?np (\"^\" as ?np_label) where {
  values ?_resource_multi_iri {}
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?_resource_multi_iri .
  }
  values (?relation ?relation_label ?order) {
    (<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> \"Type:\" 1)
    (<http://www.w3.org/2000/01/rdf-schema#label> \"Label:\" 2)
    (<https://w3id.org/sciencelive/o/terms/targetsClaim> \"Target claim:\" 3)
    (<https://w3id.org/sciencelive/o/terms/hasScopeDescription> \"Scope:\" 4)
    (<https://w3id.org/sciencelive/o/terms/hasMethodologyDescription> \"Methodology:\" 5)
    (<https://w3id.org/sciencelive/o/terms/hasDeviationDescription> \"Deviation:\" 6)
    (<http://www.w3.org/2004/02/skos/core#related> \"Related:\" 7)
    (<https://w3id.org/sciencelive/o/terms/hasDiscipline> \"Discipline:\" 8)
  }
  graph ?a {
    ?_resource_multi_iri ?relation ?value .
  }    optional {                                                                                                                                                                                                   
      service <https://w3id.org/np/l/nanopub-query-1.1/repo/type/29ca2b209f9afb89e9c2c7b61c9c6aa447fb7b941c1db2fd26099346cc4fed29> {                                                                             
        graph npa:graph {                                                                                                                                                                                        
          ?vnp np:hasAssertion ?va .                                                                                                                                                                             
          ?vnp npx:introduces ?value .                                                                                                                                                                           
          ?vnp npa:hasValidSignatureForPublicKeyHash ?vpubkey .                                                                                                                                                  
          filter not exists { ?vnpx npx:invalidates ?vnp ; npa:hasValidSignatureForPublicKeyHash ?vpubkey . }                                                                                                    
        }                                                                                                                                                                                                        
        graph ?va {
          ?value rdfs:label ?valueLabel .                                                                                                                                                                        
        }
      }                                                                                                                                                                                                          
    }
} group by ?relation ?relation_label ?order ?np order by ?order""" .

<https://w3id.org/np/RA2iGE4eTFfjc1YHhTc25Cd_QYJJF9wx0ygvUErqVDPxg/get-replication-study-outcome>
  a grlc:grlc-query;
  dct:description "This query returns the outcome relations of a replication study.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get replication study outcome";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/0e83fe9c436ab274c378c5c7e054ac5cb74d542a01b432b54530c9cbd1330ec5>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix sl: <https://w3id.org/sciencelive/o/terms/>

select ?relation ?relation_label (group_concat(replace(replace(str(?value), \"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\"), \"[\\r\\n]{1,2}\", \"\\\\\\\\n\"); separator=\"\\n\") as ?value_multi_val) ?np (\"^\" as ?np_label) where {
  { select * {
    graph npa:graph {
      ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
      filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
      ?np np:hasAssertion ?a .
      ?np npx:introduces ?outcome .
    }
    values ?_replicationStudy_multi_iri {}
    graph ?a {
      ?outcome sl:isOutcomeOf ?_replicationStudy_multi_iri .
    }
  } order by desc(?date) limit 1 }
  values (?relation ?relation_label ?order) {
    (<http://www.w3.org/2000/01/rdf-schema#label> \"Label:\" 1)
    (<https://w3id.org/sciencelive/o/terms/hasOutcomeRepository> \"Outcome repository:\" 2)
    (<http://schema.org/endDate> \"End date:\" 3)
    (<https://w3id.org/sciencelive/o/terms/hasValidationStatus> \"Validation status:\" 4)
    (<https://w3id.org/sciencelive/o/terms/hasConclusionDescription> \"Conclusion:\" 5)
    (<https://w3id.org/sciencelive/o/terms/hasEvidenceDescription> \"Evidence:\" 6)
    (<https://w3id.org/sciencelive/o/terms/hasConfidenceLevel> \"Confidence level:\" 7)
    (<https://w3id.org/sciencelive/o/terms/hasLimitationsDescription> \"Limitations:\" 8)
  }
  graph ?a {
    ?outcome ?relation ?value .
  }
} group by ?relation ?relation_label ?order ?np order by ?order""" .

<https://w3id.org/np/RAXQ3CQFsI9iWH85YwWeCfqPTosahr0uFghDd_vz-Dhy8/get-replication-study-outcome>
  a grlc:grlc-query;
  dct:description "This query returns the outcome relations of a replication study.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get replication study outcome";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/0e83fe9c436ab274c378c5c7e054ac5cb74d542a01b432b54530c9cbd1330ec5>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix sl: <https://w3id.org/sciencelive/o/terms/>

select ?relation ?relation_label (group_concat(replace(replace(str(?value), \"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\"), \"[\\r\\n]{1,2}\", \"\\\\\\\\n\")); separator=\"\\n\") as ?value_multi_val) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?outcome .
  }
  values ?_replicationStudy_multi_iri {}
  graph ?a {
    ?outcome sl:isOutcomeOf ?_replicationStudy_multi_iri .
  }
  values (?relation ?relation_label ?order) {
    (<http://www.w3.org/2000/01/rdf-schema#label> \"Label:\" 1)
    (<https://w3id.org/sciencelive/o/terms/hasOutcomeRepository> \"Outcome repository:\" 2)
    (<http://schema.org/endDate> \"End date:\" 3)
    (<https://w3id.org/sciencelive/o/terms/hasValidationStatus> \"Validation status:\" 4)
    (<https://w3id.org/sciencelive/o/terms/hasConclusionDescription> \"Conclusion:\" 5)
    (<https://w3id.org/sciencelive/o/terms/hasEvidenceDescription> \"Evidence:\" 6)
    (<https://w3id.org/sciencelive/o/terms/hasConfidenceLevel> \"Confidence level:\" 7)
    (<https://w3id.org/sciencelive/o/terms/hasLimitationsDescription> \"Limitations:\" 8)
  }
  graph ?a {
    ?outcome ?relation ?value .
  }
} group by ?relation ?relation_label ?order order by ?order""" .

<https://w3id.org/np/RAEXpRcGorHxmYST24en_fvybPK0TnHUJDTgQxf6ln7vA/get-3pff-participation-summary-for-user>
  a grlc:grlc-query;
  dct:description "Returns a summary of 3PFF event participation for a given user, with the number of events per role.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get 3PFF participation summary for user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>
prefix tpff: <https://w3id.org/fair/3pff/>

select ?role ?role_label (count(distinct ?event) as ?event_count) where {
  values (?role ?role_label) {
    (tpff:participatedAsParticipantIn \"Participant\")
    (tpff:participatedAsFacilitatorIn \"Facilitator\")
    (tpff:participatedAsTrainerIn \"Trainer\")
    (tpff:participatedAsFacilitatorAssistantIn \"Facilitator Assistant\")
    (tpff:participatedAsTrainerAssistantIn \"Trainer Assistant\")
    (tpff:participatedAsImplementerIn \"Implementer\")
    (tpff:participatedAsImplementerAspirantIn \"Implementer Aspirant\")
  }
  graph npa:graph {
    ?np npx:hasNanopubType ?role .
    ?np npa:hasValidSignatureForPublicKeyHash ?pk .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pk . }
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?_user_iri ?role ?event .
  }
  graph npa:graph {
    ?enp npx:introduces ?event .
    ?enp npa:hasValidSignatureForPublicKeyHash ?epk .
    filter not exists { ?enpx npx:invalidates ?enp ; npa:hasValidSignatureForPublicKeyHash ?epk . }
    ?enp np:hasAssertion ?ea .
  }
  graph ?ea {
    ?event a tpff:3PFF-event .
  }
}
group by ?role ?role_label
having(count(distinct ?event) > 0)
order by desc(?event_count)""" .

<https://w3id.org/np/RAY1nkPv8FgFhNOe4LhoZpTQ3dCedofD7OT1K142OH8LQ/get-3pff-event-participation-stats>
  a grlc:grlc-query;
  dct:description "Returns all 3PFF events with participant counts per role (Participants, Facilitators, Trainers, etc.).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get 3PFF event participation stats";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>
prefix tpff: <https://w3id.org/fair/3pff/>
prefix schema: <http://schema.org/>

select ?event ?event_label (sample(?ev_name) as ?event_name) (sample(?ev_date) as ?event_date) (sum(if(?role = tpff:participatedAsParticipantIn, 1, 0)) as ?Participants) (sum(if(?role = tpff:participatedAsFacilitatorIn, 1, 0)) as ?Facilitators) (sum(if(?role = tpff:participatedAsTrainerIn, 1, 0)) as ?Trainers) (sum(if(?role = tpff:participatedAsFacilitatorAssistantIn, 1, 0)) as ?Facilitator_Assistants) (sum(if(?role = tpff:participatedAsTrainerAssistantIn, 1, 0)) as ?Trainer_Assistants) (sum(if(?role = tpff:participatedAsImplementerIn, 1, 0)) as ?Implementers) (sum(if(?role = tpff:participatedAsImplementerAspirantIn, 1, 0)) as ?Implementer_Aspirants) where {
  {
    select distinct ?event ?role ?user where {
      values ?role {
        tpff:participatedAsParticipantIn
        tpff:participatedAsFacilitatorIn
        tpff:participatedAsTrainerIn
        tpff:participatedAsFacilitatorAssistantIn
        tpff:participatedAsTrainerAssistantIn
        tpff:participatedAsImplementerIn
        tpff:participatedAsImplementerAspirantIn
      }
      graph npa:graph {
        ?np npx:hasNanopubType ?role .
        ?np npa:hasValidSignatureForPublicKeyHash ?pk .
        filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pk . }
        ?np np:hasAssertion ?a .
      }
      graph ?a {
        ?user ?role ?event .
      }
    }
  }
  graph npa:graph {
    ?enp npx:introduces ?event .
    ?enp npa:hasValidSignatureForPublicKeyHash ?epk .
    filter not exists { ?enpx npx:invalidates ?enp ; npa:hasValidSignatureForPublicKeyHash ?epk . }
    ?enp np:hasAssertion ?ea .
  }
  graph ?ea {
    ?event a tpff:3PFF-event .
    ?event rdfs:label ?ename .
    optional { ?event dct:date ?dateDct . }
    optional { ?event schema:startDate ?dateSchema . }
  }
  bind(replace(str(?event), \"^.*/\", \"\") as ?event_label)
  bind(coalesce(?dateDct, strBefore(str(?dateSchema), \"T\")) as ?ev_date)
  bind(replace(?ename, \"^[^|]*\\\\| ?\", \"\") as ?ev_name)
}
group by ?event ?event_label
order by desc(sample(?ev_date))""" .

<https://w3id.org/np/RAHgb_4bZhqvaGaUEpMs6oj2WiiuGBlcrHp2gcF8jljdc/get-3pff-qualifications-for-user>
  a grlc:grlc-query;
  dct:description "Returns all 3PFF qualifications issued to a given user, including qualification type, issuer, and validity period.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get 3PFF qualifications for user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>
prefix tpff: <https://w3id.org/fair/3pff/>
prefix schema: <https://schema.org/>
prefix dcat: <https://www.w3.org/ns/dcat#>

select ?qualification ?qualification_label ?issuer ?issuer_label ?startDate ?endDate ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType tpff:3PFF-Qualification .
    ?np npa:hasValidSignatureForPublicKeyHash ?pk .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pk . }
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?np tpff:issued-to ?_user_iri .
    ?np npx:qualifies ?qualification .
    optional { ?np schema:issuedBy ?issuer . }
    optional { ?np dcat:startDate ?startDate . }
    optional { ?np dcat:endDate ?endDate . }
  }
  bind(replace(str(?qualification), \"^.*/\", \"\") as ?qualification_label)
  bind(if(?issuer = <https://ror.org/056j50v04>, \"GO FAIR Foundation\", replace(str(?issuer), \"^.*/\", \"\")) as ?issuer_label)
}
order by desc(?startDate)""" .

<https://w3id.org/np/RAvSu8-y41PaSAGH7ws9BKs9qzr2fwj1c5OxoMrbEOUWo/get-3pff-qualifications-for-user>
  a grlc:grlc-query;
  dct:description "Returns all 3PFF qualifications issued to a given user, including qualification type, issuer, and validity period.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get 3PFF qualifications for user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>
prefix tpff: <https://w3id.org/fair/3pff/>
prefix schema: <https://schema.org/>
prefix dcat: <https://www.w3.org/ns/dcat#>

select ?qualification ?qualification_label ?issuer ?startDate ?endDate ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType tpff:3PFF-Qualification .
    ?np npa:hasValidSignatureForPublicKeyHash ?pk .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pk . }
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?np tpff:issued-to ?_user_iri .
    ?np npx:qualifies ?qualification .
    optional { ?np schema:issuedBy ?issuer . }
    optional { ?np dcat:startDate ?startDate . }
    optional { ?np dcat:endDate ?endDate . }
  }
  bind(replace(str(?qualification), \"^.*/\", \"\") as ?qualification_label)
}
order by desc(?startDate)""" .

<https://w3id.org/np/RAIWAADtHjV2HRBuZ1ap4W1wqjGE9jqoWoesf4Yn1A6Qw/find-fdos> a grlc:grlc-query;
  dct:description "This query returns all FDOs that have the given search string in their labels.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Find FDOs by label search";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <http://schema.org/>
prefix fdof: <https://w3id.org/fdof/ontology#>

select ?fdo ?profile ?np ?label ?date where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np dct:created ?date .
    values ?type { fdof:FAIRDigitalObject npx:RoCrateNanopub }
    ?np npx:hasNanopubType ?type .
    ?np npx:introduces ?fdo .
    ?np np:hasAssertion ?assertion .
    ?np rdfs:label ?label .
    filter(contains(lcase(?label), ?_query))
  }
  graph ?assertion { {
      ?fdo dct:conformsTo ?profile .
    } union {
      ?metadata dct:conformsTo ?profile .
      ?metadata schema:about ?fdo .
  } }
} order by desc(?date)""" .

<https://w3id.org/np/RAyEYam0RC4L4ijNLCR5t4e-GJwxo_OM63pUx8SSDxU5w/get-spaces-and-roles-for-user>
  a grlc:grlc-query;
  dct:description "Returns all the spaces a given user belongs to, together with the role names the user has in each space.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get Spaces and roles for user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix schema: <http://schema.org/>

select ?space ?space_label (group_concat(distinct str(?role); separator=\" \") as ?roles_multi_iri) (group_concat(distinct ?roleName; separator=\"\\n\") as ?roles_label_multi) where {
  {
    {
      graph npa:graph {
        ?spaceRole_np npx:hasNanopubType gen:SpaceMemberRole .
        ?spaceRole_np npa:hasValidSignatureForPublicKeyHash ?spaceRole_pubkey .
        filter not exists { ?spaceRole_npx npx:invalidates ?spaceRole_np ; npa:hasValidSignatureForPublicKeyHash ?spaceRole_pubkey . }
        ?spaceRole_np np:hasAssertion ?spaceRole_a .
      }
      graph ?spaceRole_a {
        ?space gen:hasRole ?role .
      }
    } union {
      bind(<https://w3id.org/np/RA_eEJjQbxzSqYSwPzfjzOZi5sMPpUmHskFNsgJYSws8I/adminRole> as ?role)
    }
  }
  graph ?role_a {
    ?role a gen:SpaceMemberRole .
    ?role rdfs:label ?roleLabel .
    ?role dct:title ?roleTitle .
    ?role schema:name ?roleName .
  }
  graph npa:graph {
    ?role_np npx:embeds ?role .
    ?role_np np:hasAssertion ?role_a .
  }
  {
    {
      graph ?role_a {
        ?role gen:hasRegularProperty ?reg .
      }
      graph ?link_a {
        ?_agent_iri ?reg ?space .
      }
    } union {
      graph ?role_a {
        ?role gen:hasInverseProperty ?inv .
      }
      graph ?link_a {
        ?space ?inv ?_agent_iri .
      }
    }
  }
  graph npa:graph {
    ?link_np np:hasAssertion ?link_a .
    ?link_np npa:hasValidSignatureForPublicKeyHash ?link_pubkey .
    filter not exists { ?link_npx npx:invalidates ?link_np ; npa:hasValidSignatureForPublicKeyHash ?link_pubkey . }
  }
  optional {
    graph npa:graph {
      ?space_np npx:introduces ?space .
      ?space_np npa:hasValidSignatureForPublicKeyHash ?space_pubkey .
      filter not exists { ?space_npx npx:invalidates ?space_np ; npa:hasValidSignatureForPublicKeyHash ?space_pubkey . }
      ?space_np rdfs:label ?space_label .
    }
  }
}
group by ?space ?space_label
order by ?space_label""" .

<https://w3id.org/np/RAnIK9yRZrmpJjCqrmyb_Dt--89qjEO2Jkt0EJrPVINzs/get-presentation-details>
  a grlc:grlc-query;
  dct:description "Returns the properties of an introduced presentation or poster, with human-readable labels for recognized predicates. Known properties are shown first.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get presentation details";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix wd: <http://www.wikidata.org/entity/>
prefix schema: <https://schema.org/>

select ?property ?property_label ?value ?value_label where {
  bind(?_resourceNp_iri as ?np)
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?_resource_iri .
  }
  graph ?a {
    ?_resource_iri ?pred ?value .
    optional { ?value rdfs:label ?value_label_raw . }
  }
  bind(?pred as ?property)
  bind(
    if(?pred = rdf:type && ?value = wd:Q604733, \"Presentation\",
    if(?pred = rdf:type && ?value = <https://w3id.org/kpxl/gen/terms/PosterPresentation>, \"Poster presentation\",
    ?value_label_raw)) as ?value_label)
  bind(
    if(?pred = rdf:type, \"Type\",
    if(?pred = rdfs:label, \"Title\",
    if(?pred = dct:date, \"Date\",
    if(?pred = wd:P823, \"Speaker\",
    if(?pred = dct:creator, \"Author\",
    if(?pred = dct:isPartOf, \"Part of\",
    if(?pred = dct:description, \"Description\",
    if(?pred = rdfs:seeAlso, \"Link\",
    if(?pred = schema:about, \"Topic\",
    str(?pred)))))))))) as ?property_label)
  bind(
    if(?pred = rdf:type, 0,
    if(?pred = rdfs:label, 1,
    if(?pred = dct:date, 2,
    if(?pred = wd:P823, 3,
    if(?pred = dct:creator, 4,
    if(?pred = dct:isPartOf, 5,
    if(?pred = dct:description, 6,
    if(?pred = rdfs:seeAlso, 7,
    if(?pred = schema:about, 8,
    99))))))))) as ?sort)
} order by ?sort""" .

<https://w3id.org/np/RAaKXYMunUKMkbYpgc4PmTji21pS0Ox1hsiVLiV-AfiUU/get-poster-presentations-for-event>
  a grlc:grlc-query;
  dct:description "Returns all poster presentations for a given event, with title, date, authors, and nanopub link.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get poster presentations for event";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/61e9c0168586a3ddcef2b010c69b596ac2529760aeb82231962c228c5a63b8eb>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?poster ?poster_label ?date
  (group_concat(str(?author); separator=\" \") as ?authors_multi_iri)
  (group_concat(replace(replace(?authorname, \"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\"), \"\\\\n\", \"\\\\\\\\n\"); separator=\"\\n\") as ?authors_label_multi)
  ?np (\"^\" as ?np_label)
where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . }
    ?np dct:created ?npdate .
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?poster .
  }
  values ?_event_multi_iri {}
  graph ?a {
    ?poster a gen:PosterPresentation .
    ?poster dct:isPartOf ?_event_multi_iri .
    ?poster dct:creator ?author .
    optional { ?author rdfs:label ?authorname . }
    optional { ?poster rdfs:label ?poster_label . }
    optional { ?poster dct:date ?date . }
  }
}
group by ?poster ?poster_label ?date ?np
order by desc(?date)""" .

<https://w3id.org/np/RAWkUwFh-p9IHtX6O69nEOSc6-ICXZN3MP0k4ODhPnBUY/get-messages-about-resource-and-parts>
  a grlc:grlc-query;
  dct:description "This query returns plain-text messages about the given resource, including messages about things that are declared to be part of it (recursively up to 2 levels) or whose URI starts with the resource URI.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get messages about resource and its parts";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <https://schema.org/>

select ?about ?text (group_concat(concat('<span><a href=\"', str(?link), '\">link</a></span>'); separator=\", \") as ?link) ?user ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np dct:creator ?user .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?a rdfs:label ?text .
    ?a schema:about ?about .
    values ?_resource_multi_iri {}
    filter(
      strstarts(str(?about), str(?_resource_multi_iri))
      || exists {
        graph npa:graph {
          ?np2 npa:hasValidSignatureForPublicKeyHash ?pubkey2 .
          filter not exists { ?npx2 npx:invalidates ?np2 ; npa:hasValidSignatureForPublicKeyHash ?pubkey2 . }
          ?np2 np:hasAssertion ?a2 .
        }
        graph ?a2 {
          { ?about dct:isPartOf ?_resource_multi_iri . }
          union
          { ?_resource_multi_iri dct:hasPart ?about . }
        }
      }
      || exists {
        graph npa:graph {
          ?np3 npa:hasValidSignatureForPublicKeyHash ?pubkey3 .
          filter not exists { ?npx3 npx:invalidates ?np3 ; npa:hasValidSignatureForPublicKeyHash ?pubkey3 . }
          ?np3 np:hasAssertion ?a3 .
        }
        graph ?a3 {
          ?about dct:isPartOf ?mid .
        }
        filter(
          strstarts(str(?mid), str(?_resource_multi_iri))
          || exists {
            graph npa:graph {
              ?np4 npa:hasValidSignatureForPublicKeyHash ?pubkey4 .
              filter not exists { ?npx4 npx:invalidates ?np4 ; npa:hasValidSignatureForPublicKeyHash ?pubkey4 . }
              ?np4 np:hasAssertion ?a4 .
            }
            graph ?a4 {
              { ?mid dct:isPartOf ?_resource_multi_iri . }
              union
              { ?_resource_multi_iri dct:hasPart ?mid . }
            }
          }
        )
      }
    )
    optional { ?a rdfs:seeAlso ?link . }
  }
}
group by ?about ?text ?user ?date ?np
order by desc(?date)""" .

<https://w3id.org/np/RAp6qnaNFq9rQWNCSqrMf6rATWAwcd-Wfvg9rrLsOTGnk/get-publications>
  a grlc:grlc-query;
  dct:description "This query returns all publications with their authors, returning author IDs concatenated by spaces and author names concatenated by newlines (with backslashes and newlines escaped).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all publications";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix fabio: <http://purl.org/spar/fabio/>
prefix bibo: <http://purl.org/ontology/bibo/>
prefix foaf: <http://xmlns.com/foaf/0.1/>

select ?paper ?paper_label ?journal ?journal_label ?publication_date
  (group_concat(str(?author_id); separator=\" \") as ?authors_multi_iri)
  (group_concat(replace(replace(?author_name, \"\\\\\\\\\", \"\\\\\\\\\\\\\\\\\"), \"\\\\n\", \"\\\\\\\\n\"); separator=\"\\n\") as ?authors_label_multi)
  ?np (\"^\" as ?np_label)
where {
  graph npa:graph {
    ?np npx:hasNanopubType fabio:ScholarlyWork .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?paper .
  }
  graph ?a {
    ?paper dct:title ?paper_label .
    ?paper bibo:authorList ?author_list .
    optional { ?paper dct:date ?publication_date . }
    ?author_list ?rdfseqpred ?author_id .
    filter(strstarts(str(?rdfseqpred), \"http://www.w3.org/1999/02/22-rdf-syntax-ns#_\"))
    optional { ?author_id foaf:name ?author_name_raw . }
    bind(coalesce(?author_name_raw, \"\") as ?author_name)
    optional {
      ?paper dct:isPartOf ?journal .
      ?journal dct:title ?journal_label .
    }
  }
}
group by ?paper ?paper_label ?journal ?journal_label ?publication_date ?np
order by desc(?publication_date)""" .

<https://w3id.org/np/RA1PkOy-Jh3YIA6hSh-ShoKDcPLvMUQt9JbPfPoDeyAf4/get-recent-and-upcoming-events>
  a grlc:grlc-query;
  dct:description "Returns all recent, ongoing, and upcoming events that are defined as Spaces.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get recent and upcoming events";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/8ad572d99071cc1ba0c16e54087b43594bdd9e8b2cfb62d2a0b16945fc49e53c>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix schema: <http://schema.org/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

select ?event ?event_label ?status ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . }
    ?np npx:introduces ?event .
    ?np np:hasAssertion ?a .
    ?np dct:created ?npDate .
    filter not exists {
      ?np2 npx:introduces ?event .
      ?np2 npa:hasValidSignatureForPublicKeyHash ?pubkey2 .
      filter not exists { ?npx2 npx:invalidates ?np2 ; npa:hasValidSignatureForPublicKeyHash ?pubkey2 . }
      ?np2 dct:created ?npDate2 .
      filter(?npDate2 > ?npDate)
    }
  }
  graph ?a {
    ?event a gen:Space .
    ?event a gen:Event .
    ?event rdfs:label ?event_label .
    ?event schema:startDate ?datetime .
    optional { ?event schema:endDate ?endDatetime . }

  }
  bind(xsd:date(substr(str(?datetime), 0, 11)) as ?date)
  bind(xsd:date(substr(str(now()), 0, 11)) as ?today)
  optional { bind(xsd:date(substr(str(?endDatetime), 0, 11)) as ?endDate) }
  bind(if(bound(?endDate), ?endDate, ?date) as ?effectiveEnd)
  filter(?date >= ?today || ?effectiveEnd >= ?today - \"P7D\"^^xsd:duration)
  bind(if(?effectiveEnd < ?today, 1, if(?date > ?today, 3, 2)) as ?statusOrder)
  bind(if(?date > ?today, \"upcoming\", if(?effectiveEnd >= ?today, \"ongoing\", \"recently concluded\")) as ?status)
} order by ?statusOrder ?date""" .

<https://w3id.org/np/RABpgTBJhHNi77O5grL35QxjyHeIJSeWdw8GYbH8ob2DM/get-upcoming-events>
  a grlc:grlc-query;
  dct:description "Returns all upcoming events that are defined as Spaces, ordered by start date.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get upcoming events";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/8ad572d99071cc1ba0c16e54087b43594bdd9e8b2cfb62d2a0b16945fc49e53c>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix schema: <http://schema.org/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

select ?event ?event_label ?date ?description ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . }
    ?np npx:introduces ?event .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?event a gen:Space .
    ?event a gen:Event .
    ?event rdfs:label ?event_label .
    ?event schema:startDate ?datetime .
    optional { ?event dct:description ?description . }
  }
  bind(xsd:date(substr(str(?datetime), 0, 11)) as ?date)
  filter(?date >= xsd:date(substr(str(now()), 0, 11)))
} order by ?date""" .

<https://w3id.org/np/RAqKTemZo5f68p74eo8-7TqZJBhAV_WYuebDiaSS40wYI/get-resource-views-without-applies-to>
  a grlc:grlc-query;
  dct:description "Returns all resource view declarations that do not have a gen:appliesToInstancesOf relation.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get resource views without appliesToInstancesOf";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix nt: <https://w3id.org/np/o/ntemplate/>

select ?view ?view_label ?type ?query ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np np:hasPublicationInfo ?pi .
  }
  graph ?pi {
    ?np nt:wasCreatedFromTemplate <https://w3id.org/np/RARLsTlqbTesu1b0WJZ-zL1z96xumOiqbK3l_vV6iZoww> .
  }
  graph ?a {
    ?view a gen:ResourceView .
    optional {
      ?view a ?type .
      filter(?type != gen:ResourceView)
    }
    optional { ?view rdfs:label ?view_label . }
    optional { ?view gen:hasViewQuery ?query . }
    filter not exists { ?view gen:appliesToInstancesOf ?class . }
  }
} order by desc(?date)""" .

<https://w3id.org/np/RAzSFlOt0yD9b-GSNifkGoKfakXEYQ7f6Ic3OMwuJfwts/find-views> a grlc:grlc-query;
  dct:description "This query finds views by a text query for auto-complete lookup.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Find views";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/ec6722efa3b44e0a18aa63afe5964158a1fdb7f0413ea5f23bfddf5c03ca0221>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>
prefix search: <http://www.openrdf.org/contrib/lucenesail#>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select distinct ?thing ?label ?description ?np ?pubkey ?date where {
  graph npa:graph {
    ?np npx:hasNanopubType gen:ResourceView .
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np dct:created ?date .
    ?np npx:embeds ?thing .
    ?np rdfs:label ?label .
    optional { ?np dct:description ?description . }
    bind(concat(?label, \" \", coalesce(?description, \"\")) as ?text)
    filter(contains(lcase(?label), lcase(?_query)))
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?thing gen:appliesToInstancesOf ?__appliedViewClass_iri .
  }
}
limit 10""" .

<https://w3id.org/np/RA6MMHn6iUBCFXzBqyGhrwAiBKCkUjZhp7CM4v1aPaAuo/get-cumulative-user-count>
  a grlc:grlc-query;
  dct:description "Returns the cumulative number of human users (with ORCID) who have published an introduction nanopub, per week (Mon-Sun).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get cumulative user count by week";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>

select ?week (substr(str(min(?fd1)), 0, 11) as ?firstday) (count(distinct ?u2) as ?totalusers) where {
  {
    select ?u1 ?fd1 ?w1 where {
      {
        select ?u1 (min(?d1) as ?fd1) where {
          graph npa:graph {
            ?np1 npa:hasValidSignatureForPublicKey ?pk1 .
            ?np1 dct:creator ?u1 .
            ?np1 dct:created ?d1 .
            ?np1 np:hasAssertion ?a1 .
          }
          graph ?a1 {
            ?decl1 npx:declaredBy ?agent1 .
          }
          filter(strstarts(str(?u1), \"https://orcid.org/\"))
          filter(?u1 != <https://orcid.org/0000-0000-0000-0000>)
          filter(?u1 != <https://orcid.org/1234-1234-1234-1234>)
        }
        group by ?u1
      }
      bind(if(month(?fd1) <= 2, year(?fd1) - 1, year(?fd1)) as ?y1)
      bind(if(month(?fd1) <= 2, month(?fd1) + 9, month(?fd1) - 3) as ?m1)
      bind(365*?y1 + xsd:integer(?y1/4) - xsd:integer(?y1/100) + xsd:integer(?y1/400) + xsd:integer((153*?m1 + 2)/5) + day(?fd1) as ?dn1)
      bind(?dn1 + 1 - xsd:integer((?dn1 + 1) / 7) * 7 as ?dw1)
      bind(xsd:integer((?dn1 - ?dw1) / 7) as ?w1)
    }
  }
  {
    select ?u2 ?w2 where {
      {
        select ?u2 (min(?d2) as ?fd2) where {
          graph npa:graph {
            ?np2 npa:hasValidSignatureForPublicKey ?pk2 .
            ?np2 dct:creator ?u2 .
            ?np2 dct:created ?d2 .
            ?np2 np:hasAssertion ?a2 .
          }
          graph ?a2 {
            ?decl2 npx:declaredBy ?agent2 .
          }
          filter(strstarts(str(?u2), \"https://orcid.org/\"))
          filter(?u2 != <https://orcid.org/0000-0000-0000-0000>)
          filter(?u2 != <https://orcid.org/1234-1234-1234-1234>)
        }
        group by ?u2
      }
      bind(if(month(?fd2) <= 2, year(?fd2) - 1, year(?fd2)) as ?y2)
      bind(if(month(?fd2) <= 2, month(?fd2) + 9, month(?fd2) - 3) as ?m2)
      bind(365*?y2 + xsd:integer(?y2/4) - xsd:integer(?y2/100) + xsd:integer(?y2/400) + xsd:integer((153*?m2 + 2)/5) + day(?fd2) as ?dn2)
      bind(?dn2 + 1 - xsd:integer((?dn2 + 1) / 7) * 7 as ?dw2)
      bind(xsd:integer((?dn2 - ?dw2) / 7) as ?w2)
    }
  }
  bind(?w1 as ?week)
  filter(?w2 <= ?week)
}
group by ?week
order by desc(?week)""" .

<https://w3id.org/np/RACukHmzuKKvxudElenc0kX12E4umi9ExirfUVBXvVD3c/get-weekly-new-user-count>
  a grlc:grlc-query;
  dct:description "Returns the number of human users who published their first introduction nanopub per week (Mon-Sun).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get weekly new user count";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>

select ?week (substr(str(min(?firstdate)), 0, 11) as ?firstday) (count(distinct ?userid) as ?newusercount) where {
  {
    select ?userid (min(?date) as ?firstdate) where {
      graph npa:graph {
        ?np npa:hasValidSignatureForPublicKey ?pubkey .
        ?np npx:signedBy ?userid .
        ?np npx:hasNanopubType npx:declaredBy .
        ?np dct:created ?date .
      }
      filter(strstarts(str(?userid), \"https://orcid.org/\"))
      filter(?userid != <https://orcid.org/0000-0000-0000-0000>)
      filter(?userid != <https://orcid.org/1234-1234-1234-1234>)
    }
    group by ?userid
  }

  bind(if(month(?firstdate) <= 2, year(?firstdate) - 1, year(?firstdate)) as ?y)
  bind(if(month(?firstdate) <= 2, month(?firstdate) + 9, month(?firstdate) - 3) as ?m)
  bind(365*?y + xsd:integer(?y/4) - xsd:integer(?y/100) + xsd:integer(?y/400) + xsd:integer((153*?m + 2)/5) + day(?firstdate) as ?daynum)
  bind(?daynum + 1 - xsd:integer((?daynum + 1) / 7) * 7 as ?dow)
  bind(xsd:integer((?daynum - ?dow) / 7) as ?week)
}
group by ?week
order by desc(?week)""" .

<https://w3id.org/np/RAuQwpHEb-wdxwXbDICg1HECtTmCUbM77VY8QNP9teu68/get-weekly-active-human-user-count>
  a grlc:grlc-query;
  dct:description "Returns the number of active human users (with ORCID) per week (Mon-Sun).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get weekly active human user count";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix foaf: <http://xmlns.com/foaf/0.1/>

select ?week (substr(str(min(?date)), 0, 11) as ?firstday) (count(distinct ?userid) as ?usercount) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np npx:signedBy ?userid .
    ?np dct:created ?date .
  }
  filter(strstarts(str(?userid), \"https://orcid.org/\"))
  filter(?userid != <https://orcid.org/0000-0000-0000-0000>)
  filter(?userid != <https://orcid.org/1234-1234-1234-1234>)

  bind(if(month(?date) <= 2, year(?date) - 1, year(?date)) as ?y)
  bind(if(month(?date) <= 2, month(?date) + 9, month(?date) - 3) as ?m)
  bind(365*?y + xsd:integer(?y/4) - xsd:integer(?y/100) + xsd:integer(?y/400) + xsd:integer((153*?m + 2)/5) + day(?date) as ?daynum)
  bind(?daynum + 1 - xsd:integer((?daynum + 1) / 7) * 7 as ?dow)
  bind(xsd:integer((?daynum - ?dow) / 7) as ?week)
}
group by ?week
order by desc(?week)""" .

<https://w3id.org/np/RAqLNf0-hUqFK9oAURrkWtF_AU27-u4unk5LJObU-U04s/get-weekly-active-user-count>
  a grlc:grlc-query;
  dct:description "Returns the number of active users per week (Mon-Sun).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get weekly active user count";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix foaf: <http://xmlns.com/foaf/0.1/>

select ?week (substr(str(min(?date)), 0, 11) as ?firstday) (count(distinct ?userid) as ?usercount) where {
  { graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np dct:creator ?userid .
    ?np dct:created ?date .
  } }
  union
  {
    graph npa:graph {
      ?np npa:hasValidSignatureForPublicKey ?pubkey .
      ?np np:hasAssertion ?assertion .
      ?np np:hasProvenance ?prov .
      ?np dct:created ?date .
      ?np dct:creator ?tool .
      values ?tool { <https://fip-wizard.ds-wizard.org/wizard> }
    }
    graph ?prov {
      ?assertion prov:wasAttributedTo ?userid .
    }
  }
  filter not exists {
    graph npa:graph { ?np npa:hasSubIri ?userid . }
  }
  bind(if(month(?date) <= 2, year(?date) - 1, year(?date)) as ?y)
  bind(if(month(?date) <= 2, month(?date) + 9, month(?date) - 3) as ?m)
  bind(365*?y + xsd:integer(?y/4) - xsd:integer(?y/100) + xsd:integer(?y/400) + xsd:integer((153*?m + 2)/5) + day(?date) as ?daynum)
  bind(?daynum + 1 - xsd:integer((?daynum + 1) / 7) * 7 as ?dow)
  bind(xsd:integer((?daynum - ?dow) / 7) as ?week)
}
group by ?week
order by desc(?week)""" .

<https://w3id.org/np/RASCJYIMuvPs1MuCQaS9UcARQJ6VpEk1xm5hAepZRYV7Y/get-active-user-count-in-time-period>
  a grlc:grlc-query;
  dct:description "This query returns the number of active users, separated by whether they are an ORCID or not, for the given time period (start and end date).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get active user counts in time period";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix foaf: <http://xmlns.com/foaf/0.1/>

select (count(distinct ?userid) as ?userCount) ?isOrcid where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np npx:signedBy ?userid .
    ?np dct:created ?date .
  }
  filter not exists {
    graph npa:graph { ?np npa:hasSubIri ?userid . }
  }
  bind(substr(str(?date), 1, 10) as ?dateStr)
  filter(?dateStr >= ?_startDate)
  filter(?dateStr <= ?_endDate)
  bind(strstarts(str(?userid), \"https://orcid.org/\") as ?isOrcid)
}
group by ?isOrcid
order by ?isOrcid""" .

<https://w3id.org/np/RAQN2BzH8WVieBWa-QQ1OV-JDXHAHy2aIA4uW243x19gY/get-team-member-spaces>
  a grlc:grlc-query;
  dct:description "This query returns all the spaces where the given user has the team member role.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get team member spaces for user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix dct: <http://purl.org/dc/terms/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select distinct ?space ?space_label ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np np:hasAssertion ?a .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
  }
  graph ?a {
    ?space gen:hasTeamMember ?_user_iri .
  }
  graph npa:graph {
    ?space_np npx:introduces ?space .
    ?space_np npa:hasValidSignatureForPublicKeyHash ?space_pubkey .
    filter not exists { ?space_npx npx:invalidates ?space_np ; npa:hasValidSignatureForPublicKeyHash ?space_pubkey . }
    ?space_np np:hasAssertion ?space_a .
  }
  graph ?space_a {
    ?space rdfs:label ?space_label .
  }
}
order by ?space_label""" .

<https://w3id.org/np/RAumk_6pLPHg00vXXJXCjUDfdhQDqUqy9ZzO9PCaMdZec/get-presentations-for-event>
  a grlc:grlc-query;
  dct:description "Returns all presentations of the given event, with label, date, event, and nanopub link.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get presentations for event";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/3952cad1a6d2561f045d33e5e79c03e7264b0a492b8becf6c62656c596cf398c>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix wd: <http://www.wikidata.org/entity/>

select ?presentation ?presentation_label ?date ?speaker ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . }
    ?np dct:created ?npdate .
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?presentation .
  }
  values ?_event_multi_iri {}
  graph ?a {
    ?presentation a wd:Q604733 .
    ?presentation dct:isPartOf ?_event_multi_iri .
    ?presentation wd:P823 ?speaker .
    optional { ?presentation rdfs:label ?presentation_label . }
    optional { ?presentation dct:date ?date . }
  }
} order by desc(?date)""" .

<https://w3id.org/np/RAD1cRJlEl2sBxkgnJaEcjlk66PtjBwLBAM1gn2nWIAzM/get-nanopubs-mentioning-relevant-entities>
  a grlc:grlc-query;
  dct:description "Get nanopubs mentioning relevant entities";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get nanopubs mentioning relevant entities";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select distinct ?np ?label ?date where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    optional { ?np rdfs:label ?label . }
    filter not exists { ?np npx:hasNanopubType npx:retracts . }
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?subj ?pred ?resource .
  }
  values ?_entity_multi_iri {}
  graph ?relevantA {
    ?resource gen:isRelevantFor ?_entity_multi_iri .
    optional { ?resource rdfs:label ?resource_label . }
  }
  graph npa:graph {
    ?relevantNp npx:hasNanopubType gen:isRelevantFor .
    ?relevantNp npa:hasValidSignatureForPublicKeyHash ?relevantPubkey .
    filter not exists { ?relevantNpx npx:invalidates ?relevantNp ; npa:hasValidSignatureForPublicKeyHash ?relevantPubkey . }
  }
} order by desc(?date) limit 100""" .

<https://w3id.org/np/RA_IcmwsJjICvGpSudP3AgR9ckFFoNQh7m5m8-veaHSJM/get-presentations-by-speaker>
  a grlc:grlc-query;
  dct:description "Returns all presentations by a given speaker, with label, date, event, and nanopub link.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get presentations by speaker";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/3952cad1a6d2561f045d33e5e79c03e7264b0a492b8becf6c62656c596cf398c>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix wd: <http://www.wikidata.org/entity/>

select ?presentation ?presentation_label ?date ?event ?event_label ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . }
    ?np dct:created ?npdate .
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?presentation .
  }
  graph ?a {
    ?presentation a wd:Q604733 .
    ?presentation wd:P823 ?_speaker_iri .
    optional { ?presentation rdfs:label ?presentation_label . }
    optional { ?presentation dct:date ?date . }
    optional {
      ?presentation dct:isPartOf ?event .
      optional { ?event rdfs:label ?event_label . }
    }
  }
} order by desc(?date)""" .

<https://w3id.org/np/RAtD7C0knwUNX49Y35c78u6r47oGsDt62GLmvfaED0_ag/get-all-iadopt-variables>
  a grlc:grlc-query;
  dct:description "Returns all I-ADOPT variables with their label, entity of interest, creator, and date.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all I-ADOPT variables";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/dbf3e4836e0529b98c8e70684a03a3fb3a7b48dfa7829747dd978f2b7249ada1>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix iadopt: <https://w3id.org/iadopt/ont/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>

select ?variable ?variable_label ?entity ?entity_label ?creator ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType iadopt:Variable .
    filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . }
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?variable .
    ?np npx:signedBy ?creator .
  }
  graph ?a {
    ?variable a iadopt:Variable .
    optional { ?variable rdfs:label ?variable_label . }
    optional {
      ?variable iadopt:hasObjectOfInterest ?entity .
      optional { ?entity rdfs:label ?entity_label . }
    }
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RAcyg9La3L2Xuig-jEXicmdmEgUGYfHda6Au1Pfq64hR0/get-all-resource-views>
  a grlc:grlc-query;
  dct:description "Returns all resource view declarations with their basic structure: view ID, kind, type, label, query, template count, first template, and date.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all resource views";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix nt: <https://w3id.org/np/o/ntemplate/>

select ?view ?view_label ?viewKind ?type ?query (count(distinct ?actionTemplate) as ?template_count) (min(?actionTemplate) as ?first_template) (min(?actionLabel) as ?first_template_label) ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np np:hasPublicationInfo ?pi .
  }
  graph ?pi {
    ?np nt:wasCreatedFromTemplate <https://w3id.org/np/RARLsTlqbTesu1b0WJZ-zL1z96xumOiqbK3l_vV6iZoww> .
  }
  graph ?a {
    ?view a gen:ResourceView .
    optional {
      ?view a ?type .
      filter(?type != gen:ResourceView)
    }
    optional { ?view rdfs:label ?view_label . }
    optional { ?view dct:isVersionOf ?viewKind . }
    optional { ?view gen:hasViewQuery ?query . }
    optional {
      ?view gen:hasViewAction ?action .
      ?action gen:hasActionTemplate ?actionTemplate .
      optional { ?action rdfs:label ?actionLabel . }
    }
  }
} group by ?view ?view_label ?viewKind ?type ?query ?date ?np
order by desc(?date)""" .

<https://w3id.org/np/RAdwV588EdTzQ6UhsYX_hmg5GvOJbKvFjMOcEIpVNxyLg/get-future-planned-event-attendances>
  a grlc:grlc-query;
  dct:description "This query returns the future events the given user plans to attend.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get future planned event attendances";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/e0c10d8a3e60586806c4b357bb4767f6c71c162e061be85cfe165eaf18b13f2f>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix schema: <http://schema.org/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

select distinct ?event ?event_label ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType gen:plansToAttend .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np npx:signedBy ?_user_iri .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?_user_iri gen:plansToAttend ?event .
    optional { ?event rdfs:label ?event_label }
    optional { ?event dct:date ?date1 }
  }
  optional {
    bind(iri(concat(\"https://w3id.org/np/l/nanopub-query-1.1/repo/type/\", sha256(str(gen:Space)))) as ?space_repo)
    service ?space_repo {
      graph npa:graph {
        ?nps npx:introduces ?event .
        ?nps npa:hasValidSignatureForPublicKeyHash ?pks .
        filter not exists { ?npsx npx:invalidates ?nps ; npa:hasValidSignatureForPublicKeyHash ?pks . }
        ?nps np:hasAssertion ?as .
      }
      graph ?as {
        ?event schema:startDate ?datetime .
        bind(xsd:date(substr(str(?datetime), 0, 11)) as ?date2)
      }
    }
  }
  bind(coalesce(?date1, ?date2) as ?date)
  filter(?date >= xsd:date(substr(str(now()), 0, 11)))
} order by ?date""" .

<https://w3id.org/np/RA3MHN9nl1Erz9W-1HpyNp2CSJBQ2uS5vlSDLARla45w4/get-latest-nanopubs-by-user>
  a grlc:grlc-query;
  dct:description "This query returns the latest nanopublications by user ID.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get latest nanopubs by user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>

select distinct ?np ?label ?date where {
  graph npa:graph {
    ?np npx:signedBy ?_user_iri .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    optional { ?np rdfs:label ?label . }
    filter not exists { ?np npx:hasNanopubType npx:retracts . }
  }
} order by desc(?date) limit 100""" .

<https://w3id.org/np/RAkdyQ9BzXmooOF30BsFSNOs8EsSivp5k-eL293diNKXk/get-3pff-events>
  a grlc:grlc-query;
  dct:description "Returns a list of all events related to the Three Point FAIRification Framework (3PFF)";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get 3PFF Events";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/1c6aa07996de9244076dbdbf96515ae280fb28a8a0cc49f7b0b8c819bc8d54cf>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix tpff: <https://w3id.org/fair/3pff/>
prefix schema: <http://schema.org/>

select (?event as ?Event_ID) (?eventShortName as ?Event_ID__label) (?eventLongName as ?Event_Name) (?eventDate as ?Date) (group_concat(distinct ?eventOrganizer; separator=\" \") as ?Organizers) (group_concat(distinct ?eventFacilitator; separator=\" \") as ?Facilitators) (group_concat(distinct ?eventMoreInfoLink; separator=\" \") as ?More_Info) (?np as ?Source) where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    ?np dct:created ?npDate .
    ?np dct:creator ?npCreator .
    ?np np:hasAssertion ?assertion .
    ?np npx:introduces ?event .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
  }
  graph ?assertion {
    ?event a tpff:3PFF-event .
    ?event rdfs:label ?eventName .
    
    # Date Handling: Check for both predicates
    optional { ?event dct:date ?dateDct . }
    optional { ?event schema:startDate ?dateSchema . }
    bind(coalesce(?dateDct, strBefore(str(?dateSchema), \"T\")) as ?eventDate)
    
    bind(replace(str(?eventName), ' ?\\\\|.*$', '') as ?eventShortName)
    bind(replace(str(?eventName), '^([A-Z0-9]{2,3}).*$', '$1') as ?eventSeries)
    bind(replace(str(?eventName), '^.*\\\\| ?(.*)$', '$1') as ?eventLongName)

    optional {
      ?event tpff:has-event-organizer ?eventOrganizer .
    }
    optional {
      ?event tpff:has-event-facilitator ?eventFacilitator .
    }
    optional {
      ?event rdfs:seeAlso ?eventMoreInfoLink .
    }
  }
}
group by ?event ?eventShortName ?eventLongName ?eventDate ?np
order by desc(?eventDate)""" .

<https://w3id.org/np/RAcEqPZ1PVR7xow-lUP2_JQ5PX4LKQ6yOuFHfT8ga7150/get-all-rocrate-nanopubs>
  a grlc:grlc-query;
  dct:description "This query returns all RO-Crate nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all RO-Crate Nanopubs";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/a94355158beda26c5d1533e079a7f76e827b9037dc594fac440e0cf3a2a153d1>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>

select distinct ?rocrate ?date ?np where {
  graph npa:graph {
    ?np npx:hasNanopubType npx:RoCrateNanopub .
    filter not exists { ?npx npx:invalidates ?np }
    ?np dct:created ?date .
    ?np npx:introduces ?rocrate .
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RA-_IwzReR2_HfTLz4YcNM6Mh3Vt16y0RUS12tpJTN9FI/get-all-user-default-license>
  a grlc:grlc-query;
  dct:description "This query returns all user default license.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all user default license";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npx: <http://purl.org/nanopub/x/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix kpxl_terms: <https://w3id.org/kpxl/gen/terms/>

select ?user ?license where {
  graph npa:graph {
    ?np np:hasAssertion ?a .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
  }
  graph ?a {
	?user kpxl_terms:hasDefaultLicense ?license .
  }
}""" .

<https://w3id.org/np/RAMa2Sihh7xr62jovelVH0B4jXpbeWpAQh30VNVb8HeEk/get-all-ro-crate-nanopubs-again>
  a grlc:grlc-query;
  dct:description "This query returns all RO-Crate nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all RO-Crate nanopubs again";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/a94355158beda26c5d1533e079a7f76e827b9037dc594fac440e0cf3a2a153d1>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>

select distinct ?rocrate ?date ?np where {
  graph npa:graph {
    ?np npx:hasNanopubType npx:RoCrateNanopub .
    filter not exists { ?npx npx:invalidates ?np }
    ?np dct:created ?date .
    ?np npx:introduces ?rocrate .
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RAOV5lyG_-4-fG42jc7Qy9Ltl7_cpuCUXepv1HkQ0LHZg/sparql-construct-query-test>
  a grlc:grlc-query;
  dct:description "This is just to test SPARQL Contruct queries.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Testing SPARQL Construct queries...";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>

construct {
  ?np rdfs:label ?label .
} where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np rdfs:label ?label .
  }
} limit 10""" .

<https://w3id.org/np/RAtcodMPmTrmBvdOqwYIrNNFDO74f8B_xo0qsOcKlCwTA/get-all-user-profile-pics>
  a grlc:grlc-query;
  dct:description "This query returns all user profile pictures.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get all user profile pics";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix np: <http://www.nanopub.org/nschema#>
prefix npx: <http://purl.org/nanopub/x/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix schema: <https://schema.org/>

select ?user ?imageUrl where {
  graph npa:graph {
    ?np np:hasAssertion ?a .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
  }
  graph ?a {
	?user schema:image ?imageUrl .
  }
}""" .

<https://w3id.org/np/RAHCgNxuO4EPiN2xH2fcVEzTnOfu0vFfN32vwjg4j0nMs/get-posts-by-user>
  a grlc:grlc-query;
  dct:description "This query returns the posts by the given user.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get posts by given user";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/89ce048c79daecabd00d1a8223b30d424867c813816752a4c802e619dee6a600>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix schema: <https://schema.org/>

select ?title ?about ?text ?date ?url ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType schema:SocialMediaPosting .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np npx:introduces ?post .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?post schema:headline ?title .
    ?post schema:articleBody ?text .
    ?post schema:datePublished ?date .
    ?post schema:author ?_author_iri .
    optional { ?post schema:url ?url . }
    optional { ?post rdfs:seeAlso ?about . }
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RAFGm6dE-H9M5WgOViQJQrvKrwQofZxViNF2wq2CbAZTA/get-rocrate-nanopubs>
  a grlc:grlc-query;
  dct:description "This query returns RO-Crate nanopubs.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get RO-Crate nanopubs";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/a94355158beda26c5d1533e079a7f76e827b9037dc594fac440e0cf3a2a153d1>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>

select distinct ?rocrate ?date (?__agent_iri as ?agent) ?np (?__pubkeyhash as ?pubkey) where {
  graph npa:graph {
    ?np npx:hasNanopubType npx:RoCrateNanopub .
    ?np npa:hasValidSignatureForPublicKeyHash ?__pubkeyhash .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?__pubkeyhash . }
    ?np dct:created ?date .
    ?np npx:introduces ?rocrate .
    ?np npx:signedBy ?__agent_iri .
  }
}
order by desc(?date)""" .

<https://w3id.org/np/RAB1cGJ67wFpvE5HV2xl8-izmp_R8q25UlTg9UXIb6pRE/get-paragraphs-of-ontology-version>
  a grlc:grlc-query;
  dct:description "This query returns all paragraphs that are part of a given version of an ontology.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the paragraphs of an ontology version";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix schema: <https://schema.org/>

select distinct ?title ?content ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?_ontologyVersionNp_iri npx:introduces ?ontologyVersion .
    ?_ontologyVersionNp_iri np:hasAssertion ?ontologyVersionNpA .
  }
  graph ?ontologyVersionNpA {
    ?ontologyVersion a owl:Ontology .
    ?ontologyVersion gen:hasContentIndex ?contentIndex .
  }
  graph npa:graph {
    ?contentIndex np:hasAssertion ?contentIndexA .
  }
  graph ?contentIndexA {
    ?contentIndex npx:includesElement ?itemNp .
  }
  graph npa:graph {
    ?itemNp dct:created ?date .
    ?itemNp npx:introduces ?paragraph .
    ?itemNp np:hasAssertion ?itemNpA .
  }
  graph ?itemNpA {
    ?paragraph schema:title ?title .
    ?paragraph a gen:Paragraph .
    ?paragraph gen:hasContent ?content .
  }
}
order by ?title""" .

<https://w3id.org/np/RAnbHVsf4DjzMIjcfMcuDm0EdbCXZ8pzJhNvBkJjk21Cc/get-individuals-of-ontology-version>
  a grlc:grlc-query;
  dct:description "This query returns all named individuals that are part of a given version of an ontology.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the individuals of an ontology version";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select distinct ?individual ?individual_label (?definition as ?description) (?termNp as ?np) (\"^\" as ?np_label) where {
  graph npa:graph {
    ?_ontologyVersionNp_iri npx:introduces ?ontologyVersion .
    ?_ontologyVersionNp_iri np:hasAssertion ?ontologyVersionNpA .
  }
  graph ?ontologyVersionNpA {
    ?ontologyVersion a owl:Ontology .
    ?ontologyVersion gen:hasContentIndex ?contentIndex .
  }
  graph npa:graph {
    ?contentIndex np:hasAssertion ?contentIndexA .
  }
  graph ?contentIndexA {
    ?contentIndex npx:includesElement ?termNp .
  }
  graph npa:graph {
  }
  graph npa:graph {
    ?termNp dct:created ?date .
    ?termNp npx:introduces ?individual .
    ?termNp np:hasAssertion ?termNpA .
  }
  graph ?termNpA {
    ?individual a owl:NamedIndividual .
    optional { ?individual rdfs:label ?individual_label . }
    optional { ?individual skos:definition ?definition . }
  }
}
order by ?individual_label""" .

<https://w3id.org/np/RAFHrr_CR0c0B3NmyPpqa2V7oDSC4ntd1fEku2HFxPY_I/get-classes-of-ontology-version>
  a grlc:grlc-query;
  dct:description "This query returns all properties that are part of a given version of an ontology.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the properties of an ontology version";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select distinct ?property ?property_label (?definition as ?description) (?termNp as ?np) (\"^\" as ?np_label)where {
  graph npa:graph {
    ?_ontologyVersionNp_iri npx:introduces ?ontologyVersion .
    ?_ontologyVersionNp_iri np:hasAssertion ?ontologyVersionNpA .
  }
  graph ?ontologyVersionNpA {
    ?ontologyVersion a owl:Ontology .
    ?ontologyVersion gen:hasContentIndex ?contentIndex .
  }
  graph npa:graph {
    ?contentIndex np:hasAssertion ?contentIndexA .
  }
  graph ?contentIndexA {
    ?contentIndex npx:includesElement ?termNp .
  }
  graph npa:graph {
  }
  graph npa:graph {
    ?termNp dct:created ?date .
    ?termNp npx:introduces ?property .
    ?termNp np:hasAssertion ?termNpA .
  }
  graph ?termNpA {
    ?property a rdf:Property .
    optional { ?property rdfs:label ?property_label . }
    optional { ?property skos:definition ?definition . }
  }
}
order by ?property_label""" .

<https://w3id.org/np/RAFmmzto-WVxcSYYoys8qYgCk62rZs7qxxkGIphDnBqUs/get-classes-of-ontology-version>
  a grlc:grlc-query;
  dct:description "This query returns all classes that are part of a given version of an ontology.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the classes of an ontology version";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select distinct ?class ?class_label (?definition as ?description) (?termNp as ?np) (\"^\" as ?np_label) where {
  graph npa:graph {
    ?_ontologyVersionNp_iri npx:introduces ?ontologyVersion .
    ?_ontologyVersionNp_iri np:hasAssertion ?ontologyVersionNpA .
  }
  graph ?ontologyVersionNpA {
    ?ontologyVersion a owl:Ontology .
    ?ontologyVersion gen:hasContentIndex ?contentIndex .
  }
  graph npa:graph {
    ?contentIndex np:hasAssertion ?contentIndexA .
  }
  graph ?contentIndexA {
    ?contentIndex npx:includesElement ?termNp .
  }
  graph npa:graph {
  }
  graph npa:graph {
    ?termNp dct:created ?date .
    ?termNp npx:introduces ?class .
    ?termNp np:hasAssertion ?termNpA .
  }
  graph ?termNpA {
    ?class a owl:Class .
    optional { ?class rdfs:label ?class_label . }
    optional { ?class skos:definition ?definition . }
  }
}
order by ?class_label""" .

<https://w3id.org/np/RA_TneG2gCGpKaeRhXFvXdlVDim-FLpp_R47sw0um9Ubo/get-ontology-versions>
  a grlc:grlc-query;
  dct:description "This query returns the ontology versions for a given ontology.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get ontology versions";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/08908c7290a1a9c3219bc4e10b36d1d17f2d01aa8f6133067089e77fcdfff81b>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select ?ontologyVersion ?ontologyVersion_label ?creator ?np (\"^\" as ?np_label) where {
  values ?_ontology_multi_iri {}
  graph npa:graph {
    ?np npx:hasNanopubType owl:Ontology .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?ontologyVersion .
    ?np npx:signedBy ?creator .
  }
  graph ?a {
    ?ontologyVersion rdfs:label ?ontologyVersion_label .
    ?ontologyVersion dct:isVersionOf ?_ontology_multi_iri .
    ?ontologyVersion gen:hasContentIndex ?contentIndex .
  }
}
order by desc(?ontologyVersion)""" .

<https://w3id.org/np/RAliUJFYGJF3xnfl1825g-TB4iVvOV8RxFRbB0q0OEEsE/get-definitions-of-ontology-ns>
  a grlc:grlc-query;
  dct:description "This query returns all definition nanopublications that define the elements of a given OWL ontology, like classes and properties, including those that match the namespace and including paragraphs describing the ontology.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get the definitions of an ontology including namespace and descriptions";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix schema: <https://schema.org/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>

select distinct ?np (\"^\" as ?np_label) ?item ?item_label ?creator ?date where {
  values ?_ontology_multi_iri {}
  graph npa:graph {
    values ?itemType { owl:Class rdf:Property owl:ObjectProperty owl:DatatypeProperty owl:NamedIndividual gen:Paragraph }
    ?np npx:hasNanopubType ?itemType .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np npx:introduces ?item .
    optional { ?np npx:signedBy ?creator . }
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    {{
      ?item a ?itemType .
      filter(strstarts(str(?item), ?__ontologyNamespace))
    } union {
      ?item a ?itemType .
      ?item dct:partOf|schema:isPartOf ?_ontology_multi_iri .
    }}
    optional { ?item rdfs:label|schema:title ?item_label . }
  }
}
order by ?label""" .

<https://w3id.org/np/RAJli_clBRLj-0p5gSCevnwa17tznKXDgd45UUWgsp1ew/get-planned-event-attendances>
  a grlc:grlc-query;
  dct:description "This query returns the events the given user plans to attend.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get planned event attendances";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/e0c10d8a3e60586806c4b357bb4767f6c71c162e061be85cfe165eaf18b13f2f>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix gen: <https://w3id.org/kpxl/gen/terms/>
prefix schema: <http://schema.org/>

select distinct ?event ?event_label ?date ?np (\"^\" as ?np_label) where {
  graph npa:graph {
    ?np npx:hasNanopubType gen:plansToAttend .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np npx:signedBy ?_user_iri .
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?_user_iri gen:plansToAttend ?event .
    optional { ?event rdfs:label ?event_label }
    optional { ?event dct:date ?date1 }
  }
  optional {
    bind(iri(concat(\"https://w3id.org/np/l/nanopub-query-1.1/repo/type/\", sha256(str(gen:Space)))) as ?space_repo)
    service ?space_repo {
      graph npa:graph {
        ?nps npx:introduces ?event .
        ?nps npa:hasValidSignatureForPublicKeyHash ?pks .
        filter not exists { ?npsx npx:invalidates ?nps ; npa:hasValidSignatureForPublicKeyHash ?pks . }
        ?nps np:hasAssertion ?as .
      }
      graph ?as {
        ?event schema:startDate ?datetime .
        bind(xsd:date(substr(str(?datetime), 0, 11)) as ?date2)
      }
    }
  }
  bind(coalesce(?date1, ?date2) as ?date)
} order by desc(?date)""" .

<https://w3id.org/np/RAFv-lX-vlyT3rwXaaz2dlxQuuT8JzN0AOoOH_m8Bfmac/fers_by_type> a
    grlc:grlc-query;
  dct:description "Get FAIR-Enabling Resources by type.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get FERs by type (with community count)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix search: <http://www.openrdf.org/contrib/lucenesail#>

select distinct ?np ?thing ?description ?label ?date ?types ?qualifier (group_concat(distinct ?community; separator=\" \") as ?communities) (count(distinct ?community) as ?community_count) where {

  { select ?latest_curators_assertion where {
    graph npa:graph {
      <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> npa:hasValidSignatureForPublicKey ?curators_np_pk .
      ?latest_curators_np npa:hasValidSignatureForPublicKey ?curators_np_pk .
      filter not exists { ?latest_curators_npx npx:invalidates ?latest_curators_np ; npa:hasValidSignatureForPublicKey ?curators_np_pk . }
      ?latest_curators_np np:hasAssertion ?latest_curators_assertion .
    }
    graph npa:networkGraph {
      ?latest_curators_np (npx:supersedes)* <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> .
      filter not exists { ?latest_curators_npxx npx:supersedes ?latest_curators_np }
    }
  } }

  { select ?np ?thing ?label ?description ?date (group_concat(distinct ?type; separator=\" \") as ?types) where {

      graph npa:graph {
        ?np rdfs:label ?label ;
            dct:description ?description ;
            npa:hasValidSignatureForPublicKey ?pubkey ;
            dct:created ?date .
        ?np npx:introduces|npx:describes ?thing .
        filter(str(?date) > \"2022\")
        filter exists { ?np npx:hasNanopubType ?fsr_type . values ?fsr_type { fip:FAIR-Enabling-Resource fip:FAIR-Supporting-Resource } }
        filter not exists { ?np npx:hasNanopubType npx:ExampleNanopub . }
        ?np npx:hasNanopubType ?_type_iri .
        ?np npx:hasNanopubType ?type .
        values ?type {
          fip:Authentication-and-authorization-service
          fip:Editor
          fip:FAIR-Representation-Service
          fip:FAIR-Supporting-Software
          fip:Identifier-service
          fip:Provenance-Tracking-Service
          fip:Registry
          fip:Validation-Service
          fip:Web-API
          fip:Communication-protocol
          fip:Crosswalk
          fip:FAIR-Implementation-Profile
          fip:Knowledge-representation-language
          fip:Metadata-schema
          fip:Metadata-data-linking-schema
          fip:Provenance-model
          fip:Semantic-model
          fip:Structured-vocabulary
          fip:FAIR-Data-Policy
          fip:Data-usage-license
          fip:Metadata-preservation-policy
          fip:Persistency-Policy
          fip:FAIR-Practice
        }
        filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
      }

    filter not exists {
      graph ?da {
        ?disapprover npx:disapprovesOf ?np .
      }
      graph npa:graph {
        ?disapproval_np np:hasAssertion ?da ;
          npa:hasValidSignatureForPublicKey ?dpubkey .
        filter not exists { ?disapproval_npx npx:invalidates ?disapproval_np ; npa:hasValidSignatureForPublicKey ?dpubkey . }
      }
      graph ?latest_curators_assertion {
        ?qpubkeys npx:hasPublicKey ?dpubkey .
      }
    }

  } group by ?np ?thing ?label ?description ?date }


  optional {
    graph ?qa {
      ?qualifier npx:qualifies ?np .
    }
    graph npa:graph {
      ?qualification_np np:hasAssertion ?qa ;
        npa:hasValidSignatureForPublicKey ?qpubkey .
      filter not exists { ?qualification_npx npx:invalidates ?qualification_np ; npa:hasValidSignatureForPublicKey ?qpubkey . }
    }
    graph ?latest_curators_assertion {
      ?qpubkeys npx:hasPublicKey ?qpubkey .
    }
  }

  optional {
    graph npa:graph {
      ?decl_np npx:hasNanopubType fip:FIP-Declaration .
      ?decl_np np:hasAssertion ?decl_a ;
        npa:hasValidSignatureForPublicKey ?decl_pubkey .
      filter not exists { ?decl_npx npx:invalidates ?decl_np ; npa:hasValidSignatureForPublicKey ?decl_pubkey . }
    }
    graph ?decl_a {
      ?decl a fip:FIP-Declaration .
      # ----
      # not really needed but seems to make query faster:
      values ?use { fip:declares-current-use-of fip:declares-planned-use-of fip:declares-planned-development-of fip:declares-planned-replacement-of }
      ?decl ?use ?thing .
      # ----
      ?decl fip:declared-by ?community .
    }
  }

} group by ?np ?thing ?description ?label ?date ?types ?qualifier order by desc(?community_count)""" .

<https://w3id.org/np/RAz3G98ZMRbi7s3p_pfNd8ozHJNKGYxzS3N-dSXd5OnWE/get-iadopt-variable-definition>
  a grlc:grlc-query;
  dct:description "This Construct query returns the definition of an I-Adopt variable, corresponding to the assertion of its defining nanopublication.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get I-Adopt variable definition";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/type/dbf3e4836e0529b98c8e70684a03a3fb3a7b48dfa7829747dd978f2b7249ada1>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix iadopt: <https://w3id.org/iadopt/ont/>

construct {
  ?subj ?pred ?obj .
} where {
  graph npa:graph {
    ?np npx:introduces ?_variable_iri .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    filter not exists {
      ?np2 npx:introduces ?_variable_iri .
      ?np2 npa:hasValidSignatureForPublicKeyHash ?pubkey2 .
      filter not exists { ?np2x npx:invalidates ?np2 ; npa:hasValidSignatureForPublicKeyHash ?pubkey2 . }
      ?np2 dct:created ?date2 .
      filter(?date2 > ?date)
    }
  }
  graph npa:graph {
    ?np np:hasAssertion ?a .
  }
  graph ?a {
    ?subj ?pred ?obj .
  }
}
order by ?subj ?pred ?obj""" .

<https://w3id.org/np/RAl03y0LpJBz11POZW9MkV9scYfzfCSeaMVh3-nLphkL0/get-coauthors>
  a grlc:grlc-query;
  dct:description "This query returns the co-authors of a given author.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get co-authors";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix fabio: <http://purl.org/spar/fabio/>
prefix bibo: <http://purl.org/ontology/bibo/>
prefix foaf: <http://xmlns.com/foaf/0.1/>

select ?coauthor ?coauthor_label (count(distinct ?paper) as ?paper_count) where {
  values ?_author_multi_iri {}
  graph npa:graph {
    ?np npx:hasNanopubType fabio:ScholarlyWork .
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
    ?np npx:introduces ?paper .
  }
  graph ?a {
    ?paper dct:title ?paper_label .
    ?paper bibo:authorList ?author_list .
    ?paper dct:date ?publication_date .
    ?author_list ?rdfseqpred1 ?_author_multi_iri .
    filter(strstarts(str(?rdfseqpred1), \"http://www.w3.org/1999/02/22-rdf-syntax-ns#_\"))
    ?author_list ?rdfseqpred2 ?coauthor_id .
    filter(strstarts(str(?rdfseqpred2), \"http://www.w3.org/1999/02/22-rdf-syntax-ns#_\"))
    ?coauthor_id foaf:name ?coauthor_label .
    bind(if(strstarts(str(?coauthor_id), \"https://orcid.org/\"), ?coauthor_id, ?coauthor_label) as ?coauthor)
    filter(?coauthor_id != ?_author_multi_iri)
    optional {
      ?paper dct:isPartOf ?journal .
      ?journal dct:title ?journal_label .
    }
  }
}
group by ?coauthor ?coauthor_label
order by desc(?paper_count)""" .

<https://w3id.org/np/RAqcPT8CnnXJYZz77UHKqieFX0s4B5u1Oax3233qkv-jE/get-dggs-nanopubs>
  a grlc:grlc-query;
  dct:description "List nanopublications related to Discrete Global Grid Systems (DGGS).";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get nanopublications related to DGGS";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>

select ?np ?pubkey ?date 
       (sample(?label) as ?label) 
       (sample(?title) as ?title) 
       (sample(?text) as ?text) 
       (sample(?supersedes) as ?supersedes)
where {
  graph npa:graph {
    ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
    
    filter not exists { 
      ?npx npx:invalidates ?np ; 
           npa:hasValidSignatureForPublicKeyHash ?pubkey_inv . 
    }
    
    filter not exists {
      ?newer_np npx:supersedes ?np ;
                npa:hasValidSignatureForPublicKeyHash ?pubkey_super .
    }
    
    filter not exists {
      ?retraction_np npx:retracts ?np ;
                     npa:hasValidSignatureForPublicKeyHash ?pubkey_ret .
    }
    
    ?np dct:created ?date .
    ?np np:hasAssertion ?a .
  }
  
  optional {
    graph npa:graph {
      ?np npx:supersedes ?supersedes .
    }
  }
  
  graph ?a {
    ?s ?p ?o .
    filter(
      isLiteral(?o) && regex(str(?o), \"DGGS|Discrete Global Grid|discrete global grid\", \"i\")
    )
  }
  
  optional { 
    graph ?a { ?s rdfs:label ?label }
  }
  optional { 
    graph ?a { ?s dct:title ?title }
  }
  bind(?o as ?text)
}
group by ?np ?pubkey ?date
order by desc(?date)""" .

<https://w3id.org/np/RAgj3SiN-7KF1PY8wutORBmbh6rsel2NitTls_LGw-2ZY/find-gofair-qualified-things>
  a grlc:grlc-query;
  dct:description "This query allows for searching for resources (FERs etc.) together with the info about whether GO FAIR qualified them.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Find GO FAIR qualified things (with unchecked recommenders)";
  grlc:endpoint <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  grlc:sparql """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix prov: <http://www.w3.org/ns/prov#>

select distinct ?thing ?label ?description ?np ?date ?pubkey ?retraction ?newversion ?qualifier ?qualification_np (group_concat(distinct ?recommender; separator=\" \") as ?recommenders) (group_concat(distinct ?recommendation_np; separator=\" \") as ?recommendation_nps) (count(distinct ?recommender) as ?recommender_count) (sample(?fairAssessmentLevel) as ?fairAssessmentLevel) (sample(?fairAssessmentLevelNp) as ?fairAssessmentLevelNp) where {
  graph npa:graph {
    <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> npa:hasValidSignatureForPublicKey ?curators_np_pk .
    ?latest_curators_np npa:hasValidSignatureForPublicKey ?curators_np_pk .
    filter not exists { ?latest_curators_npx npx:invalidates ?latest_curators_np ; npa:hasValidSignatureForPublicKey ?curators_np_pk . }
    ?latest_curators_np np:hasAssertion ?latest_curators_assertion .
  }
  graph npa:networkGraph {
    ?latest_curators_np (npx:supersedes)* <https://w3id.org/np/RA27Uhopq4MHZziL2lKXX-wTb1jz4KVLbHaupxyAcCt9Y> .
    filter not exists { ?latest_curators_npxx npx:supersedes ?latest_curators_np }
  }
  
  graph npa:graph {
    ?np npx:hasNanopubType ?__type_iri .
    ?np npa:hasValidSignatureForPublicKey ?pubkey .
    optional { ?retraction npx:retracts ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    optional { ?newversion npx:supersedes ?np ; npa:hasValidSignatureForPublicKey ?pubkey . }
    ?np (npx:introduces|npx:describes) ?thing .
    ?np rdfs:label ?label .
    ?np dct:description ?description .
    ?np dct:created ?date .
    filter(str(?date) > \"2022\")
  }
  bind(concat(\" \",lcase(str(?label)),\" \",lcase(str(?description)),\" \") as ?text)
  filter( contains(?text, lcase(str(?_searchterm))) )

  optional {
    graph npa:graph {
      ?disapproval npa:hasValidSignatureForPublicKey ?dpubkey .
    }
    graph ?latest_curators_assertion {
      ?dpubkeys npx:hasPublicKey ?dpubkey .
    }
    graph npa:graph {
      filter not exists { ?disapproval_x npx:invalidates ?disapproval ; npa:hasValidSignatureForPublicKey ?dpubkey . }
      ?disapproval np:hasAssertion ?da .
    }
    graph ?da {
      ?dsomebody ( npx:disapproves-of | npx:disapprovesOf ) ?np .
    }
  } filter(!bound(?disapproval))  # Faster than \"filter not exists\" for some reason

  optional {
    graph npa:graph {
      ?recommendation_np npx:hasNanopubType fip:recommended-by .
      ?recommendation_np npa:hasValidSignatureForPublicKey ?rpubkey .
      filter not exists { ?recommendation_np_x npx:invalidates ?recommendation_np ; npa:hasValidSignatureForPublicKey ?rpubkey . }
      ?recommendation_np np:hasAssertion ?ra .
      ?recommendation_np np:hasProvenance ?rp .
    }
    graph ?ra {
      ?thing fip:recommended-by ?recommender .
    }
    #graph ?rp {
    #  ?ra prov:wasDerivedFrom ?rfip_np .
    #}
    #graph npa:graph {
    #  ?rfip_np npx:hasNanopubType fip:Reference-FAIR-Implementation-Profile .
    #  ?rfip_np npa:hasValidSignatureForPublicKey ?rfip_pubkey .
    #  ?latest_rfip_np npa:hasValidSignatureForPublicKey ?rfip_pubkey .
    #  filter not exists { ?latest_rfip_npx npx:invalidates ?latest_rfip_np ; npa:hasValidSignatureForPublicKey ?rfip_pubkey . }
    #}
    #graph npa:networkGraph {
    #  ?latest_rfip_np (npx:supersedes)* ?rfip_np .
    #}
    #graph ?rfip_qa {
    #  ?rfip_qualifier npx:qualifies ?latest_rfip_np .
    #}
    #graph npa:graph {
    #  ?rfip_qualification_np np:hasAssertion ?rfip_qa .
    #  ?rfip_qualification_np npx:hasNanopubType npx:qualifies .
    #  ?rfip_qualification_np npa:hasValidSignatureForPublicKey ?rfip_qpubkey .
    #  filter not exists { ?rfip_qualification_np_x npx:invalidates ?rfip_qualification_np ; npa:hasValidSignatureForPublicKey ?rfip_qpubkey . }
    #}
    #graph ?latest_curators_assertion {
    #  ?rfip_qpubkeys npx:hasPublicKey ?rfip_qpubkey .
    #}
  }
  optional {
    graph npa:graph {
      ?qualification_np npx:hasNanopubType npx:qualifies .
      ?qualification_np npa:hasValidSignatureForPublicKey ?qpubkey .
    }
    graph ?latest_curators_assertion {
      ?qpubkeys npx:hasPublicKey ?qpubkey .
    }
    graph npa:graph {
      filter not exists { ?qualification_np_x npx:invalidates ?qualification_np ; npa:hasValidSignatureForPublicKey ?qpubkey . }
      ?qualification_np np:hasAssertion ?qa .
    }
    graph ?qa {
      ?qualifier npx:qualifies ?np .
    }
  }

  optional {
    graph npa:graph {
      ?fairAssessmentLevelNp npx:hasNanopubType fip:has-FAIR-assessment .
      ?fairAssessmentLevelNp npa:hasValidSignatureForPublicKey ?lpubkey .
    }
    graph ?latest_curators_assertion {
      ?lpubkeys npx:hasPublicKey ?lpubkey .
    }
    graph npa:graph {
      filter not exists { ?fairAssessmentLevelNp_x npx:invalidates ?fairAssessmentLevelNp ; npa:hasValidSignatureForPublicKey ?lpubkey . }
      ?fairAssessmentLevelNp np:hasAssertion ?la .
    }
    graph ?la {
      ?thing fip:has-FAIR-assessment ?fairAssessmentLevel .
    }
  } filter(!bound(?levelNp))  # Faster than \"filter not exists\" for some reason

}
group by ?thing ?label ?description ?np ?date ?pubkey ?retraction ?newversion ?qualifier ?qualification_np
order by desc(?recommender_count) asc(?label)""" .
