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

Docs update #265

Merged
merged 77 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
50ba081
Fix underlines in modeling.rst
kkaris Nov 30, 2023
e092c73
Fix underlines in sources.rst
kkaris Nov 30, 2023
c3f0164
Fix typo
kkaris Nov 30, 2023
0bad74b
Add sources/decapodes to docs
kkaris Nov 30, 2023
9847599
Extend docstrings for terarium client functions
kkaris Nov 30, 2023
a221ce5
Fix title underline
kkaris Nov 30, 2023
628039f
Add docstring to sanity_check_amr
kkaris Nov 30, 2023
cadcc30
Fix ValueError message
kkaris Nov 30, 2023
f760662
Add file header to sources/amr/regnet.py
kkaris Nov 30, 2023
3abec4b
Extend docstring for stock_to_concept in sources/amr/stockflow.py
kkaris Nov 30, 2023
d1bb8d6
Extend docstring for reproduce_ode_semantics
kkaris Nov 30, 2023
ed116a3
Extend docstrings in sources/sbml/api.py
kkaris Dec 1, 2023
18f61e5
Add utility file to sources.rst and add docstrings to methods in sou…
nanglo123 Dec 1, 2023
085956f
Add description to search query text
kkaris Dec 1, 2023
7724b40
Fix URL in description
kkaris Dec 1, 2023
308effd
Fix more links
kkaris Dec 1, 2023
9358ba3
Add description for entity_similarities arg
kkaris Dec 1, 2023
c4d7263
Add example in response to /is_ontological_child
kkaris Dec 1, 2023
236ff08
Delete ignored title
kkaris Dec 1, 2023
39df6dd
Use functools wraps to expose docstrings
kkaris Dec 1, 2023
25264f9
Add file docstring
kkaris Dec 1, 2023
1ff58c6
Add Concept to __all__ in template_model.py
kkaris Dec 1, 2023
4847d3f
Clean up docstring for add_transition()
kkaris Dec 1, 2023
cd2bd3e
Rename argument in wrapper to correspond to docstrings
kkaris Dec 1, 2023
f26950f
Add/extend docstrings for functions in modeling/amr/ops.py
kkaris Dec 1, 2023
ddf9dd7
Copy over docstrings for pure wrapping of functions
kkaris Dec 1, 2023
070ca2b
Update metamodel/decapodes, metamodel/template_model and modeling/acs…
nanglo123 Dec 4, 2023
5255594
Do some fixing of wrapped docstrings in pure wrappers
kkaris Dec 4, 2023
5bd8f80
Explicitly import classes/methods from modules for tests and revert c…
nanglo123 Dec 4, 2023
d2fed22
Fix undeline
kkaris Dec 4, 2023
2299423
Add docstrings to template_model.py, update schema, fix error message…
nanglo123 Dec 4, 2023
cc2edcf
Update template model schema
nanglo123 Dec 4, 2023
ca6fe6f
Extend docstring for query_biomodels in sources/biomodels.py
kkaris Dec 4, 2023
5423565
Replace json typing with generic `JSON`
kkaris Dec 4, 2023
874ca9d
Extend docstrings in modeling/amr/petrinet.py
kkaris Dec 4, 2023
854ea4d
Extend docstrings in modeling/amr/regnet.py
kkaris Dec 4, 2023
3d19174
Remove extra underlines
kkaris Dec 4, 2023
89fed1a
Extend docstrings in mira/modeling/bilayer.py
kkaris Dec 4, 2023
4b2c964
Add docstrings to modeling/__init__.py
kkaris Dec 4, 2023
4e884a0
Extend docstrings for metamodel/io.py
kkaris Dec 4, 2023
17e05f2
Extend docstring of find_models_with_grounding in metamodel/search.py
kkaris Dec 4, 2023
b5c6db9
Add missing return section in io.py
kkaris Dec 4, 2023
90bceb9
Extend docstring for get_json_schema in schema.py
kkaris Dec 4, 2023
2adf331
Extend docstrings in metamodel/comparison.py
kkaris Dec 4, 2023
dcbca4c
Fix warning in docs build
kkaris Dec 4, 2023
6dbd07b
Extend docstrings in metamodel/ops.py
kkaris Dec 5, 2023
6d86894
Extend some docstrings in metamodel/templates.py
kkaris Dec 5, 2023
e86761a
Add more information to method docstrings in sources module
nanglo123 Dec 5, 2023
0ff6735
Add docstring for constructor of Decapode class
nanglo123 Dec 5, 2023
b696c87
add docstring to to_json method of modeling/acsets/stockflow
nanglo123 Dec 5, 2023
46069f2
Update schema and improve docstring punctuation for template_model.py
nanglo123 Dec 5, 2023
6c844fb
Get schema using pydantic 1.10.13
kkaris Dec 5, 2023
7259985
Finish the docstring extensions in templates.py
kkaris Dec 5, 2023
3822397
Update schema.json again
kkaris Dec 5, 2023
e79e97d
Fix file header
kkaris Dec 5, 2023
6495df1
Update file headers in chime.py and mech_bayes.py
kkaris Dec 5, 2023
54a5758
Include examples module in docs
kkaris Dec 5, 2023
b860df1
Link to directory in decapodes example README.md
kkaris Dec 5, 2023
38e1168
Add/extend docstrings for helpers in decapodes_examples.py
kkaris Dec 5, 2023
9a3f120
Add example values to add_transition endpoint
kkaris Dec 5, 2023
271ce57
Add example to AMRComparisonQuery
kkaris Dec 5, 2023
d1637da
Update contact visible in API docs
kkaris Dec 6, 2023
34b264e
Add 4 different notebooks to README
nanglo123 Dec 5, 2023
590df6d
Fix attribute docstrings for each dataclass to follow standard format…
nanglo123 Dec 6, 2023
af9eef2
Change dict to Dict in docstrings for util file in sources
nanglo123 Dec 6, 2023
e0ca2d8
Add spaces between colons for listed parameters in docstrings
nanglo123 Dec 6, 2023
2e667b0
Fix wording of notebook 10 description in README
nanglo123 Dec 6, 2023
9e86543
Add typing to returned JSON
nanglo123 Dec 6, 2023
719eb02
Fix typing for keys for input dictionaries to decapode class
nanglo123 Dec 6, 2023
22fe992
Add spaces between colons and variables in docstrings and rewrite dic…
nanglo123 Dec 6, 2023
d796b75
Include more classes in templates module
kkaris Dec 6, 2023
08f7d88
Exclude main function in biomodels
kkaris Dec 6, 2023
3476814
Remove unused parameter
kkaris Dec 6, 2023
9545b0a
Add more spaces between : in docstring for methods in modeling/acsets…
nanglo123 Dec 6, 2023
666ddd7
Add subheading for mira.modeling
kkaris Dec 6, 2023
0ca3e41
Reflect same method docstring consistency across different modules
nanglo123 Dec 7, 2023
b7ef9f6
Remove type annotation for parameter
nanglo123 Dec 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ MIRA is a framework for representing systems using ontology-grounded **meta-mode
* Using the MIRA Domain Knowledge Graph REST API: [Notebook 5](https://github.com/indralab/mira/blob/main/notebooks/dkg_api.ipynb)
* Using the Model REST API to perform various model operations: [Notebook 6](https://github.com/indralab/mira/blob/main/notebooks/model_api.ipynb)
* Using the web client in python that connects to the REST API: [Notebook 7](https://github.com/indralab/mira/blob/main/notebooks/web_client.ipynb)
* Demonstrating MIRA TemplateModel capabilities [Notebook 8](https://github.com/gyorilab/mira/blob/main/notebooks/Hackathon%20Scenario%201.ipynb)
* Rapid construction of DKGs in ASKEM: [Notebook 9](https://github.com/gyorilab/mira/blob/main/notebooks/Rapid%20construction%20of%20new%20DKGs.ipynb)
* Implement a masking intervention in a compartmental model to simulate
epidemic trajectories under different scenarios:
[Notebook 10](https://github.com/gyorilab/mira/blob/main/notebooks/hackathon_2023.07/scenario1.ipynb)
* Benchmarking the efficacy of DKG groundings on a set of COVID EPI Models:
[Notebook 11](https://github.com/gyorilab/mira/blob/main/notebooks/hackathon_2023.10/Model%20Comparison.ipynb)


[//]: # (Gromet Export fixme: uncomment when gromet works again)

Expand Down
22 changes: 22 additions & 0 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Examples
========

This module contains examples of how to assemble and modify models in MIRA.

Curated Example Models
----------------------

* `sir.py <https://github.com/gyorilab/mira/blob/main/mira/examples/sir.py>`_ - Simple examples of SIR epi models
* `chime.py <https://github.com/gyorilab/mira/blob/main/mira/examples/chime.py>`_ - Simple example of a SVIIvR epi model
* `mech_bayes.py <https://github.com/gyorilab/mira/blob/main/mira/examples/mech_bayes.py>`_ A curated model describing the Mech Bayes model (an SEIRD epi model).
* `nabi2021.py <https://github.com/gyorilab/mira/blob/main/mira/examples/nabi2021.py>`_ A curated model describing the Nabi et al. 2021 model (an 'SEIQAIRDL' epi model). See https://doi.org/10.1016/j.chaos.2021.110689 for more information.
* `jin2022.py <https://github.com/gyorilab/mira/blob/main/mira/examples/jin2022.py>`_ A curated model describing the Jin et al. 2022 model, describing a vaccine-stratified epi model.


Decapode Examples (:py:mod:`mira.examples.decapodes.decapodes_examples`)
------------------------------------------------------------------------
.. automodule:: mira.examples.decapodes.decapodes_examples
:members:
:show-inheritance:

.. mdinclude:: ../../mira/examples/decapodes/decapodes_vs_decaexpr_composite/README.md
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Table of Contents
dkg
metaregistry
terarium_client
examples

Indices and Tables
------------------
Expand Down
8 changes: 7 additions & 1 deletion docs/source/metamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Templates (:py:mod:`mira.metamodel.templates`)
----------------------------------------------
.. automodule:: mira.metamodel.templates
:members:
:exclude-members: Concept, ControlledConversion, NaturalConversion, Provenance, Template, NaturalDegradation, NaturalProduction, GroupedControlledConversion
:exclude-members: Concept
:show-inheritance:

Operations (:py:mod:`mira.metamodel.ops`)
Expand Down Expand Up @@ -58,3 +58,9 @@ Utilities (:py:mod:`mira.metamodel.utils`)
.. automodule:: mira.metamodel.utils
:members:
:show-inheritance:

Decapodes (:py:mod:`mira.metamodel.decapodes`)
----------------------------------------------
.. automodule:: mira.metamodel.decapodes
:members:
:show-inheritance:
15 changes: 9 additions & 6 deletions docs/source/modeling.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
Modeling
========

Modeling module (:py:mod:`mira.modeling`)
-----------------------------------------
.. automodule:: mira.modeling
:members:
:show-inheritance:

ASKEM AMR Petri net generation (:py:mod:`mira.modeling.amr.petrinet`)
-------------------------------------------------------------------------
---------------------------------------------------------------------
.. automodule:: mira.modeling.amr.petrinet
:members:
:show-inheritance:

ASKEM AMR Stockflow generation (:py:mod:`mira.modeling.amr.stockflow`)
-------------------------------------------------------------------------
----------------------------------------------------------------------
.. automodule:: mira.modeling.amr.stockflow
:members:
:show-inheritance:

ASKEM AMR operations (:py:mod:`mira.modeling.amr.ops`)
----------------------------------------------------------
------------------------------------------------------
.. automodule:: mira.modeling.amr.ops
:members:
:show-inheritance:

ASKEM AMR Regulatory net generation (:py:mod:`mira.modeling.amr.regnet`)
----------------------------------------------------------------------------
------------------------------------------------------------------------
.. automodule:: mira.modeling.amr.regnet
:members:
:show-inheritance:
Expand All @@ -41,13 +44,13 @@ ODE model generation and simulation (:py:mod:`mira.modeling.ode`)
:show-inheritance:

ACSets Petri net model generation (:py:mod:`mira.modeling.acsets.petri`)
-----------------------------------------------------------------
------------------------------------------------------------------------
.. automodule:: mira.modeling.acsets.petri
:members:
:show-inheritance:

ACSets Stockflow model generation (:py:mod:`mira.modeling.acsets.stockflow`)
-----------------------------------------------------------------
----------------------------------------------------------------------------
.. automodule:: mira.modeling.acsets.stockflow
:members:
:show-inheritance:
Expand Down
35 changes: 27 additions & 8 deletions docs/source/sources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ Sources of model content
:show-inheritance:

ASKEM AMR (:py:mod:`mira.sources.amr`)
------------------------------------------
--------------------------------------
.. automodule:: mira.sources.amr
:members:
:show-inheritance:

ASKEM AMR Petri nets (:py:mod:`mira.sources.amr.petrinet`)
--------------------------------------------------------------
----------------------------------------------------------
.. automodule:: mira.sources.amr.petrinet
:members:
:show-inheritance:

ASKEM AMR Stockflow (:py:mod:`mira.sources.amr.stockflow`)
--------------------------------------------------------------
----------------------------------------------------------
.. automodule:: mira.sources.amr.stockflow
:members:
:show-inheritance:


ASKEM AMR Regulatory nets (:py:mod:`mira.sources.amr.regnet`)
-----------------------------------------------------------------
-------------------------------------------------------------
.. automodule:: mira.sources.amr.regnet
:members:
:show-inherita
:show-inheritance:

Reconstruct ODE semantics (:py:mod:`mira.sources.amr.flux_span`)
--------------------------------------------------------------------
----------------------------------------------------------------
.. automodule:: mira.sources.amr.flux_span
:members:
:show-inheritance:
Expand All @@ -45,6 +45,7 @@ BioModels client (:py:mod:`mira.sources.biomodels`)
---------------------------------------------------
.. automodule:: mira.sources.biomodels
:members:
:exclude-members: main
:show-inheritance:

Bilayer extraction (:py:mod:`mira.sources.bilayer`)
Expand All @@ -54,13 +55,31 @@ Bilayer extraction (:py:mod:`mira.sources.bilayer`)
:show-inheritance:

ACSets Petri Net extraction (:py:mod:`mira.sources.acsets.petri`)
----------------------------------------------------------
-----------------------------------------------------------------
.. automodule:: mira.sources.acsets.petri
:members:
:show-inheritance:

ACSets Stockflow extraction (:py:mod:`mira.sources.acsets.stockflow`)
----------------------------------------------------------
---------------------------------------------------------------------
.. automodule:: mira.sources.acsets.stockflow
:members:
:show-inheritance:

ACSets Decapodes extraction (:py:mod:`mira.sources.acsets.decapodes.decapodes`)
-------------------------------------------------------------------------------
.. automodule:: mira.sources.acsets.decapodes.decapodes
:members:
:show-inheritance:

ACSets DecaExpr extraction (:py:mod:`mira.sources.acsets.decapodes.deca_expr`)
------------------------------------------------------------------------------
.. automodule:: mira.sources.acsets.decapodes.deca_expr
:members:
:show-inheritance:

Utility Methods (:py:mod:`mira.sources.util`)
---------------------------------------------
.. automodule:: mira.sources.util
:members:
:show-inheritance:
20 changes: 13 additions & 7 deletions mira/dkg/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def get_transitive_closure(
relation_types: List[str] = Query(
...,
description="A list of relation types to get a transitive closure for",
title="This is a title",
example=DKG_REFINER_RELS,
),
):
Expand Down Expand Up @@ -332,11 +331,17 @@ def get_relations(
class IsOntChildResult(BaseModel):
"""Result of a query to /is_ontological_child"""

child_curie: str = Field(..., description="The child CURIE")
parent_curie: str = Field(..., description="The parent CURIE")
is_child: bool = Field(..., description="True if the child CURIE is an "
"ontological child of the parent "
"CURIE")
child_curie: str = Field(...,
example="vo:0001113",
description="The child CURIE")
parent_curie: str = Field(...,
example="obi:0000047",
description="The parent CURIE")
is_child: bool = Field(
...,
description="True if the child CURIE is an ontological child of the "
"parent CURIE"
)


class IsOntChildQuery(BaseModel):
Expand Down Expand Up @@ -379,7 +384,7 @@ def is_ontological_child(
)
def search(
request: Request,
q: str = Query(..., example="infect"),
q: str = Query(..., example="infect", description="The search query"),
limit: int = 25,
offset: int = 0,
prefixes: Optional[str] = Query(
Expand Down Expand Up @@ -463,6 +468,7 @@ def entity_similarity(
request: Request,
sources: List[str] = Body(
...,
description="A list of CURIEs to use as sources",
title="source CURIEs",
examples=[["ido:0000511", "ido:0000592", "ido:0000597", "ido:0000514"]],
),
Expand Down
43 changes: 23 additions & 20 deletions mira/dkg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from fastapi.responses import FileResponse
from pydantic import BaseModel, Field

from mira.examples.sir import sir_bilayer, sir, sir_parameterized_init
from mira.examples.sir import sir_bilayer, sir, sir_parameterized_init, sir_2_city
from mira.metamodel import (
NaturalConversion, Template, ControlledConversion,
stratify, Concept, ModelComparisonGraphdata, TemplateModelDelta,
Expand Down Expand Up @@ -90,6 +90,7 @@
#: PetriNetModel json example
petrinet_json = PetriNetModel(Model(sir)).to_pydantic()
amr_petrinet_json = AMRPetriNetModel(Model(sir)).to_pydantic()
amr_petrinet_json_2_city = AMRPetriNetModel(Model(sir_2_city)).to_pydantic()
amr_petrinet_json_units_values = AMRPetriNetModel(
Model(sir_parameterized_init)
).to_pydantic()
Expand All @@ -101,9 +102,9 @@
tags=["modeling"],
description=dedent("""\
This endpoint consumes a JSON representation of a MIRA template model and converts
it into the ACSet standard for petri nets (implicitly defined `here <https://github.com/\
AlgebraicJulia/py-acsets/blob/main/src/acsets/petris.py>_), which can be used with the
Algebraic Julia ecosystem.
it into the ACSet standard for petri nets (implicitly defined
[here](https://github.com/AlgebraicJulia/py-acsets/blob/main/src/acsets/petris.py)),
which can be used with the Algebraic Julia ecosystem.

Note, this endpoint used to be called "/api/to_petrinet" but has been renamed as the ASKEM
standard now uses that endpoint.
Expand All @@ -123,9 +124,10 @@ def model_to_petri(template_model: Dict[str, Any] = Body(..., example=template_m
tags=["modeling"],
response_model=TemplateModel,
description=dedent("""\
This endpoint consumes a JSON representation of an `ACSet petri net <https://github.com/\
AlgebraicJulia/py-acsets/blob/main/src/acsets/petris.py>_ and produces a JSON representation
of a MIRA template model, which can be directly used with the MIRA ecosystem to do model
This endpoint consumes a JSON representation of an
[ACSet petri net](https://github.com/AlgebraicJulia/py-acsets/blob/main/src/acsets/petris.py)
and produces a JSON representation of a MIRA template model,
which can be directly used with the MIRA ecosystem to do model
extension, stratification, and comparison.

Note, this endpoint used to be called "/api/from_petrinet" but has been renamed as the ASKEM
Expand All @@ -143,9 +145,10 @@ def petri_to_model(petri_json: Dict[str, Any] = Body(..., example=petrinet_json)
tags=["modeling"],
description=dedent("""\
This endpoint consumes a JSON representation of a MIRA template model and converts
it into the `ASKEM standard for petri nets <https://github.com/DARPA-ASKEM/Model-\
Representations/blob/main/petrinet/petrinet_schema.json>_, which can be directly
consumed by other project members that implement this standard.
it into the
[ASKEM standard for petri nets](https://github.com/DARPA-ASKEM/Model-Representations/blob/main/petrinet/petrinet_schema.json),
which can be directly consumed by other project members that
implement this standard.
""".rstrip()),
)
def model_to_amr(template_model: Dict[str, Any] = Body(..., example=template_model_example)):
Expand All @@ -161,10 +164,11 @@ def model_to_amr(template_model: Dict[str, Any] = Body(..., example=template_mod
tags=["modeling"],
response_model=TemplateModel,
description=dedent("""\
This endpoint consumes a JSON representation of an `ASKEM petri net <https://github.\
com/DARPA-ASKEM/Model-Representations/blob/main/petrinet/petrinet_schema.json>_ and
produces a JSON representation of a MIRA template model, which can be directly used
with the MIRA ecosystem to do model extension, stratification, and comparison.
This endpoint consumes a JSON representation of an
[ASKEM petri net](https://github.com/DARPA-ASKEM/Model-Representations/blob/main/petrinet/petrinet_schema.json)
and produces a JSON representation of a MIRA template model,
which can be directly used with the MIRA ecosystem to do model
extension, stratification, and comparison.
""".rstrip()),
)
def amr_to_model(amr_json: Dict[str, Any] = Body(..., example=amr_petrinet_json)):
Expand Down Expand Up @@ -638,9 +642,10 @@ def add_transition(
...,
example={
"template_model": template_model_example,
"subject_concept": "<Add concept example>",
"object_concept": "<Add concept example>",
"parameter": "<Add parameter example>",
"subject_concept": {"name": "infected population",
"identifiers": {"ido": "0000511"}},
"outcome_concept": {"name": "dead",
"identifiers": {"ncit": "C28554"}},
},
)
):
Expand Down Expand Up @@ -695,9 +700,7 @@ def model_comparison(

class AMRComparisonQuery(BaseModel):
petrinet_models: List[Dict[str, Any]] = Field(
..., example=[ # fixme: create more examples
amr_petrinet_json,
]
..., example=[amr_petrinet_json, amr_petrinet_json_2_city]
)


Expand Down
2 changes: 1 addition & 1 deletion mira/dkg/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
),
contact={
"name": "Benjamin M. Gyori",
"email": "[email protected].edu",
"email": "b.gyori@northeastern.edu",
},
license_info={
"name": "BSD-2-Clause license",
Expand Down
2 changes: 1 addition & 1 deletion mira/examples/chime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""CHIME SVIIvR."""
"""CHIME SVIIvR epi model."""

from mira.metamodel import NaturalConversion, ControlledConversion, \
TemplateModel
Expand Down
Loading
Loading