From a074398ad6ef50b3743dd5d12cc6c51083c25293 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Tue, 9 Feb 2021 01:14:13 -0500 Subject: [PATCH 1/4] Added phylorefType to Brochu 2003 example. --- test/examples/correct/brochu_2003.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/examples/correct/brochu_2003.json b/test/examples/correct/brochu_2003.json index a886b967..e16c0bd1 100644 --- a/test/examples/correct/brochu_2003.json +++ b/test/examples/correct/brochu_2003.json @@ -45,6 +45,7 @@ "phylorefs": [ { "label": "Alligatoridae", + "phylorefType": "phyloref:PhyloreferenceUsingMinimumClade", "definition": "Alligatoridae (Cuvier 1807).\n\nLast common ancestor of Alligator mississippiensis and Caiman crocodilus and all of its descendents.", "definitionSource": { "type": "article", @@ -121,6 +122,7 @@ }, { "label": "Alligatorinae", + "phylorefType": "phyloref:PhyloreferenceUsingMaximumClade", "definition": "Alligatorinae (Kälin 1940).\n\nAlligator mississippiensis and all crocodylians closer to it than to Caiman crocodilus.", "definitionSource": { "type": "article", @@ -203,6 +205,7 @@ }, { "label": "Caimaninae", + "phylorefType": "phyloref:PhyloreferenceUsingMaximumClade", "definition": "Caimaninae (Norell 1988).\n\nCaiman crocodilus and all crocodylians closer to it than to Alligator mississippiensis.", "definitionSource": { "type": "article", @@ -284,6 +287,7 @@ }, { "label": "Crocodyloidea", + "phylorefType": "phyloref:PhyloreferenceUsingMaximumClade", "definition": "Crocodyloidea (Fitzinger 1826).\n\nCrocodylus niloticus and all crocodylians closer to it than to Alligator mississippiensis or Gavialis gangeticus.", "internalSpecifiers": [ { @@ -343,6 +347,7 @@ }, { "label": "Crocodylidae", + "phylorefType": "phyloref:PhyloreferenceUsingMinimumClade", "definition": "Crocodylidae (Cuvier 1807). Definition dependent on phylogenetic context.\n\nLast common ancestor of Crocodylus niloticus, Osteolaemus tetraspis, and Tomistoma schlegelii and all of its descendents.", "definitionSource": { "type": "article", @@ -431,6 +436,7 @@ }, { "label": "Diplocynodontinae", + "phylorefType": "phyloref:PhyloreferenceUsingMaximumClade", "definition": "Diplocynodontinae (Brochu 1999).\n\nDiplocynodon ratelii and all crocodylians closer to it than to Alligator mississippiensis.", "definitionSource": { "type": "article", From 254a36d63abe22912641a8a4a981e102eaefd5a6 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Tue, 9 Feb 2021 01:14:56 -0500 Subject: [PATCH 2/4] Added phyloref type generation and to expected JSON-LD and NQ output. --- src/wrappers/PhylorefWrapper.js | 18 ++++++++++++++++-- test/examples/correct/brochu_2003.jsonld | 24 ++++++++++++++++++------ test/examples/correct/brochu_2003.nq | 6 ++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/wrappers/PhylorefWrapper.js b/src/wrappers/PhylorefWrapper.js index a6cd743e..dba80cbd 100644 --- a/src/wrappers/PhylorefWrapper.js +++ b/src/wrappers/PhylorefWrapper.js @@ -680,13 +680,19 @@ class PhylorefWrapper { PhylorefWrapper.componentClassesByLabel = {}; phylorefAsJSONLD.hasComponentClass = []; + // The type of this phyloreference. + let calculatedPhylorefType; + // The list of logical expressions generated for this phyloref. let logicalExpressions = []; if (internalSpecifiers.length === 0) { // We can't handle phyloreferences without at least one internal specifier. + calculatedPhylorefType = 'phyloref:MalformedPhyloreference'; phylorefAsJSONLD.malformedPhyloreference = 'No internal specifiers provided'; } else if (externalSpecifiers.length > 0) { + calculatedPhylorefType = 'phyloref:PhyloreferenceUsingMaximumClade'; + // If the phyloreference has at least one external specifier, we // can provide a simplified expression for the internal specifier, // in the form: @@ -711,6 +717,8 @@ class PhylorefWrapper { ); } } else { + calculatedPhylorefType = 'phyloref:PhyloreferenceUsingMinimumClade'; + // We only have internal specifiers. We therefore need to use the algorithm in // PhylorefWrapper.createClassExpressionsForInternals() to create this expression. logicalExpressions = PhylorefWrapper.createClassExpressionsForInternals( @@ -772,8 +780,14 @@ class PhylorefWrapper { } phylorefAsJSONLD.subClassOf.push('phyloref:Phyloreference'); - // Metadata. - + // If the this Phyloref has a phylorefType that differs from the calculated + // phyloref type, throw an error. + if (has(phylorefAsJSONLD, 'phylorefType') && phylorefAsJSONLD.phylorefType !== calculatedPhylorefType) { + throw new Error( + `Phyloref ${this.label} has phylorefType set to '${phylorefAsJSONLD.phylorefType}', but it appears to be a '${calculatedPhylorefType}'.` + ); + } + phylorefAsJSONLD.subClassOf.push(calculatedPhylorefType); return phylorefAsJSONLD; } diff --git a/test/examples/correct/brochu_2003.jsonld b/test/examples/correct/brochu_2003.jsonld index a8506dee..0d407344 100644 --- a/test/examples/correct/brochu_2003.jsonld +++ b/test/examples/correct/brochu_2003.jsonld @@ -1286,6 +1286,7 @@ "phylorefs": [ { "label": "Alligatoridae", + "phylorefType": "phyloref:PhyloreferenceUsingMinimumClade", "definition": "Alligatoridae (Cuvier 1807).\n\nLast common ancestor of Alligator mississippiensis and Caiman crocodilus and all of its descendents.", "definitionSource": { "type": "article", @@ -1403,11 +1404,13 @@ } }, "subClassOf": [ - "phyloref:Phyloreference" + "phyloref:Phyloreference", + "phyloref:PhyloreferenceUsingMinimumClade" ] }, { "label": "Alligatorinae", + "phylorefType": "phyloref:PhyloreferenceUsingMaximumClade", "definition": "Alligatorinae (Kälin 1940).\n\nAlligator mississippiensis and all crocodylians closer to it than to Caiman crocodilus.", "definitionSource": { "type": "article", @@ -1527,11 +1530,13 @@ ] }, "subClassOf": [ - "phyloref:Phyloreference" + "phyloref:Phyloreference", + "phyloref:PhyloreferenceUsingMaximumClade" ] }, { "label": "Caimaninae", + "phylorefType": "phyloref:PhyloreferenceUsingMaximumClade", "definition": "Caimaninae (Norell 1988).\n\nCaiman crocodilus and all crocodylians closer to it than to Alligator mississippiensis.", "definitionSource": { "type": "article", @@ -1650,11 +1655,13 @@ ] }, "subClassOf": [ - "phyloref:Phyloreference" + "phyloref:Phyloreference", + "phyloref:PhyloreferenceUsingMaximumClade" ] }, { "label": "Crocodyloidea", + "phylorefType": "phyloref:PhyloreferenceUsingMaximumClade", "definition": "Crocodyloidea (Fitzinger 1826).\n\nCrocodylus niloticus and all crocodylians closer to it than to Alligator mississippiensis or Gavialis gangeticus.", "internalSpecifiers": [ { @@ -1934,11 +1941,13 @@ } ], "subClassOf": [ - "phyloref:Phyloreference" + "phyloref:Phyloreference", + "phyloref:PhyloreferenceUsingMaximumClade" ] }, { "label": "Crocodylidae", + "phylorefType": "phyloref:PhyloreferenceUsingMinimumClade", "definition": "Crocodylidae (Cuvier 1807). Definition dependent on phylogenetic context.\n\nLast common ancestor of Crocodylus niloticus, Osteolaemus tetraspis, and Tomistoma schlegelii and all of its descendents.", "definitionSource": { "type": "article", @@ -2682,11 +2691,13 @@ } ], "subClassOf": [ - "phyloref:Phyloreference" + "phyloref:Phyloreference", + "phyloref:PhyloreferenceUsingMinimumClade" ] }, { "label": "Diplocynodontinae", + "phylorefType": "phyloref:PhyloreferenceUsingMaximumClade", "definition": "Diplocynodontinae (Brochu 1999).\n\nDiplocynodon ratelii and all crocodylians closer to it than to Alligator mississippiensis.", "definitionSource": { "type": "article", @@ -2806,7 +2817,8 @@ ] }, "subClassOf": [ - "phyloref:Phyloreference" + "phyloref:Phyloreference", + "phyloref:PhyloreferenceUsingMaximumClade" ] } ], diff --git a/test/examples/correct/brochu_2003.nq b/test/examples/correct/brochu_2003.nq index 9e21fbfd..6c4e902c 100644 --- a/test/examples/correct/brochu_2003.nq +++ b/test/examples/correct/brochu_2003.nq @@ -261,6 +261,7 @@ . "Alligatoridae" . . + . _:b141 . "Alligatorinae (Kälin 1940).\n\nAlligator mississippiensis and all crocodylians closer to it than to Caiman crocodilus." . _:b149 . @@ -270,6 +271,7 @@ . "Alligatorinae" . . + . _:b156 . "Caimaninae (Norell 1988).\n\nCaiman crocodilus and all crocodylians closer to it than to Alligator mississippiensis." . _:b163 . @@ -279,6 +281,7 @@ . "Caimaninae" . . + . _:b170 . "Crocodyloidea (Fitzinger 1826).\n\nCrocodylus niloticus and all crocodylians closer to it than to Alligator mississippiensis or Gavialis gangeticus." . _:b177 . @@ -294,6 +297,7 @@ . "Crocodyloidea" . . + . . "(Crocodylus niloticus ~ Alligator mississippiensis)" . . @@ -340,6 +344,7 @@ . "Crocodylidae" . . + . . "(Crocodylus niloticus & Osteolaemus tetraspis & Tomistoma schlegelii)" . . @@ -393,6 +398,7 @@ . "Diplocynodontinae" . . + . _:b359 . _:b0 "Christopher A. Brochu (2003) Phylogenetic approaches toward crocodylian history Annual Review of Earth and Planetary Sciences 31 fig 1 doi: 10.1146/annurev.earth.31.100901.141308 URL: https://www.annualreviews.org/doi/10.1146/annurev.earth.31.100901.141308" . _:b0 "Phylogenetic approaches toward crocodylian history" . From f4476bf770913581d4f0103d29d43c53ed185858 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Tue, 9 Feb 2021 01:24:51 -0500 Subject: [PATCH 3/4] Removed phyloref:MalformedPhyloreference. I don't think it's worth creating a new term for this. --- src/wrappers/PhylorefWrapper.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wrappers/PhylorefWrapper.js b/src/wrappers/PhylorefWrapper.js index dba80cbd..978f912c 100644 --- a/src/wrappers/PhylorefWrapper.js +++ b/src/wrappers/PhylorefWrapper.js @@ -688,7 +688,6 @@ class PhylorefWrapper { if (internalSpecifiers.length === 0) { // We can't handle phyloreferences without at least one internal specifier. - calculatedPhylorefType = 'phyloref:MalformedPhyloreference'; phylorefAsJSONLD.malformedPhyloreference = 'No internal specifiers provided'; } else if (externalSpecifiers.length > 0) { calculatedPhylorefType = 'phyloref:PhyloreferenceUsingMaximumClade'; From ce4f352629069a84345ff0047dab460cc3496b6d Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Tue, 9 Feb 2021 01:31:24 -0500 Subject: [PATCH 4/4] Added possible phylorefTypes to the JSON Schema. --- docs/context/development/schema.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/context/development/schema.json b/docs/context/development/schema.json index e52c117f..70d63d00 100644 --- a/docs/context/development/schema.json +++ b/docs/context/development/schema.json @@ -285,6 +285,14 @@ "description": "The identifier of this clade definition in the Regnum database", "minLength": 1 }, + "phylorefType": { + "description": "The type of this phyloreference.", + "enum": [ + "phyloref:PhyloreferenceUsingMaximumClade", + "phyloref:PhyloreferenceUsingMinimumClade", + "phyloref:PhyloreferenceUsingApomorphy" + ] + }, "label": { "type": "string", "description": "The name or label of this phyloreference."