forked from cns-iu/ccf-hca-rui-locations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-rui-locations.js
71 lines (65 loc) · 2.24 KB
/
create-rui-locations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const fs = require('fs');
const path = require('path');
const iris = {
body: 'http://purl.obolibrary.org/obo/UBERON_0013702',
heart: 'http://purl.obolibrary.org/obo/UBERON_0000955' //brain
};
const defaults = JSON.parse(fs.readFileSync('defaults.json'));
const rui_locations = [];
for (const ruiFile of fs.readdirSync(defaults.ruiLocationsDir)) {
if (ruiFile.endsWith('.json')) {
const label = path.basename(ruiFile).replace('.json', '');
const link = defaults.linkBase //+ label; removed add label to link
const rui_location = JSON.parse(fs.readFileSync(path.join(defaults.ruiLocationsDir, ruiFile)));
const target = rui_location.placement.target.split('#')[1];
const annotations = rui_location.ccf_annotations || [];
if (target.indexOf('VHFAllenBrain') === 0 || target.indexOf('VHMAllenBrain') === 0) { //changed VHMHeart and VHFHeart to look for Allen Brain
if (!annotations.includes(iris.heart)) {
annotations.unshift(iris.heart);
}
}
if (!annotations.includes(iris.body)) {
annotations.unshift(iris.body);
}
let sex = 'Male';
if (target.indexOf('VHF') === 0) {
sex = 'Female'
}
rui_locations.push({
'@context': 'https://hubmapconsortium.github.io/hubmap-ontology/ccf-entity-context.jsonld',
'@id': rui_location['@id'] + '_Donor',
'@type': 'Donor',
sex,
label,
description: label,
link,
consortium_name: defaults.consortium_name,
provider_name: defaults.provider_name,
provider_uuid: defaults.provider_uuid,
samples: [
{
'@id': rui_location['@id'] + '_TissueBlock',
'@type': 'Sample',
sample_type: 'Tissue Block',
label,
description: label,
link,
section_count: 1,
section_size: 0.11,
section_units: 'millimeter',
rui_location,
datasets: [{
'@id': rui_location['@id'] + '_Dataset',
'@type': 'Dataset',
label,
descripition: label,
link,
technology: 'OTHER',
thumbnail: defaults.thumbnail
}]
}
]
});
}
}
fs.writeFileSync('rui_locations.jsonld', JSON.stringify(rui_locations, null, 2));