Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTRx API YAML #109

Merged
merged 3 commits into from
Jan 3, 2023
Merged

GTRx API YAML #109

merged 3 commits into from
Jan 3, 2023

Conversation

mnarayan1
Copy link
Contributor

YAML for GTRx API. The API is located here.

Issues

  • I couldn't find an infores for GTRx, so that field is blank for now
  • I couldn't find the Inxight id type in the biolink-model semantic types or the ID-prefix spellings, so I'm not sure if I got the x-bte annotations right. I could use some help with that and testing if the API is working

@andrewsu
Copy link
Contributor

@mnarayan1
Copy link
Contributor Author

I updated the yaml file with infores information.

For testing, I followed the instructions and I'm getting this error when I run a query: Specified SmartAPI ID (123412341234) is either invalid or missing.

Here's what my smartapi_overrides.json file looks like:

{
  "conf": {
    "only_overrides": true
  },
  "apis": {
    "123412341234": "https://raw.githubusercontent.com/mnarayan1/translator-api-registry/gtrx-yaml/gtrx/gtrx.yaml"  
  }
}

Here's the query I tested:

curl --request POST \
  --url http://localhost:3000/v1/smartapi/123412341234/query \
  --header 'Content-Type: application/json' \
  --data '{
    "message": {
        "query_graph": {
            "nodes": {
                "n0": {
                    "categories": ["biolink:Disease"],
                    "ids": ["257220"]
                },
                "n1": {
                    "categories": ["biolink:SmallMolecule"]
                }
            },
            "edges": {
                "e01": {
                    "subject": "n0",
                    "object": "n1"
                }
            }
        }
    }
}'

@colleenXu
Copy link
Collaborator

I'm reviewing this now, so I'll request some edits soon.

I think one reason @mnarayan1 is encountering issues is because the names of the operations (disease-drug and drug-disease) don't match the names of the operations in the $ref under /query.post

      x-bte-kgs-operations:
      - $ref: '#/components/x-bte-kgs-operations/chemical-disease'
      - $ref: '#/components/x-bte-kgs-operations/disease-chemical'

because the yaml parser encounters this error, it probably isn't loading the yaml.

@colleenXu
Copy link
Collaborator

@mnarayan1 @andrewsu On the "INXIGHT" IDs, some questions:

  1. Are these UNII IDs? When I put various IDs into the top search bar of https://drugs.ncats.io/, I see an icon indicating that these are UNII IDs. And for most of these, SRI Node Normalizer can retrieve the correct entity when given this ID with the UNII prefix.
  2. It looks like Inxight IDs were added as the ID namespace ncats.drug, since Andrew's issue on this was closed with this commit
  3. I tried using Inxight/INXIGHT/inxight and ncats.drug as prefixes for the IDs in SRI Node Normalizer. None of those prefixes worked. Noting this issue add INXIGHT Drug IDs  TranslatorSRI/NodeNormalization#135

@colleenXu
Copy link
Collaborator

colleenXu commented Dec 29, 2022

@mnarayan1

I've attached the edited yaml with the following changes:
gtrx.txt

  • updated SmartAPI annotation (this is documentation I did for all the BioThings APIs recently (example). Don't worry about it)
  • x-bte annotation:
    • need a different infores for the api (info.x-translator.infores) compared to the underlying resource (inside each operation). I adjusted the infores for the api and will make the edit to the infores catalog google sheet. EDIT: done, see lines 85-86 of the sheet here if you have access to Translator resources
    • fixed the $ref described above. The operation names are disease-drug/drug-disease.
    • using UNII as the ID prefix rather than ncats.drug or INXIGHT. Discussed here.
    • all the operations here need supportBatch: true. In general, queries that use the /query.post endpoint can handle batch-queries (> 1 ID at a time).
    • predicates need swapping (disease treated_by drug, drug treats disease)
    • parameter fields:
      • MUST use commas between diff fields in parameters
      • MUST add all fields that will be referenced in the response-mapping section
      • can add fields that exist in only some records / seem useful to users (these will go into the edge's "attributes" in the TRAPI response). For an association-based record structure like this, we can add fields from any part of the record to the parameter-fields/response-mapping.
      • so I added a bunch of fields and took some notes on what I was doing (what I excluded, what I used to name stuff in the response-mapping)
  • examples for testing

notes on testing:

  • contents of my bte-trapi smartapi_overrides.json (I'm using a local copy of the Smartapi yaml)
{
  "conf": {
    "only_overrides": true
  },
  "apis": {
    "gtrx": "file:///Users/colleenxu/Desktop/translator-api-registry/gtrx/gtrx.yaml"
    }
}
  • I saved my local copy of the yaml. Then I run npm run compile and API_OVERRIDE=true INSTANCE_ENV=dev npm run smartapi_sync --workspace='@biothings-explorer/bte-trapi' to set up using this local copy of the yaml. Then I run npm start to start up BTE.
  • Then I post a query to http://localhost:3000/v1/smartapi/gtrx/query. Inside the request body (TRAPI query), we must use prefixed-IDs (aka curies)...
example queries
{
    "message": {
        "query_graph": {
            "edges": {
                "e01": {
                    "subject": "n0",
                    "object": "n1"
                }
            },
            "nodes": {
                "n0": {
                    "ids": ["OMIM:250250"],
                    "categories": ["biolink:Disease"],
                    "name": "CARTILAGE-HAIR HYPOPLASIA"
                },
                "n1": {
                    "categories": ["biolink:SmallMolecule"]
                }
            }
        }
    }
}

and

{
    "message": {
        "query_graph": {
            "edges": {
                "e01": {
                    "subject": "n0",
                    "object": "n1"
                }
            },
            "nodes": {
                "n0": {
                    "ids": ["UNII:F64QU97QCR"],
                    "categories": ["biolink:SmallMolecule"],
                    "name": "Dantrolene"
                },
                "n1": {
                    "categories": ["biolink:Disease"]
                }
            }
        }
    }
}

@mnarayan1
Copy link
Contributor Author

@colleenXu Thanks for your help! I updated my branch with your changes.

I tried testing with the updated yaml and queries, and I'm getting this error:

{
    "error": "Your input query graph is invalid",
    "more_info": "Your Input Query Graph is invalid."
}

I'm guessing the yaml file loaded correctly this time, but there are some issues with how I'm testing the queries themselves? This is the query I ran this time:

curl --request POST \
  --url http://localhost:3000/v1/smartapi/gtrx/query \
  --header 'Content-Type: application/json' \
  --data '{
    "message": {
        "query_graph": {
            "edges": {
                "e01": {
                    "subject": "n0",
                    "object": "n1"
                }
            },
            "nodes": {
                "n0": {
                    "ids": ["UNII:F64QU97QCR"],
                    "categories": ["biolink:SmallMolecule"],
                    "name": "Dantrolene"
                },
                "n1": {
                    "categories": ["biolink:Disease"]
                }
            }
        }
    }
}'

@colleenXu
Copy link
Collaborator

@mnarayan1 Thanks for making these changes! I'm going to move forward and merge this PR, then do the next steps of incorporating it into BTE.

I'm not sure why you're getting this vague error. Perhaps we could do a quick zoom meeting with screen-share to figure this out?

@colleenXu colleenXu merged commit bfe0ebb into NCATS-Tangerine:master Jan 3, 2023
@colleenXu colleenXu mentioned this pull request Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants