tom-and-the-toothfairies / pathways

:older_woman: :hospital: :pill: :pill:
https://tomandthetoothfairies.info/
5 stars 0 forks source link

initial attempt at DDI categorization #164

Closed c-brenn closed 7 years ago

c-brenn commented 7 years ago

This adds the basic outline for categorizing DDIs. To do so it requires:

It iterates over the AST, mapping each drug to a list of the PML constructs it is contained in (its ancestors).

For each DDI, it looks at the ancestors of the participating drugs, and gets their intersection. It takes the common ancestor with the highest line number as the closest_common_ancestor.

The type of this ancestor is used to categorize the DDI:

Caveats:

c-brenn commented 7 years ago

The caveats/todos outline some immediate next steps. For now it only adds the type to the ddi - we probably want to include more information, like the line number etc of the construct the ddi occurred in.

c-brenn commented 7 years ago

The only edge case left at this stage is when a drug is mentioned more than once.

c-brenn commented 7 years ago

It can now handle repeated drugs. Implementing this revealed an improvement we could make to the system.

From the last commit message:

We probably want to change the parameters passed to /api/ddis to include the line number of each drug. At the moment repeated drugs can lead to duplicate DDIs because they are identified by the enclosing construct rather than the line numbers of the participating drugs.

See panacea/test/pml/analysis/ddis_test.exs for an example of repeated drugs and the corresponding response.

c-brenn commented 7 years ago

We now cover all of the possible cases.

responses from /api/ddis look like this:

{
  "ddis": [
    {
      "drug_a": "http://purl.obolibrary.org/obo/DINTO_DB00214",
      "drug_b": "http://purl.obolibrary.org/obo/DINTO_DB00519",
      "label": "torasemide/trandolapril DDI",
      "uri": "http://purl.obolibrary.org/obo/DINTO_11031",
      "harmful": false,
      "spacing": 3,
      "category": "sequential",
      "enclosing_constructs": [
        {
          "type": "sequence",
          "line": 6
        }
      ]
    }
  ]
}

enclosing_constructs will be a single element list for sequential, parallel and alternative DDIs. For repeated_alternative DDIs, it will contain two elements:

c-brenn commented 7 years ago

closes #155 #156