From 9663c4884ddce89645ab150e169e638cd4a35f1a Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Wed, 25 Oct 2023 15:05:26 -0400 Subject: [PATCH 1/4] In-progress relation diff --- .github/workflows/makefile.yml | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/makefile.yml diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml new file mode 100644 index 0000000000..b231be80ab --- /dev/null +++ b/.github/workflows/makefile.yml @@ -0,0 +1,60 @@ +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 -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/' 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 -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/' left.facts + - name: Upload PR facts + uses: actions/upload-artifact@v2 + with: + name: left.facts + path: src/ontology/left.facts + retention-days: 1 + diff: + needs: + - reason_pr + - reason_master + runs-on: ubuntu-latest + container: obolibrary/odkfull:${{ vars.ODK_VERSION }} + steps: + - uses: actions/checkout@v3 + - name: Download master classification + uses: actions/download-artifact@v2 + with: + name: left.facts + path: left.facts + - name: Download PR classification + uses: actions/download-artifact@v2 + with: + name: right.facts + path: right.facts + - name: Diff classification + run: cd src/ontology; souffle ../util/relation-diff.dl + - name: Upload diff + uses: actions/upload-artifact@v2 + with: + name: classification-diff.md + path: src/ontology/classification-diff.md + From 34c859b3da98c0e974ac85563e357f98e1ef9fcc Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Thu, 26 Oct 2023 13:39:01 -0400 Subject: [PATCH 2/4] Rename makefile.yml to relation-diff.yml --- .github/workflows/{makefile.yml => relation-diff.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{makefile.yml => relation-diff.yml} (100%) diff --git a/.github/workflows/makefile.yml b/.github/workflows/relation-diff.yml similarity index 100% rename from .github/workflows/makefile.yml rename to .github/workflows/relation-diff.yml From 45043e106c4f4a772b85562e2a2a681ef4be7f45 Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Thu, 26 Oct 2023 13:50:12 -0400 Subject: [PATCH 3/4] Update relation-diff.yml --- .github/workflows/relation-diff.yml | 34 +++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/relation-diff.yml b/.github/workflows/relation-diff.yml index b231be80ab..453f518fe6 100644 --- a/.github/workflows/relation-diff.yml +++ b/.github/workflows/relation-diff.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Run relation-graph - run: cd src/ontology; ROBOT_JAVA_ARGS=-Xmx6G robot merge -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/' right.facts + 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/' right.facts - name: Upload PR facts uses: actions/upload-artifact@v2 with: @@ -25,36 +25,56 @@ jobs: with: ref: master - name: Run relation-graph - run: cd src/ontology; ROBOT_JAVA_ARGS=-Xmx6G robot merge -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/' left.facts + 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/' 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 classification + - name: Download master relations uses: actions/download-artifact@v2 with: name: left.facts path: left.facts - - name: Download PR classification + - 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: classification-diff.md - path: src/ontology/classification-diff.md - + name: diff.tsv + path: src/ontology/diff.tsv From 3bf4a098cff7cf65e5b42c8a70416718cbdfd52a Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Thu, 26 Oct 2023 13:55:14 -0400 Subject: [PATCH 4/4] Add relation-diff script. --- src/util/relation-diff.dl | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/util/relation-diff.dl diff --git a/src/util/relation-diff.dl b/src/util/relation-diff.dl new file mode 100644 index 0000000000..85495900e0 --- /dev/null +++ b/src/util/relation-diff.dl @@ -0,0 +1,58 @@ +#define RDF_TYPE "" +#define RDFS_SUBCLASS_OF "" +#define RDFS_SUBPROPERTY_OF "" +#define OWL_TRANSITIVE_PROPERTY "" + +.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