Skip to content
Alpha: see what works today →
Menu

Named question about pod

My genetic variants

Read from the view alone, as an app would: one row for each variant entry and each code it states, the codes a page looks a variant up by. ?variant is the entry's IRI, as the other pod questions give theirs; ?gene, ?hgvs and ?variation are the literals as the entry states them, an HGVS expression or a ClinVar VariationID on a row of its own. An entry that states no code has one row without either. The page turns a literal into its code system's IRI (rule M4c). Each row names each record the entry joins with the document it was derived from, when that was retrieved, and the hospitals that wrote it and that keep it, in order, separated by U+001F, its own parts by ", ".

The query

PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?variant ?gene ?hgvs ?variation ?sources
WHERE {
  { SELECT ?variant ?gene ?hgvs ?variation
    WHERE {
      { ?variant a cascade:GeneticVariantFinding ; cascade:entryMember [] ; cascade:hgvsCodingDnaExpression ?hgvs .
        OPTIONAL { ?variant cascade:geneSymbol ?gene } }
      UNION
      { ?variant a cascade:GeneticVariantFinding ; cascade:entryMember [] ; cascade:clinvarVariationId ?variation .
        OPTIONAL { ?variant cascade:geneSymbol ?gene } }
      UNION
      { ?variant a cascade:GeneticVariantFinding ; cascade:entryMember [] .
        OPTIONAL { ?variant cascade:geneSymbol ?gene }
        FILTER NOT EXISTS { ?variant cascade:hgvsCodingDnaExpression [] }
        FILTER NOT EXISTS { ?variant cascade:clinvarVariationId [] } }
    } }
  { SELECT ?variant (REPLACE(GROUP_CONCAT(DISTINCT CONCAT(?sourceText, "\u001F"); separator=""), "\u001F$", "") AS ?sources)
    WHERE {
      { SELECT ?variant ?sourceText
        WHERE {
          { SELECT ?variant ?sourceRecord ?document ?retrievedOn
                   (REPLACE(GROUP_CONCAT(DISTINCT COALESCE(CONCAT(?hospital, ", "), ""); separator=""), ", $", "") AS ?hospitals)
            WHERE {
              { SELECT ?variant ?sourceRecord ?document ?retrievedOn ?hospital
                WHERE {
                  ?variant a cascade:GeneticVariantFinding ; cascade:entryMember ?sourceRecord .
                  OPTIONAL { ?sourceRecord cascade:currentRevision/prov:wasDerivedFrom ?document .
                             OPTIONAL { ?document pav:retrievedOn ?retrievedOn }
                             OPTIONAL { ?document prov:wasGeneratedBy/prov:qualifiedAssociation ?association .
                                        ?association prov:hadRole ?hospitalRole ; prov:agent ?agent
                                        FILTER (?hospitalRole IN (cascade:AuthorRole, cascade:CustodianRole))
                                        OPTIONAL { ?agent rdfs:label ?agentLabel }
                                        OPTIONAL { ?agent pav:hasCurrentVersion/foaf:name ?agentName }
                                        BIND (CONCAT(IF(?hospitalRole = cascade:AuthorRole, "written by ", "kept by "),
                                                     COALESCE(?agentLabel, ?agentName)) AS ?hospital) } }
                }
                ORDER BY ?variant ?sourceRecord ?document ?hospital }
            }
            GROUP BY ?variant ?sourceRecord ?document ?retrievedOn }
          BIND (CONCAT(STR(?sourceRecord), COALESCE(CONCAT(" from ", STR(?document)), ""),
                       COALESCE(CONCAT(", retrieved ", STR(?retrievedOn)), ""),
                       IF(?hospitals = "", "", CONCAT(", ", ?hospitals))) AS ?sourceText)
        }
        ORDER BY ?variant ?sourceText }
    }
    GROUP BY ?variant }
}
ORDER BY ?variant ?hgvs ?variation

Terms it reads

cascade:AuthorRole · cascade:CustodianRole · cascade:GeneticVariantFinding · cascade:clinvarVariationId · cascade:currentRevision · cascade:entryMember · cascade:geneSymbol · cascade:hgvsCodingDnaExpression · pav:hasCurrentVersion · pav:retrievedOn · prov:agent · prov:hadRole · prov:wasGeneratedBy · rdfs:label

Rules and decision notes that name it

No rule or decision note writes its path.

Its rows on Alex Rivera's pod

Alex Rivera's pod gives this question no rows. Open it in Alex Rivera's explorer.

queries/questions/pod/My genetic variants.rq on GitHub ↗