Extract all parents of a given node

前端 未结 1 1439
忘掉有多难
忘掉有多难 2021-01-25 08:42

I\'m trying to extract all parents of a each given GO Id (a node) using EBI-RDF sparql endpoint, I was based on this two similar questions to formulate the query, here\'re two e

相关标签:
1条回答
  • 2021-01-25 09:27

    Thanks to @AKSW I found a decent solution using HyperGraphQL (a GraphQL interface for querying and serving linked data on the Web).

    I'll leave the detailed answer here, it may help someone.

    1. I downloaded and set up HyperGraphQL download page
    2. Linked it to EBI Sparql endpoint as described in this tutorial

      The config.json file I used:

      {
          "name": "ebi-hgql",
          "schema": "ebischema.graphql",
          "server": {
              "port": 8081,
              "graphql": "/graphql",
              "graphiql": "/graphiql"
          },
          "services": [
              {
                  "id": "ebi-sparql",
                  "type": "SPARQLEndpointService",
                  "url": "http://www.ebi.ac.uk/rdf/services/sparql",
                  "graph": "http://rdf.ebi.ac.uk/dataset/go",
                  "user": "",
                  "password": ""
              }
          ]
      }
      

      Here's how my ebischema.graphql file looks like (Since I needed only the Class, id, label and subClassOf):

      type __Context {
          Class:          _@href(iri: "http://www.w3.org/2002/07/owl#Class")
          id:             _@href(iri: "http://www.geneontology.org/formats/oboInOwl#id")
          label:          _@href(iri: "http://www.w3.org/2000/01/rdf-schema#label")
          subClassOf:     _@href(iri: "http://www.w3.org/2000/01/rdf-schema#subClassOf")
      }
      
      type Class @service(id:"ebi-sparql") {
          id: [String] @service(id:"ebi-sparql")
          label: [String] @service(id:"ebi-sparql")
          subClassOf: [Class] @service(id:"ebi-sparql")
      }
      
    3. I started testing some simple query, but constantly getting an empty response; the answer to this issue solved my problem.

    4. Finally I constructed the query to get the tree

      Using this query:

      {
        Class_GET_BY_ID(uris:[
          "http://purl.obolibrary.org/obo/GO_0032259",
          "http://purl.obolibrary.org/obo/GO_0007267"]) {
          id
          label
          subClassOf {
            id
            label
            subClassOf {
              id
              label
            }
          }
        }
      }
      

      I got some interesting results:

      {
        "extensions": {},
        "data": {
          "@context": {
            "_type": "@type",
            "_id": "@id",
            "id": "http://www.geneontology.org/formats/oboInOwl#id",
            "label": "http://www.w3.org/2000/01/rdf-schema#label",
            "Class_GET_BY_ID": "http://hypergraphql.org/query/Class_GET_BY_ID",
            "subClassOf": "http://www.w3.org/2000/01/rdf-schema#subClassOf"
          },
          "Class_GET_BY_ID": [
            {
              "id": [
                "GO:0032259"
              ],
              "label": [
                "methylation"
              ],
              "subClassOf": [
                {
                  "id": [
                    "GO:0008152"
                  ],
                  "label": [
                    "metabolic process"
                  ],
                  "subClassOf": [
                    {
                      "id": [
                        "GO:0008150"
                      ],
                      "label": [
                        "biological_process"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "id": [
                "GO:0007267"
              ],
              "label": [
                "cell-cell signaling"
              ],
              "subClassOf": [
                {
                  "id": [
                    "GO:0007154"
                  ],
                  "label": [
                    "cell communication"
                  ],
                  "subClassOf": [
                    {
                      "id": [
                        "GO:0009987"
                      ],
                      "label": [
                        "cellular process"
                      ]
                    }
                  ]
                },
                {
                  "id": [
                    "GO:0023052"
                  ],
                  "label": [
                    "signaling"
                  ],
                  "subClassOf": [
                    {
                      "id": [
                        "GO:0008150"
                      ],
                      "label": [
                        "biological_process"
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        "errors": []
      }
      

    EDIT

    This was exactly what I wanted, but I noticed that I can't add another sublevel like this:

    {
      Class_GET_BY_ID(uris:[
        "http://purl.obolibrary.org/obo/GO_0032259",
        "http://purl.obolibrary.org/obo/GO_0007267"]) {
        id
        label
        subClassOf {
          id
          label
          subClassOf {
            id
            label
            subClassOf {  # <--- 4th sublevel
              id
              label
            }
          }
        }
      }
    }
    

    I created a new question: Endpoint returned Content-Type: text/html which is not recognized for SELECT queries

    0 讨论(0)
提交回复
热议问题