query-38c0339605af569cd9c63f5cd391365b

rq turtle/ttl

Visualising gene structure 'is part of' relationships as diagram , but I've realised here might be a more sensible location to ask.project chatI originally posted to within Wikidata. I feel like it should be possibly to recapitulate the structure of that diagram with a Wikidata Query network graph. w:Gene_structureHello, I'm trying to encode the relationships and references in the two diagrams in Colour nodes by whether they are part of open reading frame, UTR or regulatory sequence Edges down from Gene, but also across between elements eukaryotes.of (P642) in different colours (showing only those that have qualifier Property:P279, and Property:P31, Property:P361Edges of Starting at Gene 03:42, 31 January 2019 (UTC)) talk (Evolution and evolvability because I cant work out the syntax enough to implement most of the features above. Any ideas on how to fix it? Fnielsen butchered from a previous query written by Here is my first attempt19:30, 31 January 2019 (UTC)) talk (Luitzen. -- here: The Graph view doesn't allow to colour edges, see Evolution and evolvability@01:21, 1 February 2019 (UTC)) talk (Evolution and evolvability: Ah, thank you. Can the edge labels be customised (e.g. 'P' for 'part of', 'i' for 'instance of'). Luitzen@? this, but I suspect there are still redundant parts. Any ideas on how to simplify it, perhaps with some sort of structure like updated versionI've made an

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX gas: <http://www.bigdata.com/rdf/gas#>

#defaultView:Graph
# parts of a gene and their subclasses
SELECT DISTINCT ?down ?downLabel ?up ?upLabel ("#ff0000" AS ?rgb) WHERE {
  {
    {
      SELECT ?down ?up WHERE { # subclass of untranslated region
        SERVICE gas:service {
          gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS".
          gas:program gas:in wd:Q424345.
          gas:program gas:traversalDirection "Reverse".
          gas:program gas:out ?down.
          gas:program gas:out1 ?depth.
          gas:program gas:out2 ?up.
          gas:program gas:linkType wdt:P279.
        }
      }
    }
  }
  UNION
  {
    {
      SELECT ?down ?up WHERE { # subclass of regulatory sequence
        SERVICE gas:service {
          gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS".
          gas:program gas:in wd:Q3238407.
          gas:program gas:traversalDirection "Reverse".
          gas:program gas:out ?down.
          gas:program gas:out1 ?depth.
          gas:program gas:out2 ?up.
          gas:program gas:linkType wdt:P279.
        }
      }
    }
  }
  UNION
  {
    {
      SELECT ?down ?up WHERE { # part of coding region
        SERVICE gas:service {
          gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS".
          gas:program gas:in wd:Q3780824.
          gas:program gas:traversalDirection "Reverse".
          gas:program gas:out ?down.
          gas:program gas:out1 ?depth.
          gas:program gas:out2 ?up.
          gas:program gas:linkType wdt:P361.
        }
      }
    }
  }
  UNION
  {
    {
      SELECT ?down ?up WHERE { # instance of regulatory sequence
        SERVICE gas:service {
          gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS".
          gas:program gas:in wd:Q424345.
          gas:program gas:traversalDirection "Reverse".
          gas:program gas:out ?down.
          gas:program gas:out1 ?depth.
          gas:program gas:out2 ?up.
          gas:program gas:linkType wdt:P31.
        }
      }
    }
  }
   UNION
  {
    {
      SELECT ?down ?up WHERE { # part of gene
        SERVICE gas:service {
          gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS".
          gas:program gas:in wd:Q7187. # gene
          gas:program gas:traversalDirection "Reverse".
          gas:program gas:out ?down.
          gas:program gas:out1 ?depth.
          gas:program gas:out2 ?up.
          gas:program gas:linkType wdt:P361.
        }
      }
    }
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,sv,jp,zh,ru,fr,de". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?depth") v1("?down"):::projected v4("?rgb") v3("?up"):::projected c2(["gas:program"]):::iri c14(["wd:Q3238407"]):::iri c8(["Reverse"]):::literal c15(["wd:Q3780824"]):::iri c13(["wdt:P279"]):::iri c17(["wdt:P31"]):::iri c6(["wd:Q424345"]):::iri c16(["wdt:P361"]):::iri c4(["com.bigdata.rdf.graph.analytics.BFS"]):::literal c20(["bd:serviceParam"]):::iri c22(["en,da,sv,jp,zh,ru,fr,de"]):::literal c18(["wd:Q7187"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c18 c2 --"gas:traversalDirection"--> c8 c2 --"gas:out"--> v1 c2 --"gas:out1"--> v2 c2 --"gas:out2"--> v3 c2 --"gas:linkType"--> c16 end end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c6 c2 --"gas:traversalDirection"--> c8 c2 --"gas:out"--> v1 c2 --"gas:out1"--> v2 c2 --"gas:out2"--> v3 c2 --"gas:linkType"--> c17 end end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c15 c2 --"gas:traversalDirection"--> c8 c2 --"gas:out"--> v1 c2 --"gas:out1"--> v2 c2 --"gas:out2"--> v3 c2 --"gas:linkType"--> c16 end end union2r <== or ==> union2l end end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c14 c2 --"gas:traversalDirection"--> c8 c2 --"gas:out"--> v1 c2 --"gas:out1"--> v2 c2 --"gas:out2"--> v3 c2 --"gas:linkType"--> c13 end end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; subgraph s1["http://www.bigdata.com/rdf/gas#service"] style s1 stroke-width:4px; c2 --"gas:gasClass"--> c4 c2 --"gas:in"--> c6 c2 --"gas:traversalDirection"--> c8 c2 --"gas:out"--> v1 c2 --"gas:out1"--> v2 c2 --"gas:out2"--> v3 c2 --"gas:linkType"--> c13 end end union0r <== or ==> union0l end subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c20 --"wikibase:language"--> c22 end bind0[/"'#ff0000'"/] bind0 --as--o v4