Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add phyloref type to phyloreferences #61

Merged
merged 4 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/context/development/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
17 changes: 15 additions & 2 deletions src/wrappers/PhylorefWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,18 @@ 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.
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:
Expand All @@ -711,6 +716,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(
Expand Down Expand Up @@ -772,8 +779,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;
}
Expand Down
6 changes: 6 additions & 0 deletions test/examples/correct/brochu_2003.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
24 changes: 18 additions & 6 deletions test/examples/correct/brochu_2003.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -2806,7 +2817,8 @@
]
},
"subClassOf": [
"phyloref:Phyloreference"
"phyloref:Phyloreference",
"phyloref:PhyloreferenceUsingMaximumClade"
]
}
],
Expand Down
6 changes: 6 additions & 0 deletions test/examples/correct/brochu_2003.nq
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
<http://example.org/brochu_2003.json#phyloref0> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/brochu_2003.json#phyloref0> <http://www.w3.org/2000/01/rdf-schema#label> "Alligatoridae" .
<http://example.org/brochu_2003.json#phyloref0> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#Phyloreference> .
<http://example.org/brochu_2003.json#phyloref0> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#PhyloreferenceUsingMinimumClade> .
<http://example.org/brochu_2003.json#phyloref0> <http://www.w3.org/2002/07/owl#equivalentClass> _:b141 .
<http://example.org/brochu_2003.json#phyloref1> <http://purl.obolibrary.org/obo/IAO_0000115> "Alligatorinae (Kälin 1940).\n\nAlligator mississippiensis and all crocodylians closer to it than to Caiman crocodilus." .
<http://example.org/brochu_2003.json#phyloref1> <http://purl.obolibrary.org/obo/IAO_0000119> _:b149 .
Expand All @@ -270,6 +271,7 @@
<http://example.org/brochu_2003.json#phyloref1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/brochu_2003.json#phyloref1> <http://www.w3.org/2000/01/rdf-schema#label> "Alligatorinae" .
<http://example.org/brochu_2003.json#phyloref1> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#Phyloreference> .
<http://example.org/brochu_2003.json#phyloref1> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#PhyloreferenceUsingMaximumClade> .
<http://example.org/brochu_2003.json#phyloref1> <http://www.w3.org/2002/07/owl#equivalentClass> _:b156 .
<http://example.org/brochu_2003.json#phyloref2> <http://purl.obolibrary.org/obo/IAO_0000115> "Caimaninae (Norell 1988).\n\nCaiman crocodilus and all crocodylians closer to it than to Alligator mississippiensis." .
<http://example.org/brochu_2003.json#phyloref2> <http://purl.obolibrary.org/obo/IAO_0000119> _:b163 .
Expand All @@ -279,6 +281,7 @@
<http://example.org/brochu_2003.json#phyloref2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/brochu_2003.json#phyloref2> <http://www.w3.org/2000/01/rdf-schema#label> "Caimaninae" .
<http://example.org/brochu_2003.json#phyloref2> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#Phyloreference> .
<http://example.org/brochu_2003.json#phyloref2> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#PhyloreferenceUsingMaximumClade> .
<http://example.org/brochu_2003.json#phyloref2> <http://www.w3.org/2002/07/owl#equivalentClass> _:b170 .
<http://example.org/brochu_2003.json#phyloref3> <http://purl.obolibrary.org/obo/IAO_0000115> "Crocodyloidea (Fitzinger 1826).\n\nCrocodylus niloticus and all crocodylians closer to it than to Alligator mississippiensis or Gavialis gangeticus." .
<http://example.org/brochu_2003.json#phyloref3> <http://purl.org/spar/pso/holdsStatusInTime> _:b177 .
Expand All @@ -294,6 +297,7 @@
<http://example.org/brochu_2003.json#phyloref3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/brochu_2003.json#phyloref3> <http://www.w3.org/2000/01/rdf-schema#label> "Crocodyloidea" .
<http://example.org/brochu_2003.json#phyloref3> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#Phyloreference> .
<http://example.org/brochu_2003.json#phyloref3> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#PhyloreferenceUsingMaximumClade> .
<http://example.org/brochu_2003.json#phyloref3_component1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/brochu_2003.json#phyloref3_component1> <http://www.w3.org/2000/01/rdf-schema#label> "(Crocodylus niloticus ~ Alligator mississippiensis)" .
<http://example.org/brochu_2003.json#phyloref3_component1> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#PhyloreferenceUsingMaximumClade> .
Expand Down Expand Up @@ -340,6 +344,7 @@
<http://example.org/brochu_2003.json#phyloref4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/brochu_2003.json#phyloref4> <http://www.w3.org/2000/01/rdf-schema#label> "Crocodylidae" .
<http://example.org/brochu_2003.json#phyloref4> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#Phyloreference> .
<http://example.org/brochu_2003.json#phyloref4> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#PhyloreferenceUsingMinimumClade> .
<http://example.org/brochu_2003.json#phyloref4_component1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/brochu_2003.json#phyloref4_component1> <http://www.w3.org/2000/01/rdf-schema#label> "(Crocodylus niloticus & Osteolaemus tetraspis & Tomistoma schlegelii)" .
<http://example.org/brochu_2003.json#phyloref4_component1> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/brochu_2003.json#phyloref4> .
Expand Down Expand Up @@ -393,6 +398,7 @@
<http://example.org/brochu_2003.json#phyloref5> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
<http://example.org/brochu_2003.json#phyloref5> <http://www.w3.org/2000/01/rdf-schema#label> "Diplocynodontinae" .
<http://example.org/brochu_2003.json#phyloref5> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#Phyloreference> .
<http://example.org/brochu_2003.json#phyloref5> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://ontology.phyloref.org/phyloref.owl#PhyloreferenceUsingMaximumClade> .
<http://example.org/brochu_2003.json#phyloref5> <http://www.w3.org/2002/07/owl#equivalentClass> _:b359 .
_:b0 <http://purl.org/dc/terms/bibliographicCitation> "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 <http://purl.org/dc/terms/title> "Phylogenetic approaches toward crocodylian history" .
Expand Down