---
# System prepended metadata

title: Data Schema

---

# Data Schema

```ttl
@prefix : <http://pep.com/clade/> .
@prefix peps: <http://example.org/schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

peps:Clade a rdf:Class .
peps:Rank a rdf:Class .

peps:Domain a peps:Rank .
peps:Kingdom a peps:Rank ;
             rdfs:subClassOf peps:Domain .

:pep000 a peps:Clade ;
        peps:id "000" ;
        rdfs:label "Life" .

:pep010 a peps:Clade ;
        peps:id "010" ;
        rdfs:label "Bacteria" ;
        rdfs:subClassOf :pep000;
        peps:rank peps:Domain .

:pep020 a peps:Clade ;
        peps:id "020" ;
        rdfs:label "Eukaryota" ;
        rdfs:subClassOf :pep000;
        peps:rank peps:Domain .

:pep021 a peps:Clade ;
        peps:id "021" ;
        rdfs:label "Animalia" ;
        rdfs:subClassOf :pep020;
        peps:rank peps:Kingdom .
```


```typescript=

const getNode = ({ id, isRoot }) => `
    SELECT ?name ?rank ?parentId (count(?lineage) as ?depth) WHERE {
       ?s peps:id ${id} ;
          rdfs:label ?name .
       OPTIONAL { ?s  peps:rank/rdfs:label ?rank . }
       ${isRoot ? `OPTIONAL { ?s rdfs:subClassOf/peps:id ?parentId . }
       ?lineage ^rdfs:subClassOf+/peps:id ${id} . `: ''}
    }
    GROUP BY ?name ?rank ?parentId
`;

const getChildren = ({ id }) => `
    SELECT ?s WHERE {
       ?o peps:id ${id} ;
          ^rdfs:subClassOf/peps:id ?s .
    }
`;

const querySparql = query =>
    request({
        url: 'https://your-neptune-endpoint:port/sparql',
        method: 'GET',
        body: query;
    });
```


```mermaid
erDiagram
    CLADE {
        string id
        string label
    }
    CLADE ||--|{ CLADE : subclassOf
    CLADE ||--|{ CLASS : type
    CLADE ||--|{ RANK : rank
    RANK ||--|{ CLASS : type
    RANK ||--|{ RANK : subclassOf
```

```ttl=
peps:LC a peps:Status ;
 skos:prefLabel 'Least Concern' ;
 source: 'https...' .


pep:1/name a peps:SourcedValue ;
 skos:prefLabel 'Aves' ;
 peps:source 'https...' .

pep:1/commonName\:1 a peps:SourcedValue ;
 skos:prefLabel 'Bird' ;
 peps:source 'https...' .
 
pep:1/status a peps:SourcedValue ;
 skos:prefLabel 'Least Concern' ;
 peps:source 'https...' .

pep:1/attribution a peps:Attribution ;
 peps:name: 'Linaues' ;
 peps:date: '1855' ;
 peps:source 'https...' .

pep:1 a peps:Taxon ;
 peps:name: pep:1/name ;
 peps:status: pep:1/status ;
 peps:commonName pep:1/commonName\:1 ;
 peps:commonName pep:1/commonName\:2 ;
 peps:attribution pep:1/attribution .

```