From 306e904400592bef23695d9d6a2091e8a041184c Mon Sep 17 00:00:00 2001
From: Robert Bossy <Robert.Bossy@inra.fr>
Date: Tue, 5 Apr 2022 18:13:24 +0200
Subject: [PATCH 1/5] index entities multiple times if their concept has
 multiple paths

---
 plans/entities.plan | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/plans/entities.plan b/plans/entities.plan
index b54e298c..376100b8 100644
--- a/plans/entities.plan
+++ b/plans/entities.plan
@@ -1293,16 +1293,31 @@
 	  <text>"{SENT}"</text>
 	</annotations>
 	<annotations>
-	  <instances>layer:habitats</instances>
-	  <text>"{habitat}" ^ @concept-path ^ "/"</text>
+	  <instances>layer:habitats.nav:features:concept-path</instances>
+	  <text>"{habitat}" ^ @value ^ "/"</text>
+	  <fragments>
+	    <instances>$</instances>
+	    <start>nav:parent.start</start>
+	    <end>nav:parent.end</end>
+	  </fragments>
 	</annotations>
 	<annotations>
-	  <instances>layer:phenotypes</instances>
-	  <text>"{phenotype}" ^ @concept-path ^ "/"</text>
+	  <instances>layer:phenotypes.nav:features:concept-path</instances>
+	  <text>"{phenotype}" ^ @value ^ "/"</text>
+	  <fragments>
+	    <instances>$</instances>
+	    <start>nav:parent.start</start>
+	    <end>nav:parent.end</end>
+	  </fragments>
 	</annotations>
 	<annotations>
-	  <instances>layer:uses</instances>
-	  <text>"{use}" ^ @concept-path ^ "/"</text>
+	  <instances>layer:uses.nav:features:concept-path</instances>
+	  <text>"{use}" ^ @value ^ "/"</text>
+	  <fragments>
+	    <instances>$</instances>
+	    <start>nav:parent.start</start>
+	    <end>nav:parent.end</end>
+	  </fragments>
 	</annotations>
 	<annotations>
 	  <instances>relations:CooccurrenceLocalization.tuples</instances>
-- 
GitLab


From b5493154fd9f5b3476eaf84815223c0205f7c7ee Mon Sep 17 00:00:00 2001
From: Robert Bossy <Robert.Bossy@inra.fr>
Date: Tue, 5 Apr 2022 19:10:02 +0200
Subject: [PATCH 2/5] index relations multiple times if their right hand
 argument concept has multiple paths

---
 plans/entities.plan | 65 +++++++++++----------------------------------
 1 file changed, 15 insertions(+), 50 deletions(-)

diff --git a/plans/entities.plan b/plans/entities.plan
index 376100b8..4d3cf7b8 100644
--- a/plans/entities.plan
+++ b/plans/entities.plan
@@ -1320,73 +1320,38 @@
 	  </fragments>
 	</annotations>
 	<annotations>
-	  <instances>relations:CooccurrenceLocalization.tuples</instances>
-	  <fragments>
-	    <instances>sort:ival(args, start)</instances>
-	  </fragments>
-	  <text>"{livesin}{taxon}" ^ args:Bacterium.@path ^ "/~{habitat}" ^ args:Localization.@concept-path ^ "/"</text>
-	  <arguments>
-	    <taxon>args:Bacterium.id:unique</taxon>
-	    <habitat>args:Localization.id:unique</habitat>
-	  </arguments>
-	</annotations>
-	<annotations>
-	  <instances>relations:CooccurrenceLocalization.tuples</instances>
-	  <fragments>
-	    <instances>sort:ival(args, start)</instances>
-	  </fragments>
-	  <text>"{livesin}" ^ args:Bacterium.@form ^ "/~" ^ args:Localization.@form ^ "/"</text>
-	  <arguments>
-	    <taxon>args:Bacterium.id:unique</taxon>
-	    <habitat>args:Localization.id:unique</habitat>
-	  </arguments>
-	</annotations>
-	<annotations>
-	  <instances>relations:PhenotypeRelation.tuples</instances>
-	  <fragments>
-	    <instances>sort:ival(args, start)</instances>
-	  </fragments>
-	  <text>"{exhibits}{taxon}" ^ args:Microorganism.@path ^ "/~{phenotype}" ^ args:Phenotype.@concept-path ^ "/"</text>
-	  <arguments>
-	    <taxon>args:Microorganism.id:unique</taxon>
-	    <phenotype>args:Phenotype.id:unique</phenotype>
-	  </arguments>
-	</annotations>
-	<annotations>
-	  <instances>relations:PhenotypeRelation.tuples</instances>
+	  <instances>relations:CooccurrenceLocalization.tuples.nav:arguments[@role == "Localization"].nav:features:concept-path</instances>
 	  <fragments>
-	    <instances>sort:ival(args, start)</instances>
+	    <instances>sort:ival(nav:parent.nav:parent.args, start)</instances>
 	  </fragments>
-	  <text>"{exhibits}" ^ args:Microorganism.@form ^ "/~" ^ args:Phenotype.@form ^ "/"</text>
+	  <text>"{livesin}{taxon}" ^ nav:parent.nav:parent.args:Bacterium.@path ^ "/~{habitat}" ^ @value ^ "/"</text>
 	  <arguments>
-	    <taxon>args:Microorganism.id:unique</taxon>
-	    <phenotype>args:Phenotype.id:unique</phenotype>
+	    <taxon>nav:parent.nav:parent.args:Bacterium.id:unique</taxon>
+	    <habitat>nav:parent.id:unique</habitat>
 	  </arguments>
 	</annotations>
-
 	<annotations>
-	  <instances>relations:UseRelation.tuples</instances>
+	  <instances>relations:PhenotypeRelation.tuples.nav:arguments[@role == "Phenotype"].nav:features:concept-path</instances>
 	  <fragments>
-	    <instances>sort:ival(args, start)</instances>
+	    <instances>sort:ival(nav:parent.nav:parent.args, start)</instances>
 	  </fragments>
-	  <text>"{studiedfor}{taxon}" ^ args:Microorganism.@path ^ "/~{use}" ^ args:Use.@concept-path ^ "/"</text>
+	  <text>"{exhibits}{taxon}" ^ nav:parent.nav:parent.args:Microorganism.@path ^ "/~{phenotype}" ^ @value ^ "/"</text>
 	  <arguments>
-	    <taxon>args:Microorganism.id:unique</taxon>
-	    <use>args:Use.id:unique</use>
+	    <taxon>nav:parent.nav:parent.args:Microorganism.id:unique</taxon>
+	    <phenotype>nav:parent.id:unique</phenotype>
 	  </arguments>
 	</annotations>
 	<annotations>
-	  <instances>relations:UseRelation.tuples</instances>
+	  <instances>relations:UseRelation.tuples.nav:arguments[@role == "Use"].nav:features:concept-path</instances>
 	  <fragments>
-	    <instances>sort:ival(args, start)</instances>
+	    <instances>sort:ival(nav:parent.nav:parent.args, start)</instances>
 	  </fragments>
-	  <text>"{studiedfor}" ^ args:Microorganism.@form ^ "/~" ^ args:Use.@form ^ "/"</text>
+	  <text>"{studiedfor}{taxon}" ^ nav:parent.nav:parent.args:Microorganism.@path ^ "/~{use}" ^ @value ^ "/"</text>
 	  <arguments>
-	    <taxon>args:Microorganism.id:unique</taxon>
-	    <use>args:Use.id:unique</use>
+	    <taxon>nav:parent.nav:parent.args:Microorganism.id:unique</taxon>
+	    <use>nav:parent.id:unique</use>
 	  </arguments>
 	</annotations>
-
       </fields>
       <fields>
 	<instances>nav:features:mesh-name</instances>
-- 
GitLab


From c3f753ec6e24321fb593016df9c960672e2c381e Mon Sep 17 00:00:00 2001
From: Robert Bossy <Robert.Bossy@inra.fr>
Date: Fri, 8 Apr 2022 17:09:20 +0200
Subject: [PATCH 3/5] deduplicate path indexation

---
 plans/entities.plan | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/plans/entities.plan b/plans/entities.plan
index 4d3cf7b8..5e420f1b 100644
--- a/plans/entities.plan
+++ b/plans/entities.plan
@@ -1293,7 +1293,7 @@
 	  <text>"{SENT}"</text>
 	</annotations>
 	<annotations>
-	  <instances>layer:habitats.nav:features:concept-path</instances>
+	  <instances>layer:habitats.sort:nsval(nav:features:concept-path, @value)</instances>
 	  <text>"{habitat}" ^ @value ^ "/"</text>
 	  <fragments>
 	    <instances>$</instances>
@@ -1302,7 +1302,7 @@
 	  </fragments>
 	</annotations>
 	<annotations>
-	  <instances>layer:phenotypes.nav:features:concept-path</instances>
+	  <instances>layer:phenotypes.sort:nsval(nav:features:concept-path, @value)</instances>
 	  <text>"{phenotype}" ^ @value ^ "/"</text>
 	  <fragments>
 	    <instances>$</instances>
@@ -1311,7 +1311,7 @@
 	  </fragments>
 	</annotations>
 	<annotations>
-	  <instances>layer:uses.nav:features:concept-path</instances>
+	  <instances>layer:uses.sort:nsval(nav:features:concept-path, @value)</instances>
 	  <text>"{use}" ^ @value ^ "/"</text>
 	  <fragments>
 	    <instances>$</instances>
@@ -1320,7 +1320,7 @@
 	  </fragments>
 	</annotations>
 	<annotations>
-	  <instances>relations:CooccurrenceLocalization.tuples.nav:arguments[@role == "Localization"].nav:features:concept-path</instances>
+	  <instances>relations:CooccurrenceLocalization.tuples.nav:arguments[@role == "Localization"].sort:nsval(nav:features:concept-path, @value)</instances>
 	  <fragments>
 	    <instances>sort:ival(nav:parent.nav:parent.args, start)</instances>
 	  </fragments>
@@ -1331,7 +1331,7 @@
 	  </arguments>
 	</annotations>
 	<annotations>
-	  <instances>relations:PhenotypeRelation.tuples.nav:arguments[@role == "Phenotype"].nav:features:concept-path</instances>
+	  <instances>relations:PhenotypeRelation.tuples.nav:arguments[@role == "Phenotype"].sort:nsval(nav:features:concept-path, @value)</instances>
 	  <fragments>
 	    <instances>sort:ival(nav:parent.nav:parent.args, start)</instances>
 	  </fragments>
@@ -1342,7 +1342,7 @@
 	  </arguments>
 	</annotations>
 	<annotations>
-	  <instances>relations:UseRelation.tuples.nav:arguments[@role == "Use"].nav:features:concept-path</instances>
+	  <instances>relations:UseRelation.tuples.nav:arguments[@role == "Use"].sort:nsval(nav:features:concept-path, @value)</instances>
 	  <fragments>
 	    <instances>sort:ival(nav:parent.nav:parent.args, start)</instances>
 	  </fragments>
-- 
GitLab


From 78e23b5ac6493fb14d6ba7880c4ca52f7fb944d5 Mon Sep 17 00:00:00 2001
From: Robert Bossy <Robert.Bossy@inra.fr>
Date: Mon, 11 Apr 2022 23:41:33 +0200
Subject: [PATCH 4/5] fixed indexing of relation reference to arguments

---
 plans/entities.plan | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/plans/entities.plan b/plans/entities.plan
index 5e420f1b..8431acb3 100644
--- a/plans/entities.plan
+++ b/plans/entities.plan
@@ -1294,6 +1294,7 @@
 	</annotations>
 	<annotations>
 	  <instances>layer:habitats.sort:nsval(nav:features:concept-path, @value)</instances>
+	  <identifier>nav:parent.id:unique</identifier>
 	  <text>"{habitat}" ^ @value ^ "/"</text>
 	  <fragments>
 	    <instances>$</instances>
@@ -1327,7 +1328,7 @@
 	  <text>"{livesin}{taxon}" ^ nav:parent.nav:parent.args:Bacterium.@path ^ "/~{habitat}" ^ @value ^ "/"</text>
 	  <arguments>
 	    <taxon>nav:parent.nav:parent.args:Bacterium.id:unique</taxon>
-	    <habitat>nav:parent.id:unique</habitat>
+	    <habitat>nav:parent.nav:parent.args:Localization.id:unique</habitat>
 	  </arguments>
 	</annotations>
 	<annotations>
-- 
GitLab


From df73ad180aaf916e6b505d13bc4329808e0c6e10 Mon Sep 17 00:00:00 2001
From: Robert Bossy <Robert.Bossy@inra.fr>
Date: Mon, 11 Apr 2022 23:44:18 +0200
Subject: [PATCH 5/5] fixed indexing of phenotype and use relations

---
 plans/entities.plan | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/plans/entities.plan b/plans/entities.plan
index 8431acb3..a513512f 100644
--- a/plans/entities.plan
+++ b/plans/entities.plan
@@ -1304,6 +1304,7 @@
 	</annotations>
 	<annotations>
 	  <instances>layer:phenotypes.sort:nsval(nav:features:concept-path, @value)</instances>
+	  <identifier>nav:parent.id:unique</identifier>
 	  <text>"{phenotype}" ^ @value ^ "/"</text>
 	  <fragments>
 	    <instances>$</instances>
@@ -1313,6 +1314,7 @@
 	</annotations>
 	<annotations>
 	  <instances>layer:uses.sort:nsval(nav:features:concept-path, @value)</instances>
+	  <identifier>nav:parent.id:unique</identifier>
 	  <text>"{use}" ^ @value ^ "/"</text>
 	  <fragments>
 	    <instances>$</instances>
@@ -1339,7 +1341,7 @@
 	  <text>"{exhibits}{taxon}" ^ nav:parent.nav:parent.args:Microorganism.@path ^ "/~{phenotype}" ^ @value ^ "/"</text>
 	  <arguments>
 	    <taxon>nav:parent.nav:parent.args:Microorganism.id:unique</taxon>
-	    <phenotype>nav:parent.id:unique</phenotype>
+	    <phenotype>nav:parent.nav:parent.args:Phenotype.id:unique</phenotype>
 	  </arguments>
 	</annotations>
 	<annotations>
@@ -1350,7 +1352,7 @@
 	  <text>"{studiedfor}{taxon}" ^ nav:parent.nav:parent.args:Microorganism.@path ^ "/~{use}" ^ @value ^ "/"</text>
 	  <arguments>
 	    <taxon>nav:parent.nav:parent.args:Microorganism.id:unique</taxon>
-	    <use>nav:parent.id:unique</use>
+	    <use>nav:parent.nav:parent.args:Use.id:unique</use>
 	  </arguments>
 	</annotations>
       </fields>
-- 
GitLab