-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgender_map.sh
31 lines (28 loc) · 1.35 KB
/
gender_map.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
#!/bin/bash
mainRunDir=$1
inputDir=${mainRunDir}"inputs/"
bamMapFile=$2
bamType=$3
clinicalFile=$4
cd ${inputDir}
mkdir -p tmp
for i in tumor normal; do
for j in CCRC UCEC; do
touch ${inputDir}${bamMapFile}"_"${bamType}"_"${i}"_"${j}"_gender_map.txt" > ${inputDir}${bamMapFile}"_"${bamType}"_"${i}"_"${j}"_gender_map.txt"
while IFS= read -r var; do
samtools view -H ${var} | grep SM | awk -F '\t' '{print $3}' | uniq | awk -F 'SM:' '{print $2}' > tmp/tmp_specimen
cat tmp/tmp_specimen | grep -f - ${bamMapFile} | awk -F '\\s' '{print $2}' | uniq > tmp/tmp_case
cat tmp/tmp_case | grep -f - ${clinicalFile} | awk -F '\t' '{print $4}' > tmp/tmp_gender
if [ "$(cat tmp/tmp_gender)" == "male" ]; then
cat tmp/tmp_specimen | awk '{print $1"\tM"}' >> ${inputDir}${bamMapFile}"_"${bamType}"_"${i}"_"${j}"_gender_map.txt"
fi
if [ "$(cat tmp/tmp_gender)" == "female" ]; then
cat tmp/tmp_specimen | awk '{print $1"\tF"}' >> ${inputDir}${bamMapFile}"_"${bamType}"_"${i}"_"${j}"_gender_map.txt"
fi
if [ "$(cat tmp/tmp_gender)" != "female" ] && [ "$(cat tmp/tmp_gender)" != "male" ]; then
echo "grep the wrong column for gender"
cat tmp/tmp_case
fi
done < ${bamMapFile}"_"${bamType}"_"${i}"_"${j}".list"
done
done