UNPKG

3.9 kBapplication/x-shView Raw
1#! /bin/bash
2
3# When you pipe your JSON though this tool, it will:
4# 1) find the xref(s) in your JSON as specified by
5# xrefDataSource and xrefIdentifier
6# 1) map the found xrefs to equivalents/alternates from
7# other datasources. If you specified one or more
8# desiredDataSource(s), the mapped xrefs will be
9# limited to what you specified.
10# 2) Optionally add these mapped xrefs to your JSON at the
11# location(s)
12# specified by insertionPoint
13# 3) pipe your JSON back out with the added xrefs
14#
15# Paths use the format of basic jq filters, e.g.:
16# .a
17# .a.z
18# .a.z.x
19# .a.z.x.y
20# .[]
21# .[].z
22# .[].z.y
23# .[].z.y.x
24# .a[]
25# .a[].z
26# .a[].z.y
27# .a[].z.y.x
28#
29# More info: https://stedolan.github.io/jq/manual/v1.5/#Basicfilters
30#
31# Note: This has been tested on the pvjson format from gpml2pvjson:
32# <https://github.com/wikipathways/gpml2json>
33# If you are using it on another format, exercise caution and verify your results.
34#
35# Examples:
36
37# Just get xrefs:
38
39 echo '{"id":"abc123","xref":{"dataSource":"ensembl","identifier":"ENSG00000132031"}}' |\
40 ./bin/bridgedb xrefs -f "json" \
41 Human ".xref.dataSource" ".xref.identifier" \
42 ensembl uniprot |\
43 jq .
44
45 echo '[{"xrefDataSource": "Entrez Gene", "xrefIdentifier": "1234"}]' |\
46 ./bin/bridgedb xrefs -f "json" \
47 Human ".[].xrefDataSource" ".[].xrefIdentifier" \
48 ensembl ncbigene uniprot wikidata
49
50 ./bin/bridgedb xrefs -f "json" -i ".[].type" \
51 Human ".[].xrefDataSource" ".[].xrefIdentifier" \
52 ensembl ncbigene uniprot wikidata \
53 < "./test/inputs/nest0-array.json" |\
54 jq .
55
56 ./bin/bridgedb xrefs -f "json" \
57 Human ".[].xrefDataSource" ".[].xrefIdentifier" \
58 ensembl ncbigene uniprot wikidata \
59 < ./test/inputs/nest0-array.json |\
60 jq .
61
62 ./bin/bridgedb xrefs -f "json" \
63 Human ".entitiesById[].xrefDataSource" ".entitiesById[].xrefIdentifier" \
64 ensembl ncbigene uniprot wikidata \
65 < ./test/inputs/nest1-object.json |\
66 jq .
67
68 ./bin/bridgedb xrefs -f "json" \
69 Human ".entitiesById[].xrefDataSource" ".entitiesById[].xrefIdentifier" \
70 ensembl ncbigene uniprot wikidata \
71 < ./test/inputs/nest1-object.json |\
72 jq .
73
74# Get xrefs and insert them into your JSON:
75
76 echo '{"id":"abc123","xref":{"dataSource":"ensembl","identifier":"ENSG00000132031"}}' |\
77 ./bin/bridgedb xrefs -f "json" \
78 -i ".xref.alternates" \
79 Human \
80 ".xref.dataSource" \
81 ".xref.identifier" \
82 ensembl uniprot
83
84 echo '[{"xrefDataSource": "Entrez Gene", "xrefIdentifier": "1234"}]' |\
85 ./bin/bridgedb xrefs -f "json" \
86 -i ".[]" \
87 Human \
88 ".[].xrefDataSource" \
89 ".[].xrefIdentifier" \
90 ensembl ncbigene uniprot wikidata
91
92 ./bin/bridgedb xrefs -f "json" -i ".[].type" \
93 Human \
94 ".[].xrefDataSource" \
95 ".[].xrefIdentifier" \
96 ensembl ncbigene uniprot wikidata \
97 < "./test/inputs/nest0-array.json" |\
98 jq .
99
100 ./bin/bridgedb xrefs -f "json" -i ".[]" \
101 Human ".[].xrefDataSource" ".[].xrefIdentifier" \
102 ensembl ncbigene uniprot wikidata \
103 < ./test/inputs/nest0-array.json |\
104 jq .
105
106 ./bin/bridgedb xrefs -f "json" -i ".entitiesById[].type" \
107 Human ".entitiesById[].xrefDataSource" ".entitiesById[].xrefIdentifier" \
108 ensembl ncbigene uniprot wikidata \
109 < ./test/inputs/nest1-object.json |\
110 jq .
111
112 ./bin/bridgedb xrefs -f "json" -i ".entitiesById" \
113 Human ".entitiesById[].xrefDataSource" ".entitiesById[].xrefIdentifier" \
114 ensembl ncbigene uniprot wikidata \
115 < ./test/inputs/nest1-object.json |\
116 jq .