forked from BrendelGroup/BWASP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxmkdirstr
executable file
·79 lines (70 loc) · 2.6 KB
/
xmkdirstr
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
#!/bin/bash
species=$1
study=$2
sample=$3
nreps=$4
pors=$5
machine=$6
echo "$species $study $sample $nreps $pors $machine"
# Template values are needed for replacement
MERGE_TEMPLATE_LABEL=Pcan-Queen
PE_TEMPLATE_LABEL=Pcan-21Q
SE_TEMPLATE_LABEL=Amel-afbCTRL
# make the genome dir
mkdir -p ${species}/genome
# only copy GFF parse makefile if it doesn't exist
if [ ! -f "${species}/genome/Makefile" ]; then
cp ../makefiles/Makefile_parse_GFF3_template ${species}/genome/Makefile
sed -i -e "s/Pcan/${species}/g;" ${species}/genome/Makefile
fi
# check for sample dir
if [ -d ${species}/${study}/${sample} ]; then
echo 'This sample already exists.'
exit 1
fi
mkdir -p ${species}/${study}/${sample}
if (( "$nreps" == 1 )); then
pushd ${species}/${study}/${sample}
ln -s ../../genome
popd
if [ $pors == "p" ]; then
cp ../makefiles/${machine}Makefile_pe_template ${species}/${study}/${sample}/Makefile
# replace with proper sample name
sed -i -e "s/${PE_TEMPLATE_LABEL}/${sample}/;" ${species}/${study}/${sample}/Makefile
elif [ $pors == "s" ]; then
cp ../makefiles/${machine}Makefile_se_template ${species}/${study}/${sample}/Makefile
# replace with proper sample name
sed -i -e "s/${SE_TEMPLATE_LABEL}/${sample}/;" ${species}/${study}/${sample}/Makefile
else
echo "Please select 'p' for paired-end or 's' for single read data."
echo " (Your selection ${pors} is not valid."
exit 1
fi
else # ... there are multiple replicates
# copy merge makefile if there are more than one replicates
cp ../makefiles/${machine}Makefile_merge_template ${species}/${study}/${sample}/Makefile
# replace with proper sample name
sed -i -e "s/${MERGE_TEMPLATE_LABEL}/${sample}/;" ${species}/${study}/${sample}/Makefile
for ((i=1; i<= $nreps; i++)); do
replicate_path=${species}/${study}/${sample}/replicate$i
echo ${replicate_path}
mkdir -p ${replicate_path}
# link the genome to the replicate
pushd ${replicate_path}
ln -s ../../../genome
popd
if [ $pors == "p" ]; then
cp ../makefiles/${machine}Makefile_pe_template ${replicate_path}/Makefile
# replace with proper sample name
sed -i -e "s/${PE_TEMPLATE_LABEL}/${sample}${i}/;" ${replicate_path}/Makefile
elif [ $pors == "s" ]; then
cp ../makefiles/${machine}Makefile_se_template ${replicate_path}/Makefile
# replace with proper sample name
sed -i -e "s/${SE_TEMPLATE_LABEL}/${sample}${i}/;" ${replicate_path}/Makefile
else
echo "Please select 'p' for paired-end or 's' for single read data."
echo " (Your selection ${pors} is not valid.)"
exit 1
fi
done
fi