-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmultdir_merge.sh
More file actions
64 lines (61 loc) · 2.58 KB
/
multdir_merge.sh
File metadata and controls
64 lines (61 loc) · 2.58 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
#!/bin/bash
usage="Usage: $0 run_dir1 run_dir2 run_dir3 [run_dir4]"
list=()
if [ $# -eq 3 ];then
run_dir1=$1
run_dir2=$2
run_dir3=$3
for value1 in ${list[@]};do
for sample1 in `ls $run_dir1|grep $value1`;do
if [ -d $run_dir2/$sample1 ]; then
if [ -d $run_dir3/$sample1 ]; then
echo $sample1
sample2_R1="$run_dir2/$sample1/${sample1#Sample_}_combined_R1.fastq.gz"
sample2_R2="$run_dir2/$sample1/${sample1#Sample_}_combined_R2.fastq.gz"
sample3_R1="$run_dir3/$sample1/${sample1#Sample_}_combined_R1.fastq.gz"
sample3_R2="$run_dir3/$sample1/${sample1#Sample_}_combined_R2.fastq.gz"
cp -r $run_dir1/$sample1/ .
cat $sample2_R1 $sample3_R1 >> ./$sample1/${sample1#Sample_}_combined_R1.fastq.gz
cat $sample2_R2 $sample3_R2 >> ./$sample1/${sample1#Sample_}_combined_R2.fastq.gz
else
echo "The $run_dir3/$sample1 is not nonexistent "
fi
else
echo "The $run_dir2/$sample1 is not nonexistent "
fi
done
done
elif [ $# -eq 4 ];then
run_dir1=$1
run_dir2=$2
run_dir3=$3
run_dir4=$4
for value1 in ${list[@]};do
for sample1 in `ls $run_dir1|grep $value1`;do
if [ -d $run_dir2/$sample1 ]; then
if [ -d $run_dir3/$sample1 ]; then
if [ -d $run_dir4/$sample1 ]; then
echo $sample1
sample2_R1="$run_dir2/$sample1/${sample1#Sample_}_combined_R1.fastq.gz"
sample2_R2="$run_dir2/$sample1/${sample1#Sample_}_combined_R2.fastq.gz"
sample3_R1="$run_dir3/$sample1/${sample1#Sample_}_combined_R1.fastq.gz"
sample3_R2="$run_dir3/$sample1/${sample1#Sample_}_combined_R2.fastq.gz"
sample4_R1="$run_dir4/$sample1/${sample1#Sample_}_combined_R1.fastq.gz"
sample4_R2="$run_dir4/$sample1/${sample1#Sample_}_combined_R2.fastq.gz"
cp -r $run_dir1/$sample1/ .
cat $sample2_R1 $sample3_R1 $sample4_R1 >> ./$sample1/${sample1#Sample_}_combined_R1.fastq.gz
cat $sample2_R2 $sample3_R2 $sample4_R2 >> ./$sample1/${sample1#Sample_}_combined_R2.fastq.gz
else
echo "The $run_dir4/$sample1 is not nonexistent "
fi
else
echo "The $run_dir3/$sample1 is not nonexistent "
fi
else
echo "The $run_dir2/$sample1 is not nonexistent "
fi
done
done
else
echo $usage
fi