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

[BUG]: AMR ingest error caused by SKEMA bug #396

Open
liunelson opened this issue Nov 12, 2024 · 5 comments
Open

[BUG]: AMR ingest error caused by SKEMA bug #396

liunelson opened this issue Nov 12, 2024 · 5 comments

Comments

@liunelson
Copy link

We have this source model from a paper:
image

It has several natural birth and death processes. The SKEMA model-from-equations tool only partially supports such processes and produces this AMR JSON:
pretty.json

Note that the natural birth process was ignored by SKEMA and the death processes are represented for example as:

            {
                "id": "s0",
                "input": [
                    "S",
                    "S"
                ],
                "output": null,
                "name": null,
                "description": "Transition representing the natural death of susceptible individuals.",
                "expression": null,
                "grounding": {
                    "identifiers": {
                        "ncit": "C28554"
                    },
                    "context": {},
                    "modifiers": {}
                },
                "properties": null
            },

MIRA's sources.amr.petrinet throws an error from this AMR JSON because "output" should be [] and not null. Replacing all the "output": null with "output": [] allows MIRA to produce a valid template model.

The AMR schema does specify that output needs to be an array of strings.

Should MIRA cover for this bug in SKEMA?

@bgyori
Copy link
Member

bgyori commented Nov 12, 2024

Yes, we can handle the invalid value here. @nanglo123 could you check?

@liunelson
Copy link
Author

A secondary issue (SKEMA bug?) is that MIRA interprets this AMR and duplicates this transition into 2 NaturalDegradation templates. Probably done by iterating over input: [S, S]. Is this logic intended?

@bgyori
Copy link
Member

bgyori commented Nov 12, 2024

The structure

                "input": [
                    "S",
                    "S"
                ],
                "output": null,

is not exactly what we would consider a Natural Degradation of S, which would be

                "input": [
                    "S",
                ],
                "output": null,

which is probably the reason for the unexpected result.

@liunelson
Copy link
Author

Totally. SKEMA seems to create these ["S", "S"] type of structure (and other unexpected behaviour) when it receives LaTeX equations with no matching terms (representing production/degradation processes).

Currently, MIRA does accept the above structure when I correct the output to []. It just creates two natural degradation templates from it. This creates a minor bug in Terarium where the model page shows Transition (2) (because it counts the transitions in the model AMR) but has an empty table (because it converts the AMR to a MIRA template model and counts the templates (?)).

@liunelson
Copy link
Author

If I type in the following set of equations:

\frac{d S}{d t} = -\gamma S - \mu R
\frac{d R}{d t} = \gamma S

SKEMA returns this AMR:
Test 2.json

    "transitions": [
      {
        "id": "s0",
        "input": [
          "S",
          "R"
        ]
      },
      {
        "id": "t0",
        "input": [
          "S"
        ],
        "output": [
          "R"
        ]
      }
    ]

When I have MIRA ingest this model, that one -\mu R term is turned into two natural degradation templates. MIRA then produces this AMR that is quite different from the original, questionable AMR:
Test 2 - mira.json

    "transitions": [
      {
        "id": "s0",
        "input": [
          "S"
        ],
        "output": [],
        "properties": {
          "name": "s0"
        }
      },
      {
        "id": "s0",
        "input": [
          "R"
        ],
        "output": [],
        "properties": {
          "name": "s0"
        }
      },
      {
        "id": "t0",
        "input": [
          "S"
        ],
        "output": [
          "R"
        ],
        "properties": {
          "name": "t0"
        }
      }
    ]

These weird edge cases (all involving AMR files that are inconsistent with the AMR schema) are all due to bugs in SKEMA, giving us all the more reason to replace it sooner, rather than later with the eventual LaTeX-SymPy-MMT-AMR pipeline.

I think covering the initial issue of "output": null vs. "output": [] should be sufficient for now since it at least allows the Create Model from Equations operator to function without error.

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

No branches or pull requests

2 participants