├── .github └── workflows │ ├── documentation.yaml │ ├── publish_to_pypi.yaml │ ├── publish_to_test_pypi.yaml │ └── tester.yaml ├── .gitignore ├── .idea ├── inspectionProfiles │ └── Project_Default.xml └── vcs.xml ├── .travis.yml ├── MANIFEST.in ├── README.md ├── docs ├── cite.md ├── document.md ├── dosdp_schema.md ├── index.md └── validator.md ├── license.md ├── mkdocs.yml ├── pom.xml ├── pyproject.toml ├── requirements.txt ├── setup.py └── src ├── README.md ├── __init__.py ├── attic ├── ID_tools.py ├── abstract_pattern_runner.py ├── brain_io_wrapper.py ├── examples │ ├── README.md │ ├── sodium_outer_mito_mem.json │ └── term_addition_runner.py ├── lib │ └── README.md ├── ms2Markdown.py ├── pattern.py ├── patterns │ ├── adenine_import_across_plasma_membrane.md │ ├── anchored_membrane_component.json │ ├── anchored_membrane_component.md │ ├── anchored_membrane_component.yaml │ ├── bounding_membrane_of_organelle.json │ ├── bounding_membrane_of_organelle.md │ ├── bounding_membrane_of_organelle.yaml │ ├── envenomation.json │ ├── envenomation.md │ ├── envenomation.yaml │ ├── export_across_membrane.json │ ├── export_across_membrane.md │ ├── export_across_membrane.yaml │ ├── expression_pattern.json │ ├── expression_pattern.md │ ├── expression_pattern.yaml │ ├── extrinsic_membrane_component.json │ ├── extrinsic_membrane_component.md │ ├── extrinsic_membrane_component.yaml │ ├── generic_go_pattern_outline.yaml │ ├── import_across_membrane.json │ ├── import_across_membrane.md │ ├── import_across_membrane.yaml │ ├── import_across_plasma_membrane.json │ ├── import_across_plasma_membrane.md │ ├── import_across_plasma_membrane.yaml │ ├── import_into_cell.json │ ├── import_into_cell.md │ ├── import_into_cell.yaml │ ├── integral_membrane_component.json │ ├── integral_membrane_component.md │ ├── integral_membrane_component.yaml │ ├── intrinsic_membrane_component.json │ ├── intrinsic_membrane_component.md │ ├── intrinsic_membrane_component.yaml │ ├── membrane_receptor_activity_draft.yaml │ ├── membrane_spanning_component.json │ ├── membrane_spanning_component.md │ ├── membrane_spanning_component.yaml │ ├── transmembrane_import_into_cell.json │ ├── transmembrane_import_into_cell.md │ ├── transmembrane_import_into_cell.yaml │ └── var_spec_examples │ │ └── glucose_import_into_cell.yaml └── spec │ ├── DOSDP_schema_core.yaml │ ├── DOSDP_schema_full.json │ ├── DOSDP_schema_full.yaml │ ├── OBO_import.yml │ ├── README.md │ ├── attic │ ├── DOSDP_OBO_fields.json │ └── DOSDP_OBO_fields.yaml │ ├── dosdp_tsv_schema.md │ ├── draft │ ├── DOSDP_schema_OBO.yaml │ └── DOSDP_schema_core.yaml │ ├── test │ ├── cellPartOfAnatomicalEntity.yaml │ └── test_positive.yaml │ └── test_schema.py ├── dosdp ├── __init__.py ├── __main__.py ├── document │ ├── __init__.py │ ├── document.py │ ├── pattern │ │ ├── __init__.py │ │ ├── patterns_create_docs.py │ │ └── patterns_create_overview.py │ └── schema │ │ ├── __init__.py │ │ └── schema_create_docs.py └── validator.py ├── json_yaml_tools.py ├── schema ├── __init__.py ├── dosdp_schema.yaml ├── dosdp_schema_doc.ini ├── schema_validator.py └── test │ ├── __init__.py │ ├── generic_test │ ├── __init__.py │ ├── document_test.py │ ├── schema_test.py │ ├── test_suite.py │ └── validator_test.py │ ├── negative_test_set │ ├── __init__.py │ ├── acute_negative.yaml │ ├── axiom_multi_clause_nesting.yaml │ ├── axiom_separator.yaml │ ├── dummy.yaml │ ├── generic_go_pattern_outline.yaml │ ├── membrane_receptor_activity_draft.yaml │ ├── multi_clause_with_multi_list.yaml │ ├── multi_clause_with_multi_list2.yaml │ ├── not_schema_compliant.yaml │ ├── quotes_miss_match.yaml │ ├── undeclared_annotation_prop.yaml │ ├── undeclared_class.yaml │ ├── undeclared_relation.yaml │ ├── undeclared_relation_multi_clause.yaml │ ├── undeclared_var.yaml │ └── wrong_indentation.yaml │ └── positive_test_set │ ├── __init__.py │ ├── export_across_membrane.yaml │ └── patterns │ ├── abnormallyHyperplasticAnatomicalEntity.yaml │ ├── acute.yaml │ ├── adenine_import_across_plasma_membrane.md │ ├── anchored_membrane_component.json │ ├── anchored_membrane_component.md │ ├── anchored_membrane_component.yaml │ ├── bounding_membrane_of_organelle.yaml │ ├── data │ ├── acute.yaml │ ├── acute2.yaml │ ├── dummy.yaml │ ├── generated │ │ └── dummy.text │ └── sample_data │ │ └── acute.tsv │ ├── envenomation.yaml │ ├── export_across_membrane.yaml │ ├── expression_pattern.yaml │ ├── extrinsic_membrane_component.yaml │ ├── import_across_membrane.yaml │ ├── import_across_plasma_membrane.yaml │ ├── import_into_cell.yaml │ ├── integral_membrane_component.yaml │ ├── intrinsic_membrane_component.yaml │ ├── membrane_spanning_component.yaml │ ├── multi_clause_schema.yaml │ └── transmembrane_import_into_cell.yaml ├── simple_pattern_tester.py └── yaml2json_runner.py /.github/workflows/documentation.yaml: -------------------------------------------------------------------------------- 1 | name: Publish mkdocs documentation 2 | 3 | on: 4 | # Allows you to run this workflow manually from the Actions tab 5 | workflow_dispatch: 6 | release: 7 | types: [created] 8 | # push: 9 | # branches: 10 | # - main 11 | # paths: 12 | # - 'README.md' 13 | # - 'docs/**' 14 | # For testing purpose, delete this trigger afterwards 15 | push: 16 | paths: 17 | - '.github/workflows/documentation.yaml' 18 | 19 | jobs: 20 | build-and-publish: 21 | name: Publish mkdocs documentation 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v2 25 | - name: Set up Python 3.8 26 | uses: actions/setup-python@v2 27 | with: 28 | python-version: 3.8 29 | - run: pip install mkdocs 30 | - name: Copy the Readme 31 | run: | 32 | cp "./README.md" "./docs/overview.md" 33 | # change relative paths to docs folder in the README '(docs/xx' -> '(xx' 34 | - name: Update relative paths 35 | run: | 36 | sed -i 's/(docs\//(/g' ./docs/overview.md 37 | # - name: Commit documentation 38 | # run: | 39 | # git config user.email "41898282+github-actions[bot]@users.noreply.github.com" 40 | # git config user.name "github-actions[bot]" 41 | # git add ./docs/overview.md 42 | # git commit -m "Automatic documentation update." || echo "No changes to commit" 43 | # git push || echo "No changes to push" 44 | - run: mkdocs gh-deploy --force -------------------------------------------------------------------------------- /.github/workflows/publish_to_pypi.yaml: -------------------------------------------------------------------------------- 1 | name: Publish to PyPI 2 | 3 | on: 4 | # Allows you to run this workflow manually from the Actions tab 5 | workflow_dispatch: 6 | release: 7 | types: [created] 8 | # For testing purpose, delete this trigger afterwards 9 | # push: 10 | # paths: 11 | # - '.github/workflows/publish_to_pypi.yaml' 12 | 13 | jobs: 14 | build-and-publish: 15 | name: Publish Python distributions to PyPI 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up Python 3.8 20 | uses: actions/setup-python@v2 21 | with: 22 | python-version: 3.8 23 | - name: Install Deployment Tools 24 | run: | 25 | python -m pip install --upgrade pip 26 | pip install setuptools wheel twine 27 | - name: Install Project Dependencies 28 | run: | 29 | pip install -r requirements.txt 30 | - name: Auto-Generate schema documentation 31 | run: PYTHONPATH=./src:$PYTHONPATH python -m dosdp document --schema -o ./src/schema/ 32 | - name: Package Distribution 33 | run: >- 34 | python 35 | setup.py 36 | sdist 37 | bdist_wheel 38 | - name: Deploy Package 39 | env: 40 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 41 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 42 | run: | 43 | twine upload dist/* -------------------------------------------------------------------------------- /.github/workflows/publish_to_test_pypi.yaml: -------------------------------------------------------------------------------- 1 | name: Publish to test PyPI 2 | 3 | # Expect this action to be triggered manually before 4 | 5 | on: 6 | # Allows you to run this workflow manually from the Actions tab 7 | workflow_dispatch: 8 | 9 | jobs: 10 | build-and-publish: 11 | name: Publish Python distributions to PyPI 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Set up Python 3.8 16 | uses: actions/setup-python@v2 17 | with: 18 | python-version: 3.8 19 | - name: Install Deployment Tools 20 | run: | 21 | python -m pip install --upgrade pip 22 | pip install setuptools wheel twine 23 | - name: Install Project Dependencies 24 | run: | 25 | pip install -r requirements.txt 26 | - name: Auto-Generate schema documentation 27 | run: PYTHONPATH=./src:$PYTHONPATH python -m dosdp document --schema -o ./src/schema/ 28 | - name: Package Distribution 29 | run: >- 30 | python 31 | setup.py 32 | sdist 33 | bdist_wheel 34 | - name: Deploy Package 35 | env: 36 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 37 | TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }} 38 | run: | 39 | twine upload --repository-url https://test.pypi.org/legacy/ dist/* -------------------------------------------------------------------------------- /.github/workflows/tester.yaml: -------------------------------------------------------------------------------- 1 | name: Run Tests 2 | 3 | # Controls when the action will run. 4 | on: 5 | # Triggers the workflow on push or pull request events but only for the master branch 6 | push: 7 | branches: [ master ] 8 | pull_request: 9 | branches: [ master ] 10 | 11 | # Allows you to run this workflow manually from the Actions tab 12 | workflow_dispatch: 13 | 14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 15 | jobs: 16 | build: 17 | # The type of runner that the job will run on 18 | runs-on: ubuntu-latest 19 | 20 | # Steps represent a sequence of tasks that will be executed as part of the job 21 | steps: 22 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 23 | - uses: actions/checkout@v2 24 | - name: install dependencies 25 | run: | 26 | python -m pip install --upgrade pip 27 | pip install -r requirements.txt 28 | - name: Validate DOSDP Schema 29 | run: python ./src/schema/schema_validator.py 30 | - name: Run Test 31 | run: PYTHONPATH=./src:$PYTHONPATH python -m unittest discover -s src -p '*_test.py' 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | .idea 3 | **/.DS_Store 4 | 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # specify python as the language 2 | language: python 3 | 4 | # python versions to be used for testing 5 | python: 6 | - "3.5" 7 | 8 | install: 9 | - pip install -r requirements.txt 10 | 11 | script: 12 | - cd spec 13 | - python test_schema.py 14 | - cd ../src 15 | - python simple_pattern_tester.py ../spec/test 16 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include src/schema/*.yaml src/schema/*.ini src/schema/*.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/INCATools/dead_simple_owl_design_patterns.svg?branch=master)](https://travis-ci.org/INCATools/dead_simple_owl_design_patterns) 2 | 3 | # Dead simple owl design pattern (DOS-DP) exchange format 4 | 5 | ## For details please see: 6 | 7 | [Dead Simple OWL Design Patterns](https://jbiomedsem.biomedcentral.com/articles/10.1186/s13326-017-0126-0) 8 | David Osumi-Sutherland, Melanie Courtot, James P. Balhoff and Christopher Mungall 9 | Journal of Biomedical Semantics 2017 8:18 DOI:10.1186/s13326-017-0126-0 10 | 11 | 12 | ## Motivation 13 | 14 | The job of editing the GO and many other OBOish OWL ontologies increasingly involves specifying OWL design patterns. We need a simple, light-weight standard for specifying these design patterns that can then be used for generating documentation, generating new terms and retrofitting old ones. The solution must be readable and editable by anyone with a basic knowledge of OWL and the ability to read manchester syntax. It must also be easy to use programatically without the need for custom parsers - i.e. it should follow some existing data exchange standard. 15 | 16 | Human readability and editability requires that Manchester syntax be written using labels, but sustainability and consistency checking requires that the pattern record IDs. 17 | 18 | ## Approach 19 | 20 | * Patterns are specified in the subset of YAML that can be converted to JSON. 21 | * JSON format is the ideal exchange format for programatic consumption: It is already javascript; Standard libraries are available to convert it into datastructures in many languages;Developers are typically experienced at consuming it. 22 | * *But* YAML is much easier than JSON for humans to edit (it can be difficult for human editors to keep curly braces and quotes balanced and to add commas correctly in JSON). YAML also has the great advantage over JSON of allowing comments to be embedded. [Conversion between YAML and JSON is trivial](http://yamltojson.com/) 23 | 24 | * All patterns contain dictionaries (hash lookups) that can be used to lookup up OWL shortform IDs from labels. OWL ShortFormIDs are assumed to be sufficient for entity resolution during usage of the pattern. Labels are assumed to be sufficient for entity resolution _within_ a pattern. 25 | 26 | * Variable interpolation into Manchester syntax and text is specified using [printf format strings](https://en.wikipedia.org/wiki/Printf_format_string). Variable names are stored in associated lists. 27 | 28 | * Variables are specified in a dictionary with variable name as key and value as range specified as a Manchester syntax expresssion. 29 | 30 | ## DOSDP Specification: 31 | 32 | [JSON schema specification in YAML](https://github.com/INCATools/dead_simple_owl_design_patterns/blob/master/src/schema/dosdp_schema.yaml). 33 | 34 | The same specification [rendered in mardown](docs/dosdp_schema.md), with references resolved. This is generated from the original spec using the `dosdp document` command (see below for details). 35 | 36 | ## Setup 37 | 38 | ``` 39 | pip install dosdp 40 | ``` 41 | 42 | See https://pypi.org/project/dosdp/ 43 | 44 | ## Validator spec 45 | 46 | See [validator documentation](docs/validator.md) 47 | 48 | ## Documentation generation spec 49 | 50 | See [documentation_generation](docs/document.md) 51 | 52 | ## Implementation 53 | 54 | The aim of this project is to specify a simple design pattern system that can easily be consumed, whatever your code base. 55 | This repository includes a simple Python validator (src/simple_pattern_tester.py). 56 | 57 | For implementation, we recommend [dosdp-tools](https://github.com/INCATools/dosdp-tools). 58 | 59 | ## Uses 60 | 61 | * [ENVO](http://obofoundry.org/ontology/envo.html): envo [patterns/](https://github.com/EnvironmentOntology/envo/tree/master/src/envo/patterns) 62 | * [OBA](http://obofoundry.org/ontology/oba.html): oba [patterns/](https://github.com/obophenotype/bio-attribute-ontology/tree/master/src/ontology/patterns) 63 | * draft environmental conditions ontology: ecto [patterns/](https://github.com/cmungall/environmental-conditions/tree/master/src/patterns) 64 | * [Uberon](http://obofoundry.org/ontology/uberon.html): uberon [patterns/](https://github.com/obophenotype/uberon/tree/master/patterns) 65 | * [uPheno](https://github.com/obophenotype/upheno) 66 | * [Mondo](http://www.obofoundry.org/ontology/mondo.html) 67 | -------------------------------------------------------------------------------- /docs/cite.md: -------------------------------------------------------------------------------- 1 | # How to cite DOS-DP 2 | 3 | Please cite [Dead Simple OWL Design Patterns](https://jbiomedsem.biomedcentral.com/articles/10.1186/s13326-017-0126-0) 4 | 5 | David Osumi-Sutherland, Melanie Courtot, James P. Balhoff and Christopher Mungall 6 | Journal of Biomedical Semantics 2017 8:18 DOI:10.1186/s13326-017-0126-0 -------------------------------------------------------------------------------- /docs/document.md: -------------------------------------------------------------------------------- 1 | # DOSDP Documentation Generation 2 | 3 | DODSP provides automatic documentation generation service for both pattern files and the dosdp schema itself. 4 | 5 | ### Pattern Documentation 6 | 7 | DOSDP provides several CLI interfaces for automatic pattern generation. 8 | 9 | ```sh 10 | $ dosdp document -i pattern.yaml 11 | $ dosdp document -i pattern.yaml -o pattern.md 12 | $ dosdp document -i pattern.yaml -o 'output folder' 13 | 14 | $ dosdp document -i 'pattern folder' -o 'output folder' 15 | 16 | $ dosdp document -i pattern.yaml -d 'sample data folder' -o pattern.md 17 | $ dosdp document -i 'pattern folder' -d 'sample data folder' -o 'output folder' 18 | ``` 19 | 20 | A [sample dosdp pattern](https://github.com/obophenotype/cell-ontology/blob/master/src/patterns/dosdp-patterns/cellBearerOfQuality.yaml) and its [auto generated documentation](https://github.com/obophenotype/cell-ontology/blob/master/docs/patterns/cellBearerOfQuality.md) can be seen in the cell ontology. 21 | 22 | An additional [overview document](https://github.com/obophenotype/cell-ontology/blob/master/docs/patterns/overview.md) generated to present a summary of the patterns, if a directory is provided as input. 23 | 24 | If the optional `sample data folder` parameter is provided, a [data preview](https://github.com/obophenotype/cell-ontology/blob/master/docs/patterns/overview.md#data-preview) is generated in both the pattern and overview documents. To achieve this, the pattern file name and the data file must match. 25 | 26 | ### DOSDP Schema Documentation 27 | 28 | With each version release, DOSDP generates and publishes a schema documentation. 29 | 30 | ```sh 31 | $ dosdp document --schema 32 | $ dosdp document --schema -o 33 | ``` 34 | 35 | Generates md formatted documentation for the [schema](https://github.com/INCATools/dead_simple_owl_design_patterns/tree/master/src/schema/dosdp_schema.md) exists in the dosdp package. An output document location can be optionally identified to specify documentation location or current folder (os current working directory) is used by default. -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Dead simple owl design pattern (DOS-DP) Documentation 2 | 3 | For project homepage visit [dos-dp](https://github.com/INCATools/dead_simple_owl_design_patterns). 4 | 5 | - [Overview](overview.md) 6 | - [Specification](dosdp_schema.md) 7 | - [Schema _(raw)_](https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/master/src/schema/dosdp_schema.yaml) 8 | - [Validation](validator.md) 9 | - [Documentation](document.md) 10 | 11 | -------------------------------------------------------------------------------- /docs/validator.md: -------------------------------------------------------------------------------- 1 | # DOSDP Validator 2 | 3 | DOSDP provides a validation interface for both CLI and Python. 4 | 5 | ### From the CLI 6 | 7 | ```sh 8 | $ dosdp validate -i 9 | ``` 10 | 11 | ### From Python 12 | 13 | ```python 14 | from dosdp import validator 15 | 16 | validator.validate("test.yaml") 17 | ``` 18 | 19 | DOSDP validates given argument if it is a yaml/yml file. If argument is a folder, validates all pattern files located in the given directory. 20 | 21 | ### Validation Steps 22 | 23 | 1. Test converstion of YAML to JSON 24 | 2. Validate against JSON schema (e.g. see [dosdp_schema.md](https://github.com/INCATools/dead_simple_owl_design_patterns/tree/master/src/schema/dosdp_schema.md) and [dosdp_schema.yaml](https://github.com/INCATools/dead_simple_owl_design_patterns/tree/master/src/schema/dosdp_schema.yaml)) 25 | 3. Test that all var names in printf statements are valid (declared) for the pattern 26 | 4. Checks quoted names in the printf_owl field correspond to dictionary entries in the pattern. -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Dead simple owl design pattern (DOS-DP) 2 | theme: readthedocs 3 | nav: 4 | - Getting started: index.md 5 | - Cite: cite.md 6 | - How-to guides: 7 | - Overview: overview.md 8 | - Schema Specification: dosdp_schema.md 9 | - Documentation Generation: document.md 10 | - Validation: validator.md 11 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | foo.bar 5 | jython-test 6 | 0.0.1-SNAPSHOT 7 | 8 | 9 | UTF-8 10 | UTF-8 11 | 0.2.2-SNAPSHOT 12 | 13 | 14 | 15 | 16 | 17 | 18 | org.apache.maven.plugins 19 | maven-compiler-plugin 20 | 2.5.1 21 | 22 | 1.7 23 | 1.7 24 | 25 | 26 | 27 | maven-dependency-plugin 28 | 29 | 30 | package 31 | 32 | copy-dependencies 33 | 34 | 35 | ${project.basedir}/lib 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | BerkeleyBOP 47 | Berkeley BOP maven repository 48 | http://code.berkeleybop.org/maven/repository/ 49 | 50 | true 51 | 52 | 53 | 54 | 55 | BerkeleyBOPSnapshot 56 | http://code.berkeleybop.org/maven/snapshot-repository/ 57 | 58 | true 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.bbop 66 | OWLTools-Core 67 | ${owltools.version} 68 | 69 | 70 | uk.ac.ebi.brain 71 | Brain 72 | 1.5.1 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=42", 4 | "wheel" 5 | ] 6 | build-backend = "setuptools.build_meta" -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | PyYAML 2 | jsonschema 3 | requests 4 | jsonpath_rw 5 | ruamel.yaml 6 | jsonschema2md 7 | pandas 8 | tabulate 9 | 10 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from setuptools import setup 3 | 4 | READTHEDOCS = "(http://incatools.github.io/dead_simple_owl_design_patterns/" 5 | relative_link_mapping = {"(docs/dosdp_schema.md)": READTHEDOCS + "dosdp_schema/)", 6 | "(docs/validator.md)": READTHEDOCS + "validator/)", 7 | "(docs/document.md)": READTHEDOCS + "document/)"} 8 | 9 | 10 | def update_relative_links(readme_content): 11 | """ 12 | Relative links are broken in the pypi home page. So replace them with read the docs absolute links. 13 | """ 14 | for key, value in relative_link_mapping.items(): 15 | readme_content = readme_content.replace(key, value) 16 | return readme_content 17 | 18 | 19 | # The directory containing this file 20 | HERE = pathlib.Path(__file__).parent 21 | 22 | # The text of the README file 23 | README = (HERE / "README.md").read_text() 24 | README = update_relative_links(README) 25 | 26 | # This call to setup() does all the work 27 | setup( 28 | name="dosdp", 29 | version="0.1.10.dev1", 30 | description="The aim of this project is to specify a simple OWL design pattern system that can easily be consumed, whatever your code base.", 31 | long_description=README, 32 | long_description_content_type="text/markdown", 33 | url="https://github.com/INCATools/dead_simple_owl_design_patterns", 34 | author="INCATools", 35 | license="GPL-3.0 License", 36 | classifiers=[ 37 | "Programming Language :: Python :: 3", 38 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", 39 | "Operating System :: OS Independent", 40 | ], 41 | package_dir={'': 'src'}, 42 | packages=["dosdp", "schema", "dosdp.document", "dosdp.document.pattern", "dosdp.document.schema"], 43 | include_package_data=True, 44 | install_requires=["PyYAML", "jsonschema", "requests", "jsonpath_rw", "ruamel.yaml", "jsonschema2md", "pandas"], 45 | entry_points={ 46 | "console_scripts": [ 47 | "dosdp=dosdp.__main__:main", 48 | ] 49 | }, 50 | ) 51 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # Dead simple OWL design patterns 2 | 3 | Dead simple OWL design patterns (DOSDPs) provide a way to specify templates for generation of OWL classes and related axioms using YAML. 4 | 5 | * Details: [Osumi-Sutherland et al, 2017](https://jbiomedsem.biomedcentral.com/articles/10.1186/s13326-017-0126-0) JBMS 8:18; DOI:10.1186/s13326-017-0126-0. 6 | 7 | * Specification (JSON schema written in YAML)[spec/DOSDP_schema_full.yaml] 8 | 9 | * Test your YAML files for schema compliance with [simple_pattern_tester.py](/src/simple_pattern_tester.py) 10 | 11 | * Generate terms from DOSDP YAML templates and TSVs using [INCATools/dosdp-tools](https://github.com/INCATools/dosdp-tools). 12 | 13 | 14 | This work was funded by the Gene Ontology Consortium P41 grant from the National Human Genome Research Institute (NHGRI) [grant 5U41HG002273- 14] and by BD2K [grant U01 HG009453] and with the support of the Director, Office of Science, Office of Basic Energy Sciences, of the US Department of Energy (DE-AC02- 05CH11231). 15 | -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/__init__.py -------------------------------------------------------------------------------- /src/attic/ID_tools.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env jython 2 | import warnings 3 | import uuid 4 | 5 | class ontId: 6 | """Generate an OBOish OWL shortform ID given specifications of idp, accession length and an id_name dict.""" 7 | def __str__(self): 8 | return "IDP: %s; accession length: %d; Separator: '%s'; number of IDs in dict: %d" % (self.idp, self.length, self.sep, len(self.id_name.keys())) 9 | def __init__(self, idp, length, id_name): 10 | """ARG1: ID prefix (string), ARG2, length of numeric portion ID, ARG3 an id:name hash""" 11 | # if type(length) not integer # How to properly add type checks here? 12 | # if type(id_name) not dict # How to properly add type checks here? 13 | self.idp = idp 14 | self.length = length 15 | self.id_name = id_name 16 | self.sep = '_' 17 | self.accession = 1 # default starting accession for init. 18 | self.name_id = dict((v,k) for k, v in id_name.iteritems()) 19 | def gen_id(self, name): 20 | return self._gen_id(name) 21 | def _gen_id(self, name): 22 | k = self._gen_key () 23 | while k in self.id_name: 24 | self.accession += 1 25 | k = self._gen_key() 26 | self.id_name[k]=name 27 | self.name_id[name] = k 28 | return k # 29 | def _gen_key(self): 30 | dl = len(str(self.accession)) # coerce int to string. 31 | k = self.idp+self.sep+(self.length - dl)*'0'+str(self.accession) 32 | return k 33 | 34 | class ontId_owl(ontId): 35 | def __init__(self, idp, length, ont, start, end): 36 | """Generate an OBOish OWL shortform ID given specifications of: 37 | idp; accession length; Brain object and the start & end of an ID range. 38 | Assumes all existing IDs are used for *classes* in Ontology.""" 39 | self.idp = idp 40 | self.ont = ont 41 | self.sep = '_' 42 | self._gen_lookups() 43 | self.accession = start 44 | self.end = end 45 | self.length = length 46 | 47 | def _gen_lookups(self): 48 | self.id_name = {} 49 | self.name_id = {} 50 | clist = self.ont.getSubClasses("Thing", 0) 51 | for c in clist: 52 | n = uuid.uuid4() 53 | try: 54 | n = self.ont.getLabel(c) # Isolating this lookup in case names missing! Maybe better to not bother making lookup. 55 | except: 56 | pass 57 | self.id_name[c]=n 58 | self.name_id[n]=c 59 | 60 | def gen_id(self, name): 61 | newid = self._gen_id(name) 62 | if self.accession > self.end: 63 | warnings.warn("Generated ID is past end of range!") # Should raise an exception here! 64 | return False 65 | else: 66 | return newid 67 | 68 | 69 | class goId(ontId_owl): 70 | """An object for generating GO id, given 71 | go: a Brain object, loaded with GO. 72 | start: start of range (int) 73 | end: end of range (int) 74 | """ 75 | def __init__(self, go, start, end): 76 | self.idp = 'GO' 77 | self.length = 7 78 | self.sep = '_' 79 | self.ont = go 80 | self._gen_lookups() 81 | self.accession = start 82 | self.end = end 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | def test_gen_id(): 92 | # make a dict 93 | 94 | id_name = {} 95 | id_name['HSNT:00000001'] = 'head' 96 | id_name['HSNT:00000002'] = 'shoulders' 97 | id_name['HSNT:00000003']= 'knees' 98 | 99 | hsnt = ontId('HSNT', 8, id_name) 100 | hsnt.sep = ':' 101 | 102 | # Generate ID for new term 'toes' 103 | k = hsnt.gen_id('toes') 104 | # Change these to warnings: 105 | if (k == 'HSNT:00000004') & (hsnt.id_name[k] == 'toes'): 106 | return True 107 | else: 108 | warnings.warn('gen_id is broken') 109 | return False 110 | 111 | 112 | test_gen_id() 113 | -------------------------------------------------------------------------------- /src/attic/abstract_pattern_runner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env jython -J-Xmx8000m 2 | 3 | import json 4 | import pattern 5 | import glob 6 | import re 7 | from uk.ac.ebi.brain.core import Brain 8 | import sys 9 | 10 | 11 | """Runs verification tests on abstract patterns and generates markdown docs. 12 | 1st ARG specifies path to input/output files. 13 | Second ARG specifies ontology file to use in validation.""" 14 | 15 | def load_json_from_file(path): 16 | json_file = open(path, "r") 17 | json_string = json_file.read() 18 | json_file.close() 19 | return json.loads(json_string) 20 | 21 | # Testing abstract pattern validation and documentation 22 | o = Brain() 23 | o.learn(sys.argv[2]) # Running with local file for now. 24 | # Switch this to specify path as argv 25 | json_files = glob.glob(sys.argv[1] + "*.json") # Note - glob returns full file path 26 | 27 | for f in json_files: 28 | p = load_json_from_file(f) 29 | m = re.search("(.+).json", f) 30 | pattern_name = m.group(1) 31 | print "Processing %s" % pattern_name 32 | ap = pattern.abstract_pattern(p, o) 33 | md = open(pattern_name + ".md", "w") 34 | #print ap.gen_markdown_doc() 35 | md.write(ap.gen_markdown_doc()) 36 | md.close() 37 | o.sleep() 38 | -------------------------------------------------------------------------------- /src/attic/brain_io_wrapper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Jython -Xmx4000m 2 | 3 | from uk.ac.ebi.brain.core import Brain 4 | from org.semanticweb.owlapi.io import OWLFunctionalSyntaxOntologyFormat 5 | from org.semanticweb.owlapi.model import IRI 6 | from java.io import File 7 | from org.semanticweb.owlapi.apibinding.OWLManager import createOWLOntologyManager 8 | 9 | # Kinda sucks that this is needed. Should be written into some extension to Brain. 10 | 11 | def load_brain_from_file(path): 12 | """Created a Brain object from a file, preserving ontology metadata. 13 | path = path to file. May be absolute or relative. 14 | """ 15 | m = createOWLOntologyManager() 16 | o_file = File(path) 17 | o = m.loadOntologyFromOntologyDocument(o_file) 18 | return Brain(o) 19 | 20 | def save_brain_as_ofn(brain, path): 21 | """ 22 | Wot it sez on' tin. 23 | brain = Brain object 24 | path = *FULL* path to file (relative paths not allowed). 25 | """ 26 | ofn = OWLFunctionalSyntaxOntologyFormat() 27 | brain.manager.saveOntology(brain.getOntology(), ofn, IRI.create("file://" + path)) 28 | -------------------------------------------------------------------------------- /src/attic/examples/README.md: -------------------------------------------------------------------------------- 1 | ## An example implementation of dos-dp, adding a class to the GO 2 | 3 | ### Example use 4 | 5 | ./term_addition_runner.py ../../patterns/transport\_across\_membrane.py sodium\_outer\_mito\_mem.json 6 | 7 | (relative paths in example depend on checkout of whole repo) 8 | 9 | ### Todo: 10 | 11 | Add wrapper for specification of terms in tsv. 12 | -------------------------------------------------------------------------------- /src/attic/examples/sodium_outer_mito_mem.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "cargo" : [ "sodium(1+)", "CHEBI_29101" ], 3 | "start" : [ "cytosol", "GO_0005829" ], 4 | "end" : [ "mitochondrial intermembrane space", "GO_0005758" ], 5 | "membrane" : [ "mitochondrial outer membrane", "GO_0005741" ] 6 | } 7 | ] -------------------------------------------------------------------------------- /src/attic/examples/term_addition_runner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Jython -J-Xmx4000m 2 | from pattern import applied_pattern 3 | from pattern import load_json_from_file 4 | import sys 5 | sys.path.append("../src") 6 | from brain_io_wrapper import load_brain_from_file, save_brain_as_ofn 7 | from ID_tools import goId 8 | # TBA - import ID generation script 9 | 10 | """This example script assumes the user is editing a local GO file (Arg 3), saving to the same file. 11 | Arg 1 = a pattern file 12 | Arg 2 = specification of vars 13 | Arg 3 = A *full* path to the GO OWL file to be edited. 14 | """ 15 | 16 | ### Load up a brain with GO 17 | go = load_brain_from_file(sys.argv[3]) 18 | goid = goId(go = go, start = 98900, end = 100000) 19 | pattern = load_json_from_file(path = sys.argv[1]) 20 | var_spec = load_json_from_file(path = sys.argv[2]) 21 | 22 | for spec in var_spec: 23 | ap = applied_pattern(pattern = pattern, cdict = spec, ont = go) 24 | ID = goid.gen_id(name = ap.label) # Call to ID generation thingy. 25 | ap.add_class_to_ont(ID) 26 | 27 | # Move save out of Brain. 28 | save_brain_as_ofn(brain = go, path = "file://" + sys.argv[3]) # No brain method to choose syntax 29 | go.sleep() 30 | 31 | -------------------------------------------------------------------------------- /src/attic/lib/README.md: -------------------------------------------------------------------------------- 1 | # java imports - automatically populated by mvn 2 | -------------------------------------------------------------------------------- /src/attic/ms2Markdown.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | def hyperlink_quoted_entities(string, name_id, baseURI): 5 | """Hyperlink all quoted entities in 'string', rolling URIs using baseURI + name_id dict to look up shortForm IDs based on match to label""" 6 | # sub anything in quotes to ['label'](full_URI) 7 | string = re.sub("\'(.+?)\'", lambda m: "[" + m.group(0) + "]" + "(" + baseURI + name_id[m.group(1)] + ")", string) # Perhaps should worry about word boundaries here? 8 | return string 9 | # test_hyperlink_quoted_entities(): 10 | assert hyperlink_quoted_entities("'abc' some 'xy z'", { "abc" : "123", "xy z": "456" }, "http://fu.bar/") == "['abc'](http://fu.bar/123) some ['xy z'](http://fu.bar/456)" 11 | 12 | def italic_keywords(owlMS_string): 13 | """Make MS keywords italic""" 14 | keywords = ("equivalentTo", "disjointWith", "subClassOf", "and", "that", "or", "some", "only", "not", "min", "max", "exactly") # Probably worth breaking this down further. 15 | # check for match to keyword and sub _keyword_ 16 | for k in keywords: 17 | owlMS_string = re.sub(r"\b%s\b" % k, "_" + k + "_", owlMS_string) # TODO: Add word boundaries to match, also avoid matching inside quotes. 18 | return owlMS_string 19 | 20 | # italic keywords test 21 | assert italic_keywords("equivalentTo disjointWith subClassOf and that or some only not min max exactly") == "_equivalentTo_ _disjointWith_ _subClassOf_ _and_ _that_ _or_ _some_ _only_ _not_ _min_ _max_ _exactly_" 22 | 23 | def bold_relations(owlMS_string, relations): 24 | """Make relations bold. Args: owlMS_string = OWL Manchester syntax string, all entities quoted; relations = list of relations""" 25 | for r in relations: 26 | owlMS_string = re.sub("(\'"+r+"\')", "__'" + r + "'__", owlMS_string) 27 | return owlMS_string 28 | 29 | # bold relations test. 30 | assert bold_relations("'abc' some 'xy z'", ["abc"]) == "__'abc'__ some 'xy z'" 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/attic/patterns/adenine_import_across_plasma_membrane.md: -------------------------------------------------------------------------------- 1 | ## Template: import_across_plasma_membrane 2 | ### imported: [adenine](http://purl.obolibrary.org/obo/CHEBI_16708) 3 | 4 | __label:__ adenine import across plasma membrane 5 | 6 | __def:__ The directed movement of adenine from outside of a cell, across the plasma membrane and into the cytoplasmic compartment. 7 | 8 | __equivalentTo:__ ['transport'](http://purl.obolibrary.org/obo/GO_0006810) _and_ (__['has target start location'](http://purl.obolibrary.org/obo/RO_0002338)__ _some_ ['extracellular region'](http://purl.obolibrary.org/obo/GO_0005576)) _and_ (__['has target end location'](http://purl.obolibrary.org/obo/RO_0002339)__ _some_ ['cytosol'](http://purl.obolibrary.org/obo/GO_0005829)) _and_ (__['results in transport across'](http://purl.obolibrary.org/obo/RO_0002342)__ _some_ ['plasma membrane'](http://purl.obolibrary.org/obo/GO_0005886)) _and_ (__['imports'](http://purl.obolibrary.org/obo/RO_0002340)__ _some_ [adenine](http://purl.obolibrary.org/obo/CHEBI_16708)) 9 | -------------------------------------------------------------------------------- /src/attic/patterns/anchored_membrane_component.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "anchored component of membrane": "GO_0031225", 4 | "membrane": "GO_0016020", 5 | "side of membrane": "GO_0098552" 6 | }, 7 | "def": { 8 | "text": "The component of the %s consisting of the gene products that are tethered to the membrane only by a covalently attached anchor, such as a lipid group that is embedded in the membrane. Gene products with peptide sequences that are embedded in the membrane are excluded from this grouping.", 9 | "vars": [ 10 | "membrane" 11 | ] 12 | }, 13 | "equivalentTo": { 14 | "text": "'anchored component of membrane' and ('part of' some %s)", 15 | "vars": [ 16 | "membrane" 17 | ] 18 | }, 19 | "name": { 20 | "text": "anchored component of %s", 21 | "vars": [ 22 | "membrane" 23 | ] 24 | }, 25 | "pattern_name": "anchored_membrane_component", 26 | "relations": { 27 | "part of": "BFO_0000050" 28 | }, 29 | "vars": { 30 | "membrane": "'membrane' or 'side of membrane'" 31 | } 32 | } -------------------------------------------------------------------------------- /src/attic/patterns/anchored_membrane_component.md: -------------------------------------------------------------------------------- 1 | ## anchored_membrane_component 2 | __label:__ anchored component of \{ membrane \} 3 | 4 | __def:__ The component of the \{ membrane \} consisting of the gene products that are tethered to the membrane only by a covalently attached anchor, such as a lipid group that is embedded in the membrane. Gene products with peptide sequences that are embedded in the membrane are excluded from this grouping. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/anchored_membrane_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: anchored_membrane_component 2 | 3 | classes: 4 | membrane: GO_0016020 5 | side of membrane: GO_0098552 6 | anchored component of membrane: GO_0031225 7 | 8 | 9 | relations: 10 | part of: BFO_0000050 11 | 12 | vars: 13 | membrane: "'membrane' or 'side of membrane'" 14 | 15 | name: 16 | text: anchored component of %s 17 | vars: 18 | - membrane 19 | 20 | def: 21 | text: "The component of the %s consisting of the gene products that are tethered to the membrane only by a covalently attached anchor, such as a lipid group that is embedded in the membrane. Gene products with peptide sequences that are embedded in the membrane are excluded from this grouping." 22 | vars: 23 | - membrane 24 | 25 | equivalentTo: 26 | text: "'anchored component of membrane' and ('part of' some %s)" 27 | vars: 28 | - membrane 29 | -------------------------------------------------------------------------------- /src/attic/patterns/bounding_membrane_of_organelle.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "membrane-bounded organelle": "GO_0043227", 4 | "whole membrane": "GO_0098805" 5 | }, 6 | "def": { 7 | "text": "The lipid bilayer that forms the outer layer of a %s.", 8 | "vars": [ 9 | "organelle" 10 | ] 11 | }, 12 | "equivalentTo": { 13 | "text": "'whole membrane' that ('bounding layer of' some %s)", 14 | "vars": [ 15 | "organelle" 16 | ] 17 | }, 18 | "name": { 19 | "text": "%s membrane", 20 | "vars": [ 21 | "organelle" 22 | ] 23 | }, 24 | "pattern_name": "bounding_membrane_of_organelle", 25 | "relations": { 26 | "bounding layer of": "RO_0002007" 27 | }, 28 | "vars": { 29 | "organelle": "'membrane-bounded organelle'" 30 | } 31 | } -------------------------------------------------------------------------------- /src/attic/patterns/bounding_membrane_of_organelle.md: -------------------------------------------------------------------------------- 1 | ## bounding_membrane_of_organelle 2 | __label:__ \{ organelle \} membrane 3 | 4 | __def:__ The lipid bilayer that forms the outer layer of a \{ organelle \}. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/bounding_membrane_of_organelle.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: bounding_membrane_of_organelle 2 | 3 | classes: 4 | 'whole membrane': GO_0098805 5 | 'membrane-bounded organelle': GO_0043227 6 | 7 | relations: 8 | 'bounding layer of': RO_0002007 9 | 10 | vars: 11 | organelle: "'membrane-bounded organelle'" 12 | 13 | name: 14 | text: "%s membrane" 15 | vars: 16 | - organelle 17 | 18 | def: 19 | text: "The lipid bilayer that forms the outer layer of a %s." 20 | vars: 21 | - organelle 22 | 23 | equivalentTo: 24 | text: "'whole membrane' that ('bounding layer of' some %s)" 25 | vars: 26 | - organelle 27 | -------------------------------------------------------------------------------- /src/attic/patterns/envenomation.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "envenomation resulting in modification of morphology or physiology of other organism": "GO_0044468", 4 | "modification of morphology or physiology of other organism": "GO_0035821" 5 | }, 6 | "def": { 7 | "text": "A process that begins with venom being forced into an organism by the bite or sting of another organism, and ends with the resultant %s", 8 | "vars": [ 9 | "mod" 10 | ] 11 | }, 12 | "equivalentTo": { 13 | "text": "'envenomation resulting in modification of morphology or physiology of other organism' and 'has part' some %s", 14 | "vars": [ 15 | "mod" 16 | ] 17 | }, 18 | "name": { 19 | "text": "envenomation resulting in %s", 20 | "vars": [ 21 | "mod" 22 | ] 23 | }, 24 | "pattern_name": "envenomation", 25 | "relations": { 26 | "has part": "BFO_0000051" 27 | }, 28 | "vars": { 29 | "mod": "'modification of morphology or physiology of other organism'" 30 | } 31 | } -------------------------------------------------------------------------------- /src/attic/patterns/envenomation.md: -------------------------------------------------------------------------------- 1 | ## envenomation 2 | __label:__ envenomation resulting in \{ mod \} 3 | 4 | __def:__ A process that begins with venom being forced into an organism by the bite or sting of another organism, and ends with the resultant \{ mod \} 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/envenomation.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: envenomation 2 | 3 | classes: 4 | 'envenomation resulting in modification of morphology or physiology of other organism' : 'GO_0044468' 5 | 'modification of morphology or physiology of other organism' : 'GO_0035821' 6 | 7 | relations: 8 | 'has part' : 'BFO_0000051' 9 | 10 | vars: 11 | mod: "'modification of morphology or physiology of other organism'" 12 | 13 | name: 14 | text: 'envenomation resulting in %s' 15 | vars: 16 | - mod 17 | 18 | def: 19 | text: "A process that begins with venom being forced into an organism by the bite or sting of another organism, and ends with the resultant %s" 20 | vars: 21 | - mod # Need a way to specify regex transformation that subs 'in the bitten organism' for 'in other organism' 22 | 23 | equivalentTo: 24 | text: "'envenomation resulting in modification of morphology or physiology of other organism' and 'has part' some %s" 25 | vars: 26 | - mod -------------------------------------------------------------------------------- /src/attic/patterns/export_across_membrane.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "cellular_component": "GO_0005575", 4 | "chemical entity": "CHEBI_24431", 5 | "macromolecular complex": "GO_0032991", 6 | "membrane": "GO_0016020", 7 | "transcript": "SO_0000673", 8 | "transport": "GO_0006810" 9 | }, 10 | "comment": { 11 | "text": "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane.", 12 | "vars": [ 13 | "cargo", 14 | "membrane", 15 | "membrane" 16 | ] 17 | }, 18 | "def": { 19 | "text": "The directed import of %s from %s, across the %s and into the %s.", 20 | "vars": [ 21 | "cargo", 22 | "start", 23 | "membrane", 24 | "end" 25 | ] 26 | }, 27 | "equivalentTo": { 28 | "text": "'transport' that and ('has target start location' some %s) and ('has target end location' some %s) and ('exports' some %s) and ('results in transport across' some %s)", 29 | "vars": [ 30 | "start", 31 | "end", 32 | "cargo", 33 | "membrane" 34 | ] 35 | }, 36 | "name": { 37 | "text": "%s export across %s", 38 | "vars": [ 39 | "cargo", 40 | "membrane" 41 | ] 42 | }, 43 | "pattern_name": "import_across_membrane", 44 | "relations": { 45 | "exports": "RO_0002345", 46 | "has target end location": "RO_0002339", 47 | "has target start location": "RO_0002338", 48 | "results in transport across": "RO_0002342", 49 | "transports or maintains localization of": "RO_0002313" 50 | }, 51 | "vars": { 52 | "cargo": "'chemical entity' or 'macromolecular complex' or 'transcript'", 53 | "end": "'cellular_component'", 54 | "membrane": "'membrane'", 55 | "start": "'cellular_component'" 56 | } 57 | } -------------------------------------------------------------------------------- /src/attic/patterns/export_across_membrane.md: -------------------------------------------------------------------------------- 1 | ## import_across_membrane 2 | __label:__ \{ cargo \} export across \{ membrane \} 3 | 4 | __def:__ The directed import of \{ cargo \} from \{ start \}, across the \{ membrane \} and into the \{ end \}. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/export_across_membrane.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | exports: RO_0002345 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s export across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | equivalentTo: 46 | text: "'transport' that 47 | and ('has target start location' some %s) 48 | and ('has target end location' some %s) 49 | and ('exports' some %s) 50 | and ('results in transport across' some %s)" 51 | 52 | vars: 53 | - start 54 | - end 55 | - cargo 56 | - membrane 57 | -------------------------------------------------------------------------------- /src/attic/patterns/expression_pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "cell": null, 4 | "expression pattern": null 5 | }, 6 | "def": { 7 | "text": "The sum total of all cells in a single organism in which expression of %s is occurring.", 8 | "vars": [ 9 | "expressed_feature" 10 | ] 11 | }, 12 | "equivalentTo": { 13 | "text": "", 14 | "vars": [ 15 | "expressed_feature" 16 | ] 17 | }, 18 | "name": { 19 | "text": "%s expression pattern", 20 | "vars": [ 21 | "expressed_feature" 22 | ] 23 | }, 24 | "pattern_name": "expression_pattern", 25 | "relations": { 26 | "has part": null, 27 | "part of": "BFO_0000050" 28 | }, 29 | "vars": { 30 | "expressed_feature": "'gene'" 31 | } 32 | } -------------------------------------------------------------------------------- /src/attic/patterns/expression_pattern.md: -------------------------------------------------------------------------------- 1 | ## expression_pattern 2 | __label:__ \{ expressed_feature \} expression pattern 3 | 4 | __def:__ The sum total of all cells in a single organism in which expression of \{ expressed_feature \} is occurring. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/expression_pattern.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: expression_pattern 2 | 3 | classes: 4 | expression pattern: 5 | cell: 6 | 7 | relations: 8 | 'part of': BFO_0000050 9 | 'has part': 10 | 11 | vars: 12 | expressed_feature: "'gene'" # Needs to be gene or transgene. Use SO? 13 | 14 | name: 15 | text: "%s expression pattern" 16 | vars: 17 | - expressed_feature 18 | 19 | def: 20 | text: "The sum total of all cells in a single organism in which expression of %s is occurring." 21 | vars: 22 | - expressed_feature 23 | 24 | 25 | equivalentTo: 26 | text: "" 27 | vars: 28 | - expressed_feature 29 | -------------------------------------------------------------------------------- /src/attic/patterns/extrinsic_membrane_component.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "extrinsic component of membrane": "GO_0019898", 4 | "membrane": "GO_0016020", 5 | "side of membrane": "GO_0098552" 6 | }, 7 | "def": { 8 | "text": "The component of the %s consisting of gene products and protein complexes that are loosely bound to one of its surfaces, but not integrated into the hydrophobic region.", 9 | "vars": [ 10 | "membrane" 11 | ] 12 | }, 13 | "equivalentTo": { 14 | "text": "'extrinsic component of membrane' and ('part of' some %s)", 15 | "vars": [ 16 | "membrane" 17 | ] 18 | }, 19 | "name": { 20 | "text": "extrinsic component of %s", 21 | "vars": [ 22 | "membrane" 23 | ] 24 | }, 25 | "pattern_name": "extrinsic_membrane_component", 26 | "relations": { 27 | "part of": "BFO_0000050" 28 | }, 29 | "vars": { 30 | "membrane": "'membrane' or 'side of membrane'" 31 | } 32 | } -------------------------------------------------------------------------------- /src/attic/patterns/extrinsic_membrane_component.md: -------------------------------------------------------------------------------- 1 | ## extrinsic_membrane_component 2 | __label:__ extrinsic component of \{ membrane \} 3 | 4 | __def:__ The component of the \{ membrane \} consisting of gene products and protein complexes that are loosely bound to one of its surfaces, but not integrated into the hydrophobic region. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/extrinsic_membrane_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: extrinsic_membrane_component 2 | 3 | classes: 4 | membrane: GO_0016020 5 | side of membrane: GO_0098552 6 | extrinsic component of membrane: GO_0019898 7 | 8 | relations: 9 | part of: BFO_0000050 10 | 11 | vars: 12 | membrane: "'membrane' or 'side of membrane'" 13 | 14 | name: 15 | text: extrinsic component of %s 16 | vars: 17 | - membrane 18 | 19 | def: 20 | text: "The component of the %s consisting of gene products and protein complexes that are loosely bound to one of its surfaces, but not integrated into the hydrophobic region." 21 | vars: 22 | - membrane 23 | 24 | equivalentTo: 25 | text: "'extrinsic component of membrane' and ('part of' some %s)" 26 | vars: 27 | - membrane 28 | -------------------------------------------------------------------------------- /src/attic/patterns/generic_go_pattern_outline.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: . 2 | 3 | classes: 4 | '.':'.' 5 | 6 | relations: 7 | '.':'.' 8 | 9 | vars: 10 | '.':'.' 11 | 12 | data_list_vars: 13 | def_xrefs: "xsd:string" 14 | cross_references: "xsd:string" 15 | exact_syn: "xsd:string" 16 | narrow_syn: "xsd:string" 17 | broad_syn: "xsd:string" 18 | related_syn: "xsd:string" 19 | 20 | name: 21 | text: '.' 22 | vars: 23 | - '.' 24 | 25 | def: 26 | text: '.' 27 | vars: 28 | - '.' 29 | xrefs: 30 | value: def_xrefs 31 | 32 | xrefs: 33 | value: cross_references 34 | 35 | namespace: 36 | text: '.' 37 | 38 | equivalentTo: 39 | text: '.' 40 | vars: 41 | - '.' 42 | 43 | exact_synonyms: 44 | value: exact_syn 45 | narrow_synonyms: 46 | value: narrow_syn 47 | broad_synonyms: 48 | value: broad_syn 49 | related_synonyms: 50 | value: related_syn 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/attic/patterns/import_across_membrane.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "cellular_component": "GO_0005575", 4 | "chemical entity": "CHEBI_24431", 5 | "macromolecular complex": "GO_0032991", 6 | "membrane": "GO_0016020", 7 | "transcript": "SO_0000673", 8 | "transport": "GO_0006810" 9 | }, 10 | "comment": { 11 | "text": "This term covers %s *across* the %s through a channel or pore. It does not cover import via vesicle fusion with %s or vesiculation, as in these cases transport does not involve crossing the membrane.", 12 | "vars": [ 13 | "cargo", 14 | "membrane", 15 | "membrane" 16 | ] 17 | }, 18 | "def": { 19 | "text": "The directed import of %s from %s, across the %s and into the %s.", 20 | "vars": [ 21 | "cargo", 22 | "start", 23 | "membrane", 24 | "end" 25 | ] 26 | }, 27 | "equivalentTo": { 28 | "text": "'transport' and ('has target start location' some %s) and ('has target end location' some %s) and ('imports' some %s) and ('results in transport across' some %s)", 29 | "vars": [ 30 | "start", 31 | "end", 32 | "cargo", 33 | "membrane" 34 | ] 35 | }, 36 | "name": { 37 | "text": "%s import across %s", 38 | "vars": [ 39 | "cargo", 40 | "membrane" 41 | ] 42 | }, 43 | "pattern_name": "import_across_membrane", 44 | "relations": { 45 | "has target end location": "RO_0002339", 46 | "has target start location": "RO_0002338", 47 | "imports": "RO_0002340", 48 | "results in transport across": "RO_0002342", 49 | "transports or maintains localization of": "RO_0002313" 50 | }, 51 | "vars": { 52 | "cargo": "'chemical entity' or 'macromolecular complex' or 'transcript'", 53 | "end": "'cellular_component'", 54 | "membrane": "'membrane'", 55 | "start": "'cellular_component'" 56 | } 57 | } -------------------------------------------------------------------------------- /src/attic/patterns/import_across_membrane.md: -------------------------------------------------------------------------------- 1 | ## import_across_membrane 2 | __label:__ \{ cargo \} import across \{ membrane \} 3 | 4 | __def:__ The directed import of \{ cargo \} from \{ start \}, across the \{ membrane \} and into the \{ end \}. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/import_across_membrane.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | imports: RO_0002340 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s import across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover import via vesicle fusion with %s or vesiculation, as in these cases transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | 46 | equivalentTo: 47 | text: "'transport' 48 | and ('has target start location' some %s) 49 | and ('has target end location' some %s) 50 | and ('imports' some %s) 51 | and ('results in transport across' some %s)" 52 | 53 | vars: 54 | - start 55 | - end 56 | - cargo 57 | - membrane 58 | -------------------------------------------------------------------------------- /src/attic/patterns/import_across_plasma_membrane.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "chemical entity": "CHEBI_24431", 4 | "cytosol": "GO_0005829", 5 | "extracellular region": "GO_0005576", 6 | "macromolecular complex": "GO_0043234", 7 | "plasma membrane": "GO_0005886", 8 | "transport": "GO_0006810" 9 | }, 10 | "def": { 11 | "text": "The directed movement of %s from outside of a cell, across the plasma membrane and into the cytoplasmic compartment.", 12 | "vars": [ 13 | "imported" 14 | ] 15 | }, 16 | "equivalentTo": { 17 | "text": "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'cytosol') and ('results in transport across' some 'plasma membrane') and ('imports' some %s)", 18 | "vars": [ 19 | "imported" 20 | ] 21 | }, 22 | "name": { 23 | "text": "%s import across plasma membrane", 24 | "vars": [ 25 | "imported" 26 | ] 27 | }, 28 | "pattern_name": "import_across_plasma_membrane", 29 | "relations": { 30 | "has target end location": "RO_0002339", 31 | "has target start location": "RO_0002338", 32 | "imports": "RO_0002340", 33 | "results in transport across": "RO_0002342" 34 | }, 35 | "vars": { 36 | "imported": "'chemical entity' or 'macromolecular complex'" 37 | } 38 | } -------------------------------------------------------------------------------- /src/attic/patterns/import_across_plasma_membrane.md: -------------------------------------------------------------------------------- 1 | ## import_across_plasma_membrane 2 | __label:__ \{ imported \} import across plasma membrane 3 | 4 | __def:__ The directed movement of \{ imported \} from outside of a cell, across the plasma membrane and into the cytoplasmic compartment. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/import_across_plasma_membrane.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_plasma_membrane 2 | # implicitly import into cell across plamsa membrane 3 | 4 | classes: 5 | transport: GO_0006810 6 | extracellular region: GO_0005576 7 | cytosol: GO_0005829 8 | chemical entity: CHEBI_24431 # encompasses protein 9 | macromolecular complex: GO_0043234 # encompasses protein complex 10 | plasma membrane: GO_0005886 11 | 12 | relations: 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | imports: RO_0002340 17 | 18 | vars: 19 | imported: "'chemical entity' or 'macromolecular complex'" 20 | 21 | name: 22 | text: "%s import across plasma membrane" 23 | vars: 24 | - imported 25 | 26 | def: 27 | text: The directed movement of %s from outside of a cell, across the plasma membrane and into the cytoplasmic compartment. 28 | vars: 29 | - imported 30 | 31 | equivalentTo: 32 | text: "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'cytosol') and ('results in transport across' some 'plasma membrane') and ('imports' some %s)" 33 | vars: 34 | - imported 35 | -------------------------------------------------------------------------------- /src/attic/patterns/import_into_cell.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "chemical entity": "CHEBI_24431", 4 | "extracellular region": "GO_0005576", 5 | "intracellular part": "GO_0044424", 6 | "macromolecular complex": "GO_0043234", 7 | "transport": "GO_0006810" 8 | }, 9 | "def": { 10 | "text": "The directed movement of %s from outside of a cell into the cytoplasmic compartment. This may occur via transport across the plasma membrane or via endocytosis.", 11 | "vars": [ 12 | "imported" 13 | ] 14 | }, 15 | "equivalentTo": { 16 | "text": "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'intracellular part') and ('imports' some %s)", 17 | "vars": [ 18 | "imported" 19 | ] 20 | }, 21 | "name": { 22 | "text": "%s import into cell", 23 | "vars": [ 24 | "imported" 25 | ] 26 | }, 27 | "pattern_name": "import_into_cell", 28 | "relations": { 29 | "has target end location": "RO_0002339", 30 | "has target start location": "RO_0002338", 31 | "imports": "RO_0002340" 32 | }, 33 | "vars": { 34 | "imported": "'chemical entity' or 'macromolecular complex'" 35 | } 36 | } -------------------------------------------------------------------------------- /src/attic/patterns/import_into_cell.md: -------------------------------------------------------------------------------- 1 | ## import_into_cell 2 | __label:__ \{ imported \} import into cell 3 | 4 | __def:__ The directed movement of \{ imported \} from outside of a cell into the cytoplasmic compartment. This may occur via transport across the plasma membrane or via endocytosis. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/import_into_cell.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_into_cell 2 | classes: 3 | transport: GO_0006810 4 | extracellular region: GO_0005576 5 | intracellular part: GO_0044424 6 | chemical entity: CHEBI_24431 # encompasses protein 7 | macromolecular complex: GO_0043234 # encompasses protein complex 8 | 9 | relations: 10 | has target start location: RO_0002338 11 | has target end location: RO_0002339 12 | imports: RO_0002340 13 | 14 | vars: 15 | imported: "'chemical entity' or 'macromolecular complex'" 16 | 17 | name: 18 | text: "%s import into cell" 19 | vars: 20 | - imported 21 | 22 | def: 23 | text: "The directed movement of %s from outside of a cell into the cytoplasmic compartment. This may occur via transport across the plasma membrane or via endocytosis." 24 | vars: 25 | - imported 26 | 27 | equivalentTo: 28 | text: "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'intracellular part') and ('imports' some %s)" 29 | vars: 30 | - imported 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/attic/patterns/integral_membrane_component.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "integral component of membrane": "GO_0016021", 4 | "membrane": "GO_0016020", 5 | "side of membrane": "GO_0098552" 6 | }, 7 | "def": { 8 | "text": "The component of the %s consisting of the gene products and protein complexes having at least some part of their peptide sequence embedded in the hydrophobic region of the membrane.", 9 | "vars": [ 10 | "membrane" 11 | ] 12 | }, 13 | "equivalentTo": { 14 | "text": "'integral component of membrane' and ('part of' some %s)", 15 | "vars": [ 16 | "membrane" 17 | ] 18 | }, 19 | "name": { 20 | "text": "integral component of %s", 21 | "vars": [ 22 | "membrane" 23 | ] 24 | }, 25 | "pattern_name": "integral_membrane_component", 26 | "relations": { 27 | "part of": "BFO_0000050" 28 | }, 29 | "vars": { 30 | "membrane": "'membrane' or 'side of membrane'" 31 | } 32 | } -------------------------------------------------------------------------------- /src/attic/patterns/integral_membrane_component.md: -------------------------------------------------------------------------------- 1 | ## integral_membrane_component 2 | __label:__ integral component of \{ membrane \} 3 | 4 | __def:__ The component of the \{ membrane \} consisting of gene products and protein complexes that have some part that penetrates at least one leaflet of the membrane bilayer. This component includes gene products that are buried in the bilayer with no exposure outside the bilayer. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/integral_membrane_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: integral_membrane_component 2 | 3 | classes: 4 | membrane: GO_0016020 5 | side of membrane: GO_0098552 6 | integral component of membrane: GO_0016021 7 | 8 | relations: 9 | part of: BFO_0000050 10 | 11 | vars: 12 | membrane: "'membrane' or 'side of membrane'" 13 | 14 | name: 15 | text: integral component of %s 16 | vars: 17 | - membrane 18 | 19 | def: 20 | text: "The component of the %s consisting of the gene products and protein complexes having at least some part of their peptide sequence embedded in the hydrophobic region of the membrane." 21 | vars: 22 | - membrane 23 | 24 | equivalentTo: 25 | text: "'integral component of membrane' and ('part of' some %s)" 26 | vars: 27 | - membrane 28 | -------------------------------------------------------------------------------- /src/attic/patterns/intrinsic_membrane_component.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "intrinsic component of membrane": "GO_0031224", 4 | "membrane": "GO_0016020", 5 | "side of membrane": "GO_0098552" 6 | }, 7 | "def": { 8 | "text": "The component of the %s consisting of gene products and protein complexes that have some covalently attached part (e.g. peptide sequence or GPI anchor), which spans or is embedded in one or both leaflets the membrane.", 9 | "vars": [ 10 | "membrane" 11 | ] 12 | }, 13 | "equivalentTo": { 14 | "text": "'intrinsic component of membrane' and ('part of' some %s)", 15 | "vars": [ 16 | "membrane" 17 | ] 18 | }, 19 | "name": { 20 | "text": "intrinsic component of %s", 21 | "vars": [ 22 | "membrane" 23 | ] 24 | }, 25 | "pattern_name": "intrinsic_membrane_component", 26 | "relations": { 27 | "part of": "BFO_0000050" 28 | }, 29 | "vars": { 30 | "membrane": "'membrane' or 'side of membrane'" 31 | } 32 | } -------------------------------------------------------------------------------- /src/attic/patterns/intrinsic_membrane_component.md: -------------------------------------------------------------------------------- 1 | ## intrinsic_membrane_component 2 | __label:__ intrinsic component of \{ membrane \} 3 | 4 | __def:__ The component of the \{ membrane \} consisting of gene products and protein complexes that have some covalently attached part (e.g. peptide sequence or GPI anchor), which spans or is embedded in one or both leaflets the membrane. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/intrinsic_membrane_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: intrinsic_membrane_component 2 | 3 | classes: 4 | membrane: GO_0016020 5 | side of membrane: GO_0098552 6 | intrinsic component of membrane: GO_0031224 7 | 8 | relations: 9 | part of: BFO_0000050 10 | 11 | vars: 12 | membrane: "'membrane' or 'side of membrane'" 13 | 14 | name: 15 | text: intrinsic component of %s 16 | vars: 17 | - membrane 18 | 19 | def: 20 | text: The component of the %s consisting of gene products and protein complexes that have some covalently attached part (e.g. peptide sequence or GPI anchor), which spans or is embedded in one or both leaflets the membrane. 21 | vars: 22 | - membrane 23 | 24 | equivalentTo: 25 | text: "'intrinsic component of membrane' and ('part of' some %s)" 26 | vars: 27 | - membrane 28 | -------------------------------------------------------------------------------- /src/attic/patterns/membrane_receptor_activity_draft.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: membrane_receptor_activity 2 | 3 | classes: 4 | 'receptor activity': GO_ 5 | 'membrane': GO_ 6 | 'binding activity': GO_ 7 | 'catalytic activity': GO_ 8 | 'transporter activity': GO_ 9 | 10 | 11 | relations: 12 | 'has part': BFO_ 13 | 'directly activates': RO_ 14 | 'occurs in': RO_ 15 | 16 | vars: 17 | 'effector activity': "'catalytic activity' or 'transporter activity'" # may be others.. 18 | 'ligand': '"chemical entity" or "protein"' # chemical entity should be sufficient given Pro links to ChEBI - are they in place? 19 | 20 | subClassOf: 21 | "receptor activity' and ( 22 | 'has_part' some ( 23 | 'binding activity' that has_input some %s and 24 | directly_activates some %s)) 25 | and ('has_part' some 'effector activity') 26 | and (occurs_in some membrane)" # Strictly, this has co-reference issues, e.g. the regulation could be of another 27 | vars: 28 | - 'ligand' 29 | - 'effector activity' 30 | - 'effector activity' 31 | 32 | 33 | 34 | # Could we make a has_ligand shortcut relation? Problem is, it needs two slots. -------------------------------------------------------------------------------- /src/attic/patterns/membrane_spanning_component.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "membrane": "GO_0016020", 4 | "spanning component of membrane": "GO_0089717" 5 | }, 6 | "comment": { 7 | "text": "Proteins that span the membrane but have the bulk on one side of the membrane may be additionally annotated with a term of the form integral to X side of the %s.", 8 | "vars": [ 9 | "membrane" 10 | ] 11 | }, 12 | "def": { 13 | "text": "The component of the %s consisting of gene products and protein complexes that have some part that spans both leaflets of the membrane.", 14 | "vars": [ 15 | "membrane" 16 | ] 17 | }, 18 | "equivalentTo": { 19 | "text": "'spanning component of membrane' that 'part of' some %s", 20 | "vars": [ 21 | "membrane" 22 | ] 23 | }, 24 | "name": { 25 | "text": "spanning component of %s", 26 | "vars": [ 27 | "membrane" 28 | ] 29 | }, 30 | "pattern_name": "spanning_component_of_membrane", 31 | "relations": { 32 | "part of": "BFO_0000050" 33 | }, 34 | "vars": { 35 | "membrane": "'membrane'" 36 | } 37 | } -------------------------------------------------------------------------------- /src/attic/patterns/membrane_spanning_component.md: -------------------------------------------------------------------------------- 1 | ## spanning_component_of_membrane 2 | __label:__ spanning component of \{ membrane \} 3 | 4 | __def:__ The component of the \{ membrane \} consisting of gene products and protein complexes that have some part that spans both leaflets of the membrane. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/membrane_spanning_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: spanning_component_of_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | spanning component of membrane: GO_0089717 6 | 7 | relations: 8 | 'part of': BFO_0000050 9 | 10 | vars: 11 | membrane: "'membrane'" 12 | 13 | name: 14 | text: "spanning component of %s" 15 | vars: 16 | - membrane 17 | 18 | def: 19 | text: "The component of the %s consisting of gene products and protein complexes that have some part that spans both leaflets of the membrane." 20 | vars: 21 | - membrane 22 | 23 | equivalentTo: 24 | text: "'spanning component of membrane' that 'part of' some %s" 25 | vars: 26 | - membrane 27 | -------------------------------------------------------------------------------- /src/attic/patterns/transmembrane_import_into_cell.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "chemical entity": "CHEBI_24431", 4 | "cytosol": "GO_0005829", 5 | "extracellular region": "GO_0005576", 6 | "macromolecular complex": "GO_0043234", 7 | "plasma membrane": "GO_0005886", 8 | "transport": "GO_0006810" 9 | }, 10 | "def": { 11 | "text": "The directed movement of %s from outside of a cell, across the plasma membrane and into the cytoplasmic compartment.", 12 | "vars": [ 13 | "imported" 14 | ] 15 | }, 16 | "equivalentTo": { 17 | "text": "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'cytosol') and ('results in transport across' some 'plasma membrane') and ('imports' some %s)", 18 | "vars": [ 19 | "imported" 20 | ] 21 | }, 22 | "name": { 23 | "text": "%s import across plasma membrane", 24 | "vars": [ 25 | "imported" 26 | ] 27 | }, 28 | "pattern_name": "transmembrane_import_into_cytosol", 29 | "relations": { 30 | "has target end location": "RO_0002339", 31 | "has target start location": "RO_0002338", 32 | "imports": "RO_0002340", 33 | "results in transport across": "RO_0002342" 34 | }, 35 | "vars": { 36 | "imported": "'chemical entity' or 'macromolecular complex'" 37 | } 38 | } -------------------------------------------------------------------------------- /src/attic/patterns/transmembrane_import_into_cell.md: -------------------------------------------------------------------------------- 1 | ## transmembrane_import_into_cytosol 2 | __label:__ \{ imported \} import across plasma membrane 3 | 4 | __def:__ The directed movement of \{ imported \} from outside of a cell, across the plasma membrane and into the cytoplasmic compartment. 5 | 6 | -------------------------------------------------------------------------------- /src/attic/patterns/transmembrane_import_into_cell.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: transmembrane_import_into_cytosol 2 | # implicitly import into cell across plamsa membrane 3 | 4 | classes: 5 | transport: GO_0006810 6 | extracellular region: GO_0005576 7 | cytosol: GO_0005829 8 | chemical entity: CHEBI_24431 # encompasses protein 9 | macromolecular complex: GO_0043234 # encompasses protein complex 10 | plasma membrane: GO_0005886 11 | 12 | relations: 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | imports: RO_0002340 17 | 18 | vars: 19 | imported: "'chemical entity' or 'macromolecular complex'" 20 | 21 | name: 22 | text: "%s import across plasma membrane" 23 | vars: 24 | - imported 25 | 26 | def: 27 | text: The directed movement of %s from outside of a cell, across the plasma membrane and into the cytoplasmic compartment. 28 | vars: 29 | - imported 30 | 31 | equivalentTo: 32 | text: "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'cytosol') and ('results in transport across' some 'plasma membrane') and ('imports' some %s)" 33 | vars: 34 | - imported 35 | -------------------------------------------------------------------------------- /src/attic/patterns/var_spec_examples/glucose_import_into_cell.yaml: -------------------------------------------------------------------------------- 1 | imported: 2 | glucose: CHEBI_17234 -------------------------------------------------------------------------------- /src/attic/spec/DOSDP_schema_core.yaml: -------------------------------------------------------------------------------- 1 | $schema: http://json-schema.org/draft-04/schema# 2 | id: https://github.com/dosumis/dead_simple_owl_design_patterns/edit/master/spec/DOSDP_spec.json # Use Purl? 3 | title: DOSDP 4 | type: object 5 | 6 | definitions: 7 | printf_annotation: 8 | additionalProperties: False 9 | properties: 10 | annotationProperty: 11 | description: > 12 | A string corresponding to the rdfs:label 13 | of an owl annotation property. If the annotation property has no label, 14 | the shortForm ID should be used. The annotation property must be listed 15 | in the annotation property dictionary.' 16 | type: string 17 | annotations: 18 | items: {$ref: '#/definitions/printf_annotation'} 19 | type: array 20 | text: 21 | description: A print format string. 22 | type: string 23 | vars: 24 | description: > 25 | An ordered list of variables for substitution into the accompanying 26 | print format string. Each entry must correspond to the name of a variable 27 | specified in either the 'vars' field or the data_var field of the pattern. 28 | Where an OWL entity is specified, the label for the OWL entity should be 29 | used in the substitution. 30 | items: {type: string} 31 | type: array 32 | required: [annotationProperty, text, vars] 33 | type: object 34 | printf_owl: 35 | additionalProperties: False 36 | properties: 37 | annotations: 38 | items: {$ref: '#/definitions/printf_annotation'} 39 | type: array 40 | axiom_type: 41 | description: > 42 | 'OWL axiom type expressed as manchester syntax: equivalentTo, 43 | subClassOf, disjointWith. GCI - for general class inclusion axioms, is 44 | also valid (although missing from manchester syntax.) This specifies the 45 | axiom type to be generated from the text following substitution.' 46 | enum: [equivalentTo, subClassOf, disjointWith, GCI] 47 | type: string 48 | text: 49 | type: string 50 | description: > 51 | A print format string in OWL Manchester syntax. Each entry 52 | must correspond to an entry in o the name of a var in the var field of the 53 | pattern. Entries in single quotes must correspond to the labels of entries 54 | in owl_entity dictionaries (classes, relations, dataProperties) 55 | vars: 56 | description: > 57 | An ordered list of variables for substitution into the accompanying 58 | print format string. Each entry must correspond to the name of a variable 59 | specified in either the 'vars' field or the data_var field of the pattern. 60 | items: {type: string} 61 | type: array 62 | required: [axiom_type, text, vars] 63 | type: object 64 | 65 | properties: 66 | pattern_name: 67 | type: string # possible to specifiy ASCII? 68 | description: > 69 | The name of the pattern. This must be an ASCII string with 70 | no spaces. The only special characters allowed are '_' and '-'. 71 | By convention, this is used as the file name of the 72 | pattern - with an appropriate extension. 73 | 74 | pattern_iri: 75 | type: string 76 | description: > 77 | A global identifier for the pattern. This can be a full IRI or a CURIE, using 78 | the same prefix mappings as other CURIEs in the pattern. 79 | 80 | base_IRI: # not rqd, give JSON-LD base. 81 | type: string # how to spec IRI? 82 | description: "Specifies the base IRI to be used to generate new classes." 83 | 84 | description: 85 | type: string # specify UTF-8 string? 86 | description: "A free text description of the pattern. Must be UTF-8 encoded." 87 | 88 | readable_identifiers: 89 | type: array 90 | items: 91 | type: string 92 | description: "A list of annotation properties used as naming fields, in order of preference." 93 | 94 | #### owl_entity Dictionaries 95 | 96 | classes: 97 | type: object 98 | description: "A dictionary of OWL classes. key :label; value : short form id" 99 | objectProperties: 100 | type: object 101 | description: "A dictionary of OWL object properties. key : label; value : short form id" 102 | relations: 103 | # Just an alternative name for the ObjectProperties dict 104 | type: object 105 | description: "A dictionary of OWL object properties. key : label; value : short form id" 106 | dataProperties: 107 | type: object 108 | description: "A dictionary of OWL data properties key : label; value : short form id" 109 | annotationProperties: 110 | type: object 111 | description: "A dictionary of OWL annotation properties key : label; value : short form id" 112 | 113 | # Var types 114 | 115 | vars: 116 | type: object 117 | description: > 118 | A dictionary of variables ranging over OWL classes. 119 | Key = variable name, value = variable range as manchester syntax string. 120 | 121 | data_vars: 122 | type: object 123 | description: > 124 | A dictionary of variables ranging over OWL data-types. 125 | Key = variable name, value = variable range specified as a valid OWL 126 | data-type. 127 | 128 | # string_list_vars: 129 | # description: > 130 | # A variable slot that takes an array of strings. 131 | # type: string 132 | 133 | # axioms 134 | 135 | annotations: 136 | items: {$ref: '#/definitions/printf_annotation'} 137 | type: array 138 | 139 | logical_axioms: 140 | items: {$ref: '#/definitions/printf_owl'} 141 | type: array 142 | 143 | -------------------------------------------------------------------------------- /src/attic/spec/OBO_import.yml: -------------------------------------------------------------------------------- 1 | readable_identifier: 2 | - rdfs:label 3 | 4 | base_IRI: http://purl.obolibrary.org/obo 5 | -------------------------------------------------------------------------------- /src/attic/spec/README.md: -------------------------------------------------------------------------------- 1 | ## JSON-Schema spec for DOS-DP 2 | 3 | ### Beta release: 4 | 5 | * Combined core and OBO schema: [DOSDP_schema_full.yaml](https://github.com/dosumis/dead_simple_owl_design_patterns/blob/master/spec/DOSDP_schema_full.yaml) [![Build Status](https://travis-ci.org/dosumis/dead_simple_owl_design_patterns.svg?branch=master)](https://travis-ci.org/dosumis/dead_simple_owl_design_patterns). Please use this to validate patterns. 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/attic/spec/attic/DOSDP_OBO_fields.json: -------------------------------------------------------------------------------- 1 | { 2 | "annotationProperties": { 3 | "comment": "rdfs:comment", 4 | "definition": "obo:IAO_0000115", 5 | "definition_cross_reference": "oboInOwl:hasDbXref", 6 | "has_broad_synonym": "oboInOwl:hasBroadSynonym", 7 | "has_exact_synonym": "oboInOwl:hasExactSynonym", 8 | "has_narrow_synonym": "oboInOwl:hasNarrowSynonym", 9 | "has_related_synonym": "oboInOwl:hasRelatedSynonym", 10 | "label": "rdfs:label" 11 | }, 12 | "mappings": [ 13 | { 14 | "field": "name", 15 | "maps_to": { 16 | "$ref": "printf_annotation" 17 | }, 18 | "with": { 19 | "annotationProperty": "label" 20 | } 21 | }, 22 | { 23 | "field": "def", 24 | "maps_to": { 25 | "$ref": "printf_annotation" 26 | }, 27 | "with": { 28 | "annotationProperty": "definition" 29 | } 30 | }, 31 | { 32 | "field": "exact_synonym", 33 | "maps_to": { 34 | "$ref": "printf_annotation" 35 | }, 36 | "with": { 37 | "annotationProperty": "has_exact_synonym" 38 | } 39 | }, 40 | { 41 | "field": "broad_synonym", 42 | "maps_to": { 43 | "$ref": "printf_annotation" 44 | }, 45 | "with": { 46 | "annotationProperty": "has_broad_synonym" 47 | } 48 | }, 49 | { 50 | "field": "narrow_synonym", 51 | "maps_to": { 52 | "$ref": "printf_annotation" 53 | }, 54 | "with": { 55 | "annotationProperty": "has_narrow_synonym" 56 | } 57 | }, 58 | { 59 | "field": "related_synonym", 60 | "maps_to": { 61 | "$ref": "printf_annotation" 62 | }, 63 | "with": { 64 | "annotationProperty": "has_related_synonym" 65 | } 66 | }, 67 | { 68 | "field": "xref", 69 | "maps_to": { 70 | "$ref": "printf_annotation" 71 | }, 72 | "with": { 73 | "annotationProperty": "definition_cross_reference" 74 | } 75 | } 76 | ] 77 | } -------------------------------------------------------------------------------- /src/attic/spec/attic/DOSDP_OBO_fields.yaml: -------------------------------------------------------------------------------- 1 | id: https://github.com/dosumis/dead_simple_owl_design_patterns/edit/master/spec/DOSDP_OBO_fields.json 2 | # Import refs need some work. 3 | title: DOSDP_OBO_fields 4 | 5 | # This schema doc contains additional fields that are not part of JSON-schema. 6 | # These are intended for for use in mapping in implementations. 7 | 8 | curies: 9 | rdfs: http://www.w3.org/2000/01/rdf-schema# 10 | obo: http://purl.obolibary.org/obo/ 11 | oboInOwl: http://www.geneontology.org/formats/oboInOwl# 12 | 13 | definitions: 14 | printf_annotation_obo: 15 | type: object 16 | additionalProperties: False 17 | required: [text, vars] 18 | properties: 19 | annotations: 20 | items: {$ref: '#/definitions/printf_annotation_obo'} 21 | type: array 22 | text: 23 | description: A print format string. 24 | type: string 25 | vars: 26 | description: > 27 | An ordered list of variables for substitution into the accompanying 28 | print format string. Each entry must correspond to the name of a variable 29 | specified in either the 'vars' field or the data_var field of the pattern. 30 | Where an OWL entity is specified, the label for the OWL entity should be 31 | used in the substitution. 32 | items: {type: string} 33 | type: array 34 | 35 | type: object 36 | properties: 37 | allOf: 38 | - "$ref" : "DOSDP_schema_core" 39 | - properties: 40 | name: 41 | type: { $ref: '#/definitions/printf_annotation_obo' } 42 | mapping: "rdfs:label" 43 | comment: 44 | type: { $ref: '#/definitions/printf_annotation_obo' } 45 | mapping: "rdfs:comment" 46 | def: 47 | type: { $ref: '#/definitions/printf_annotation_obo' } 48 | mapping: "obo:IAO_0000115" 49 | exact_synonym: 50 | type: array 51 | items: { $ref: '#/definitions/printf_annotation_obo' } 52 | mapping: "oboInOwl:hasExactSynonym" 53 | narrow_synonym: 54 | type: array 55 | items: { $ref: '#/definitions/printf_annotation_obo' } 56 | mapping: "oboInOwl:hasNarrowSynonym" 57 | related_synonym: 58 | type: array 59 | items: { $ref: '#/definitions/printf_annotation_obo' } 60 | mapping: "oboInOwl:hasRelatedSynonym" 61 | broad_synonym: 62 | type: array 63 | items: { $ref: '#/definitions/printf_annotation_obo' } 64 | mapping: "oboInOwl:hasBroadSynonym" 65 | xref: 66 | type: array 67 | items: { $ref: '#/definitions/printf_annotation_obo' } 68 | mapping: "oboInOwl:hasDbXref" 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/attic/spec/dosdp_tsv_schema.md: -------------------------------------------------------------------------------- 1 | This spec follows: https://www.w3.org/TR/tabular-metadata/ 2 | 3 | However, a complete spec in JSON is not possible given that most columns will be derived from variable names. 4 | 5 | Dialect Description is default apart from specifying tab as a separator. 6 | Doublequote may be used to escape whole cells but is not compulsory: 7 | 8 | ```json 9 | { 10 | "encoding": "utf-8", 11 | "lineTerminators": ["\r\n", "\n"], 12 | "quoteChar": "\"", 13 | "doubleQuote": true, 14 | "skipRows": 0, 15 | "commentPrefix": "#", 16 | "header": true, 17 | "headerRowCount": 1, 18 | "delimiter": "\t", 19 | "skipColumns": 0, 20 | "skipBlankRows": false, 21 | "skipInitialSpace": false, 22 | "trim": false 23 | } 24 | 25 | ``` 26 | 27 | Core spec 28 | 29 | ```json 30 | { 31 | "url": "dosdp.tsv", 32 | "dc:title": "DOSDP TSV", 33 | "dcat:keyword": ["OWL", "design pattern"], 34 | "dc:publisher": { 35 | "schema:name": "DOSDP TSV", 36 | "schema:url": {"@id": "https://github.com/dosumis/dead_simple_owl_design_patterns/new/master/spec/"} 37 | }, 38 | "dc:license": {"@id": "http://opendefinition.org/licenses/cc-by/"}, 39 | "dc:modified": {"@value": "2017-06-21", "@type": "xsd:date"}, 40 | "tableSchema": { 41 | "columns": [{ 42 | "name": "defined_class", 43 | "dc:description": "A curie that expands to an IRI for the class being defined", 44 | "datatype": "string", 45 | "required": true 46 | }, { 47 | "name": "defined_class_label", 48 | "dc:description": "The label derived using the pattern spec. This should be left blank", 49 | "datatype": "string", 50 | "required": false 51 | }, { 52 | "name": "overide_label", 53 | "dc:description": "A column which allows the pattern derived label to be overriden with a user defined one.", 54 | "datatype": "string", 55 | "required": false 56 | 57 | }, { 58 | "name": "overide_definition", 59 | "dc:description": "A column which allows the pattern derived label to be overriden with a user defined one.", 60 | "datatype": "string", 61 | "required": false 62 | }], 63 | "primaryKey": "defined_class" 64 | } 65 | } 66 | ``` 67 | 68 | Columns defined by pattern vars. The name is derived from the variable name (indicated by {}). `required : true` means that a column of this type must be present for each var/data_list_var specified in the pattern. 69 | 70 | 71 | ```json 72 | "columns": [{ 73 | "name": "{var}", 74 | "dc:description": "A curie that expands to an IRI for var in the pattern spec.", 75 | "datatype": "string", 76 | "required": true 77 | }, { 78 | "name": "{var} label", 79 | "dc:description": "The label of the OWL enti", 80 | "datatype": "string", 81 | "required": false 82 | }, { 83 | "name": "{data_list_var}", 84 | "dc:description": "A pipe delimited list of literals, whose type is defined by the data_list_var in the pattern.", 85 | "datatype": "string", 86 | "delimiter": "|", 87 | "required": true 88 | }] 89 | ``` 90 | -------------------------------------------------------------------------------- /src/attic/spec/draft/DOSDP_schema_OBO.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/attic/spec/draft/DOSDP_schema_OBO.yaml -------------------------------------------------------------------------------- /src/attic/spec/draft/DOSDP_schema_core.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/attic/spec/draft/DOSDP_schema_core.yaml -------------------------------------------------------------------------------- /src/attic/spec/test/cellPartOfAnatomicalEntity.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: cellPartOfAnatomicalEntity 2 | pattern_iri: http://purl.obolibrary.org/obo/cl/cellPartOfAnatomicalEntity 3 | 4 | description: A cell that is part of an anatomical entity. 5 | #examples: CL_0009001 compound eye retinal cell, CL_2000004 pituitary gland cell (654 total) 6 | 7 | contributors: 8 | - https://orcid.org/0000-0001-5208-3432 9 | - https://orcid.org/0000-0002-6601-2165 10 | 11 | classes: 12 | cell: "CL:0000000" 13 | anatomical entity: "UBERON:0001062" 14 | 15 | relations: 16 | part of: "BFO:0000050" 17 | 18 | vars: 19 | cell: "'cell'" 20 | anatomical_entity: "'anatomical entity'" 21 | 22 | name: 23 | text: "%s %s" 24 | vars: 25 | - cell 26 | - anatomical_entity 27 | 28 | def: 29 | text: "Any %s that is part of a %s." 30 | vars: 31 | - cell 32 | - anatomical_entity 33 | 34 | equivalentTo: 35 | text: "%s and ('part of' some %s)" 36 | vars: 37 | - cell 38 | - anatomical_entity 39 | -------------------------------------------------------------------------------- /src/attic/spec/test/test_positive.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | relations: 11 | transports or maintains localization of: RO_0002313 12 | has target start location: RO_0002338 13 | has target end location: RO_0002339 14 | results in transport across: RO_0002342 15 | imports: RO_0002340 16 | annotationProperties: 17 | label: "rdfs:label" 18 | definition: IAO_0000115 19 | 20 | readable_identifiers: 21 | - label 22 | 23 | vars: 24 | membrane: "'membrane'" 25 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 26 | start: "'cellular_component'" 27 | end: "'cellular_compomnent'" 28 | 29 | annotations: 30 | - 31 | annotationProperty: label 32 | text: "%s import across %s" 33 | vars: 34 | - cargo 35 | - membrane 36 | - 37 | annotationProperty: definition 38 | text: "The directed import of %s from %s, across the %s and into the %s." 39 | vars: 40 | - cargo 41 | - start 42 | - membrane 43 | - end 44 | 45 | logical_axioms: 46 | - 47 | axiom_type: equivalentTo 48 | text: > 49 | 'transport' 50 | and ('has target start location' some %s) 51 | and ('has target end location' some %s) 52 | and ('imports' some %s) 53 | and ('results in transport across' some %s) 54 | vars: 55 | - start 56 | - end 57 | - cargo 58 | - membrane 59 | -------------------------------------------------------------------------------- /src/attic/spec/test_schema.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | from jsonschema import Draft4Validator 3 | import warnings 4 | 5 | dosdp_full_file = open("DOSDP_schema_full.yaml", "r") 6 | dosdp = yaml.load(dosdp_full_file.read()) 7 | 8 | def test_jschema(validator, file_path): 9 | test_file = open(file_path, "r") 10 | test_pattern = yaml.load(test_file.read()) 11 | 12 | if not validator.is_valid(test_pattern): 13 | es = validator.iter_errors(test_pattern) 14 | for e in es: 15 | warnings.warn(str(e)) 16 | return False 17 | else: 18 | return True 19 | 20 | V = Draft4Validator(dosdp) 21 | stat = True 22 | 23 | # Test core - positive 24 | if not test_jschema(V, "test/test_positive.yaml"): stat = False 25 | # Test obo - positive 26 | if not test_jschema(V, "../patterns/import_across_membrane.yaml"): stat = False 27 | 28 | if not stat: 29 | sys.exit(1) 30 | 31 | 32 | 33 | # TODO - add some negative tests - designed to fail to test aspects of spec. 34 | 35 | -------------------------------------------------------------------------------- /src/dosdp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/dosdp/__init__.py -------------------------------------------------------------------------------- /src/dosdp/__main__.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import sys 3 | import pathlib 4 | import os 5 | import logging 6 | from dosdp import validator 7 | from dosdp.document import document 8 | 9 | logging.basicConfig(level=logging.INFO) 10 | 11 | 12 | def main(): 13 | parser = argparse.ArgumentParser(prog="dosdp", description='DOS-DP exchange format cli interface.') 14 | subparsers = parser.add_subparsers(help='Available dosdp actions', dest='action') 15 | 16 | parser_validate = subparsers.add_parser("validate", 17 | description="The validate parser", 18 | help="Validates given argument if it is a yaml/yaml file. If argument is a " 19 | "folder, validates all pattern files located in the given directory.") 20 | parser_validate.add_argument('-i', '--input', action='store', type=pathlib.Path, required=True) 21 | 22 | parser_document = subparsers.add_parser("document", add_help=False, 23 | description="The document generation parser", 24 | help="Generates documentation for the given YAML schema.") 25 | parser_document.add_argument('-s', '--schema', action='store_true') 26 | parser_document.add_argument('-i', '--input', action='store', type=pathlib.Path) 27 | parser_document.add_argument('-o', '--output', action='store', type=pathlib.Path) 28 | parser_document.add_argument('-d', '--data', action='store', type=pathlib.Path) 29 | 30 | args = parser.parse_args() 31 | 32 | if args.action == "validate": 33 | is_valid = validator.validate(str(args.input)) 34 | if not is_valid: 35 | sys.exit(1) 36 | elif args.action == "document": 37 | if 'schema' in args and args.schema: 38 | document.generate_schema_documentation(args.output) 39 | elif 'input' in args: 40 | document.generate_pattern_documentation(str(args.input), args.output, args.data) 41 | else: 42 | logging.error("Please use '--schema' to generate schema documentation " 43 | "or '--input' for pattern documentation.") 44 | 45 | 46 | if __name__ == "__main__": 47 | main() 48 | -------------------------------------------------------------------------------- /src/dosdp/document/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/dosdp/document/__init__.py -------------------------------------------------------------------------------- /src/dosdp/document/document.py: -------------------------------------------------------------------------------- 1 | import os 2 | import glob 3 | import logging 4 | from ruamel.yaml import YAML, YAMLError 5 | from dosdp.document.schema import schema_create_docs 6 | from dosdp.document.pattern import patterns_create_docs, patterns_create_overview 7 | 8 | 9 | logging.basicConfig(level=logging.INFO) 10 | 11 | 12 | def generate_schema_documentation(md_location=None): 13 | """ 14 | Generates md formatted documentation for the schema exists in the dosdp package. An output md_location can be 15 | optionally identified to specify documentation location or current folder is used by default. 16 | """ 17 | logging.info("Documenting dosdp schema.") 18 | if md_location is None: 19 | md_location = os.getcwd() 20 | 21 | schema_create_docs.generate_schema_documentation(md_output=md_location) 22 | 23 | 24 | def generate_pattern_documentation(yaml_location, md_location=None, sample_data_dir=None): 25 | """ 26 | Creates md formatted documentation for the given pattern file in the given location. 27 | 28 | Args: 29 | yaml_location: pattern file location 30 | md_location: If the yaml_location is a directory, expects md_location parameter to be a folder as well 31 | and creates documentation in it. If the yaml_location is a file, md_location can be a folder or file. 32 | If md_location is not given at all, documentation is generated next to the pattern file. 33 | sample_data_dir: Optional parameter for the sample date folder to read sample tabular data. 34 | """ 35 | logging.info("Documenting pattern file: " + yaml_location) 36 | if md_location is None: 37 | if yaml_location.endswith(".yaml"): 38 | md_location = str(yaml_location).split(".yaml")[0] + ".md" 39 | else: 40 | md_location = str(yaml_location).split(".yml")[0] + ".md" 41 | 42 | if os.path.isdir(yaml_location): 43 | if not yaml_location.endswith(os.path.sep): 44 | yaml_location += os.path.sep 45 | pattern_docs = glob.glob(yaml_location + "*.yaml") 46 | pattern_docs.extend(glob.glob(yaml_location + "*.yml")) 47 | if not os.path.isdir(md_location): 48 | logging.error("If input parameter is a folder, output parameter also should be a folder.", ) 49 | else: 50 | for pattern_doc in pattern_docs: 51 | create_indv_pattern_doc(pattern_doc, md_location, sample_data_dir) 52 | patterns_create_overview.create_overview(yaml_location, 53 | md_file=os.path.join(md_location, "overview.md"), 54 | matches_dir=sample_data_dir) 55 | elif yaml_location.endswith('.yaml') or yaml_location.endswith('.yml'): 56 | create_indv_pattern_doc(yaml_location, md_location, sample_data_dir) 57 | else: 58 | logging.error("Given path has unsupported file extension:", yaml_location) 59 | 60 | 61 | def create_indv_pattern_doc(yaml_location, md_location, sample_data_dir=None): 62 | if patterns_create_docs.is_dosdp_pattern_file(yaml_location): 63 | if os.path.isdir(md_location): 64 | file_name = os.path.basename(yaml_location) 65 | md_location = os.path.join(md_location, (os.path.splitext(file_name)[0] + ".md")) 66 | patterns_create_docs.generate_pattern_documentation(yaml_location, md_location, sample_data_dir) 67 | else: 68 | logging.warning("File is not a pattern file, skipping: " + yaml_location) 69 | -------------------------------------------------------------------------------- /src/dosdp/document/pattern/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/dosdp/document/pattern/__init__.py -------------------------------------------------------------------------------- /src/dosdp/document/pattern/patterns_create_docs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Created on Mon Oct 8 14:24:37 2018 4 | 5 | @author: Nicolas Matentzoglu 6 | """ 7 | 8 | from pathlib import Path 9 | import yaml 10 | import re 11 | import os 12 | import logging 13 | import pandas as pd 14 | from ruamel.yaml import YAML, YAMLError 15 | 16 | ROOT = Path(__file__).resolve().parent.parent.parent 17 | mkdocs_file = ROOT / "mkdocs.yml" 18 | pattern_files = (ROOT / "src/patterns/dosdp-patterns").glob("*.yaml") 19 | pattern_doc_dir = ROOT / "docs/editors-guide/patterns" 20 | # sample_data_dir = ROOT / "src/patterns/data/matches" 21 | pattern_matches_location_raw = "https://raw.githubusercontent.com/monarch-initiative/mondo/master/src/patterns/data/matches" 22 | pattern_matches_location_gh = "https://github.com/monarch-initiative/mondo/blob/master/src/patterns/data/matches" 23 | 24 | logging.basicConfig(level=logging.INFO) 25 | 26 | 27 | def curie_to_uri(curie): 28 | prefix, identifier = curie.split(":") 29 | if prefix == 'owl': 30 | return f"http://www.w3.org/2002/07/owl#{identifier}" 31 | elif prefix == 'oio': 32 | return f"http://www.geneontology.org/formats/oboInOwl#{identifier}" 33 | else: 34 | return f"http://purl.obolibrary.org/obo/{prefix}_{identifier}" 35 | 36 | 37 | def curie_to_link(curie): 38 | return f"[{curie}]({curie_to_uri(curie)})" 39 | 40 | 41 | def is_curie(s): 42 | return ":" in s 43 | 44 | 45 | def render_token(var, mapping, pattern): 46 | var_str = mapping[var] 47 | if is_curie(var_str): 48 | return f"[{var}]({curie_to_uri(var_str)})" 49 | # check format ''class'' 50 | p = re.compile(r"'([^']*)'") 51 | if p.match(var_str) and len(re.findall(r"'([^']*)'", var_str)) > 1: 52 | link_str = re.sub(r"'([^']*)'", lambda m: curie_to_link(pattern["classes"][m.group(1)]), var_str) 53 | return f"{var}\({link_str}\)" 54 | else: 55 | if p.match(var_str): 56 | link_str = re.sub(r"'([^']*)'", lambda m: curie_to_uri(pattern["classes"][m.group(1)]), var_str) 57 | else: 58 | link_str = curie_to_uri(pattern["classes"][var_str]) 59 | 60 | return f"[{var}]({link_str})" 61 | 62 | 63 | def render_equivalent(text, vars, pattern): 64 | ret = text % tuple("{" + render_token(var, pattern["vars"], pattern) + "}" for var in vars) 65 | mapping = {} 66 | mapping.update(pattern["classes"]) 67 | mapping.update(pattern["relations"]) 68 | p = re.compile(r"'[^']*'") 69 | ret = re.sub(r"'([^']*)'", lambda m: "[" + m.group(1) + "](" + curie_to_uri(mapping[m.group(1)]) + ")", ret) 70 | return ret 71 | 72 | 73 | def render_str(text, vars, pattern): 74 | ret = text % tuple("{" + render_token(var, pattern["vars"], pattern) + "}" for var in vars) 75 | return ret 76 | 77 | 78 | def generate_pattern_documentation(pattern_file, md_file_path, sample_data_dir=None): 79 | """ 80 | Creates md formatted documentation for the given pattern file in the given location. 81 | """ 82 | pattern_file = Path(pattern_file) 83 | md_file_path = Path(md_file_path) 84 | pattern = yaml.load(pattern_file.read_text(), Loader=yaml.FullLoader) 85 | 86 | logging.info("Target is: " + os.path.abspath(md_file_path)) 87 | with md_file_path.open("w") as fout: 88 | fout.write(f"# {pattern['pattern_name']} \n\n") 89 | fout.write(f"[{pattern['pattern_iri']}]({pattern['pattern_iri']})\n") 90 | fout.write("## Description \n\n") 91 | fout.write(pattern["description"].replace("\n", "\n\n") + "\n") 92 | if "contributors" in pattern: 93 | fout.write("## Contributors \n") 94 | for contributor in pattern["contributors"]: 95 | fout.write(f"* [{contributor}]({contributor}) \n") 96 | if "name" in pattern: 97 | fout.write("## Name \n\n") 98 | fout.write(render_str(pattern["name"]["text"], pattern["name"]["vars"], pattern)) 99 | fout.write("\n\n") 100 | if "annotations" in pattern: 101 | fout.write("## Annotations \n\n") 102 | for anno in pattern["annotations"]: 103 | fout.write("* ") 104 | fout.write( 105 | render_token(anno['annotationProperty'], pattern['annotationProperties'], pattern) + ": " + render_str( 106 | anno["text"], anno["vars"], pattern)) 107 | fout.write("\n\n") 108 | if "def" in pattern: 109 | fout.write("## Definition \n\n") 110 | fout.write(render_str(pattern["def"]["text"], pattern["def"]["vars"], pattern)) 111 | fout.write("\n\n") 112 | if "equivalentTo" in pattern: 113 | fout.write("## Equivalent to \n\n") 114 | fout.write(render_equivalent(pattern["equivalentTo"]["text"], pattern["equivalentTo"]["vars"], pattern)) 115 | fout.write("\n\n") 116 | 117 | # Create sample table 118 | sample_file = pattern_file.stem + ".tsv" 119 | if sample_data_dir is not None and Path(os.path.join(sample_data_dir, sample_file)).exists(): 120 | tsv_file = os.path.join(sample_data_dir, sample_file) 121 | examples = [] 122 | try: 123 | df = pd.read_csv(tsv_file, sep="\t") 124 | ghurl = f"{pattern_matches_location_gh}/{pattern_file.stem}.tsv" 125 | if not df.empty: 126 | examples.append('[mondo]({})'.format(ghurl)) 127 | example = ghurl 128 | dfh = df.head() 129 | sample_table = dfh.to_markdown(index=False) 130 | fout.write("## Data preview \n") 131 | oboiri = "http://purl.obolibrary.org/obo/" 132 | fout.write(re.sub(r"http://purl.obolibrary.org/obo/([^_]+)_([^\s]+)", 133 | lambda m: f"[{m.group(1)}:{m.group(2)}]({m.group(0)})", sample_table)) 134 | fout.write("\n\n") 135 | fout.write(f"See full table [here]({example}) \n") 136 | else: 137 | print("No matches!") 138 | except Exception as e: 139 | logging.error("Error processing the tsv file!", e) 140 | else: 141 | logging.warning("Data dir: '" + os.path.join(str(sample_data_dir), 142 | sample_file) + "' does not exist to provide sample data!") 143 | 144 | return pattern 145 | 146 | 147 | def is_dosdp_pattern_file(yaml_path): 148 | """ 149 | Checks if given file is a dosdp pattern file. 150 | 151 | Return: True if given file is a dosdp pattern file, otherwise False. 152 | """ 153 | is_dosdp_pattern = False 154 | ryaml = YAML(typ='safe') 155 | with open(yaml_path, "r") as stream: 156 | try: 157 | content = ryaml.load(stream) 158 | 159 | if "pattern_name" in content or "pattern_iri" in content: 160 | is_dosdp_pattern = True 161 | 162 | except YAMLError as exc: 163 | logging.error('Failed to load pattern file: ' + yaml_path) 164 | 165 | return is_dosdp_pattern 166 | 167 | # We might need to make changes to the mkdocs.yaml file 168 | # mkdocs_yaml = yaml.load(mkdocs_file.read_text(), Loader=yaml.FullLoader) 169 | 170 | # pattern_lst = [] 171 | # 172 | # for pattern_file in pattern_files: 173 | # pattern = generate_documentation(pattern_file) 174 | # pattern_lst.append((pattern_file.stem, pattern)) 175 | # 176 | # # create the index.md file 177 | # pattern_lst.sort(key=lambda x: x[1]['pattern_name'].lower()) 178 | # index_md_path = pattern_doc_dir / "index.md" 179 | # with index_md_path.open("w") as fout: 180 | # fout.write(f"# Design Patterns \n\n") 181 | # fout.write(f"\n") 182 | # fout.write("| Pattern | Description | \n") 183 | # fout.write("|:---|:---|\n") 184 | # for pattern_file_name, pattern in pattern_lst: 185 | # description = pattern['description'].replace("\n", "
") 186 | # description = re.sub(r"(http://purl[^\s]*\.[yaml|sparql]+)", lambda m: f"[{m.group(1).split('/')[-1]}]({m.group(1)})", description) 187 | # fout.write(f"| [{pattern['pattern_name']}]({pattern_file_name}/) | {description} | \n") 188 | -------------------------------------------------------------------------------- /src/dosdp/document/pattern/patterns_create_overview.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Mon Oct 8 14:24:37 2018 5 | 6 | @author: Nicolas Matentzoglu 7 | """ 8 | 9 | import os, sys 10 | import yaml 11 | import re 12 | import logging 13 | import pandas as pd 14 | from dosdp.document.pattern import patterns_create_docs as pattern_doc 15 | 16 | logging.basicConfig(level=logging.INFO) 17 | 18 | pattern_matches_location = "https://raw.githubusercontent.com/monarch-initiative/mondo/master/src/patterns/data/matches" 19 | pattern_matches_location_gh = "https://github.com/monarch-initiative/mondo/blob/master/src/patterns/data/matches" 20 | 21 | 22 | def create_overview(pattern_dirs, matches_dir=None, md_file=None): 23 | """ 24 | Creates an overview document for the pattern files located in the given folder. 25 | Args: 26 | pattern_dir: Director or directories (split by '|') that contains pattern files. 27 | matches_dir: Directory of pattern sample tsv files 28 | md_file: Overview document path. 29 | """ 30 | logging.info("Creating overview documentation.") 31 | lines = [] 32 | lines.append("# Pattern directory") 33 | lines.append("This is a listing of all the patterns hosted as part of this directory") 34 | lines.append("") 35 | i = 0 36 | for pattern_dir in pattern_dirs.split("|"): 37 | lines.append("## Patterns in {}".format(os.path.basename(pattern_dir))) 38 | files = os.listdir(pattern_dir) 39 | files.sort() 40 | 41 | for filename in files: 42 | logging.info("Processing %s" % filename) 43 | f_path = os.path.join(pattern_dir, filename) 44 | if filename.endswith(".yaml") and pattern_doc.is_dosdp_pattern_file(f_path): 45 | f = open(f_path) 46 | try: 47 | y = yaml.load(f, Loader=yaml.FullLoader) 48 | fn = os.path.basename(filename) 49 | splitted = " ".join( 50 | re.sub('([A-Z][a-z]+)', r' \1', re.sub('([A-Z]+)', r' \1', fn)).split()).replace( 51 | ".yaml", "") 52 | splitted = splitted.lower().capitalize() 53 | variables = "" 54 | classes = "" 55 | contributors = "" 56 | 57 | for v in y['vars']: 58 | # vs = re.sub("[^0-9a-zA-Z _]", "", y['vars'][v]) 59 | vsv = re.sub("[']", "", y['vars'][v]) 60 | variables = variables + v 61 | if vsv in y['classes']: 62 | variables = variables + " (" + y['classes'][vsv] + ")" 63 | variables = variables + ", " 64 | 65 | for v in y['classes']: 66 | cid = y['classes'][v] 67 | classes = classes + cid + ", " 68 | 69 | if 'contributors' in y: 70 | for v in y['contributors']: 71 | contributors = contributors + "[" + re.sub("https[:][/][/]orcid[.]org[/]", "", 72 | v) + "](" + v + "), " 73 | 74 | examples = [] 75 | fn_yaml = fn.replace(".yaml", ".tsv") 76 | url = "{}/{}".format(pattern_matches_location, fn_yaml) 77 | ghurl = "{}/{}".format(pattern_matches_location_gh, fn_yaml) 78 | sample_table = "" 79 | example = "" 80 | if matches_dir is not None and os.path.exists(os.path.join(matches_dir, fn_yaml)): 81 | tsv = os.path.join(matches_dir, fn_yaml) 82 | try: 83 | df = pd.read_csv(tsv, sep="\t") 84 | if not df.empty: 85 | examples.append('[mondo]({})'.format(ghurl)) 86 | example = '{}'.format(ghurl) 87 | dfh = df.head() 88 | sample_table = dfh.to_markdown(index=False) 89 | i = i + 1 90 | else: 91 | logging.warning("No matches for overview!") 92 | except Exception as e: 93 | logging.error("No matches for overview!", e) 94 | else: 95 | logging.warning(str(matches_dir) + "/" + fn_yaml + " does not exist!") 96 | 97 | lines.append("### " + splitted.replace("_", " ")) 98 | lines.append("*" + y['description'].strip() + "*") 99 | lines.append("") 100 | lines.append("| Attribute | Info |") 101 | lines.append("|----------|----------|") 102 | lines.append("| IRI | " + y['pattern_iri'] + " |") 103 | lines.append("| Name | " + y['pattern_name'] + " |") 104 | lines.append("| Classes | " + classes + " |") 105 | lines.append("| Variables | " + variables + " |") 106 | lines.append("| Contributors | " + contributors + " |") 107 | lines.append("| Examples | " + ' '.join(examples) + " |") 108 | lines.append("") 109 | if sample_table: 110 | lines.append("#### Data preview: ") 111 | oboiri = "http://purl.obolibrary.org/obo/" 112 | lines.append(sample_table.replace(oboiri, "").replace("_", ":")) 113 | lines.append("") 114 | lines.append("See full table [here]({})".format(example)) 115 | 116 | f.close() 117 | except yaml.YAMLError as exc: 118 | f.close() 119 | logging.error("Error occurred while processing yaml!", exc) 120 | 121 | with open(md_file, 'w') as f: 122 | for item in lines: 123 | f.write("%s\n" % item) 124 | 125 | logging.info("Overview documentation created: " + str(md_file)) 126 | 127 | 128 | -------------------------------------------------------------------------------- /src/dosdp/document/schema/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/dosdp/document/schema/__init__.py -------------------------------------------------------------------------------- /src/dosdp/validator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import glob 3 | import re 4 | import warnings 5 | import os 6 | import logging 7 | from jsonschema import Draft7Validator 8 | from jsonpath_rw import parse 9 | from ruamel.yaml import YAML, YAMLError 10 | 11 | SCHEMA_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../schema/dosdp_schema.yaml") 12 | 13 | logging.basicConfig(level=logging.INFO) 14 | 15 | 16 | def test_jschema(validator, pattern): 17 | """ 18 | Validates if given schema is a valid json schema. 19 | Args: 20 | validator: sjon schema validator 21 | pattern: schema in yaml format to validate 22 | 23 | Returns: True if schema is valid, False otherwise. 24 | """ 25 | is_valid = True 26 | 27 | if not validator.is_valid(pattern): 28 | es = validator.iter_errors(pattern) 29 | for e in es: 30 | warnings.warn(str(e.message)) 31 | is_valid = False 32 | 33 | return is_valid 34 | 35 | 36 | def test_vars(pattern): 37 | """ 38 | Tests whether variable names in any field with key 'vars' is in the vars list for the pattern 39 | Args: 40 | pattern: schema in yaml format to validate 41 | 42 | Returns: True if schema vars are valid, False otherwise. 43 | """ 44 | if 'vars' in pattern.keys(): 45 | vars = set(pattern['vars'].keys()) 46 | else: 47 | warnings.warn("Pattern has no vars") 48 | return True ## If this is to be compulsory, should be spec'd as such in json_schema 49 | if 'list_vars' in pattern.keys(): 50 | vars.update(set(pattern['list_vars'].keys())) 51 | if 'data_vars' in pattern.keys(): 52 | vars.update(set(pattern['data_vars'].keys())) 53 | if 'data_list_vars' in pattern.keys(): 54 | vars.update(set(pattern['data_list_vars'].keys())) 55 | if 'substitutions' in pattern.keys(): 56 | subvars = [X['out'] for X in pattern['substitutions']] 57 | vars.update(set(subvars)) 58 | if 'internal_vars' in pattern.keys(): 59 | internal_vars = [X['var_name'] for X in pattern['internal_vars']] 60 | vars.update(set(internal_vars)) 61 | expr = parse('*..vars') 62 | var_fields = [match for match in expr.find(pattern)] 63 | stat = True 64 | if var_fields: 65 | for field in var_fields: 66 | val = set(field.value) 67 | if not vars.issuperset(val): 68 | warnings.warn("%s has values (%s) not found in pattern variable list (%s): " 69 | % (field.full_path, str(val.difference(vars)), str(vars))) 70 | stat = False 71 | else: 72 | warnings.warn("Pattern has no var fields") 73 | return stat 74 | 75 | 76 | def test_text_fields(pattern): 77 | """ 78 | Structurally tests whether quotations match and declared values exist in owl entity dictionaries. 79 | Args: 80 | pattern: schema in yaml format to validate 81 | 82 | Returns: True if schema text fields are valid, False otherwise. 83 | """ 84 | owl_entities = set() 85 | if 'classes' in pattern.keys(): owl_entities.update(set(pattern['classes'].keys())) 86 | if 'relations' in pattern.keys(): owl_entities.update(set(pattern['relations'].keys())) 87 | expr = parse('logical_axioms.[*].text') 88 | ms_fields = [match for match in expr.find(pattern)] 89 | expr = parse('logical_axioms.[*].multi_clause.clauses.[*].text') 90 | ms_fields.extend(match for match in expr.find(pattern)) 91 | expr = parse('equivalentTo|subClassOf|GCI|disjointWith.text') 92 | ms_fields.extend([match for match in expr.find(pattern)]) 93 | expr = parse('equivalentTo|subClassOf|GCI|disjointWith.multi_clause.clauses.[*].text') 94 | ms_fields.extend([match for match in expr.find(pattern)]) 95 | stat=True 96 | if ms_fields: 97 | for field in ms_fields: 98 | # Test for even number single quotes 99 | val = field.value 100 | m = re.findall("'", val) 101 | if divmod(len(m), 2)[1]: 102 | warnings.warn("text field '%s' has an odd number of single quotes." % val) 103 | stat = False 104 | # Test that single quoted strings are OWL entities in dict. 105 | m = re.findall("'(.+?)'", val) 106 | quoted = set(m) 107 | if not owl_entities.issuperset(quoted): 108 | warnings.warn("%s has values (%s) not found in owl entity dictionaries t (%s): " 109 | % (field.full_path, str(quoted.difference(owl_entities)), str(owl_entities))) 110 | stat = False 111 | else: 112 | warnings.warn("Pattern has no text fields") 113 | return stat 114 | 115 | 116 | def test_clause_nesting(pattern): 117 | """ 118 | Structurally tests that logical axioms and annotations don't use nested multi_clause structures. 119 | Only one level of multi_clause allowed (clauses of the multi_clause cannot have sub_clauses). 120 | Args: 121 | pattern: schema in yaml format to validate 122 | 123 | Returns: True if multi_clause nesting is valid, False otherwise. 124 | """ 125 | expr = parse('logical_axioms.[*].multi_clause.clauses.[*].sub_clauses') 126 | ms_fields = [match for match in expr.find(pattern)] 127 | expr = parse('equivalentTo|subClassOf|GCI|disjointWith.multi_clause.clauses.[*].sub_clauses') 128 | ms_fields.extend([match for match in expr.find(pattern)]) 129 | 130 | stat = True 131 | if ms_fields: 132 | stat = False 133 | warnings.warn("Detected multi_clause nesting in expressions. " 134 | "Logical axioms and annotations cannot have sub_clauses.") 135 | return stat 136 | 137 | 138 | def test_axiom_separator(pattern): 139 | """ 140 | Structurally tests that logical axioms can only have ' and ' and ' or ' as value. 141 | Args: 142 | pattern: schema in yaml format to validate 143 | 144 | Returns: True if axiom separators are valid, False otherwise. 145 | """ 146 | expr = parse('logical_axioms.[*].multi_clause.sep') 147 | ms_fields = [match for match in expr.find(pattern)] 148 | expr = parse('equivalentTo|subClassOf|GCI|disjointWith.multi_clause.sep') 149 | ms_fields.extend([match for match in expr.find(pattern)]) 150 | 151 | stat = True 152 | if ms_fields: 153 | for field in ms_fields: 154 | val = field.value 155 | if val != " and " and val != " or ": 156 | warnings.warn("Logical axioms can only have ' and ' and ' or ' as value. '%s' is not a valid value." % val) 157 | stat = False 158 | return stat 159 | 160 | 161 | def test_multi_clause_multi_list(pattern): 162 | """ 163 | Multi_clauses can have at most one list variable. 164 | Args: 165 | pattern: schema in yaml format to validate 166 | 167 | Returns: True if multi_clause list variable usage is valid, False otherwise. 168 | """ 169 | list_vars = set() 170 | if 'list_vars' in pattern.keys(): 171 | list_vars.update(pattern['list_vars'].keys()) 172 | if 'data_list_vars' in pattern.keys(): 173 | list_vars.update(set(pattern['data_list_vars'].keys())) 174 | 175 | expr = parse('$..multi_clause') 176 | multi_clause_matches = [match for match in expr.find(pattern)] 177 | multi_clauses = [str(i.full_path) for i in multi_clause_matches] 178 | 179 | mc_vars = {} 180 | for mc in multi_clauses: 181 | mc_vars[mc] = list() 182 | 183 | expr = parse('$..multi_clause..vars') 184 | var_fields = [match for match in expr.find(pattern)] 185 | 186 | for field in var_fields: 187 | var_path = str(field.full_path) 188 | parent_mc = str(var_path[0: (var_path.find("multi_clause") + len("multi_clause"))]) 189 | new_list = list(mc_vars[parent_mc]) 190 | new_list.extend(list(field.value)) 191 | mc_vars[parent_mc] = new_list 192 | 193 | stat = True 194 | for mc_var in mc_vars: 195 | list_references = [var for var in mc_vars[mc_var] if var in list_vars] 196 | if len(list_references) > 1: 197 | warnings.warn("Multi_clauses can have at most one list variable. But has multiple list references: %s" 198 | % str(list_references)) 199 | stat = False 200 | return stat 201 | 202 | 203 | def test_annotation_properties(pattern): 204 | """ 205 | Structurally tests whether an annotation property is declared before use. 206 | Args: 207 | pattern: schema in yaml format to validate 208 | 209 | Returns: True if all used annotation properties are declared, False otherwise. 210 | """ 211 | declared_annotations = set() 212 | if 'annotationProperties' in pattern.keys(): declared_annotations.update(set(pattern['annotationProperties'].keys())) 213 | expr = parse('annotations.[*].annotationProperty') 214 | used_annotations = [match for match in expr.find(pattern)] 215 | 216 | stat = True 217 | if used_annotations: 218 | for annotation_prop in used_annotations: 219 | val = annotation_prop.value 220 | if val not in declared_annotations: 221 | warnings.warn("Annotation property '%s' didn't declared before use." % val) 222 | stat = False 223 | return stat 224 | 225 | 226 | def format_warning(message, category, filename, lineno, line=None): 227 | return '%s:%s: %s:%s\n' % (filename, lineno, category.__name__, message) 228 | 229 | 230 | def validate(pattern): 231 | """ 232 | If given parameter is a yaml/yaml file, validates it. If parameter is a folder, validates all pattern files located 233 | in the given path. 234 | Args: 235 | pattern: path to a yaml file or path to directory with pattern files in yaml. Files must have the extension .yaml or .yml. 236 | All files in directory with these extensions are assumed to be dosdp pattern files. 237 | 238 | Returns: True if patterns are valid, False otherwise. 239 | """ 240 | schema_path = SCHEMA_PATH 241 | ryaml = YAML(typ='safe') 242 | 243 | dosdp = None 244 | with open(schema_path) as stream: 245 | try: 246 | dosdp = ryaml.load(stream) 247 | except YAMLError as exc: 248 | logging.error('Failed to open dosdp schema: ' + schema_path) 249 | 250 | validator = Draft7Validator(dosdp) 251 | 252 | warnings.formatwarning = format_warning 253 | if os.path.isdir(pattern): 254 | if not pattern.endswith(os.path.sep): 255 | pattern += os.path.sep 256 | pattern_docs = glob.glob(pattern + "*.yaml") 257 | pattern_docs.extend(glob.glob(pattern + "*.yml")) 258 | elif pattern.endswith('.yaml') or pattern.endswith('.yaml'): 259 | pattern_docs = [os.path.abspath(pattern)] 260 | else: 261 | logging.error("Given path has unsupported file extension.", ) 262 | 263 | stat = True 264 | for pattern_doc in pattern_docs: 265 | if len(pattern_docs) > 1: 266 | logging.info("Checking %s" % pattern_doc) 267 | with open(pattern_doc, "r") as stream: 268 | try: 269 | pattern = ryaml.load(stream) 270 | if not test_jschema(validator, pattern): stat = False 271 | if not test_vars(pattern): stat = False 272 | if not test_text_fields(pattern): stat = False 273 | if not test_clause_nesting(pattern): stat = False 274 | if not test_axiom_separator(pattern): stat = False 275 | if not test_multi_clause_multi_list(pattern): stat = False 276 | if not test_annotation_properties(pattern): stat = False 277 | except YAMLError as exc: 278 | stat = False 279 | logging.error('Failed to load pattern file: ' + pattern_doc) 280 | except AttributeError as exc: 281 | stat = False 282 | logging.error('Unexpected pattern file content: ' + pattern_doc) 283 | logging.error(exc) 284 | if stat: 285 | logging.info("Validation completed without any issues to report.") 286 | else: 287 | logging.info("Validation completed with issues to be fixed.") 288 | 289 | return stat 290 | -------------------------------------------------------------------------------- /src/json_yaml_tools.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | import json 3 | 4 | def load_yaml_from_file(filePath): 5 | f = open(filePath, "r") 6 | y = yaml.load(f) 7 | f.close() 8 | return y 9 | 10 | def load_json_from_file(path): 11 | json_file = open(path, "r") 12 | json_string = json_file.read() 13 | json_file.close() 14 | return json.loads(json_string) 15 | 16 | def yaml2json(YamlFilePath, JsonFilePath): 17 | """Convert YAML file to JSON file""" 18 | pdm = load_yaml_from_file(YamlFilePath) 19 | j = open(JsonFilePath, "w") 20 | j.write(json.dumps(pdm, sort_keys=True, indent=4)) 21 | j.close() 22 | 23 | def json2yaml(JsonFilePath, YamlFilePath): 24 | pdm = load_json_from_file(JsonFilePath) 25 | y = open(YamlFilePath, "w") 26 | y.write(yaml.dumps(pdm)) 27 | 28 | -------------------------------------------------------------------------------- /src/schema/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/schema/__init__.py -------------------------------------------------------------------------------- /src/schema/dosdp_schema_doc.ini: -------------------------------------------------------------------------------- 1 | [root] 2 | title = Properties 3 | description = 4 | 5 | [owl_entity_dict] 6 | title = OWL Entity Dictionaries 7 | description = 8 | 9 | [var_types] 10 | title = Var Types 11 | description = 12 | 13 | [var_munging] 14 | title = Var Munging 15 | description = 16 | 17 | [axioms] 18 | title = Axioms 19 | description = 20 | 21 | [convenience] 22 | title = Logical Convenience Fields 23 | description = Where only one of any OWL axiom type is present, these convenience fields may be used. 24 | 25 | [obo] 26 | title = OBO fields 27 | description = 28 | 29 | [instance_graph] 30 | title = Instance Graph Spec 31 | description = -------------------------------------------------------------------------------- /src/schema/schema_validator.py: -------------------------------------------------------------------------------- 1 | import os 2 | from ruamel.yaml import YAML 3 | from jsonschema import Draft7Validator 4 | 5 | SCHEMA_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../schema/dosdp_schema.yaml") 6 | 7 | 8 | ryaml = YAML(typ='safe') 9 | with open(SCHEMA_PATH) as stream: 10 | dosdp_schema = ryaml.load(stream) 11 | 12 | Draft7Validator.check_schema(dosdp_schema) 13 | -------------------------------------------------------------------------------- /src/schema/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/schema/test/__init__.py -------------------------------------------------------------------------------- /src/schema/test/generic_test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/schema/test/generic_test/__init__.py -------------------------------------------------------------------------------- /src/schema/test/generic_test/document_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | from dosdp.document.schema import schema_create_docs 4 | from dosdp.document.pattern import patterns_create_docs as pattern_doc 5 | from dosdp.document import document 6 | 7 | 8 | class DocumentGenerationCase(unittest.TestCase): 9 | 10 | def tearDown(self): 11 | """ 12 | Delete files generated during tests 13 | """ 14 | if os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 15 | "../positive_test_set/patterns/data/acute.md")): 16 | os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), 17 | "../positive_test_set/patterns/data/acute.md")) 18 | 19 | if os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 20 | "../positive_test_set/patterns/data/acute2.md")): 21 | os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), 22 | "../positive_test_set/patterns/data/acute2.md")) 23 | 24 | if os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 25 | "../positive_test_set/patterns/data/generated/acute.md")): 26 | os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), 27 | "../positive_test_set/patterns/data/generated/acute.md")) 28 | 29 | if os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 30 | "../positive_test_set/patterns/data/generated/acute2.md")): 31 | os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), 32 | "../positive_test_set/patterns/data/generated/acute2.md")) 33 | 34 | if os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 35 | "../positive_test_set/patterns/data/generated/overview.md")): 36 | os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), 37 | "../positive_test_set/patterns/data/generated/overview.md")) 38 | 39 | if os.path.exists(os.path.join(os.getcwd(), "./dosdp_schema.md")): 40 | os.remove(os.path.join(os.getcwd(), "./dosdp_schema.md")) 41 | 42 | if os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 43 | "../positive_test_set/patterns/data/generated/schema.md")): 44 | os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), 45 | "../positive_test_set/patterns/data/generated/schema.md")) 46 | 47 | def test_mapping_definition_search(self): 48 | mappings = schema_create_docs.find_mapping_definitions() 49 | 50 | self.assertTrue("printf_annotation_obo$xrefs" in mappings.keys()) 51 | self.assertEqual("oboInOwl:hasDbXref", mappings["printf_annotation_obo$xrefs"]) 52 | 53 | self.assertTrue("name" in mappings.keys()) 54 | self.assertEqual("rdfs:label", mappings["name"]) 55 | 56 | self.assertTrue("generated_narrow_synonyms$items" in mappings.keys()) 57 | self.assertEqual("oboInOwl:hasNarrowSynonym", mappings["generated_narrow_synonyms$items"]) 58 | 59 | self.assertTrue("generated_synonyms$items" in mappings.keys()) 60 | self.assertEqual("oboInOwl:hasExactSynonym", mappings["generated_synonyms$items"]) 61 | 62 | def test_is_schema(self): 63 | self.assertTrue(pattern_doc.is_dosdp_pattern_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), 64 | "../positive_test_set/patterns/anchored_membrane_component.yaml"))) 65 | self.assertFalse(pattern_doc.is_dosdp_pattern_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), 66 | "../../dosdp_schema.yaml"))) 67 | self.assertTrue(pattern_doc.is_dosdp_pattern_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), 68 | "../positive_test_set/patterns/expression_pattern.yaml"))) 69 | self.assertFalse(pattern_doc.is_dosdp_pattern_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), 70 | "../negative_test_set/dummy.yaml"))) 71 | 72 | def test_pattern_interface_single_param(self): 73 | document.generate_pattern_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 74 | "../positive_test_set/patterns/data/acute.yaml")) 75 | self.assertTrue(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 76 | "../positive_test_set/patterns/data/acute.md"))) 77 | 78 | def test_pattern_interface_two_param(self): 79 | document.generate_pattern_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 80 | "../positive_test_set/patterns/data/acute.yaml"), 81 | os.path.join(os.path.dirname(os.path.realpath(__file__)), 82 | "../positive_test_set/patterns/data/acute2.md")) 83 | self.assertTrue(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 84 | "../positive_test_set/patterns/data/acute2.md"))) 85 | 86 | self.assertFalse(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 87 | "../positive_test_set/patterns/data/overview.md"))) 88 | 89 | def test_pattern_interface_folder_input(self): 90 | document.generate_pattern_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 91 | "../positive_test_set/patterns/data/"), 92 | os.path.join(os.path.dirname(os.path.realpath(__file__)), 93 | "../positive_test_set/patterns/data/generated")) 94 | self.assertTrue(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 95 | "../positive_test_set/patterns/data/generated/acute.md"))) 96 | self.assertTrue(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 97 | "../positive_test_set/patterns/data/generated/acute2.md"))) 98 | self.assertFalse(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 99 | "../positive_test_set/patterns/data/generated/dummy.md"))) 100 | 101 | def test_pattern_interface_non_pattern(self): 102 | document.generate_pattern_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 103 | "../positive_test_set/patterns/data/dummy.yaml")) 104 | self.assertFalse(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 105 | "./dummy.md"))) 106 | 107 | def test_pattern_interface_folder_none_params(self): 108 | document.generate_pattern_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 109 | "../positive_test_set/patterns/data/")) 110 | self.assertFalse(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 111 | "../positive_test_set/patterns/data/generated/acute.md"))) 112 | 113 | def test_patterns_interface_overview(self): 114 | document.generate_pattern_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 115 | "../positive_test_set/patterns/data/"), 116 | os.path.join(os.path.dirname(os.path.realpath(__file__)), 117 | "../positive_test_set/patterns/data/generated")) 118 | 119 | self.assertTrue(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 120 | "../positive_test_set/patterns/data/generated/overview.md"))) 121 | 122 | def test_pattern_interface_with_sample_data(self): 123 | document.generate_pattern_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 124 | "../positive_test_set/patterns/data/acute.yaml"), 125 | md_location=os.path.join(os.path.dirname(os.path.realpath(__file__)), 126 | "../positive_test_set/patterns/data/acute.md"), 127 | sample_data_dir=os.path.join(os.path.dirname(os.path.realpath(__file__)), 128 | "../positive_test_set/patterns/data/sample_data")) 129 | self.assertFalse(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 130 | "../positive_test_set/patterns/data/generated/acute.md"))) 131 | 132 | def test_pattern_interface_folder_with_sample_data(self): 133 | document.generate_pattern_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 134 | "../positive_test_set/patterns/data/"), 135 | os.path.join(os.path.dirname(os.path.realpath(__file__)), 136 | "../positive_test_set/patterns/data/generated"), 137 | sample_data_dir=os.path.join(os.path.dirname(os.path.realpath(__file__)), 138 | "../positive_test_set/patterns/data/sample_data")) 139 | self.assertTrue(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 140 | "../positive_test_set/patterns/data/generated/acute.md"))) 141 | self.assertTrue(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 142 | "../positive_test_set/patterns/data/generated/acute2.md"))) 143 | self.assertFalse(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 144 | "../positive_test_set/patterns/data/generated/dummy.md"))) 145 | 146 | def test_schema_interface(self): 147 | document.generate_schema_documentation() 148 | self.assertTrue(os.path.exists(os.path.join(os.getcwd(), "./dosdp_schema.md"))) 149 | 150 | def test_schema_interface_single_param(self): 151 | document.generate_schema_documentation(os.path.join(os.path.dirname(os.path.realpath(__file__)), 152 | "../positive_test_set/patterns/data/generated/schema.md")) 153 | self.assertTrue(os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 154 | "../positive_test_set/patterns/data/generated/schema.md"))) 155 | 156 | 157 | if __name__ == '__main__': 158 | unittest.main() 159 | -------------------------------------------------------------------------------- /src/schema/test/generic_test/schema_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | import pathlib 4 | from ruamel.yaml import YAML, YAMLError 5 | from jsonschema import Draft4Validator 6 | 7 | SCHEMA = os.path.join(os.path.dirname(os.path.realpath(__file__)), 8 | "../../dosdp_schema.yaml") 9 | POSITIVE_PATTERN_1 = os.path.join(os.path.dirname(os.path.realpath(__file__)), 10 | "../positive_test_set/patterns/acute.yaml") 11 | POSITIVE_PATTERN_2 = os.path.join(os.path.dirname(os.path.realpath(__file__)), 12 | "../positive_test_set/patterns/multi_clause_schema.yaml") 13 | POSITIVE_PATTERN_3 = os.path.join(os.path.dirname(os.path.realpath(__file__)), 14 | "../positive_test_set/patterns/abnormallyHyperplasticAnatomicalEntity.yaml") 15 | NEGATIVE_PATTERN_1 = os.path.join(os.path.dirname(os.path.realpath(__file__)), 16 | "../negative_test_set/acute_negative.yaml") 17 | 18 | 19 | def show_errors(pattern, validator): 20 | es = validator.iter_errors(pattern) 21 | for e in es: 22 | print(" => ".join([str(e.schema_path), str(e.message), str(e.context)])) 23 | 24 | 25 | class SchemaValidationTests(unittest.TestCase): 26 | 27 | def test_schema_validity1(self): 28 | self.assertTrue(pathlib.Path(SCHEMA).exists()) 29 | 30 | validator = Draft4Validator(self.read_yaml(SCHEMA)) 31 | 32 | ## self.show_errors(pattern, validator) 33 | self.assertTrue(validator.is_valid(self.read_yaml(POSITIVE_PATTERN_1))) 34 | self.assertTrue(validator.is_valid(self.read_yaml(POSITIVE_PATTERN_2))) 35 | 36 | negative_pattern_1 = self.read_yaml(NEGATIVE_PATTERN_1) 37 | self.assertFalse(validator.is_valid(negative_pattern_1)) 38 | es = validator.iter_errors(negative_pattern_1) 39 | 40 | # failing because def does not have a text 41 | self.assertEqual("{'vars': ['disease']} is not valid under any of the given schemas", next(es).message) 42 | 43 | def test_array_validity(self): 44 | self.assertTrue(pathlib.Path(SCHEMA).exists()) 45 | 46 | validator = Draft4Validator(self.read_yaml(SCHEMA)) 47 | 48 | self.assertTrue(validator.is_valid(self.read_yaml(POSITIVE_PATTERN_3))) 49 | 50 | def read_yaml(self, yaml_path): 51 | with open(yaml_path, "r") as stream: 52 | try: 53 | yaml_file = YAML(typ='safe').load(stream) 54 | except YAMLError as exc: 55 | self.fail("Yaml read failed:"+yaml_path) 56 | return yaml_file 57 | 58 | -------------------------------------------------------------------------------- /src/schema/test/generic_test/test_suite.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | loader = unittest.TestLoader() 4 | suite = loader.discover(start_dir='./', pattern='*_test.py') 5 | 6 | runner = unittest.TextTestRunner() 7 | runner.run(suite) 8 | -------------------------------------------------------------------------------- /src/schema/test/generic_test/validator_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | 4 | 5 | from dosdp.validator import validate 6 | 7 | POSITIVE_PATTERNS_FOLDER = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../positive_test_set/patterns") 8 | POSITIVE_PATTERN_1 = os.path.join(os.path.dirname(os.path.realpath(__file__)), 9 | "../positive_test_set/export_across_membrane.yaml") 10 | 11 | NEGATIVE_PATTERN_INDENTATION = os.path.join(os.path.dirname(os.path.realpath(__file__)), 12 | "../negative_test_set/wrong_indentation.yaml") 13 | NEGATIVE_PATTERN_QUOTES = os.path.join(os.path.dirname(os.path.realpath(__file__)), 14 | "../negative_test_set/quotes_miss_match.yaml") 15 | NEGATIVE_PATTERN_UNDECLARED_VAR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 16 | "../negative_test_set/undeclared_var.yaml") 17 | NEGATIVE_PATTERN_UNDECLARED_CLASS = os.path.join(os.path.dirname(os.path.realpath(__file__)), 18 | "../negative_test_set/undeclared_class.yaml") 19 | NEGATIVE_PATTERN_UNDECLARED_REL = os.path.join(os.path.dirname(os.path.realpath(__file__)), 20 | "../negative_test_set/undeclared_relation.yaml") 21 | NEGATIVE_PATTERN_UNDECLARED_REL_MC = os.path.join(os.path.dirname(os.path.realpath(__file__)), 22 | "../negative_test_set/undeclared_relation_multi_clause.yaml") 23 | NEGATIVE_PATTERN_AXIOM_CLAUSE_NESTING = os.path.join(os.path.dirname(os.path.realpath(__file__)), 24 | "../negative_test_set/axiom_multi_clause_nesting.yaml") 25 | NEGATIVE_PATTERN_AXIOM_SEPARATOR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 26 | "../negative_test_set/axiom_separator.yaml") 27 | NEGATIVE_PATTERN_MULTI_CLAUSE_MULTI_LIST = os.path.join(os.path.dirname(os.path.realpath(__file__)), 28 | "../negative_test_set/multi_clause_with_multi_list.yaml") 29 | NEGATIVE_PATTERN_MULTI_CLAUSE_MULTI_LIST2 = os.path.join(os.path.dirname(os.path.realpath(__file__)), 30 | "../negative_test_set/multi_clause_with_multi_list2.yaml") 31 | NEGATIVE_PATTERN_UNDECLARED_ANNOT_PROP = os.path.join(os.path.dirname(os.path.realpath(__file__)), 32 | "../negative_test_set/undeclared_annotation_prop.yaml") 33 | NEGATIVE_PATTERN_SCHEMA = os.path.join(os.path.dirname(os.path.realpath(__file__)), 34 | "../negative_test_set/not_schema_compliant.yaml") 35 | 36 | 37 | class ValidatorTest(unittest.TestCase): 38 | 39 | def test_positive_folder(self): 40 | self.assertTrue(validate(POSITIVE_PATTERNS_FOLDER)) 41 | 42 | def test_positive_file(self): 43 | self.assertTrue(validate(POSITIVE_PATTERN_1)) 44 | 45 | def test_wrong_indentation(self): 46 | self.assertFalse(validate(NEGATIVE_PATTERN_INDENTATION)) 47 | 48 | def test_undeclared_var(self): 49 | self.assertFalse(validate(NEGATIVE_PATTERN_UNDECLARED_VAR)) 50 | 51 | def test_undeclared_class(self): 52 | self.assertFalse(validate(NEGATIVE_PATTERN_UNDECLARED_CLASS)) 53 | 54 | def test_undeclared_relation(self): 55 | self.assertFalse(validate(NEGATIVE_PATTERN_UNDECLARED_REL)) 56 | self.assertFalse(validate(NEGATIVE_PATTERN_UNDECLARED_REL_MC)) 57 | 58 | def test_axiom_clause_nesting(self): 59 | self.assertFalse(validate(NEGATIVE_PATTERN_AXIOM_CLAUSE_NESTING)) 60 | 61 | def test_axiom_separator(self): 62 | self.assertFalse(validate(NEGATIVE_PATTERN_AXIOM_SEPARATOR)) 63 | 64 | def test_single_list_per_multi_clause(self): 65 | self.assertFalse(validate(NEGATIVE_PATTERN_MULTI_CLAUSE_MULTI_LIST)) 66 | self.assertFalse(validate(NEGATIVE_PATTERN_MULTI_CLAUSE_MULTI_LIST2)) 67 | 68 | def test_undeclared_annotation_prop(self): 69 | self.assertFalse(validate(NEGATIVE_PATTERN_UNDECLARED_ANNOT_PROP)) 70 | 71 | def test_schema_validation(self): 72 | self.assertFalse(validate(NEGATIVE_PATTERN_SCHEMA)) 73 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/schema/test/negative_test_set/__init__.py -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/acute_negative.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: acute 2 | 3 | pattern_iri: http://purl.obolibrary.org/obo/mondo/patterns/acute.yaml 4 | 5 | description: 'This pattern is applied to diseases that are described as having an acute onset, i.e. the sudden appearance of disease manifestations over a short period of time. 6 | 7 | Examples: [acute bronchiolitis](http://purl.obolibrary.org/obo/MONDO_0020680), 8 | [acute liver failure](http://purl.obolibrary.org/obo/MONDO_0019542)' 9 | 10 | contributors: 11 | - https://orcid.org/0000-0002-6601-2165 12 | - https://orcid.org/0000-0001-5208-3432 13 | 14 | classes: 15 | acute: PATO:0000389 16 | disease: MONDO:0000001 17 | 18 | relations: 19 | has modifier: RO:0002573 20 | 21 | annotationProperties: 22 | exact_synonym: oio:hasExactSynonym 23 | related_synonym: oio:hasRelatedSynonym 24 | 25 | vars: 26 | disease: '''disease''' 27 | 28 | name: 29 | text: acute %s 30 | vars: 31 | - disease 32 | 33 | annotations: 34 | - annotationProperty: exact_synonym 35 | text: '%s, acute' 36 | vars: 37 | - disease 38 | 39 | # failing because 40 | #oneOf: 41 | # - required: [text, vars] 42 | # - required: [multi_clause] 43 | def: 44 | vars: 45 | - disease 46 | 47 | equivalentTo: 48 | text: '%s and ''has modifier'' some ''acute''' 49 | vars: 50 | - disease -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/axiom_multi_clause_nesting.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: brainCellClasses 2 | pattern_iri: http://purl.obolibrary.org/obo/odk/brainCellClasses.yaml 3 | description: "Class template for BDS." 4 | 5 | classes: 6 | "cell": "CL:0000000" 7 | "thing": "owl:Thing" 8 | 9 | relations: 10 | expresses: "RO:0002292" 11 | 12 | annotationProperties: 13 | hasExactSynonym: "oboInOwl:hasExactSynonym" 14 | rdfsComment: "rdfs:comment" 15 | hasDbXref: "oboInOwl:hasDbXref" 16 | 17 | list_vars: 18 | Expresses: "'thing'" 19 | Expresses2: "'thing'" 20 | 21 | vars: 22 | Classification: "'cell'" 23 | 24 | data_list_vars: 25 | Curated_synonyms: "xsd:string" 26 | Expresses_comment: "xsd:string" 27 | Expresses_pub: "xsd:string" 28 | 29 | data_vars: 30 | Comment: "xsd:string" 31 | 32 | comment: 33 | text: "%s" 34 | vars: 35 | - Comment 36 | 37 | logical_axioms: 38 | - axiom_type: subClassOf 39 | multi_clause: 40 | sep: " and " 41 | clauses: 42 | - text: "'expresses' some %s" 43 | vars: 44 | - Expresses 45 | sub_clauses: 46 | - sep: " and " 47 | - clauses: 48 | - text: '%s' 49 | vars: 50 | - Expresses 51 | annotations: 52 | - annotationProperty: rdfsComment 53 | text: "%s" 54 | vars: 55 | - Expresses_comment 56 | - annotationProperty: hasDbXref 57 | multi_clause: 58 | sep: " " 59 | clauses: 60 | - text: '%s' 61 | vars: 62 | - Expresses_pub 63 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/axiom_separator.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: brainCellClasses 2 | pattern_iri: http://purl.obolibrary.org/obo/odk/brainCellClasses.yaml 3 | description: "Class template for BDS." 4 | 5 | classes: 6 | "cell": "CL:0000000" 7 | "thing": "owl:Thing" 8 | 9 | relations: 10 | expresses: "RO:0002292" 11 | 12 | annotationProperties: 13 | hasExactSynonym: "oboInOwl:hasExactSynonym" 14 | rdfsComment: "rdfs:comment" 15 | hasDbXref: "oboInOwl:hasDbXref" 16 | 17 | list_vars: 18 | Expresses: "'thing'" 19 | Expresses2: "'thing'" 20 | 21 | vars: 22 | Classification: "'cell'" 23 | 24 | data_list_vars: 25 | Curated_synonyms: "xsd:string" 26 | Expresses_comment: "xsd:string" 27 | Expresses_pub: "xsd:string" 28 | 29 | data_vars: 30 | Comment: "xsd:string" 31 | 32 | comment: 33 | text: "%s" 34 | vars: 35 | - Comment 36 | 37 | logical_axioms: 38 | - axiom_type: subClassOf 39 | multi_clause: 40 | sep: " may " 41 | clauses: 42 | - text: "'expresses' some %s" 43 | vars: 44 | - Expresses 45 | annotations: 46 | - annotationProperty: rdfsComment 47 | text: "%s" 48 | vars: 49 | - Expresses_comment 50 | - annotationProperty: hasDbXref 51 | multi_clause: 52 | sep: " " 53 | clauses: 54 | - text: '%s' 55 | vars: 56 | - Expresses_pub 57 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/dummy.yaml: -------------------------------------------------------------------------------- 1 | # An unrelated yaml file 2 | - martin: 3 | name: Martin D'vloper 4 | job: Developer 5 | skills: 6 | - python 7 | - perl 8 | - pascal 9 | - tabitha: 10 | name: Tabitha Bitumen 11 | job: Developer 12 | skills: 13 | - lisp 14 | - fortran 15 | - erlang -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/generic_go_pattern_outline.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: . 2 | 3 | classes: 4 | '.':'.' 5 | 6 | relations: 7 | '.':'.' 8 | 9 | vars: 10 | '.':'.' 11 | 12 | data_list_vars: 13 | def_xrefs: "xsd:string" 14 | cross_references: "xsd:string" 15 | exact_syn: "xsd:string" 16 | narrow_syn: "xsd:string" 17 | broad_syn: "xsd:string" 18 | related_syn: "xsd:string" 19 | 20 | name: 21 | text: '.' 22 | vars: 23 | - '.' 24 | 25 | def: 26 | text: '.' 27 | vars: 28 | - '.' 29 | xrefs: 30 | value: def_xrefs 31 | 32 | xrefs: 33 | value: cross_references 34 | 35 | namespace: 36 | text: '.' 37 | 38 | equivalentTo: 39 | text: '.' 40 | vars: 41 | - '.' 42 | 43 | exact_synonyms: 44 | value: exact_syn 45 | narrow_synonyms: 46 | value: narrow_syn 47 | broad_synonyms: 48 | value: broad_syn 49 | related_synonyms: 50 | value: related_syn 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/membrane_receptor_activity_draft.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: membrane_receptor_activity 2 | 3 | classes: 4 | 'receptor activity': GO_ 5 | 'membrane': GO_ 6 | 'binding activity': GO_ 7 | 'catalytic activity': GO_ 8 | 'transporter activity': GO_ 9 | 10 | 11 | relations: 12 | 'has part': BFO_ 13 | 'directly activates': RO_ 14 | 'occurs in': RO_ 15 | 16 | vars: 17 | 'effector activity': "'catalytic activity' or 'transporter activity'" # may be others.. 18 | 'ligand': '"chemical entity" or "protein"' # chemical entity should be sufficient given Pro links to ChEBI - are they in place? 19 | 20 | subClassOf: 21 | "receptor activity' and ( 22 | 'has_part' some ( 23 | 'binding activity' that has_input some %s and 24 | directly_activates some %s)) 25 | and ('has_part' some 'effector activity') 26 | and (occurs_in some membrane)" # Strictly, this has co-reference issues, e.g. the regulation could be of another 27 | vars: 28 | - 'ligand' 29 | - 'effector activity' 30 | - 'effector activity' 31 | 32 | 33 | 34 | # Could we make a has_ligand shortcut relation? Problem is, it needs two slots. -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/multi_clause_with_multi_list.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: multiClauseTest 2 | pattern_iri: http://purl.obolibrary.org/obo/odk/brainCellRegionMinimalMarkers.yaml 3 | description: "Naming scheme and axiomatisation for brain cells from BDS." 4 | 5 | classes: 6 | "animal cell": "CL:0000548" 7 | "Vertebrata ": "NCBITaxon:7742" 8 | "regional part of brain": "UBERON:0002616" 9 | "cell": "CL:0000000" 10 | "sequence_feature": "SO:0000110" 11 | "layer of neocortex": "UBERON:0002301" 12 | "projection type": "PATO:..." 13 | 14 | relations: 15 | part_of: "BFO:0000050" 16 | in_taxon: "RO:0002162" 17 | has_soma_location: "RO:0002100" 18 | bearer_of: "RO:0002162" 19 | 20 | vars: 21 | gross_cell_type: "'cell'" 22 | taxon: "'Vertebrata '" 23 | brain_region: "'regional part of brain'" 24 | projection_type: "'projection type'" 25 | 26 | data_vars: 27 | cell_set_preferred_alias: "xsd:string" 28 | 29 | list_vars: 30 | minimal_markers: "'sequence_feature'" 31 | allen_markers: "'sequence_feature'" 32 | layers: "'layer of neocortex'" 33 | 34 | internal_vars: 35 | - var_name: minimal_markers_cat 36 | input: minimal_markers 37 | apply: 38 | join: 39 | sep: ',' 40 | - var_name: allen_markers_cat 41 | input: allen_markers 42 | apply: 43 | join: 44 | sep: ',' 45 | - var_name: cortical_layer_cat 46 | input: layers 47 | apply: 48 | join: 49 | sep: ' or ' 50 | 51 | name: 52 | multi_clause: 53 | sep: " " 54 | clauses: 55 | - text: "%s %s %s (%s)" 56 | vars: 57 | - cell_set_preferred_alias 58 | - brain_region 59 | - gross_cell_type 60 | - taxon 61 | 62 | def: 63 | multi_clause: 64 | sep: " " 65 | clauses: 66 | - text: 'A %s of the %s %s. These cells can be distinguished from other cells in the %s by their expression of %s.' 67 | vars: 68 | - gross_cell_type 69 | - taxon 70 | - brain_region 71 | - brain_region 72 | - minimal_markers_cat 73 | sub_clauses: 74 | - sep: ' ' 75 | - clauses: 76 | - text: 'These cells also express %s %s.' 77 | vars: 78 | - allen_markers_cat 79 | - minimal_markers 80 | - text: 'These cells have projection type %s %s.' 81 | vars: 82 | - projection_type 83 | - allen_markers 84 | - text: 'The soma of these cells in located in: %s.' 85 | vars: 86 | - cortical_layer_cat 87 | 88 | generated_synonyms: 89 | - text: "%s expressing %s of %s (%s)" 90 | vars: 91 | - minimal_markers_cat 92 | - gross_cell_type 93 | - brain_region 94 | - taxon 95 | 96 | logical_axioms: 97 | - axiom_type: subClassOf 98 | text: "'in_taxon' some %s" 99 | vars: 100 | - taxon 101 | - axiom_type: subClassOf 102 | text: "%s" 103 | vars: 104 | - gross_cell_type 105 | - axiom_type: subClassOf 106 | text: "'bearer_of' some %s" 107 | vars: 108 | - projection_type 109 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/multi_clause_with_multi_list2.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: multiClauseTest 2 | pattern_iri: http://purl.obolibrary.org/obo/odk/brainCellRegionMinimalMarkers.yaml 3 | description: "Naming scheme and axiomatisation for brain cells from BDS." 4 | 5 | classes: 6 | "animal cell": "CL:0000548" 7 | "Vertebrata ": "NCBITaxon:7742" 8 | "regional part of brain": "UBERON:0002616" 9 | "cell": "CL:0000000" 10 | "sequence_feature": "SO:0000110" 11 | "layer of neocortex": "UBERON:0002301" 12 | "projection type": "PATO:..." 13 | 14 | relations: 15 | part_of: "BFO:0000050" 16 | in_taxon: "RO:0002162" 17 | has_soma_location: "RO:0002100" 18 | bearer_of: "RO:0002162" 19 | 20 | vars: 21 | gross_cell_type: "'cell'" 22 | taxon: "'Vertebrata '" 23 | brain_region: "'regional part of brain'" 24 | projection_type: "'projection type'" 25 | 26 | data_vars: 27 | cell_set_preferred_alias: "xsd:string" 28 | 29 | list_vars: 30 | minimal_markers: "'sequence_feature'" 31 | allen_markers: "'sequence_feature'" 32 | layers: "'layer of neocortex'" 33 | 34 | internal_vars: 35 | - var_name: minimal_markers_cat 36 | input: minimal_markers 37 | apply: 38 | join: 39 | sep: ',' 40 | - var_name: allen_markers_cat 41 | input: allen_markers 42 | apply: 43 | join: 44 | sep: ',' 45 | - var_name: cortical_layer_cat 46 | input: layers 47 | apply: 48 | join: 49 | sep: ' or ' 50 | 51 | name: 52 | text: "%s %s %s (%s)" 53 | vars: 54 | - cell_set_preferred_alias 55 | - brain_region 56 | - gross_cell_type 57 | - taxon 58 | 59 | def: 60 | multi_clause: 61 | sep: " " 62 | clauses: 63 | - text: 'A %s of the %s %s. These cells can be distinguished from other cells in the %s by their expression of %s.' 64 | vars: 65 | - gross_cell_type 66 | - taxon 67 | - brain_region 68 | - brain_region 69 | - minimal_markers_cat 70 | sub_clauses: 71 | - sep: ' ' 72 | - clauses: 73 | - text: 'These cells also express %s %s.' 74 | vars: 75 | - allen_markers_cat 76 | - minimal_markers 77 | - text: 'These cells have projection type %s %s.' 78 | vars: 79 | - projection_type 80 | - minimal_markers 81 | - text: 'The soma of these cells in located in: %s.' 82 | vars: 83 | - cortical_layer_cat 84 | 85 | generated_synonyms: 86 | - text: "%s expressing %s of %s (%s)" 87 | vars: 88 | - minimal_markers_cat 89 | - gross_cell_type 90 | - brain_region 91 | - taxon 92 | 93 | logical_axioms: 94 | - axiom_type: subClassOf 95 | text: "'in_taxon' some %s" 96 | vars: 97 | - taxon 98 | - axiom_type: subClassOf 99 | text: "%s" 100 | vars: 101 | - gross_cell_type 102 | - axiom_type: subClassOf 103 | text: "'bearer_of' some %s" 104 | vars: 105 | - projection_type 106 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/not_schema_compliant.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: acute 2 | 3 | pattern_iri: http://purl.obolibrary.org/obo/mondo/patterns/acute.yaml 4 | 5 | description: 'This pattern is applied to diseases that are described as having an acute onset, i.e. the sudden appearance of disease manifestations over a short period of time. 6 | 7 | Examples: [acute bronchiolitis](http://purl.obolibrary.org/obo/MONDO_0020680), 8 | [acute liver failure](http://purl.obolibrary.org/obo/MONDO_0019542)' 9 | 10 | contributors: 11 | - https://orcid.org/0000-0002-6601-2165 12 | - https://orcid.org/0000-0001-5208-3432 13 | 14 | classes: 15 | acute: PATO:0000389 16 | disease: MONDO:0000001 17 | 18 | relations: 19 | has modifier: RO:0002573 20 | 21 | annotationProperties: 22 | exact_synonym: oio:hasExactSynonym 23 | related_synonym: oio:hasRelatedSynonym 24 | 25 | vars: 26 | disease: '''disease''' 27 | 28 | name: 29 | text: acute %s 30 | vars: 31 | - disease 32 | 33 | # axioms is not valid 34 | axioms: 35 | - annotationProperty: exact_synonym 36 | text: '%s, acute' 37 | vars: 38 | - disease 39 | 40 | annotations: 41 | # property is not valid 42 | - property: exact_synonym 43 | text: '%s, acute' 44 | vars: 45 | - disease 46 | 47 | def: 48 | text: Acute form of %s. 49 | vars: 50 | - disease 51 | 52 | equivalentTo: 53 | text: '%s and ''has modifier'' some ''acute''' 54 | vars: 55 | - disease -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/quotes_miss_match.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | exports: RO_0002345 17 | 18 | vars: 19 | membrane: "'membrane" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s export across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | equivalentTo: 46 | text: "'transport' that 47 | and ('has target start location' some %s) 48 | and ('has target end location' some %s) 49 | and ('exports' some %s) 50 | and ('results in transport across' some %s)" 51 | 52 | vars: 53 | - start 54 | - end 55 | - cargo 56 | - membrane 57 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/undeclared_annotation_prop.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: acute 2 | 3 | pattern_iri: http://purl.obolibrary.org/obo/mondo/patterns/acute.yaml 4 | 5 | description: 'This pattern is applied to diseases that are described as having an acute onset, i.e. the sudden appearance of disease manifestations over a short period of time. 6 | 7 | Examples: [acute bronchiolitis](http://purl.obolibrary.org/obo/MONDO_0020680), 8 | [acute liver failure](http://purl.obolibrary.org/obo/MONDO_0019542)' 9 | 10 | contributors: 11 | - https://orcid.org/0000-0002-6601-2165 12 | - https://orcid.org/0000-0001-5208-3432 13 | 14 | classes: 15 | acute: PATO:0000389 16 | disease: MONDO:0000001 17 | 18 | relations: 19 | has modifier: RO:0002573 20 | 21 | annotationProperties: 22 | # exact_synonym: oio:hasExactSynonym 23 | related_synonym: oio:hasRelatedSynonym 24 | 25 | vars: 26 | disease: '''disease''' 27 | 28 | name: 29 | text: acute %s 30 | vars: 31 | - disease 32 | 33 | annotations: 34 | - annotationProperty: exact_synonym 35 | text: '%s, acute' 36 | vars: 37 | - disease 38 | 39 | def: 40 | text: Acute form of %s. 41 | vars: 42 | - disease 43 | 44 | equivalentTo: 45 | text: '%s and ''has modifier'' some ''acute''' 46 | vars: 47 | - disease -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/undeclared_class.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | exports: RO_0002345 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s export across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | equivalentTo: 46 | text: "'NOT_EXISTING_CLASS' that 47 | and ('has target start location' some %s) 48 | and ('has target end location' some %s) 49 | and ('exports' some %s) 50 | and ('results in transport across' some %s)" 51 | 52 | vars: 53 | - start 54 | - end 55 | - cargo 56 | - membrane 57 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/undeclared_relation.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | exports: RO_0002345 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s export across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | equivalentTo: 46 | text: "'transport' that 47 | and ('NOT_DECLARED_RELATION' some %s) 48 | and ('has target end location' some %s) 49 | and ('exports' some %s) 50 | and ('results in transport across' some %s)" 51 | 52 | vars: 53 | - start 54 | - end 55 | - cargo 56 | - membrane 57 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/undeclared_relation_multi_clause.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: brainCellClasses 2 | pattern_iri: http://purl.obolibrary.org/obo/odk/brainCellClasses.yaml 3 | description: "Class template for BDS." 4 | 5 | classes: 6 | "cell": "CL:0000000" 7 | "thing": "owl:Thing" 8 | 9 | #relations: 10 | # expresses: "RO:0002292" 11 | 12 | annotationProperties: 13 | hasExactSynonym: "oboInOwl:hasExactSynonym" 14 | rdfsComment: "rdfs:comment" 15 | hasDbXref: "oboInOwl:hasDbXref" 16 | 17 | list_vars: 18 | Expresses: "'thing'" 19 | Expresses2: "'thing'" 20 | 21 | vars: 22 | Classification: "'cell'" 23 | 24 | data_list_vars: 25 | Curated_synonyms: "xsd:string" 26 | Expresses_comment: "xsd:string" 27 | Expresses_pub: "xsd:string" 28 | 29 | data_vars: 30 | Comment: "xsd:string" 31 | 32 | comment: 33 | text: "%s" 34 | vars: 35 | - Comment 36 | 37 | logical_axioms: 38 | - axiom_type: subClassOf 39 | multi_clause: 40 | sep: " and " 41 | clauses: 42 | - text: "'expresses' some %s" 43 | vars: 44 | - Expresses 45 | annotations: 46 | - annotationProperty: rdfsComment 47 | text: "%s" 48 | vars: 49 | - Expresses_comment 50 | - annotationProperty: hasDbXref 51 | multi_clause: 52 | sep: " " 53 | clauses: 54 | - text: '%s' 55 | vars: 56 | - Expresses_pub 57 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/undeclared_var.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | exports: RO_0002345 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s export across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - not_existing_var 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | equivalentTo: 46 | text: "'transport' that 47 | and ('has target start location' some %s) 48 | and ('has target end location' some %s) 49 | and ('exports' some %s) 50 | and ('results in transport across' some %s)" 51 | 52 | vars: 53 | - start 54 | - end 55 | - cargo 56 | - membrane 57 | -------------------------------------------------------------------------------- /src/schema/test/negative_test_set/wrong_indentation.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | exports: RO_0002345 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s export across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | equivalentTo: 46 | text: "'transport' that 47 | and ('has target start location' some %s) 48 | and ('has target end location' some %s) 49 | and ('exports' some %s) 50 | and ('results in transport across' some %s)" 51 | 52 | vars: 53 | - start 54 | - end 55 | - cargo 56 | - membrane 57 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/schema/test/positive_test_set/__init__.py -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/export_across_membrane.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | exports: RO_0002345 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s export across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | equivalentTo: 46 | text: "'transport' that 47 | and ('has target start location' some %s) 48 | and ('has target end location' some %s) 49 | and ('exports' some %s) 50 | and ('results in transport across' some %s)" 51 | 52 | vars: 53 | - start 54 | - end 55 | - cargo 56 | - membrane 57 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/abnormallyHyperplasticAnatomicalEntity.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: abnormallyHyperplasticAnatomicalEntity.yaml 2 | 3 | pattern_iri: http://purl.obolibrary.org/obo/upheno/patterns-dev/abnormallyHyperplasticAnatomicalEntity.yaml 4 | 5 | description: 'Hyperplastic anatomical entity, for example, thyroid gland hyperplasia. The increase in size of the anatomical entitiy is due to an increase in cell number,' 6 | 7 | examples: 8 | - http://purl.obolibrary.org/obo/HP_0008249 9 | - http://purl.obolibrary.org/obo/MP_0000630 10 | - http://purl.obolibrary.org/obo/MP_0013765 11 | 12 | contributors: 13 | - https://orcid.org/0000-0001-8314-2140 14 | 15 | classes: 16 | abnormal: PATO:0000460 17 | anatomical_entity: UBERON:0001062 18 | hyperplastic: PATO:0000644 19 | 20 | relations: 21 | characteristic_of: RO:0000052 22 | has_modifier: RO:0002573 23 | has_part: BFO:0000051 24 | 25 | annotationProperties: 26 | exact_synonym: oio:hasExactSynonym 27 | 28 | vars: 29 | anatomical_entity: "'anatomical_entity'" 30 | 31 | name: 32 | text: "%s hyperplasia" 33 | vars: 34 | - anatomical_entity 35 | 36 | annotations: 37 | - annotationProperty: exact_synonym 38 | text: "hyperplastic %s" 39 | vars: 40 | - anatomical_entity 41 | 42 | def: 43 | text: "The increased size of the %s is due to an increase in cell number (hyperplasia)." 44 | vars: 45 | - anatomical_entity 46 | 47 | equivalentTo: 48 | text: "'has_part' some ('hyperplastic' and ('characteristic_of' some %s) and ('has_modifier' some 'abnormal'))" 49 | vars: 50 | - anatomical_entity 51 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/acute.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: acute 2 | 3 | pattern_iri: http://purl.obolibrary.org/obo/mondo/patterns/acute.yaml 4 | 5 | description: 'This pattern is applied to diseases that are described as having an acute onset, i.e. the sudden appearance of disease manifestations over a short period of time. 6 | 7 | Examples: [acute bronchiolitis](http://purl.obolibrary.org/obo/MONDO_0020680), 8 | [acute liver failure](http://purl.obolibrary.org/obo/MONDO_0019542)' 9 | 10 | contributors: 11 | - https://orcid.org/0000-0002-6601-2165 12 | - https://orcid.org/0000-0001-5208-3432 13 | 14 | classes: 15 | acute: PATO:0000389 16 | disease: MONDO:0000001 17 | 18 | relations: 19 | has modifier: RO:0002573 20 | 21 | annotationProperties: 22 | exact_synonym: oio:hasExactSynonym 23 | related_synonym: oio:hasRelatedSynonym 24 | 25 | vars: 26 | disease: '''disease''' 27 | 28 | name: 29 | text: acute %s 30 | vars: 31 | - disease 32 | 33 | annotations: 34 | - annotationProperty: exact_synonym 35 | text: '%s, acute' 36 | vars: 37 | - disease 38 | 39 | def: 40 | text: Acute form of %s. 41 | vars: 42 | - disease 43 | 44 | equivalentTo: 45 | text: '%s and ''has modifier'' some ''acute''' 46 | vars: 47 | - disease -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/adenine_import_across_plasma_membrane.md: -------------------------------------------------------------------------------- 1 | ## Template: import_across_plasma_membrane 2 | ### imported: [adenine](http://purl.obolibrary.org/obo/CHEBI_16708) 3 | 4 | __label:__ adenine import across plasma membrane 5 | 6 | __def:__ The directed movement of adenine from outside of a cell, across the plasma membrane and into the cytoplasmic compartment. 7 | 8 | __equivalentTo:__ ['transport'](http://purl.obolibrary.org/obo/GO_0006810) _and_ (__['has target start location'](http://purl.obolibrary.org/obo/RO_0002338)__ _some_ ['extracellular region'](http://purl.obolibrary.org/obo/GO_0005576)) _and_ (__['has target end location'](http://purl.obolibrary.org/obo/RO_0002339)__ _some_ ['cytosol'](http://purl.obolibrary.org/obo/GO_0005829)) _and_ (__['results in transport across'](http://purl.obolibrary.org/obo/RO_0002342)__ _some_ ['plasma membrane'](http://purl.obolibrary.org/obo/GO_0005886)) _and_ (__['imports'](http://purl.obolibrary.org/obo/RO_0002340)__ _some_ [adenine](http://purl.obolibrary.org/obo/CHEBI_16708)) 9 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/anchored_membrane_component.json: -------------------------------------------------------------------------------- 1 | { 2 | "classes": { 3 | "anchored component of membrane": "GO_0031225", 4 | "membrane": "GO_0016020", 5 | "side of membrane": "GO_0098552" 6 | }, 7 | "def": { 8 | "text": "The component of the %s consisting of the gene products that are tethered to the membrane only by a covalently attached anchor, such as a lipid group that is embedded in the membrane. Gene products with peptide sequences that are embedded in the membrane are excluded from this grouping.", 9 | "vars": [ 10 | "membrane" 11 | ] 12 | }, 13 | "equivalentTo": { 14 | "text": "'anchored component of membrane' and ('part of' some %s)", 15 | "vars": [ 16 | "membrane" 17 | ] 18 | }, 19 | "name": { 20 | "text": "anchored component of %s", 21 | "vars": [ 22 | "membrane" 23 | ] 24 | }, 25 | "pattern_name": "anchored_membrane_component", 26 | "relations": { 27 | "part of": "BFO_0000050" 28 | }, 29 | "vars": { 30 | "membrane": "'membrane' or 'side of membrane'" 31 | } 32 | } -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/anchored_membrane_component.md: -------------------------------------------------------------------------------- 1 | ## anchored_membrane_component 2 | __label:__ anchored component of \{ membrane \} 3 | 4 | __def:__ The component of the \{ membrane \} consisting of the gene products that are tethered to the membrane only by a covalently attached anchor, such as a lipid group that is embedded in the membrane. Gene products with peptide sequences that are embedded in the membrane are excluded from this grouping. 5 | 6 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/anchored_membrane_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: anchored_membrane_component 2 | 3 | classes: 4 | membrane: GO_0016020 5 | side of membrane: GO_0098552 6 | anchored component of membrane: GO_0031225 7 | 8 | 9 | relations: 10 | part of: BFO_0000050 11 | 12 | vars: 13 | membrane: "'membrane' or 'side of membrane'" 14 | 15 | name: 16 | text: anchored component of %s 17 | vars: 18 | - membrane 19 | 20 | def: 21 | text: "The component of the %s consisting of the gene products that are tethered to the membrane only by a covalently attached anchor, such as a lipid group that is embedded in the membrane. Gene products with peptide sequences that are embedded in the membrane are excluded from this grouping." 22 | vars: 23 | - membrane 24 | 25 | equivalentTo: 26 | text: "'anchored component of membrane' and ('part of' some %s)" 27 | vars: 28 | - membrane 29 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/bounding_membrane_of_organelle.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: bounding_membrane_of_organelle 2 | 3 | classes: 4 | 'whole membrane': GO_0098805 5 | 'membrane-bounded organelle': GO_0043227 6 | 7 | relations: 8 | 'bounding layer of': RO_0002007 9 | 10 | vars: 11 | organelle: "'membrane-bounded organelle'" 12 | 13 | name: 14 | text: "%s membrane" 15 | vars: 16 | - organelle 17 | 18 | def: 19 | text: "The lipid bilayer that forms the outer layer of a %s." 20 | vars: 21 | - organelle 22 | 23 | equivalentTo: 24 | text: "'whole membrane' that ('bounding layer of' some %s)" 25 | vars: 26 | - organelle 27 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/data/acute.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: acute 2 | 3 | pattern_iri: http://purl.obolibrary.org/obo/mondo/patterns/acute.yaml 4 | 5 | description: 'This pattern is applied to diseases that are described as having an acute onset, i.e. the sudden appearance of disease manifestations over a short period of time. 6 | 7 | Examples: [acute bronchiolitis](http://purl.obolibrary.org/obo/MONDO_0020680), 8 | [acute liver failure](http://purl.obolibrary.org/obo/MONDO_0019542)' 9 | 10 | contributors: 11 | - https://orcid.org/0000-0002-6601-2165 12 | - https://orcid.org/0000-0001-5208-3432 13 | 14 | classes: 15 | acute: PATO:0000389 16 | disease: MONDO:0000001 17 | 18 | relations: 19 | has modifier: RO:0002573 20 | 21 | annotationProperties: 22 | exact_synonym: oio:hasExactSynonym 23 | related_synonym: oio:hasRelatedSynonym 24 | 25 | vars: 26 | disease: '''disease''' 27 | 28 | name: 29 | text: acute %s 30 | vars: 31 | - disease 32 | 33 | annotations: 34 | - annotationProperty: exact_synonym 35 | text: '%s, acute' 36 | vars: 37 | - disease 38 | 39 | def: 40 | text: Acute form of %s. 41 | vars: 42 | - disease 43 | 44 | equivalentTo: 45 | text: '%s and ''has modifier'' some ''acute''' 46 | vars: 47 | - disease -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/data/acute2.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: acute 2 | 3 | pattern_iri: http://purl.obolibrary.org/obo/mondo/patterns/acute.yaml 4 | 5 | description: 'This pattern is applied to diseases that are described as having an acute onset, i.e. the sudden appearance of disease manifestations over a short period of time. 6 | 7 | Examples: [acute bronchiolitis](http://purl.obolibrary.org/obo/MONDO_0020680), 8 | [acute liver failure](http://purl.obolibrary.org/obo/MONDO_0019542)' 9 | 10 | contributors: 11 | - https://orcid.org/0000-0002-6601-2165 12 | - https://orcid.org/0000-0001-5208-3432 13 | 14 | classes: 15 | acute: PATO:0000389 16 | disease: MONDO:0000001 17 | 18 | relations: 19 | has modifier: RO:0002573 20 | 21 | annotationProperties: 22 | exact_synonym: oio:hasExactSynonym 23 | related_synonym: oio:hasRelatedSynonym 24 | 25 | vars: 26 | disease: '''disease''' 27 | 28 | name: 29 | text: acute %s 30 | vars: 31 | - disease 32 | 33 | annotations: 34 | - annotationProperty: exact_synonym 35 | text: '%s, acute' 36 | vars: 37 | - disease 38 | 39 | def: 40 | text: Acute form of %s. 41 | vars: 42 | - disease 43 | 44 | equivalentTo: 45 | text: '%s and ''has modifier'' some ''acute''' 46 | vars: 47 | - disease -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/data/dummy.yaml: -------------------------------------------------------------------------------- 1 | # An unrelated yaml file 2 | - martin: 3 | name: Martin D'vloper 4 | job: Developer 5 | skills: 6 | - python 7 | - perl 8 | - pascal 9 | - tabitha: 10 | name: Tabitha Bitumen 11 | job: Developer 12 | skills: 13 | - lisp 14 | - fortran 15 | - erlang -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/data/generated/dummy.text: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/INCATools/dead_simple_owl_design_patterns/c9333788e675d865323d119dd77a71635d343e24/src/schema/test/positive_test_set/patterns/data/generated/dummy.text -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/data/sample_data/acute.tsv: -------------------------------------------------------------------------------- 1 | defined_class defined_class_label disease disease_label 2 | http://purl.obolibrary.org/obo/MONDO_0001090 acute anterolateral myocardial infarction http://purl.obolibrary.org/obo/MONDO_0006652 anterolateral myocardial infarction 3 | http://purl.obolibrary.org/obo/MONDO_0020680 acute bronchiolitis http://purl.obolibrary.org/obo/MONDO_0002465 bronchiolitis (disease) 4 | http://purl.obolibrary.org/obo/MONDO_0001081 acute cervicitis http://purl.obolibrary.org/obo/MONDO_0002345 cervicitis (disease) 5 | http://purl.obolibrary.org/obo/MONDO_0001930 acute cholangitis http://purl.obolibrary.org/obo/MONDO_0004789 cholangitis 6 | http://purl.obolibrary.org/obo/MONDO_0001817 acute closed-angle glaucoma http://purl.obolibrary.org/obo/MONDO_0001744 angle-closure glaucoma 7 | http://purl.obolibrary.org/obo/MONDO_0001214 acute conjunctivitis http://purl.obolibrary.org/obo/MONDO_0003799 conjunctivitis (disease) 8 | http://purl.obolibrary.org/obo/MONDO_0004598 acute cor pulmonale http://purl.obolibrary.org/obo/MONDO_0004596 cor pulmonale 9 | http://purl.obolibrary.org/obo/MONDO_0001650 acute cystitis (disease) http://purl.obolibrary.org/obo/MONDO_0006032 cystitis 10 | http://purl.obolibrary.org/obo/MONDO_0004812 acute dacryoadenitis http://purl.obolibrary.org/obo/MONDO_0004804 dacryoadenitis 11 | http://purl.obolibrary.org/obo/MONDO_0001610 acute dacryocystitis http://purl.obolibrary.org/obo/MONDO_0004926 dacryocystitis 12 | http://purl.obolibrary.org/obo/MONDO_0000257 acute diarrhea http://purl.obolibrary.org/obo/MONDO_0001673 diarrheal disease 13 | http://purl.obolibrary.org/obo/MONDO_0001871 acute diffuse glomerulonephritis http://purl.obolibrary.org/obo/MONDO_0003137 diffuse glomerulonephritis 14 | http://purl.obolibrary.org/obo/MONDO_0020683 acute disease http://purl.obolibrary.org/obo/MONDO_0000001 disease or disorder 15 | http://purl.obolibrary.org/obo/MONDO_0004265 acute endometritis http://purl.obolibrary.org/obo/MONDO_0000918 endometritis 16 | http://purl.obolibrary.org/obo/MONDO_0017202 acute endophthalmitis http://purl.obolibrary.org/obo/MONDO_0016047 endophthalmitis 17 | http://purl.obolibrary.org/obo/MONDO_0041366 acute epiglottitis http://purl.obolibrary.org/obo/MONDO_0005753 epiglottitis 18 | http://purl.obolibrary.org/obo/MONDO_0004810 acute ethmoiditis http://purl.obolibrary.org/obo/MONDO_0005756 ethmoid sinusitis 19 | http://purl.obolibrary.org/obo/MONDO_0001912 acute frontal sinusitis http://purl.obolibrary.org/obo/MONDO_0001121 frontal sinusitis 20 | http://purl.obolibrary.org/obo/MONDO_0001080 acute gonococcal cervicitis http://purl.obolibrary.org/obo/MONDO_0021157 gonococcal cervicitis 21 | http://purl.obolibrary.org/obo/MONDO_0001777 acute gonococcal cystitis http://purl.obolibrary.org/obo/MONDO_0021160 gonococcal cystitis 22 | http://purl.obolibrary.org/obo/MONDO_0001125 acute gonococcal epididymo-orchitis http://purl.obolibrary.org/obo/MONDO_0021158 gonococcal epididymo-orchitis 23 | http://purl.obolibrary.org/obo/MONDO_0001838 acute gonococcal prostatitis http://purl.obolibrary.org/obo/MONDO_0021161 gonococcal prostatitis 24 | http://purl.obolibrary.org/obo/MONDO_0001837 acute gonococcal salpingitis http://purl.obolibrary.org/obo/MONDO_0021159 gonococcal salpingitis 25 | http://purl.obolibrary.org/obo/MONDO_0020546 acute graft versus host disease http://purl.obolibrary.org/obo/MONDO_0013730 graft versus host disease 26 | http://purl.obolibrary.org/obo/MONDO_0005174 acute hypotension http://purl.obolibrary.org/obo/MONDO_0005468 hypotensive disorder 27 | http://purl.obolibrary.org/obo/MONDO_0044213 acute idiopathic urticaria http://purl.obolibrary.org/obo/MONDO_0044211 idiopathic urticaria 28 | http://purl.obolibrary.org/obo/MONDO_0002492 acute kidney failure http://purl.obolibrary.org/obo/MONDO_0001106 kidney failure 29 | http://purl.obolibrary.org/obo/MONDO_0004777 acute laryngitis http://purl.obolibrary.org/obo/MONDO_0002647 laryngitis 30 | http://purl.obolibrary.org/obo/MONDO_0019542 acute liver failure http://purl.obolibrary.org/obo/MONDO_0100192 liver failure 31 | http://purl.obolibrary.org/obo/MONDO_0002186 acute maxillary sinusitis http://purl.obolibrary.org/obo/MONDO_0005842 maxillary sinusitis 32 | http://purl.obolibrary.org/obo/MONDO_0007896 acute monocytic leukemia http://purl.obolibrary.org/obo/MONDO_0004600 monocytic leukemia 33 | http://purl.obolibrary.org/obo/MONDO_0018874 acute myeloid leukemia http://purl.obolibrary.org/obo/MONDO_0004643 myeloid leukemia 34 | http://purl.obolibrary.org/obo/MONDO_0004781 acute myocardial infarction http://purl.obolibrary.org/obo/MONDO_0005068 myocardial infarction (disease) 35 | http://purl.obolibrary.org/obo/MONDO_0002815 acute myocarditis http://purl.obolibrary.org/obo/MONDO_0004496 myocarditis 36 | http://purl.obolibrary.org/obo/MONDO_0001051 acute otitis externa http://purl.obolibrary.org/obo/MONDO_0004795 otitis externa 37 | http://purl.obolibrary.org/obo/MONDO_0006515 acute pancreatitis http://purl.obolibrary.org/obo/MONDO_0004982 pancreatitis 38 | http://purl.obolibrary.org/obo/MONDO_0041295 acute papillary necrosis http://purl.obolibrary.org/obo/MONDO_0006821 kidney papillary necrosis 39 | http://purl.obolibrary.org/obo/MONDO_0001028 acute pericementitis http://purl.obolibrary.org/obo/MONDO_0005076 periodontitis 40 | http://purl.obolibrary.org/obo/MONDO_0002240 acute perichondritis of pinna http://purl.obolibrary.org/obo/MONDO_0002246 perichondritis of auricle 41 | http://purl.obolibrary.org/obo/MONDO_0020600 acute pharyngitis http://purl.obolibrary.org/obo/MONDO_0002258 pharyngitis 42 | http://purl.obolibrary.org/obo/MONDO_0001644 acute proliferative glomerulonephritis http://purl.obolibrary.org/obo/MONDO_0003134 proliferative glomerulonephritis 43 | http://purl.obolibrary.org/obo/MONDO_0003529 acute pyelonephritis http://purl.obolibrary.org/obo/MONDO_0006939 pyelonephritis 44 | http://purl.obolibrary.org/obo/MONDO_0001208 acute respiratory failure http://purl.obolibrary.org/obo/MONDO_0021113 respiratory failure 45 | http://purl.obolibrary.org/obo/MONDO_0001895 acute retrobulbar neuritis http://purl.obolibrary.org/obo/MONDO_0024335 retrobulbar neuritis 46 | http://purl.obolibrary.org/obo/MONDO_0001173 acute salpingitis http://purl.obolibrary.org/obo/MONDO_0003619 salpingitis 47 | http://purl.obolibrary.org/obo/MONDO_0001171 acute salpingo-oophoritis http://purl.obolibrary.org/obo/MONDO_0001172 salpingo-oophoritis 48 | http://purl.obolibrary.org/obo/MONDO_0001624 acute sphenoidal sinusitis http://purl.obolibrary.org/obo/MONDO_0005964 sphenoid sinusitis 49 | http://purl.obolibrary.org/obo/MONDO_0000990 acute subendocardial myocardial infarction http://purl.obolibrary.org/obo/MONDO_0003674 subendocardial myocardial infarction 50 | http://purl.obolibrary.org/obo/MONDO_0001949 acute thyroiditis http://purl.obolibrary.org/obo/MONDO_0004126 thyroiditis (disease) 51 | http://purl.obolibrary.org/obo/MONDO_0020686 acute tonsillitis http://purl.obolibrary.org/obo/MONDO_0001039 tonsillitis 52 | http://purl.obolibrary.org/obo/MONDO_0002738 acute transudative otitis media http://purl.obolibrary.org/obo/MONDO_0001212 non-suppurative otitis media 53 | http://purl.obolibrary.org/obo/MONDO_0001031 purulent acute otitis media http://purl.obolibrary.org/obo/MONDO_0005975 suppurative otitis media 54 | http://purl.obolibrary.org/obo/MONDO_0000222 seminal vesicle acute gonorrhea http://purl.obolibrary.org/obo/MONDO_0001027 gonococcal seminal vesiculitis 55 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/envenomation.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: envenomation 2 | 3 | classes: 4 | 'envenomation resulting in modification of morphology or physiology of other organism' : 'GO_0044468' 5 | 'modification of morphology or physiology of other organism' : 'GO_0035821' 6 | 7 | relations: 8 | 'has part' : 'BFO_0000051' 9 | 10 | vars: 11 | mod: "'modification of morphology or physiology of other organism'" 12 | 13 | name: 14 | text: 'envenomation resulting in %s' 15 | vars: 16 | - mod 17 | 18 | def: 19 | text: "A process that begins with venom being forced into an organism by the bite or sting of another organism, and ends with the resultant %s" 20 | vars: 21 | - mod # Need a way to specify regex transformation that subs 'in the bitten organism' for 'in other organism' 22 | 23 | equivalentTo: 24 | text: "'envenomation resulting in modification of morphology or physiology of other organism' and 'has part' some %s" 25 | vars: 26 | - mod -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/export_across_membrane.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | exports: RO_0002345 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s export across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover export via vesicle fusion with %s, as in this case transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | equivalentTo: 46 | text: "'transport' that 47 | and ('has target start location' some %s) 48 | and ('has target end location' some %s) 49 | and ('exports' some %s) 50 | and ('results in transport across' some %s)" 51 | 52 | vars: 53 | - start 54 | - end 55 | - cargo 56 | - membrane 57 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/expression_pattern.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: expression_pattern 2 | 3 | classes: 4 | expression pattern: 5 | cell: 6 | 7 | relations: 8 | 'part of': BFO_0000050 9 | 'has part': 10 | 11 | vars: 12 | expressed_feature: "'gene'" # Needs to be gene or transgene. Use SO? 13 | 14 | name: 15 | text: "%s expression pattern" 16 | vars: 17 | - expressed_feature 18 | 19 | def: 20 | text: "The sum total of all cells in a single organism in which expression of %s is occurring." 21 | vars: 22 | - expressed_feature 23 | 24 | 25 | equivalentTo: 26 | text: "" 27 | vars: 28 | - expressed_feature 29 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/extrinsic_membrane_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: extrinsic_membrane_component 2 | 3 | classes: 4 | membrane: GO_0016020 5 | side of membrane: GO_0098552 6 | extrinsic component of membrane: GO_0019898 7 | 8 | relations: 9 | part of: BFO_0000050 10 | 11 | vars: 12 | membrane: "'membrane' or 'side of membrane'" 13 | 14 | name: 15 | text: extrinsic component of %s 16 | vars: 17 | - membrane 18 | 19 | def: 20 | text: "The component of the %s consisting of gene products and protein complexes that are loosely bound to one of its surfaces, but not integrated into the hydrophobic region." 21 | vars: 22 | - membrane 23 | 24 | equivalentTo: 25 | text: "'extrinsic component of membrane' and ('part of' some %s)" 26 | vars: 27 | - membrane 28 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/import_across_membrane.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | cellular_component: GO_0005575 6 | chemical entity: CHEBI_24431 7 | macromolecular complex: GO_0032991 8 | transcript: SO_0000673 9 | transport: GO_0006810 10 | 11 | relations: 12 | transports or maintains localization of: RO_0002313 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | imports: RO_0002340 17 | 18 | vars: 19 | membrane: "'membrane'" 20 | cargo: "'chemical entity' or 'macromolecular complex' or 'transcript'" 21 | start: "'cellular_component'" 22 | end: "'cellular_component'" 23 | 24 | name: 25 | text: "%s import across %s" 26 | vars: 27 | - cargo 28 | - membrane 29 | 30 | def: 31 | text: "The directed import of %s from %s, across the %s and into the %s." 32 | vars: 33 | - cargo 34 | - start 35 | - membrane 36 | - end 37 | 38 | comment: 39 | text: "This term covers %s *across* the %s through a channel or pore. It does not cover import via vesicle fusion with %s or vesiculation, as in these cases transport does not involve crossing the membrane." 40 | vars: 41 | - cargo 42 | - membrane 43 | - membrane 44 | 45 | 46 | equivalentTo: 47 | text: "'transport' 48 | and ('has target start location' some %s) 49 | and ('has target end location' some %s) 50 | and ('imports' some %s) 51 | and ('results in transport across' some %s)" 52 | 53 | vars: 54 | - start 55 | - end 56 | - cargo 57 | - membrane 58 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/import_across_plasma_membrane.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_across_plasma_membrane 2 | # implicitly import into cell across plamsa membrane 3 | 4 | classes: 5 | transport: GO_0006810 6 | extracellular region: GO_0005576 7 | cytosol: GO_0005829 8 | chemical entity: CHEBI_24431 # encompasses protein 9 | macromolecular complex: GO_0043234 # encompasses protein complex 10 | plasma membrane: GO_0005886 11 | 12 | relations: 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | imports: RO_0002340 17 | 18 | vars: 19 | imported: "'chemical entity' or 'macromolecular complex'" 20 | 21 | name: 22 | text: "%s import across plasma membrane" 23 | vars: 24 | - imported 25 | 26 | def: 27 | text: The directed movement of %s from outside of a cell, across the plasma membrane and into the cytoplasmic compartment. 28 | vars: 29 | - imported 30 | 31 | equivalentTo: 32 | text: "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'cytosol') and ('results in transport across' some 'plasma membrane') and ('imports' some %s)" 33 | vars: 34 | - imported 35 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/import_into_cell.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: import_into_cell 2 | classes: 3 | transport: GO_0006810 4 | extracellular region: GO_0005576 5 | intracellular part: GO_0044424 6 | chemical entity: CHEBI_24431 # encompasses protein 7 | macromolecular complex: GO_0043234 # encompasses protein complex 8 | 9 | relations: 10 | has target start location: RO_0002338 11 | has target end location: RO_0002339 12 | imports: RO_0002340 13 | 14 | vars: 15 | imported: "'chemical entity' or 'macromolecular complex'" 16 | 17 | name: 18 | text: "%s import into cell" 19 | vars: 20 | - imported 21 | 22 | def: 23 | text: "The directed movement of %s from outside of a cell into the cytoplasmic compartment. This may occur via transport across the plasma membrane or via endocytosis." 24 | vars: 25 | - imported 26 | 27 | equivalentTo: 28 | text: "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'intracellular part') and ('imports' some %s)" 29 | vars: 30 | - imported 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/integral_membrane_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: integral_membrane_component 2 | 3 | classes: 4 | membrane: GO_0016020 5 | side of membrane: GO_0098552 6 | integral component of membrane: GO_0016021 7 | 8 | relations: 9 | part of: BFO_0000050 10 | 11 | vars: 12 | membrane: "'membrane' or 'side of membrane'" 13 | 14 | name: 15 | text: integral component of %s 16 | vars: 17 | - membrane 18 | 19 | def: 20 | text: "The component of the %s consisting of the gene products and protein complexes having at least some part of their peptide sequence embedded in the hydrophobic region of the membrane." 21 | vars: 22 | - membrane 23 | 24 | equivalentTo: 25 | text: "'integral component of membrane' and ('part of' some %s)" 26 | vars: 27 | - membrane 28 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/intrinsic_membrane_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: intrinsic_membrane_component 2 | 3 | classes: 4 | membrane: GO_0016020 5 | side of membrane: GO_0098552 6 | intrinsic component of membrane: GO_0031224 7 | 8 | relations: 9 | part of: BFO_0000050 10 | 11 | vars: 12 | membrane: "'membrane' or 'side of membrane'" 13 | 14 | name: 15 | text: intrinsic component of %s 16 | vars: 17 | - membrane 18 | 19 | def: 20 | text: The component of the %s consisting of gene products and protein complexes that have some covalently attached part (e.g. peptide sequence or GPI anchor), which spans or is embedded in one or both leaflets the membrane. 21 | vars: 22 | - membrane 23 | 24 | equivalentTo: 25 | text: "'intrinsic component of membrane' and ('part of' some %s)" 26 | vars: 27 | - membrane 28 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/membrane_spanning_component.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: spanning_component_of_membrane 2 | 3 | classes: 4 | membrane: GO_0016020 5 | spanning component of membrane: GO_0089717 6 | 7 | relations: 8 | 'part of': BFO_0000050 9 | 10 | vars: 11 | membrane: "'membrane'" 12 | 13 | name: 14 | text: "spanning component of %s" 15 | vars: 16 | - membrane 17 | 18 | def: 19 | text: "The component of the %s consisting of gene products and protein complexes that have some part that spans both leaflets of the membrane." 20 | vars: 21 | - membrane 22 | 23 | equivalentTo: 24 | text: "'spanning component of membrane' that 'part of' some %s" 25 | vars: 26 | - membrane 27 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/multi_clause_schema.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: multiClauseTest 2 | pattern_iri: http://purl.obolibrary.org/obo/odk/brainCellRegionMinimalMarkers.yaml 3 | description: "Naming scheme and axiomatisation for brain cells from BDS." 4 | 5 | classes: 6 | "animal cell": "CL:0000548" 7 | "Vertebrata ": "NCBITaxon:7742" 8 | "regional part of brain": "UBERON:0002616" 9 | "cell": "CL:0000000" 10 | "sequence_feature": "SO:0000110" 11 | "layer of neocortex": "UBERON:0002301" 12 | "projection type": "PATO:..." 13 | 14 | relations: 15 | part_of: "BFO:0000050" 16 | in_taxon: "RO:0002162" 17 | has_soma_location: "RO:0002100" 18 | bearer_of: "RO:0002162" 19 | 20 | vars: 21 | gross_cell_type: "'cell'" 22 | taxon: "'Vertebrata '" 23 | brain_region: "'regional part of brain'" 24 | projection_type: "'projection type'" 25 | 26 | data_vars: 27 | cell_set_preferred_alias: "xsd:string" 28 | 29 | list_vars: 30 | minimal_markers: "'sequence_feature'" 31 | allen_markers: "'sequence_feature'" 32 | layers: "'layer of neocortex'" 33 | 34 | internal_vars: 35 | - var_name: minimal_markers_cat 36 | input: minimal_markers 37 | apply: 38 | join: 39 | sep: ',' 40 | - var_name: allen_markers_cat 41 | input: allen_markers 42 | apply: 43 | join: 44 | sep: ',' 45 | - var_name: cortical_layer_cat 46 | input: layers 47 | apply: 48 | join: 49 | sep: ' or ' 50 | 51 | name: 52 | text: "%s %s %s (%s)" 53 | vars: 54 | - cell_set_preferred_alias 55 | - brain_region 56 | - gross_cell_type 57 | - taxon 58 | 59 | def: 60 | multi_clause: 61 | sep: " " 62 | clauses: 63 | - text: 'A %s of the %s %s. These cells can be distinguished from other cells in the %s by their expression of %s.' 64 | vars: 65 | - gross_cell_type 66 | - taxon 67 | - brain_region 68 | - brain_region 69 | - minimal_markers_cat 70 | sub_clauses: 71 | - sep: ' ' 72 | - clauses: 73 | - text: 'These cells also express %s.' 74 | vars: 75 | - allen_markers_cat 76 | - text: 'These cells have projection type %s.' 77 | vars: 78 | - projection_type 79 | - text: 'The soma of these cells in located in: %s.' 80 | vars: 81 | - cortical_layer_cat 82 | 83 | generated_synonyms: 84 | - text: "%s expressing %s of %s (%s)" 85 | vars: 86 | - minimal_markers_cat 87 | - gross_cell_type 88 | - brain_region 89 | - taxon 90 | 91 | logical_axioms: 92 | - axiom_type: subClassOf 93 | text: "'in_taxon' some %s" 94 | vars: 95 | - taxon 96 | - axiom_type: subClassOf 97 | text: "%s" 98 | vars: 99 | - gross_cell_type 100 | - axiom_type: subClassOf 101 | text: "'bearer_of' some %s" 102 | vars: 103 | - projection_type 104 | -------------------------------------------------------------------------------- /src/schema/test/positive_test_set/patterns/transmembrane_import_into_cell.yaml: -------------------------------------------------------------------------------- 1 | pattern_name: transmembrane_import_into_cytosol 2 | # implicitly import into cell across plamsa membrane 3 | 4 | classes: 5 | transport: GO_0006810 6 | extracellular region: GO_0005576 7 | cytosol: GO_0005829 8 | chemical entity: CHEBI_24431 # encompasses protein 9 | macromolecular complex: GO_0043234 # encompasses protein complex 10 | plasma membrane: GO_0005886 11 | 12 | relations: 13 | has target start location: RO_0002338 14 | has target end location: RO_0002339 15 | results in transport across: RO_0002342 16 | imports: RO_0002340 17 | 18 | vars: 19 | imported: "'chemical entity' or 'macromolecular complex'" 20 | 21 | name: 22 | text: "%s import across plasma membrane" 23 | vars: 24 | - imported 25 | 26 | def: 27 | text: The directed movement of %s from outside of a cell, across the plasma membrane and into the cytoplasmic compartment. 28 | vars: 29 | - imported 30 | 31 | equivalentTo: 32 | text: "'transport' and ('has target start location' some 'extracellular region') and ('has target end location' some 'cytosol') and ('results in transport across' some 'plasma membrane') and ('imports' some %s)" 33 | vars: 34 | - imported 35 | -------------------------------------------------------------------------------- /src/simple_pattern_tester.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from jsonschema import Draft7Validator 4 | import sys 5 | import glob 6 | import re 7 | import warnings 8 | import requests 9 | from jsonpath_rw import parse 10 | from ruamel.yaml import YAML 11 | 12 | """ARG = path to directory with pattern files in yaml 13 | Files must have the extension .yaml or .yml. 14 | All files in directory with these extensions are assumed to be dosdp 15 | pattern files. 16 | """ 17 | 18 | def test_jschema(validator, test_pattern): 19 | if not validator.is_valid(test_pattern): 20 | es = validator.iter_errors(test_pattern) 21 | for e in es: 22 | warnings.warn(" => ".join([str(e.schema_path), 23 | str(e.message), 24 | str(e.context)])) 25 | return False 26 | else: 27 | return True 28 | 29 | def test_vars(pattern): 30 | """Tests whether variable names in any field with key 'vars' 31 | is in the vars list for the pattern""" 32 | if 'vars' in pattern.keys(): 33 | vars = set(pattern['vars'].keys()) 34 | else: 35 | warnings.warn("Pattern has no vars") 36 | return True ## If this is to be compulsory, should be spec'd as such in json_schema 37 | if 'data_vars' in pattern.keys(): 38 | vars.update(set(pattern['data_vars'].keys())) 39 | if 'substitutions' in pattern.keys(): 40 | subvars = [X['out'] for X in pattern['substitutions']] 41 | vars.update(set(subvars)) 42 | expr = parse('*..vars') 43 | var_fields = [match for match in expr.find(pattern)] 44 | stat = True 45 | if var_fields: 46 | for field in var_fields: 47 | val = set(field.value) 48 | if not vars.issuperset(val): 49 | warnings.warn("%s has values (%s) not found in pattern variable list (%s): " 50 | % (field.full_path, str(val.difference(vars)), str(vars))) 51 | stat = False 52 | else: 53 | warnings.warn("Pattern has no var fields") 54 | return stat 55 | 56 | def test_text_fields(pattern): 57 | owl_entities = set() 58 | if 'classes' in pattern.keys(): owl_entities.update(set(pattern['classes'].keys())) 59 | if 'relations' in pattern.keys(): owl_entities.update(set(pattern['relations'].keys())) 60 | expr = parse('logical_axioms.[*].text') 61 | ms_fields = [match for match in expr.find(pattern)] 62 | expr = parse('equivalentTo|subClassOf|GCI|disjointWith.text') 63 | ms_fields.extend([match for match in expr.find(pattern)]) 64 | stat=True 65 | if ms_fields: 66 | for field in ms_fields: 67 | # Test for even number single quotes 68 | val = field.value 69 | m = re.findall("'", val) 70 | if divmod(len(m), 2)[1]: 71 | warnings.warn("text field '%s' has an odd number of single quotes." % val) 72 | stat = False 73 | # Test that single quoted strings are OWL entities in dict. 74 | m = re.findall("'(.+?)'", val) 75 | quoted = set(m) 76 | if not owl_entities.issuperset(quoted): 77 | warnings.warn("%s has values (%s) not found in owl entity dictionaries t (%s): " 78 | % (field.full_path, str(quoted.difference(owl_entities)), str(owl_entities))) 79 | stat = False 80 | else: 81 | warnings.warn("Pattern has no text fields") 82 | return stat 83 | 84 | schema_url = 'https://raw.githubusercontent.com/dosumis/dead_simple_owl_design_patterns/master/spec/DOSDP_schema_full.yaml' 85 | 86 | dosdp_full_text = requests.get(schema_url) 87 | 88 | ryaml = YAML(typ='safe') 89 | 90 | dosdp = ryaml.load(dosdp_full_text.text) 91 | # TODO - Add better parsing for ryaml execptions. 92 | 93 | v = Draft7Validator(dosdp) 94 | 95 | pattern_docs = glob.glob(sys.argv[1] + "*.yaml") 96 | pattern_docs.extend(glob.glob(sys.argv[1] + "*.yml")) 97 | stat = True 98 | for pattern_doc in pattern_docs: 99 | warnings.warn("Checking %s" % pattern_doc) 100 | file = open(pattern_doc, "r") 101 | pattern = ryaml.load(file.read()) 102 | if not test_jschema(v, pattern): stat = False 103 | if not test_vars(pattern): stat = False 104 | if not test_text_fields(pattern): stat = False 105 | 106 | if not stat: 107 | sys.exit(1) 108 | -------------------------------------------------------------------------------- /src/yaml2json_runner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import json_yaml_tools 4 | import glob 5 | import re 6 | import sys 7 | 8 | """Convert all yaml files in a specified directory (arg1) into json files 9 | """ 10 | 11 | # FInd all YAML files in directory. 12 | yaml_files = glob.glob(sys.argv[1] + "*.yaml") # Note - glob returns full file path 13 | 14 | for f in yaml_files: 15 | m = re.search("(.+).yaml", f) 16 | pattern_name = m.group(1) 17 | json_yaml_tools.yaml2json(f, pattern_name + ".json") 18 | 19 | 20 | 21 | # Run conversion to JSON 22 | --------------------------------------------------------------------------------