-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbackup.sh
More file actions
executable file
·68 lines (51 loc) · 1.8 KB
/
backup.sh
File metadata and controls
executable file
·68 lines (51 loc) · 1.8 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
#!/bin/bash
set -e
hostdir=${1}
destdir=${2}
impname=${3}
filtername1=${4}
filtername2=${5}
hapname=${6}
chr=${7}
i=${chr}
function check_cp {
if [ ! -f ${2} ]; then
cp ${1} ${2}
fi
}
if [ ! -d "${destdir}" ]; then
mkdir ${destdir}
fi
if [ ! -d "${destdir}/haplotypes" ]; then
mkdir ${destdir}/haplotypes
fi
if [ ! -d "${destdir}/chr${i}" ]; then
mkdir ${destdir}/chr${i}
fi
# First copy haplotypes
hap=${hostdir}/data/haplotypes/chr${i}/${hapname}${i}.haps
sample=${hostdir}/data/haplotypes/chr${i}/${hapname}${i}.sample
echo "Compressing ${hap}"
if [ -f ${hap} ]; then
gzip -f ${hap}
fi
echo "Copying ${hap}"
check_cp ${hap}.gz ${destdir}/haplotypes/${haplotypes}/${hapname}${i}.haps.gz
check_cp ${sample} ${destdir}/haplotypes/${haplotypes}/${hapname}${i}.sample
# Next copy the imputed data
imp=${hostdir}/data/imputed/chr${i}/${impname}_${i}
echo "Copying ${imp}"
check_cp ${imp}.bed ${destdir}/chr${i}/${impname}_${i}.bed
check_cp ${imp}.bim ${destdir}/chr${i}/${impname}_${i}.bim
check_cp ${imp}.fam ${destdir}/chr${i}/${impname}_${i}.fam
check_cp ${imp}.gz ${destdir}/chr${i}/${impname}_${i}.gz
check_cp ${imp}_haps.gz ${destdir}/chr${i}/${impname}_${i}_haps.gz
check_cp ${imp}_info.txt.gz ${destdir}/chr${i}/${impname}_${i}_info.txt.gz
# Now copy the filtered data
fil=${hostdir}/data/imputed/chr${i}/${filtername1}${i}${filtername2}
echo "Copying ${fil}"
check_cp ${fil}.bed ${destdir}/chr${i}/${filtername1}${i}${filtername2}.bed
check_cp ${fil}.bim ${destdir}/chr${i}/${filtername1}${i}${filtername2}.bim
check_cp ${fil}.fam ${destdir}/chr${i}/${filtername1}${i}${filtername2}.fam
check_cp ${fil}_info.txt.gz ${destdir}/chr${i}/${filtername1}${i}${filtername2}_info.txt.gz
# ./backup.sh ~/ibimp/twge /fileserver/group/wrayvisscher/gib/imputed/twge twge_1kg_p1v3 twge_1kg_p1v3_ _polygenic TWGE 22