-
Notifications
You must be signed in to change notification settings - Fork 40
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 #26315 from geneontology/balhoff-patch-2
Add relation-diff action for testing
- Loading branch information
Showing
2 changed files
with
138 additions
and
0 deletions.
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,80 @@ | ||
name: Relation diff | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
reason_pr: | ||
runs-on: ubuntu-latest | ||
container: obolibrary/odkfull:${{ vars.ODK_VERSION }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Run relation-graph | ||
run: cd src/ontology; ROBOT_JAVA_ARGS=-Xmx6G robot merge --catalog catalog-v001.xml -i go-edit.obo -o go-merged.ofn; JAVA_OPTS=-Xmx6G relation-graph --ontology-file go-merged.ofn --mode RDF --output-file go-rels.nt --output-subclasses true --reflexive-subclasses false --equivalence-as-subclass false; sed 's/ /\t/' <go-merged.nt | sed 's/ /\t/' | sed 's/ \.$//' >right.facts | ||
- name: Upload PR facts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: right.facts | ||
path: src/ontology/right.facts | ||
retention-days: 1 | ||
reason_master: | ||
runs-on: ubuntu-latest | ||
container: obolibrary/odkfull:${{ vars.ODK_VERSION }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: master | ||
- name: Run relation-graph | ||
run: cd src/ontology; ROBOT_JAVA_ARGS=-Xmx6G robot merge --catalog catalog-v001.xml -i go-edit.obo -o go-merged.ofn; JAVA_OPTS=-Xmx6G relation-graph --ontology-file go-merged.ofn --mode RDF --output-file go-rels.nt --output-subclasses true --reflexive-subclasses false --equivalence-as-subclass false; sed 's/ /\t/' <go-merged.nt | sed 's/ /\t/' | sed 's/ \.$//' >left.facts | ||
- name: Upload PR facts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: left.facts | ||
path: src/ontology/left.facts | ||
retention-days: 1 | ||
merge_ontology: | ||
runs-on: ubuntu-latest | ||
container: obolibrary/odkfull:${{ vars.ODK_VERSION }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Create merged ontology | ||
run: cd src/ontology; ROBOT_JAVA_ARGS=-Xmx6G robot merge --catalog catalog-v001.xml -i go-edit.obo -o go-merged.ttl; riot --output=ntriples go-merged.ttl | sed 's/ /\t/' | sed 's/ /\t/' | sed 's/ \.$//' >ontrdf.facts | ||
- name: Upload ontrdf facts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ontrdf.facts | ||
path: src/ontology/ontrdf.facts | ||
retention-days: 1 | ||
diff: | ||
needs: | ||
- reason_pr | ||
- reason_master | ||
- merge_ontology | ||
runs-on: ubuntu-latest | ||
container: obolibrary/odkfull:${{ vars.ODK_VERSION }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Download master relations | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: left.facts | ||
path: left.facts | ||
- name: Download PR relations | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: right.facts | ||
path: right.facts | ||
- name: Download merged ontology | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ontrdf.facts | ||
path: ontrdf.facts | ||
- name: Diff classification | ||
run: cd src/ontology; souffle ../util/relation-diff.dl | ||
- name: Combine output | ||
run: cat lost.csv gained.csv >diff.tsv | ||
- name: Upload diff | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: diff.tsv | ||
path: src/ontology/diff.tsv |
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,58 @@ | ||
#define RDF_TYPE "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>" | ||
#define RDFS_SUBCLASS_OF "<http://www.w3.org/2000/01/rdf-schema#subClassOf>" | ||
#define RDFS_SUBPROPERTY_OF "<http://www.w3.org/2000/01/rdf-schema#subPropertyOf>" | ||
#define OWL_TRANSITIVE_PROPERTY "<http://www.w3.org/2002/07/owl#TransitiveProperty>" | ||
|
||
.decl left(s: symbol, p: symbol, o: symbol) | ||
.decl right(s: symbol, p: symbol, o: symbol) | ||
.decl left_equivalent(x: symbol, y: symbol) | ||
.decl left_subClassOf(sub: symbol, super: symbol) | ||
.decl right_equivalent(x: symbol, y: symbol) | ||
.decl right_subClassOf(sub: symbol, super: symbol) | ||
.decl ontrdf(s: symbol, p: symbol, o: symbol) | ||
.decl transitive(prop: symbol) | ||
.decl subPropertyOf(sub: symbol, super: symbol) | ||
|
||
.decl lost_entailment(s: symbol, p: symbol, o: symbol) | ||
.decl gained_entailment(s: symbol, p: symbol, o: symbol) | ||
.decl lost_redundant(s: symbol, p: symbol, o: symbol) | ||
.decl lost(s: symbol, p: symbol, o: symbol, dot: symbol) | ||
.decl gained_redundant(s: symbol, p: symbol, o: symbol) | ||
.decl gained(s: symbol, p: symbol, o: symbol, dot: symbol) | ||
|
||
.input left | ||
.input right | ||
.input ontrdf //using right version | ||
|
||
|
||
left_equivalent(x, y) :- left(x, RDFS_SUBCLASS_OF, y), x != y, left(y, RDFS_SUBCLASS_OF, x). | ||
left_subClassOf(sub, super) :- left(sub, RDFS_SUBCLASS_OF, super), sub != super, !left_equivalent(sub, super). | ||
|
||
right_equivalent(x, y) :- right(x, RDFS_SUBCLASS_OF, y), x != y, right(y, RDFS_SUBCLASS_OF, x). | ||
right_subClassOf(sub, super) :- right(sub, RDFS_SUBCLASS_OF, super), sub != super, !right_equivalent(sub, super). | ||
|
||
transitive(prop) :- ontrdf(prop, RDF_TYPE, OWL_TRANSITIVE_PROPERTY). | ||
subPropertyOf(sub, super) :- ontrdf(sub, RDFS_SUBPROPERTY_OF, super), sub != super. | ||
subPropertyOf(sub, supersuper) :- subPropertyOf(sub, super), ontrdf(super, RDFS_SUBPROPERTY_OF, supersuper), super != supersuper, sub != supersuper. | ||
|
||
lost_entailment(s, p, o) :- left(s, p, o), !right(s, p, o). | ||
gained_entailment(s, p, o) :- right(s, p, o), !left(s, p, o). | ||
|
||
lost_redundant(s, p, o) :- left(s, p, other), s != other, !left_equivalent(s, other), left_subClassOf(other, o), lost_entailment(s, p, o). | ||
lost_redundant(s, p, o) :- lost_entailment(s, p, o), left_subClassOf(s, other), left(other, p, o), other != o, !left_equivalent(other, o). | ||
lost_redundant(s, p, o) :- lost_entailment(s, p, o), transitive(p), lost_entailment(s, p, other), other != o, lost_entailment(other, p, o). | ||
lost_redundant(s, p, o) :- lost_entailment(s, p, o), subPropertyOf(sub, p), lost_entailment(s, sub, o). | ||
lost_redundant(s, RDFS_SUBCLASS_OF, s) :- lost_entailment(s, RDFS_SUBCLASS_OF, s). | ||
|
||
lost(s, p, o, ".") :- lost_entailment(s, p, o), !lost_redundant(s, p, o). | ||
|
||
gained_redundant(s, p, o) :- right(s, p, other), s != other, !right_equivalent(s, other), right_subClassOf(other, o), gained_entailment(s, p, o). | ||
gained_redundant(s, p, o) :- gained_entailment(s, p, o), right_subClassOf(s, other), right(other, p, o), other != o, !right_equivalent(other, o). | ||
gained_redundant(s, p, o) :- gained_entailment(s, p, o), transitive(p), gained_entailment(s, p, other), other != o, gained_entailment(other, p, o). | ||
gained_redundant(s, p, o) :- gained_entailment(s, p, o), subPropertyOf(sub, p), gained_entailment(s, sub, o). | ||
gained_redundant(s, RDFS_SUBCLASS_OF, s) :- gained_entailment(s, RDFS_SUBCLASS_OF, s). | ||
|
||
gained(s, p, o, ".") :- gained_entailment(s, p, o), !gained_redundant(s, p, o). | ||
|
||
.output lost | ||
.output gained |