-
Notifications
You must be signed in to change notification settings - Fork 9
/
step3-summaryNeoantigens.sh
executable file
·67 lines (54 loc) · 1.77 KB
/
step3-summaryNeoantigens.sh
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
#! /usr/bin/env bash
# Summary neoantigen result and not run neoantigen quality computation
echo ---------------------------------
echo -- Summary Neoantigen Results --
echo ---------------------------------
# load arguments
source $(pwd)/inputArgs.txt
###########<<<<<< Summary all result data processed by pVACseq tool
input_dir=$OUTPUT/pvacseqResults
neo_dir=$OUTPUT/neoantigens
# make sure the neo dir exisit, otherwise create it
if [ ! -d $neo_dir ]; then
echo -e "\033[33m The neoantigens result directory does not exist under $OUTPUT, we will create it. \033[0m"
mkdir -p $neo_dir
fi
final_dir=$neo_dir/final_neoantigens
mkdir -p $final_dir
# get all final neoantigens of listed samples in input directory
neodirs=$(ls $input_dir | grep "res")
for neodir in $neodirs
do
#sample=$(echo $neodir | cut -b 5-19)
sample=$(echo $neodir | sed -E 's/res_(.*)/\1/')
neofile=$input_dir/$neodir/"MHC_Class_I"/$sample".final.tsv"
if [ -f $neofile ]; then
cp $neofile $final_dir
printf "\rcopy %s to $final_dir ..." $neofile
else
echo "Sample $sample has no final neoantigen result processed by pVACseq, please check it."
fi
done
# merge all neoantigen files
allfiles=$(ls $final_dir | grep "final")
i=0
for onefile in $allfiles
do
let i+=1
printf "\rprocess %s .." $onefile
if [ $i -eq 1 ]; then
cat $final_dir/$onefile > $neo_dir/"merged_neoantigens.tsv"
else
cat $final_dir/$onefile | sed '1d' >> $neo_dir/"merged_neoantigens.tsv"
fi
done
if [ $i -eq 0 ]; then
echo
echo "Something wrong with files, aborting..."
exit 1
fi
echo
echo "===> Process of merging Neoantigen files complete successfully!"
echo "$i files have been merged into $neo_dir/merged_neoantigens.tsv."
echo
echo "DONE!"