-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-obo.sh
More file actions
executable file
·60 lines (50 loc) · 1.74 KB
/
get-obo.sh
File metadata and controls
executable file
·60 lines (50 loc) · 1.74 KB
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
#!/usr/bin/env bash
set -e
USAGE="$ ./get-obo.sh NCIT_C40098"
if [ -z $1 ] || [ ! -z $2 ]; then
echo "Usage: $USAGE"; exit 1
fi
cd "$(dirname "$0")"
mkdir -p out
curl -L "https://ontobee.org/ontology/catalog/NCIT?iri=http://purl.obolibrary.org/obo/$1" \
| grep -A 1 '<a class="term"' \
| tr -d '\n' \
| sed -r 's|</li>(</ul>)?|</li>\n|g' \
| sed -r 's|^.*/NCIT\?iri=(.*)">(.*)</a>.*$|<\1> <http://www.w3.org/2000/01/rdf-schema#label> "\2" .|' \
> out/obo-$1.ttl
cat out/obo-$1.ttl
(
echo "@prefix : <http://purl.org/nanopub/temp/obo-labels/> ."
echo "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ."
echo "@prefix np: <http://www.nanopub.org/nschema#> ."
echo "@prefix dct: <http://purl.org/dc/terms/> ."
echo "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> ."
echo "@prefix orcid: <https://orcid.org/> ."
echo "@prefix npx: <http://purl.org/nanopub/x/> ."
echo "@prefix prov: <http://www.w3.org/ns/prov#> ."
echo "@prefix obo: <http://purl.obolibrary.org/obo/> ."
echo ""
echo ":Head {"
echo " : np:hasAssertion :assertion ;"
echo " np:hasProvenance :provenance ;"
echo " np:hasPublicationInfo :pubinfo ;"
echo " a np:Nanopublication ."
echo "}"
echo ""
echo ":assertion {"
cat out/obo-$1.ttl
echo "}"
echo ""
echo ":provenance {"
echo " :assertion prov:wasDerivedFrom <https://ontobee.org/ontology/catalog/NCIT> ."
echo "}"
echo ""
echo ":pubinfo {"
echo ' : rdfs:label "Labels for OBO classes under '"$1"'" .'
echo " : npx:hasNanopubType rdfs:label ."
echo " : dct:creator orcid:0000-0002-1267-0234 ."
echo ' : dct:created "'$(./np now)'"^^xsd:dateTime .'
echo "}"
) > out/obo-$1-labels.trig
./np sign out/obo-$1-labels.trig
./np check out/signed.obo-$1-labels.trig