-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit
More file actions
executable file
·46 lines (39 loc) · 1.6 KB
/
init
File metadata and controls
executable file
·46 lines (39 loc) · 1.6 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
#!/bin/bash
dir_scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
source $dir_scripts/Utility/utils.sh
# A config file will is needed to tell the init script which files should be analyzed
# and which control file should be used with wach treatment file.
config_file=config.txt
# Reset main directory's Makefile
rm -f Makefile
# Parse configuration file
for treatment in $(cut -f1 $config_file)
do
# Check if files are valid
control=$(grep $treatment $config_file | cut -f2 | head -n1)
check_file $treatment
check_file $control
base_treatment=$(basename ${treatment%.*})
base_control=$(basename ${control%.*})
# Build directory structure
dir_treatment=$base_treatment/treatment
dir_control=$base_treatment/control
mkdir -p $dir_treatment
mkdir -p $dir_control
# Create sub-directory's Makefile
raw_data_dir=$(dirname $treatment)
sed_script=$(echo $dir_scripts| sed 's/\//\\\//g')
# echo "| sed \"s/__SCRIPTS_DIR__/$sed_script/g\" \ "
cat $dir_scripts/Templates/Makefile_SubDirectories_Template \
| sed "s/__SCRIPTS_DIR__/$sed_script/g" \
| sed "s/__TREATMENT_BASE__/$base_treatment/g" \
| sed "s/__CONTROL_BASE__/$base_control/g" \
| sed "s/__RAW_DATA_DIR__/$raw_data_dir/g" \
> $base_treatment/Makefile
# TODO: Should there be a __RAW_DATA_DIR_TREATMENT__ and a __RAW_DATA_DIR_CONTROL__?
# Add current file to main directory's Makefile
echo SUBDIRS+=$base_treatment >> Makefile
done
# Complete the main makefile
echo "" >> Makefile
cat $dir_scripts/Templates/Makefile_MainDirectory_Template >> Makefile