-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimport-data.sh
executable file
·67 lines (55 loc) · 2.49 KB
/
import-data.sh
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
#!/bin/sh
set -e
DOCKER_COMPOSE_REPO="https://github.com/cbioportal/cbioportal-docker-compose.git"
# Get named arguments
. utils/parse-args.sh "$@"
# Check required args
if [ ! "$seed" ] || [ ! "$schema" ] || [ ! "$studies" ]; then
echo "Missing required args. Usage: ./scripts/import-data.sh --seed=/path/to/seed.sql.gz --schema=/path/to/schema.sql --studies=/path/to/studies-dir"
exit 1
else
seed=$(eval echo "$seed")
schema=$(eval echo "$schema")
studies=$(eval echo "$studies")
fi
# Create a temporary directory
ROOT_DIR=$(pwd)
TEMP_DIR=$(mktemp -d)
mkdir "$TEMP_DIR/study"
cd "$TEMP_DIR/study" || exit 1
# Check cbioportal is live at localhost:8080 and get portal version
printf "\nChecking cbioportal portal at localhost:8080 ...\n\n"
cd "$ROOT_DIR"
utils/check-connection.sh --url=localhost:8080
# Clone docker compose repo
git clone "$DOCKER_COMPOSE_REPO" "$TEMP_DIR/cbioportal-docker-compose"
cd "$TEMP_DIR/cbioportal-docker-compose"
# Copy schema to database container
SCHEMA_PATH=$(docker inspect cbioportal-database-container | jq -r '.[].Mounts[].Source' | grep 'cgds.sql')
cp "$schema" "$SCHEMA_PATH"
# Copy seed to database container
SEED_PATH=$(docker inspect cbioportal-database-container | jq -r '.[].Mounts[].Source' | grep 'seed.sql.gz')
cp "$seed" "$SEED_PATH"
# Copy genesets to database container
STUDY_PATH=$(docker inspect cbioportal-container | jq -r '.[].Mounts[].Source' | grep 'study')
cp -r "$ROOT_DIR/data/genesets" "$STUDY_PATH/genesets"
# Copy studies to database container
find "$studies" -type d -mindepth 1 -maxdepth 1 | while read -r DIR; do
STUDY_NAME=$(basename "$DIR")
cp -r "$DIR" "$STUDY_PATH/$STUDY_NAME"
done
# Import genepanel data
cd "$TEMP_DIR/cbioportal-docker-compose"
docker compose exec cbioportal sh -c 'cd /core/scripts/ \
&& ./importGenePanel.pl --data /study/study_es_0/data_gene_panel_testpanel1.txt \
&& ./importGenePanel.pl --data /study/study_es_0/data_gene_panel_testpanel2.txt \
&& ./importGenesetData.pl --data /study/genesets/study_es_0_genesets.gmt --new-version msigdb_7.5.1 \
--sup /study/genesets/study_es_0_supp-genesets.txt --confirm-delete-all-genesets-hierarchy-genesetprofiles\
&& ./importGenesetHierarchy.pl --data /study/genesets/study_es_0_tree.yaml'
# Load studies from given directory
cd "$TEMP_DIR/cbioportal-docker-compose"
docker compose restart cbioportal-database
for DIR in "$studies"/*/; do
STUDY_NAME=$(basename "$DIR")
docker compose exec -T cbioportal metaImport.py -u http://localhost:8080 -s "study/$STUDY_NAME/" -o
done