-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_hubmap.sh
More file actions
executable file
·72 lines (65 loc) · 2.19 KB
/
example_hubmap.sh
File metadata and controls
executable file
·72 lines (65 loc) · 2.19 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
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# Example script for downloading data from HuBMAP
# HuBMAP = Human BioMolecular Atlas Program
#
# This script demonstrates:
# - Downloading complete datasets using the /search endpoint
# - OR downloading limited results (~500-1000 items) using /param-search
#
set -e
echo "================================"
echo "HuBMAP Data Download Example"
echo "================================"
echo ""
# Create output directory
OUTPUT_DIR="./hubmap_data"
mkdir -p "$OUTPUT_DIR"
# Download the OpenAPI spec
echo "Step 1: Downloading HuBMAP Search API specification..."
SPEC_FILE="$OUTPUT_DIR/hubmap_search_spec.json"
curl -s "https://smart-api.info/api/metadata/7aaf02b838022d564da776b03f357158" > "$SPEC_FILE"
echo "✓ Spec downloaded to $SPEC_FILE"
echo ""
# Choose download method
echo "Step 2: Choose download method"
echo ""
echo "Option A: Complete datasets (recommended for research)"
echo " Uses POST /search endpoint with Elasticsearch pagination"
echo " Downloads ALL available data (may take longer)"
echo ""
echo "Option B: Quick sample (good for testing)"
echo " Uses GET /param-search endpoint"
echo " Downloads ~500-1000 items per entity type"
echo ""
read -p "Choose option (A/B) [B]: " OPTION
OPTION=${OPTION:-B}
if [ "$OPTION" = "A" ] || [ "$OPTION" = "a" ]; then
echo ""
echo "Step 3: Downloading COMPLETE datasets from HuBMAP..."
echo "This will download ALL donors, samples, datasets, files, etc."
echo "(This may take several minutes)"
echo ""
python3 openapi_downloader.py \
--openapi "$SPEC_FILE" \
--out-dir "$OUTPUT_DIR" \
--use-search-api
else
echo ""
echo "Step 3: Downloading LIMITED sample data from HuBMAP..."
echo "This will download up to ~500-1000 items per entity type"
echo ""
python3 openapi_downloader.py \
--openapi "$SPEC_FILE" \
--out-dir "$OUTPUT_DIR"
fi
echo ""
echo "================================"
echo "✓ Download complete!"
echo "================================"
echo ""
echo "CSV files saved to: $OUTPUT_DIR"
ls -lh "$OUTPUT_DIR"/*.csv 2>/dev/null || echo "No CSV files generated"
echo ""
echo "Example data in Donors.csv:"
head -n 3 "$OUTPUT_DIR/Donors.csv" 2>/dev/null || echo "Donors.csv not found"