|
| 1 | +#!/usr/bin/env bash |
| 2 | +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/../../ |
| 3 | +. "$DIR"/env.sh || exit 1 |
| 4 | + |
| 5 | +if [ $# -ne 2 ]; then |
| 6 | + echo "Usage: $0 [PATH] [WEB ROOT]" |
| 7 | + echo "E.g. '$0 $(date +%Y-%m-%d) \"http://localhost:8000\"'" |
| 8 | + exit 1 |
| 9 | +fi |
| 10 | + |
| 11 | +assert-env-or-die RG_NS_OUTPUT |
| 12 | +assert-env-or-die RG_EQ_OUTPUT |
| 13 | +assert-env-or-die RG_ANNO_OUTPUT |
| 14 | + |
| 15 | +output_dir="$1" |
| 16 | +if [ -d "$output_dir" ]; then |
| 17 | + echo "Output directory \"$output_dir\" already exists." >&2 |
| 18 | + exit 1 |
| 19 | +fi |
| 20 | +webroot="$2" |
| 21 | + |
| 22 | +mkdir "$output_dir" && cd "$output_dir" |
| 23 | + |
| 24 | +echo -en "Mirroring latest BEL framework resources... " |
| 25 | +wget --quiet --mirror --no-parent --cut-dirs=2 "http://resource.belframework.org/belframework/latest-release/" |
| 26 | +mv resource.belframework.org/* . |
| 27 | +rmdir resource.belframework.org |
| 28 | +echo "done" |
| 29 | + |
| 30 | +rm -fr namespace annotation equivalence index.xml* |
| 31 | + |
| 32 | +cp -a "$RG_NS_OUTPUT" . |
| 33 | +cp -a "$RG_EQ_OUTPUT" . |
| 34 | +cp -a "$RG_ANNO_OUTPUT" . |
| 35 | + |
| 36 | +echo '<idx:index |
| 37 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 38 | + xsi:schemaLocation="http://www.belscript.org/schema/index index.xsd" |
| 39 | + xmlns:idx="http://www.belscript.org/schema/index" |
| 40 | + idx:belframework_version="2.0"> |
| 41 | +
|
| 42 | + <idx:annotationdefinitions>' > index.xml |
| 43 | + |
| 44 | +find -name "*.belanno" | while read belanno; do |
| 45 | + belanno=annotation/$(basename $belanno) |
| 46 | + echo " <idx:annotationdefinition idx:resourceLocation=\"$webroot/$belanno\" />" >> index.xml |
| 47 | +done |
| 48 | + |
| 49 | +echo ' </idx:annotationdefinitions> |
| 50 | +
|
| 51 | + <idx:namespaces>' >> index.xml |
| 52 | + |
| 53 | +find -name "*.belns" | while read belns; do |
| 54 | + belns=namespace/$(basename $belns) |
| 55 | + echo " <idx:namespace idx:resourceLocation=\"$webroot/$belns\" />" >> index.xml |
| 56 | +done |
| 57 | + |
| 58 | +echo ' </idx:namespaces> |
| 59 | +
|
| 60 | + <idx:equivalences>' >> index.xml |
| 61 | + |
| 62 | +find -name "*.beleq" | while read beleq; do |
| 63 | + beleq=equivalence/$(basename $beleq) |
| 64 | + belns=namespace/$(basename $beleq | sed 's/beleq/belns/') |
| 65 | + echo " <idx:equivalence idx:resourceLocation=\"$webroot/$beleq\" >" >> index.xml |
| 66 | + echo " <idx:namespace-ref idx:resourceLocation=\"$webroot/$belns\" />" >> index.xml |
| 67 | + echo " </idx:equivalence>" >> index.xml |
| 68 | +done |
| 69 | + |
| 70 | +echo " </idx:equivalences> |
| 71 | +
|
| 72 | + <idx:knowledge> |
| 73 | + <idx:protein-families idx:resourceLocation=\"$webroot/resource/protein-families.bel\" /> |
| 74 | + <idx:named-complexes idx:resourceLocation=\"$webroot/resource/named-complexes.bel\" /> |
| 75 | + <idx:gene-scaffolding idx:resourceLocation=\"$webroot/resource/gene_scaffolding_document_9606_10090_10116.bel\" /> |
| 76 | + <idx:orthologies> |
| 77 | + <idx:orthology idx:resourceLocation=\"$webroot/resource/gene-orthology.bel\" /> |
| 78 | + </idx:orthologies> |
| 79 | + </idx:knowledge> |
| 80 | +</idx:index>" >> index.xml |
| 81 | + |
| 82 | +sha256sum index.xml > index.xml.sha256 |
| 83 | + |
| 84 | +base=$(pwd) |
| 85 | +# create sha256 hashes for each namespace |
| 86 | +cd namespace || exit 1 |
| 87 | +for x in *.belns; do sha256sum "$x" > "$x.sha256"; done |
| 88 | +cd "$base" |
| 89 | + |
| 90 | +# create sha256 hashes for each equivalence |
| 91 | +cd equivalence || exit 1 |
| 92 | +for x in *.beleq; do sha256sum "$x" > "$x.sha256"; done |
| 93 | +cd "$base" |
| 94 | + |
| 95 | +# create sha256 hashes for each annotation |
| 96 | +cd annotation || exit 1 |
| 97 | +for x in *.belanno; do sha256sum "$x" > "$x.sha256"; done |
| 98 | +cd "$base" |
| 99 | + |
| 100 | +echo "Done!" |
| 101 | + |
0 commit comments