-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from djarecka/enh/bican_biolink_update
adding script and GA to edit bican_biolink
- Loading branch information
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: generating other formats | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'linkml-schema/bican_biolink.yaml' | ||
|
||
permissions: | ||
contents: write | ||
|
||
|
||
jobs: | ||
generate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout this repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install the required python packages | ||
run: python -m pip install .[test] | ||
|
||
- name: Other installations | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential git wget curl | ||
- name: Editing the bican biolink yaml file | ||
run: | | ||
cd linkml-schema | ||
python ../utils/bican_biolink_edit.py bican_biolink.yaml | ||
cd .. | ||
- name: Adding edited file to git | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
if ! git diff linkml-schema/bican_biolink.yaml --quiet; then | ||
git add linkml-schema/bican_biolink.yaml | ||
git commit -m "Updating the bican biolink yaml file for the bican specific case" | ||
git push | ||
else | ||
echo "No changes to commit" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Functions to edit the biolink model after running the general trimmer from bkbit | ||
# Edits are specific to our needs in bican and are not generalizable. | ||
# Earlier the issues were "fixed" by adding "slot_usage", but it might be easier to add it to the bican_biolink directly. | ||
import sys | ||
import yaml | ||
from pathlib import Path | ||
|
||
def bican_biolink_edit(schema_yaml: str) -> None: | ||
""" | ||
Edit the biolink model to fit the bican needs | ||
:param schema: SchemaView object | ||
""" | ||
# Change the category slot to have a curie range and a pattern for bican categories | ||
schema_yaml_path = Path(schema_yaml) | ||
with schema_yaml_path.open("r") as f: | ||
schema_dict = yaml.safe_load(f) | ||
schema_dict["slots"]["category"]["range"] = "curie" | ||
schema_dict["slots"]["category"]["pattern"] = r"^bican:[A-Z][A-Za-z]+$" | ||
schema_dict["slots"]["category"]["description"] = schema_dict["slots"]["category"]["description"] + ". NOTE: The category slot was modified to have a curie range and a pattern for bican categories." | ||
|
||
with schema_yaml_path.open("w") as f: | ||
f.write(yaml.dump(schema_dict, sort_keys=False)) | ||
|
||
|
||
if __name__ == '__main__': | ||
bican_biolink_yaml_path = sys.argv[1] | ||
bican_biolink_edit(bican_biolink_yaml_path) |