Skip to content

Commit

Permalink
Updated PhylogenyWrapper to use the updated API.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav committed May 22, 2019
1 parent 4fd6517 commit 733b5e9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/wrappers/PhylogenyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class PhylogenyWrapper {
// If that doesn't work, we can try to extract scientific names from
// the node label. Note that taxonomic units will NOT be extracted from
// the label if there is a taxonomic unit present!
return TaxonomicUnitWrapper.getTaxonomicUnitsFromNodeLabel(nodeLabel.trim());
return [TaxonomicUnitWrapper.fromLabel(nodeLabel.trim())];
}

getNodeLabelsMatchedBySpecifier(specifier) {
Expand Down
63 changes: 40 additions & 23 deletions test/phylogenies.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,22 @@ describe('PhylogenyWrapper', function () {
additionalNodeProperties: {
MVZ225749: {
representsTaxonomicUnits: [{
scientificNames: [{ scientificName: 'Rana luteiventris' }],
includesSpecimens: [{ occurrenceID: 'MVZ:225749' }],
'@type': [
phyx.TaxonomicUnitWrapper.TYPE_SPECIMEN,
phyx.TaxonomicUnitWrapper.TYPE_TAXON_CONCEPT,
],
nameString: 'Rana luteiventris',
occurrenceID: 'MVZ:225749',
}],
},
MVZ191016: {
representsTaxonomicUnits: [{
scientificNames: [{ scientificName: 'Rana luteiventris' }],
includesSpecimens: [{ occurrenceID: 'MVZ:191016' }],
'@type': [
phyx.TaxonomicUnitWrapper.TYPE_SPECIMEN,
phyx.TaxonomicUnitWrapper.TYPE_TAXON_CONCEPT,
],
nameString: 'Rana luteiventris',
occurrenceID: 'MVZ:191016',
}],
},
},
Expand All @@ -176,22 +184,34 @@ describe('PhylogenyWrapper', function () {
describe('#getTaxonomicUnitsForNodeLabel', function () {
it('should return the list of taxonomic units using information from additional node properties', function () {
expect(wrapper.getTaxonomicUnitsForNodeLabel('MVZ191016')).to.deep.equal([{
scientificNames: [{ scientificName: 'Rana luteiventris' }],
includesSpecimens: [{ occurrenceID: 'MVZ:191016' }],
'@type': [
phyx.TaxonomicUnitWrapper.TYPE_SPECIMEN,
phyx.TaxonomicUnitWrapper.TYPE_TAXON_CONCEPT,
],
nameString: 'Rana luteiventris',
occurrenceID: 'MVZ:191016',
}]);

expect(wrapper.getTaxonomicUnitsForNodeLabel('MVZ225749')).to.deep.equal([{
scientificNames: [{ scientificName: 'Rana luteiventris' }],
includesSpecimens: [{ occurrenceID: 'MVZ:225749' }],
'@type': [
phyx.TaxonomicUnitWrapper.TYPE_SPECIMEN,
phyx.TaxonomicUnitWrapper.TYPE_TAXON_CONCEPT,
],
nameString: 'Rana luteiventris',
occurrenceID: 'MVZ:225749',
}]);

expect(wrapper.getTaxonomicUnitsForNodeLabel('Rana boylii')).to.deep.equal([{
'@type': 'http://rs.tdwg.org/ontology/voc/TaxonConcept#TaxonConcept',
label: 'Rana boylii',
nameComplete: 'Rana boylii',
genusPart: 'Rana',
specificEpithet: 'boylii',
nomenclaturalCode: 'http://purl.obolibrary.org/obo/NOMEN_0000036',
'@type': 'http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName',
hasName: {
'@type': 'http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName',
label: 'Rana boylii',
nameComplete: 'Rana boylii',
genusPart: 'Rana',
specificEpithet: 'boylii',
nomenclaturalCode: 'http://purl.obolibrary.org/obo/NOMEN_0000036',
},
}]);
});
});
Expand All @@ -200,9 +220,8 @@ describe('PhylogenyWrapper', function () {
it('should match a specifier to MVZ225749 based on occurrence ID', function () {
const specifier1 = {
referencesTaxonomicUnits: [{
includesSpecimens: [{
occurrenceID: 'MVZ:225749',
}],
'@type': phyx.TaxonomicUnitWrapper.TYPE_SPECIMEN,
occurrenceID: 'MVZ:225749',
}],
};
expect(wrapper.getNodeLabelsMatchedBySpecifier(specifier1))
Expand All @@ -212,9 +231,8 @@ describe('PhylogenyWrapper', function () {
it('should match a specifier to MVZ191016 based on occurrence ID', function () {
const specifier2 = {
referencesTaxonomicUnits: [{
includesSpecimens: [{
occurrenceID: 'MVZ:191016',
}],
'@type': phyx.TaxonomicUnitWrapper.TYPE_SPECIMEN,
occurrenceID: 'MVZ:191016',
}],
};

Expand All @@ -225,14 +243,13 @@ describe('PhylogenyWrapper', function () {
it('should match a specifier to node "Rana boylii" based on the parsed scientific name', function () {
const specifier3 = {
referencesTaxonomicUnits: [{
scientificNames: [{
scientificName: 'Rana boyli',
}],
'@type': phyx.TaxonomicUnitWrapper.TYPE_TAXON_CONCEPT,
nameString: 'Rana boylii',
}],
};

expect(wrapper.getNodeLabelsMatchedBySpecifier(specifier3))
.to.have.members([]);
.to.have.members(['Rana boylii']);
});
});
});
Expand Down

0 comments on commit 733b5e9

Please sign in to comment.