Skip to content

Commit

Permalink
Merge pull request #230 from phyloref/export-as-nquads
Browse files Browse the repository at this point in the history
This PR upgrades @phyloref/phyx.js to the latest version, allowing us to use reference-based (model 2.0) expectations (#65) and to export the ontology in n-Quads (#222). A few phyx.js methods have been renamed or replaced since this code was written; this PR updates them so that phyloref resolution works again.

See #231 and #232 for some follow-up changes that will be needed after this PR.

Closes #65, closes #204, closes #222.
  • Loading branch information
gaurav authored Feb 15, 2022
2 parents 88aef84 + cd0e4e0 commit cc1e24f
Show file tree
Hide file tree
Showing 8 changed files with 1,432 additions and 2,861 deletions.
1,008 changes: 911 additions & 97 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@fortawesome/fontawesome-svg-core": "^1.2.29",
"@fortawesome/free-solid-svg-icons": "^5.13.1",
"@fortawesome/vue-fontawesome": "^0.1.10",
"@phyloref/phyx": "^0.2.1",
"@phyloref/phyx": "^1.0.1",
"bootstrap": "^4.5.0",
"bootstrap-vue": "^2.15.0",
"filesaver.js-npm": "^1.0.1",
Expand Down
1,645 changes: 491 additions & 1,154 deletions public/examples/brochu_2003.json

Large diffs are not rendered by default.

404 changes: 0 additions & 404 deletions public/examples/fisher_et_al_2007.json

This file was deleted.

1,194 changes: 0 additions & 1,194 deletions public/examples/hillis_and_wilcox_2005.json

This file was deleted.

30 changes: 22 additions & 8 deletions src/components/sidebar/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
class="list-group-item list-group-item-action"
href="javascript: void(0)"
@click="downloadAsJSONLD()"
>
Export as JSON-LD
</a>

<a
class="list-group-item list-group-item-action"
href="javascript: void(0)"
@click="downloadAsNQuads()"
>
Export as ontology
</a>
Expand Down Expand Up @@ -272,14 +280,6 @@ export default {
examplePHYXURLs() {
// Returns a list of example files to display in the "Examples" menu.
return [
{
url: 'examples/fisher_et_al_2007.json',
title: 'Fisher et al, 2007',
},
{
url: 'examples/hillis_and_wilcox_2005.json',
title: 'Hillis and Wilcox, 2005',
},
{
url: 'examples/brochu_2003.json',
title: 'Brochu 2003',
Expand Down Expand Up @@ -427,6 +427,20 @@ export default {
saveAs(jsonldFile, `${this.downloadFilenameForPhyx}.jsonld`);
},
downloadAsNQuads() {
// Exports the PHYX file as an OWL/N-Quads file, which can be opened in
// Protege or converted into other RDF formats.
const wrapped = new PhyxWrapper(this.$store.state.phyx.currentPhyx);
// TODO: we need a baseIRI here because of https://github.com/phyloref/phyx.js/issues/113
// Once that is fixed in phyx.js, we can remove it here.
wrapped.toRDF('https://example.phyloref.org/phyx#').then((content) => {
// Save to local hard drive.
const nqFile = new File([content], `${this.downloadFilenameForPhyx}.owl`, { type: 'application/n-quads;charset=utf-8' });
saveAs(nqFile, `${this.downloadFilenameForPhyx}.owl`);
});
},
reasonOverPhyloreferences() {
// Reason over all the phyloreferences and store the results on
// the Vue model at vm.reasoningResults so we can access them.
Expand Down
2 changes: 1 addition & 1 deletion src/components/specifiers/Specifier.vue
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export default {
computed: {
nomenCodes: () => TaxonNameWrapper.getNomenclaturalCodes(),
nomenclaturalCodeObj() {
return TaxonNameWrapper.getNomenCodeAsObject(this.enteredNomenclaturalCode);
return TaxonNameWrapper.getNomenCodeDetails(this.enteredNomenclaturalCode);
},
specifier() {
// Check the specifierClass before we figure out how to construct the
Expand Down
8 changes: 6 additions & 2 deletions src/store/modules/resolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ export default {
reasoningResults: undefined,
},
getters: {
// TODO: the following base URIs need to be in this form because that's how they are rendered in the Phyx file.
// We previously used methods in phyx.js to coordinate these, but they were removed during a previous cleanup.
// So we should probably put them back.

// Return a base URI for a given phylogeny.
getBaseURIForPhylogeny: (state, getters, rootState) => phylogeny => PhyxWrapper.getBaseURIForPhylogeny(rootState.phyx.currentPhyx.phylogenies.indexOf(phylogeny)),
getBaseURIForPhylogeny: (state, getters, rootState) => phylogeny => `#phylogeny${rootState.phyx.currentPhyx.phylogenies.indexOf(phylogeny)}`,
// Return a base URI for a given phyloreference.
getBaseURIForPhyloref: (state, getters, rootState) => phyloref => PhyxWrapper.getBaseURIForPhyloref(rootState.phyx.currentPhyx.phylorefs.indexOf(phyloref)),
getBaseURIForPhyloref: (state, getters, rootState) => phyloref => `#phyloref${rootState.phyx.currentPhyx.phylorefs.indexOf(phyloref)}`,
// Return the identifier for a given phylogeny. We will use getBaseURIForPhylogeny()
// unless one has already been set.
getPhylogenyId: (state, getters) => (phylogeny) => {
Expand Down

0 comments on commit cc1e24f

Please sign in to comment.