Matcher rule
same-variation-through-current-tables-key-joined-first
Two records of one kind match when their current versions find one row of one version of a variant classifications table. A version that carries a ClinVar VariationID finds the row of that variation, <https://identifiers.org/clinvar:> and the ID, through that ID alone: its HGVS expression is not read. A version that carries none finds the row that holds its HGVS expression, <https://ns.cascadeprotocol.org/codes/hgvs/> and the expression percent-encoded as ENCODE_FOR_URI does. The classification plays no part: the join is identity. Left alone: a pair that shares an ID, which the rule that joins by ID has, so no pair is judged by both; a pair whose versions carry different IDs, whatever expressions they hold; and a version whose expression is on more than one row, since it would join two variations and entries would then join through it. Rows are counted as distinct row subjects over the current version of every series of the kind, the one no version revises, so two series that both hold one variation are one row and an older version's rows are never counted. A version finds its row in an origin only when that origin holds the row, and, for an expression, holds the expression on it. Each ordered pair is a row, with the version whose rows joined it; a graph that is not a version of a variant classifications table is never read for rows. A run binds ?record to each record it compares.
The query
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT DISTINCT ?record ?other ?origin
WHERE {
{ SELECT ?record ?version ?kind (COALESCE(SAMPLE(?found), "") AS ?row) (COALESCE(SAMPLE(?lookup), "") AS ?key)
WHERE {
{ ?version cascade:clinvarVariationId ?id .
?record pav:hasCurrentVersion ?version ; cascade:recordKind ?kind
BIND (IRI(CONCAT("https://identifiers.org/clinvar:", ENCODE_FOR_URI(STR(?id)))) AS ?lookup)
BIND (?lookup AS ?found) }
UNION
{ ?version cascade:hgvsCodingDnaExpression ?hgvs .
?record pav:hasCurrentVersion ?version ; cascade:recordKind ?kind
FILTER NOT EXISTS { ?version cascade:clinvarVariationId [] }
BIND (COALESCE(IRI(CONCAT("https://ns.cascadeprotocol.org/codes/hgvs/", ENCODE_FOR_URI(STR(?hgvs)))), "") AS ?lookup)
?current prov:specializationOf/cascade:tableKind cascade:VariantClassifications .
FILTER NOT EXISTS { ?newer prov:wasRevisionOf ?current }
GRAPH ?current { ?found cascade:hgvsExpression ?lookup } }
}
GROUP BY ?record ?version ?kind
HAVING (COUNT(DISTINCT ?found) = 1 && COUNT(DISTINCT ?lookup) = 1) }
{ SELECT ?other ?otherVersion ?kind (COALESCE(SAMPLE(?otherFound), "") AS ?row) (COALESCE(SAMPLE(?otherLookup), "") AS ?otherKey)
WHERE {
{ ?otherVersion cascade:clinvarVariationId ?otherId .
?other pav:hasCurrentVersion ?otherVersion ; cascade:recordKind ?kind
BIND (IRI(CONCAT("https://identifiers.org/clinvar:", ENCODE_FOR_URI(STR(?otherId)))) AS ?otherLookup)
BIND (?otherLookup AS ?otherFound) }
UNION
{ ?otherVersion cascade:hgvsCodingDnaExpression ?otherHgvs .
?other pav:hasCurrentVersion ?otherVersion ; cascade:recordKind ?kind
FILTER NOT EXISTS { ?otherVersion cascade:clinvarVariationId [] }
BIND (COALESCE(IRI(CONCAT("https://ns.cascadeprotocol.org/codes/hgvs/", ENCODE_FOR_URI(STR(?otherHgvs)))), "") AS ?otherLookup)
?otherCurrent prov:specializationOf/cascade:tableKind cascade:VariantClassifications .
FILTER NOT EXISTS { ?otherNewer prov:wasRevisionOf ?otherCurrent }
GRAPH ?otherCurrent { ?otherFound cascade:hgvsExpression ?otherLookup } }
}
GROUP BY ?other ?otherVersion ?kind
HAVING (COUNT(DISTINCT ?otherFound) = 1 && COUNT(DISTINCT ?otherLookup) = 1) }
?origin prov:specializationOf/cascade:tableKind cascade:VariantClassifications .
GRAPH ?origin {
?row ?held [] .
?key ^cascade:hgvsExpression? ?row .
?otherKey ^cascade:hgvsExpression? ?row .
}
?record pav:hasCurrentVersion ?version .
FILTER (?record != ?other)
FILTER NOT EXISTS {
?version cascade:clinvarVariationId ?shared .
?otherVersion cascade:clinvarVariationId ?shared
}
}
Terms it reads
cascade:VariantClassifications · cascade:clinvarVariationId · cascade:hgvsCodingDnaExpression · cascade:hgvsExpression · cascade:recordKind · pav:hasCurrentVersion · prov:specializationOf · prov:wasRevisionOf
Rules and decision notes that name it
- M4d. Each version of the rule list names, for each of its rules from R1 to R21, the query that rule's row runs runtime/matcher.feature
- When two variant records are one variant decisions/variant-identity.md
queries/matcher/same-variation-through-current-tables-key-joined-first.rq on GitHub ↗