Home Manual Reference Source Test
import {PhyxWrapper} from '@phyloref/phyx/src/wrappers/PhyxWrapper.js'
public class | source

PhyxWrapper

The PhyxWrapper wraps an entire Phyx document.

Static Method Summary

Static Public Methods
public static

normalize(phyxDocument: *): *

Return a provided Phyx document as a normalized JSON document.

Constructor Summary

Public Constructor
public

constructor(phyx: Object, newickParser: function(newick: string): {name)

Wraps an entire PHYX document.

Member Summary

Public Members
public get
public
public

phyx: *

Method Summary

Public Methods
public

asJSONLD(baseIRI: string): Object

Generate an executable ontology from this Phyx document.

public

toRDF(baseIRI: string, filePath: string): Promise[string]

Generate an executable ontology from this Phyx document as N-Quads.

Static Public Methods

public static normalize(phyxDocument: *): * source

Return a provided Phyx document as a normalized JSON document. We ignore most keys -- including keys we don't know -- but any key that can be wrapped by one of the other Wrappers in this package will be wrapped and normalized before being returned.

Normalization is mostly needed for TaxonomicUnitWrappers and its subclasses (TaxonConceptWrapper, TaxonNameWrapper), since these can be represented in several essentially identical ways. But if we implement it at every level, we can implement comparison code in Klados easily.

Two Phyx documents should -- upon being normalized -- be comparable with each other with lodash.deepEqual().

Params:

NameTypeAttributeDescription
phyxDocument *

Return:

*

Public Constructors

public constructor(phyx: Object, newickParser: function(newick: string): {name) source

Wraps an entire PHYX document.

Params:

NameTypeAttributeDescription
phyx Object

The Phyx structure to wrap.

newickParser function(newick: string): {name
  • optional
  • default: PhylogenyWrapper.getParsedNewick

A method that accepts a Newick string and returns a list of nodes. Each node should have a 'children' key with its children and optionally a 'name' key with its label. This code previously depended on phylotree.js, whose newick_parser() function works exactly like this. This option allows you to drop in Phylotree's newick_parser() or -- if you prefer -- any other option.

Public Members

public get defaultNomenCode: * source

public newickParser: * source

public phyx: * source

Public Methods

public asJSONLD(baseIRI: string): Object source

Generate an executable ontology from this Phyx document. The document is mostly in JSON-LD already, except for three important things:

  1. We have to convert all phylogenies into a series of statements relating to the nodes inside these phylogenies.
  2. We have to convert phylogenies into OWL restrictions.
  3. Insert all matches between taxonomic units in this file.

Params:

NameTypeAttributeDescription
baseIRI string
  • optional
  • default: ""

The base IRI to use when generating this Phyx document. This should include a trailing '#' or '/'. Use '' to indicate that relative IDs should be generated in the produced ontology (e.g. '#phylogeny1'). Note that if a baseIRI is provided, then relative IDs already in the Phyx file (identified by an initial '#') will be turned into absolute IDs by removing the initial # and prepending them with the baseIRI.

Return:

Object

This Phyx document as an OWL ontology as a JSON-LD object.

public toRDF(baseIRI: string, filePath: string): Promise[string] source

Generate an executable ontology from this Phyx document as N-Quads. Under the hood, we generate an OWL/JSON-LD representation of this Phyx document, and then convert it into N-Quads so that OWLAPI-supporting tools can directly consume it.

Params:

NameTypeAttributeDescription
baseIRI string
  • optional
  • default: ""

The base IRI to use when generating this Phyx document. This should include a trailing '#' or '/'. Use '' to indicate that relative IDs should be generated in the produced ontology (e.g. '#phylogeny1'). Note that if a baseIRI is provided, then relative IDs already in the Phyx file (identified by an initial '#') will be turned into absolute IDs by removing the initial # and prepending them with the baseIRI.

filePath string
  • optional
  • default: undefined

The path of the Phyx file being converted. Used only if the @context of the file is a relative path.

Return:

Promise[string]

A Promise to return this Phyx document as a string that can be written to an N-Quads file.