Skip to content

Commit f2ac917

Browse files
authored
Merge pull request #31 from psychoinformatics-de/data
Towards an improved structure for graph data loading and traversal
2 parents 7c5de92 + 043439e commit f2ac917

File tree

14 files changed

+417
-37
lines changed

14 files changed

+417
-37
lines changed

src/App.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,36 @@
2828

2929

3030
<script setup>
31-
import { ref } from 'vue'
31+
import { ref, provide, onMounted} from 'vue';
32+
import { useGraphData } from '@/composables/graphdata';
33+
import { DLTHING, XSD } from '@/modules/namespaces';
34+
import rdf from 'rdf-ext';
35+
3236
var tab = ref(1)
37+
38+
const { graphData, getGraphData, graphPrefixes, serializedGraphData, graphTriples } = useGraphData()
39+
40+
provide('graphData', graphData)
41+
provide('serializedGraphData', serializedGraphData)
42+
provide('graphTriples', graphTriples)
43+
provide('graphPrefixes', graphPrefixes)
44+
45+
46+
onMounted( async () => {
47+
console.log("App.vue async onmounted...")
48+
const penguins = new URL("@/assets/distribution-penguins.ttl", import.meta.url).href
49+
await getGraphData(penguins)
50+
51+
console.log(graphTriples.length)
52+
console.log(graphData.size)
53+
54+
const mypersonB = rdf.grapoi({ dataset: graphData })
55+
.hasOut(DLTHING.meta_type, rdf.literal('dldist:Person', XSD.anyURI))
56+
.quads();
57+
console.log('Persons in Penguin Dataset, using literal in query:')
58+
for (const quad of mypersonB) {
59+
console.log(`\t${quad.subject.value}`)
60+
}
61+
})
3362
3463
</script>

src/assets/distribution-penguins.ttl

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
@prefix CiTO: <http://purl.org/spar/cito/> .
2+
@prefix dldist: <https://concepts.datalad.org/s/distribution/unreleased/> .
3+
@prefix dlprov: <https://concepts.datalad.org/s/prov/unreleased/> .
4+
@prefix dlsdd: <https://concepts.datalad.org/s/sdd/unreleased/> .
5+
@prefix dlthing: <https://concepts.datalad.org/s/thing/unreleased/> .
6+
@prefix dpv: <https://w3id.org/dpv#> .
7+
@prefix licenses: <http://spdx.org/licenses/> .
8+
@prefix marcrel: <http://id.loc.gov/vocabulary/relators/> .
9+
@prefix schema1: <http://schema.org/> .
10+
@prefix spdx: <http://spdx.org/rdf/terms#> .
11+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
12+
13+
<https://example.org/ns/datasetversion/.> dldist:has_part <https://example.org/ns/datasetversion/./adelie.csv>,
14+
<https://example.org/ns/datasetversion/./chinstrap.csv>,
15+
<https://example.org/ns/datasetversion/./gentoo.csv> ;
16+
dldist:is_distribution_of <https://example.org/ns/datasetversion/#> ;
17+
dldist:license licenses:CC0-1.0 ;
18+
dldist:qualified_part [ a dldist:DistributionPart ;
19+
dlprov:entity <https://example.org/ns/datasetversion/./gentoo.csv> ;
20+
dlthing:name "gentoo.csv" ],
21+
[ a dldist:DistributionPart ;
22+
dlprov:entity <https://example.org/ns/datasetversion/./chinstrap.csv> ;
23+
dlthing:name "chinstrap.csv" ],
24+
[ a dldist:DistributionPart ;
25+
dlprov:entity <https://example.org/ns/datasetversion/./adelie.csv> ;
26+
dlthing:name "adelie.csv" ] ;
27+
dlprov:relation <https://example.org/ns/dataset/#RStudio>,
28+
<https://example.org/ns/dataset/#UCSB>,
29+
<https://example.org/ns/dataset/#ahill>,
30+
<https://example.org/ns/dataset/#ahorst>,
31+
<https://example.org/ns/dataset/#gormanetal>,
32+
<https://example.org/ns/dataset/#kgorman>,
33+
<https://example.org/ns/dataset/#nsf0217282>,
34+
<https://example.org/ns/dataset/#nsf0741351>,
35+
<https://example.org/ns/dataset/#nsf0823101>,
36+
<https://example.org/ns/datasetversion/#>,
37+
<https://ror.org/01j7nq853>,
38+
<https://ror.org/021nxhr62>,
39+
<https://ror.org/05nwjp114> ;
40+
dlprov:was_attributed_to <https://example.org/ns/dataset/#RStudio>,
41+
<https://example.org/ns/dataset/#UCSB>,
42+
<https://example.org/ns/dataset/#ahill>,
43+
<https://example.org/ns/dataset/#ahorst>,
44+
<https://example.org/ns/dataset/#kgorman>,
45+
<https://ror.org/01j7nq853>,
46+
<https://ror.org/021nxhr62>,
47+
<https://ror.org/05nwjp114> ;
48+
dlthing:meta_type "dldist:Distribution"^^xsd:anyURI .
49+
50+
<https://example.org/ns/dataset/#gormanetal> dldist:date_published "2014-03-05"^^<https://www.w3.org/TR/NOTE-datetime> ;
51+
dlprov:qualified_attribution [ a dlprov:Attribution ;
52+
dlprov:agent <https://example.org/ns/dataset/#kgorman> ;
53+
dlprov:had_role marcrel:aut ] ;
54+
dlthing:identifier [ a dlthing:Identifier ;
55+
dlthing:notation "10.1371/journal.pone.0090081" ;
56+
dlthing:schema_agency <https://doi.org> ] ;
57+
dlthing:meta_type "dlsdd:Publication"^^xsd:anyURI ;
58+
dlthing:notation "'Gorman KB, Williams TD, Fraser WR (2014) Ecological Sexual Dimorphism and Environmental Variability within a Community of Antarctic Penguins (Genus Pygoscelis). PLoS ONE 9(3): e90081.'" .
59+
60+
<https://example.org/ns/dataset/#nsf0217282> dlsdd:cites_as_authority "https://www.nsf.gov/awardsearch/showAward?AWD_ID=0217282"^^xsd:anyURI ;
61+
dlsdd:sponsor <https://ror.org/05nwjp114> ;
62+
dlthing:identifier [ a dlthing:Identifier ;
63+
dlthing:notation "0217282" ;
64+
dlthing:schema_agency <https://ror.org/021nxhr62> ] ;
65+
dlthing:meta_type "dlsdd:Grant"^^xsd:anyURI ;
66+
dlthing:name "LTER: PALMER, ANTARCTICA LTER: Climate Change, Ecosystem Migration and Teleconnections in an Ice-Dominated Environment" .
67+
68+
<https://example.org/ns/dataset/#nsf0741351> dlsdd:cites_as_authority "https://www.nsf.gov/awardsearch/showAward?AWD_ID=0741351"^^xsd:anyURI ;
69+
dlsdd:sponsor <https://ror.org/05nwjp114> ;
70+
dlthing:identifier [ a dlthing:Identifier ;
71+
dlthing:notation "0741351" ;
72+
dlthing:schema_agency <https://ror.org/021nxhr62> ] ;
73+
dlthing:meta_type "dlsdd:Grant"^^xsd:anyURI ;
74+
dlthing:name "Collaborative Research: Possible Climate-induced Change in the Distribution of Pleuragramma Antarcticum on the Western Antarctic Peninsula Shelf" .
75+
76+
<https://example.org/ns/dataset/#nsf0823101> dlsdd:cites_as_authority "https://www.nsf.gov/awardsearch/showAward?AWD_ID=0823101"^^xsd:anyURI ;
77+
dlsdd:sponsor <https://ror.org/05nwjp114> ;
78+
dlthing:identifier [ a dlthing:Identifier ;
79+
dlthing:notation "0823101" ;
80+
dlthing:schema_agency <https://ror.org/021nxhr62> ] ;
81+
dlthing:meta_type "dlsdd:Grant"^^xsd:anyURI ;
82+
dlthing:name "Palmer, Antarctica Long Term Ecological Research Project" .
83+
84+
<https://example.org/ns/datasetversion/#> dldist:date_modified "2020-07-16"^^<https://www.w3.org/TR/NOTE-datetime> ;
85+
dldist:is_version_of <https://example.org/ns/dataset/#> ;
86+
dldist:keyword "animal sexual behavior",
87+
"antarctica",
88+
"ecological niches",
89+
"foraging",
90+
"islands",
91+
"isotopes",
92+
"penguins",
93+
"sea ice" ;
94+
dldist:landing_page "https://github.com/allisonhorst/palmerpenguins"^^xsd:anyURI ;
95+
dldist:version "0.1.0" ;
96+
dlprov:qualified_attribution [ a dlprov:Attribution ;
97+
dlprov:agent <https://ror.org/01j7nq853> ;
98+
dlprov:had_role marcrel:sht ],
99+
[ a dlprov:Attribution ;
100+
dlprov:agent <https://example.org/ns/dataset/#RStudio> ;
101+
dlprov:had_role marcrel:sht ],
102+
[ a dlprov:Attribution ;
103+
dlprov:agent <https://example.org/ns/dataset/#UCSB> ;
104+
dlprov:had_role marcrel:sht ],
105+
[ a dlprov:Attribution ;
106+
dlprov:agent <https://example.org/ns/dataset/#ahorst> ;
107+
dlprov:had_role marcrel:aut,
108+
dpv:DataController ],
109+
[ a dlprov:Attribution ;
110+
dlprov:agent <https://example.org/ns/dataset/#kgorman> ;
111+
dlprov:had_role marcrel:aut,
112+
marcrel:cre ],
113+
[ a dlprov:Attribution ;
114+
dlprov:agent <https://example.org/ns/dataset/#ahill> ;
115+
dlprov:had_role marcrel:aut ] ;
116+
dlprov:qualified_relation [ dlprov:entity <https://example.org/ns/dataset/#nsf0217282>,
117+
<https://example.org/ns/dataset/#nsf0741351>,
118+
<https://example.org/ns/dataset/#nsf0823101> ;
119+
dlprov:had_role schema1:funding ;
120+
dlthing:meta_type "dlprov:EntityInfluence"^^xsd:anyURI ],
121+
[ dlprov:entity <https://example.org/ns/dataset/#gormanetal> ;
122+
dlprov:had_role CiTO:citesAsAuthority,
123+
CiTO:isCitedAsDataSourceBy ;
124+
dlthing:meta_type "dlprov:EntityInfluence"^^xsd:anyURI ] ;
125+
dlthing:description "The goal of palmerpenguins is to provide a great dataset for data exploration and visualization, as an alternative to iris. Data were collected and made available by Dr. Kristen Gorman and the Palmer Station, Antarctica LTER, a member of the Long Term Ecological Research Network." ;
126+
dlthing:identifier [ a dlthing:Identifier ;
127+
dlthing:notation "10.5281/zenodo.3960218" ;
128+
dlthing:schema_agency <https://doi.org> ] ;
129+
dlthing:meta_type "dldist:Resource"^^xsd:anyURI ;
130+
dlthing:name "penguins" ;
131+
dlthing:same_as "https://doi.org/10.5281/zenodo.3960218"^^xsd:anyURI ;
132+
dlthing:title "Palmer Penguins" .
133+
134+
<https://example.org/ns/datasetversion/./adelie.csv> dldist:byte_size "23755"^^xsd:nonNegativeInteger ;
135+
dldist:checksum [ a dldist:Checksum ;
136+
spdx:algorithm "md5"^^xsd:anyURI ;
137+
dldist:digest "e7e2be6b203a221949f05e02fcefd853"^^xsd:hexBinary ] ;
138+
dldist:download_url "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.219.3&entityid=002f3893385f710df69eeebe893144ff"^^xsd:anyURI ;
139+
dldist:media_type "text/csv" ;
140+
dlthing:meta_type "dldist:Distribution"^^xsd:anyURI .
141+
142+
<https://example.org/ns/datasetversion/./chinstrap.csv> dldist:byte_size "18872"^^xsd:nonNegativeInteger ;
143+
dldist:checksum [ a dldist:Checksum ;
144+
spdx:algorithm "md5"^^xsd:anyURI ;
145+
dldist:digest "e4b0710c69297031d63866ce8b888f25"^^xsd:hexBinary ] ;
146+
dldist:download_url "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.221.2&entityid=fe853aa8f7a59aa84cdd3197619ef462"^^xsd:anyURI ;
147+
dldist:media_type "text/csv" ;
148+
dlthing:meta_type "dldist:Distribution"^^xsd:anyURI .
149+
150+
<https://example.org/ns/datasetversion/./gentoo.csv> dldist:byte_size "11263"^^xsd:nonNegativeInteger ;
151+
dldist:checksum [ a dldist:Checksum ;
152+
spdx:algorithm "md5"^^xsd:anyURI ;
153+
dldist:digest "1549566fb97afa879dc9446edcf2015f"^^xsd:hexBinary ] ;
154+
dldist:download_url "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.220.3&entityid=e03b43c924f226486f2f0ab6709d2381"^^xsd:anyURI ;
155+
dldist:media_type "text/csv" ;
156+
dlthing:meta_type "dldist:Distribution"^^xsd:anyURI .
157+
158+
<https://example.org/ns/dataset/#RStudio> dlthing:meta_type "dldist:Organization"^^xsd:anyURI ;
159+
dlthing:name "RStudio: Boston, MA, US" .
160+
161+
<https://example.org/ns/dataset/#ahill> dldist:affiliation <https://example.org/ns/dataset/#Rstudio> ;
162+
dldist:email "[email protected]"^^dldist:EmailAddress ;
163+
dlthing:identifier [ a dlthing:Identifier ;
164+
dlthing:notation "0000-0002-8082-1890" ;
165+
dlthing:schema_agency <https://orcid.org> ] ;
166+
dlthing:meta_type "dldist:Person"^^xsd:anyURI ;
167+
dlthing:name "Allison Hill" .
168+
169+
<https://example.org/ns/dataset/#ahorst> dldist:affiliation <https://example.org/ns/dataset/#UCSB> ;
170+
dldist:email "[email protected]"^^dldist:EmailAddress ;
171+
dlthing:identifier [ a dlthing:Identifier ;
172+
dlthing:notation "0000-0002-6047-5564" ;
173+
dlthing:schema_agency <https://orcid.org> ] ;
174+
dlthing:meta_type "dldist:Person"^^xsd:anyURI ;
175+
dlthing:name "Allison Horst" ;
176+
dlthing:same_as "https://orcid.org/0000-0002-6047-5564"^^xsd:anyURI .
177+
178+
<https://example.org/ns/dataset/#UCSB> dlthing:meta_type "dldist:Organization"^^xsd:anyURI ;
179+
dlthing:name "UC Santa Barbara: Santa Barbara, CA, US" .
180+
181+
<https://example.org/ns/dataset/#kgorman> dldist:affiliation <https://ror.org/01j7nq853> ;
182+
dldist:email "[email protected]"^^dldist:EmailAddress ;
183+
dlthing:identifier [ a dlthing:Identifier ;
184+
dlthing:notation "0000-0002-0258-9264" ;
185+
dlthing:schema_agency <https://orcid.org> ] ;
186+
dlthing:meta_type "dldist:Person"^^xsd:anyURI ;
187+
dlthing:name "Kirsten Gorman" .
188+
189+
<https://ror.org/01j7nq853> dlthing:identifier [ a dlthing:Identifier ;
190+
dlthing:notation "01j7nq853" ;
191+
dlthing:schema_agency <https://ror.org> ] ;
192+
dlthing:meta_type "dldist:Organization"^^xsd:anyURI ;
193+
dlthing:name "University of Alaska Fairbanks: Fairbanks, AK, US" .
194+
195+
<https://ror.org/021nxhr62> dlthing:identifier [ a dlthing:Identifier ;
196+
dlthing:notation "021nxhr62" ;
197+
dlthing:schema_agency <https://ror.org> ] ;
198+
dlthing:meta_type "dlthing:Thing"^^xsd:anyURI ;
199+
dlthing:name "US National Science Foundation" ;
200+
dlthing:same_as "https://www.nsf.org"^^xsd:anyURI .
201+
202+
<https://ror.org/05nwjp114> dlthing:identifier [ a dlthing:Identifier ;
203+
dlthing:notation "05nwjp114" ;
204+
dlthing:schema_agency <https://ror.org> ] ;
205+
dlthing:meta_type "dlthing:Thing"^^xsd:anyURI ;
206+
dlthing:name "NSF Office of Polar Programs" .
207+
208+

src/assets/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
code {
22
font-size: 12px;
3+
}
4+
.formatted-pre {
5+
white-space:normal;
6+
overflow-x: scroll;
7+
}
8+
.formatted-code {
9+
white-space:pre;
310
}

src/components/AppHeader.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,3 @@
2020
</template>
2121
</v-app-bar>
2222
</template>
23-
24-
<script setup>
25-
//
26-
</script>

src/components/InstancesSelectEditor.vue

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,63 @@
22
<v-autocomplete
33
label="(instances select editor)"
44
v-model="formData[props.node_uid][props.triple_uid]"
5-
:items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
5+
:items="instanceItems"
66
validate-on="lazy input"
77
:rules="rules"
88
></v-autocomplete>
99
</template>
1010

1111
<script setup>
12-
import { inject } from 'vue'
12+
import { inject, reactive, onMounted, ref, computed} from 'vue'
1313
import { useRules } from '../composables/rules'
14+
import rdf from 'rdf-ext'
15+
import {SHACL, RDF, DLTHING, XSD} from '@/modules/namespaces'
16+
import { toCURIE } from '../modules/utils';
17+
18+
const predicateSelector = DLTHING.meta_type
19+
// const predicateSelector = RDF.type.value
1420
1521
const props = defineProps({
1622
property_shape: Object,
1723
node_uid: String,
1824
triple_uid: String,
1925
})
2026
const formData = inject('formData');
27+
const graphData = inject('graphData');
28+
const graphPrefixes = inject('graphPrefixes');
29+
const shapePrefixes = inject('shapePrefixes');
2130
const { rules } = useRules(props.property_shape)
31+
// var classNodes = reactive(null)
32+
// var classNodes2 = reactive(null)
33+
var propClass = ref(null)
34+
const combinedQuads = reactive([])
35+
const instanceItems = reactive([])
36+
37+
onMounted(() => {
38+
console.log(`\nMounted InstancesSelectEditor: ${props.property_shape[SHACL.path.value]} (graphdata is ${graphData.size})`)
39+
propClass.value = props.property_shape[SHACL.class.value] ?? false // TODO: what should the correct default value be here?
40+
41+
let allprefixes = {...shapePrefixes, ...graphPrefixes};
42+
var propClassCurie = toCURIE(propClass.value, allprefixes)
43+
const literalNodes = rdf.grapoi({ dataset: graphData })
44+
.hasOut(predicateSelector, rdf.literal(String(propClassCurie), XSD.anyURI))
45+
.quads();
46+
const uriNodes = rdf.grapoi({ dataset: graphData })
47+
.hasOut(predicateSelector, propClass.value)
48+
.quads();
49+
const combinedQuads = Array.from(literalNodes).concat(Array.from(uriNodes));
50+
console.log("Concatenated results")
51+
combinedQuads.forEach(quad => {
52+
console.log(`\t${quad.subject.value}`)
53+
instanceItems.push(quad.subject.value)
54+
});
55+
})
56+
2257
</script>
2358
2459
2560
<script>
26-
import { SHACL } from '../modules/namespaces'
61+
import { SHACL } from '@/modules/namespaces'
2762
export const matchingLogic = (shape) => {
2863
// sh:nodeKind exists
2964
if ( shape.hasOwnProperty(SHACL.nodeKind.value) ) {

0 commit comments

Comments
 (0)