-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.sh
More file actions
98 lines (77 loc) · 2.62 KB
/
loop.sh
File metadata and controls
98 lines (77 loc) · 2.62 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# Configuration
SCRIPT_PATH="hubmap_dir_conversion_v3.6.py"
MICROSCOPE_HARDWARE=""
CUSTOM_PROBES_BED=""
TISSUE_BOUNDARY_DIR=""
BASE_OUT_DIR=""
# Array - populate with your input directory paths
inputs=(
)
# Validate required files and directories exist
if [ ! -f "$MICROSCOPE_HARDWARE" ]; then
echo "Error: Microscope hardware file not found: $MICROSCOPE_HARDWARE"
exit 1
fi
if [ ! -f "$CUSTOM_PROBES_BED" ]; then
echo "Error: Custom probes BED file not found: $CUSTOM_PROBES_BED"
exit 1
fi
if [ ! -f "$SCRIPT_PATH" ]; then
echo "Error: Python script not found: $SCRIPT_PATH"
exit 1
fi
if [ ! -d "$TISSUE_BOUNDARY_DIR" ]; then
echo "Error: Tissue boundary directory not found: $TISSUE_BOUNDARY_DIR"
exit 1
fi
# Process each sample
for i in "${!inputs[@]}"; do
input_dir="${inputs[$i]}"
# Extract sample name from input directory
sample_name=$(basename "$input_dir")
# Find corresponding tissue boundary file
tissue_file=$(find "$TISSUE_BOUNDARY_DIR" -name "${sample_name}.tissue-boundary.geojson" -type f)
output_dir=$BASE_OUT_DIR/$sample_name
echo "Processing sample $((i+1))/${#inputs[@]}: $sample_name"
echo "Input: $input_dir"
echo "Output: $output_dir"
# Validate input directory exists
if [ ! -d "$input_dir" ]; then
echo "Warning: Input directory not found: $input_dir"
echo "Skipping..."
continue
fi
# Check if tissue boundary file was found
if [ -z "$tissue_file" ]; then
echo "Warning: Tissue boundary file not found for sample: ${sample_name}.tissue-boundary.geojson"
echo "Skipping..."
continue
fi
# Check if multiple files were found (shouldn't happen but good to check)
tissue_file_count=$(echo "$tissue_file" | wc -l)
if [ "$tissue_file_count" -gt 1 ]; then
echo "Warning: Multiple tissue boundary files found for sample: $sample_name"
echo "$tissue_file"
echo "Using first match..."
tissue_file=$(echo "$tissue_file" | head -n1)
fi
echo "Tissue boundary: $tissue_file"
# Run the Python script
python "$SCRIPT_PATH" \
--input "$input_dir" \
--output "$output_dir" \
--sample "$sample_name" \
--microscope-hardware "$MICROSCOPE_HARDWARE" \
--tissue-boundary "$tissue_file" \
--custom-probes-bed "$CUSTOM_PROBES_BED" \
--verbose
# Check exit status
if [ $? -eq 0 ]; then
echo "Successfully processed: $sample_name"
else
echo "Error processing: $sample_name"
fi
echo "----------------------------------------"
done
echo "Processing complete!"