-
Notifications
You must be signed in to change notification settings - Fork 0
/
GGP-Tumor-Normal-TView.sh~
executable file
·86 lines (77 loc) · 3 KB
/
GGP-Tumor-Normal-TView.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
### ./tumor-normal-tview.sh ARC < file.vcf
### stdin must have: chr <TAB> pos <TAB> ...
### prints tviews of tumor and normal samples starting at given position
### and with:
width=30
offset=10
samtools=/ifs/scratch/c2b2/rr_lab/shares/samtools/samtools ### development version
ref_samtools_genome=/ifs/scratch/c2b2/rr_lab/shares/ref/hg19/Illumina_iGenome/Homo_sapiens/Ensembl/GRCh37/Sequence/BWAIndex/genome.fa
function list_join {
local OLDIFS=$IFS
IFS=${1:?"Missing separator"}; shift
echo "$*"
IFS=$OLDIFS
}
# if [[ $# -eq 2 ]]; then
# N1=$1; shift ### bam file
# N2=$1; shift
# tumor=$(echo /ifs/scratch/c2b2/rr_lab/shares/GGP/*/*/GRCh37_*_GGP-$N1.pe.MarkDuplicates.bam)
# normal=$(echo /ifs/scratch/c2b2/rr_lab/shares/GGP/*/*/GRCh37_*_GGP-$N2.pe.MarkDuplicates.bam)
# elif [[ $# -eq 4 ]]; then
declare -a bam_files
for patient in "$@"; do
# bam=$(echo /ifs/scratch/c2b2/rr_lab/shares/GGP/*/*/GRCh37_*_GGP-$N.pe.MarkDuplicates.bam)
# bam_files=("${bam_files[@]}" $bam)
bam=$(echo /ifs/scratch/c2b2/rr_lab/shares/GGP/links_numbered/*-$patient-*.bam)
bam_files=("${bam_files[@]}" $bam)
done
#fi
echo "${bam_files[@]}"
while read line; do
if [[ ${line:0:1} = "#" ]]; then continue; fi
### split line by tab
array=(${line//\t/})
### assume chr:pos if there is a colon in the first field
if [[ ${array[0]} == *:* ]]; then
first_field=${array[0]}
chrpos=("${first_field//:/}")
chr=${chrpos[0]}
pos=${chrpos[1]}
echo pos $chrpos
else
### else assume chr pos are the first two fields
chr=${array[0]}
pos=${array[1]}
fi
pos=$(( $pos - $offset ))
pos=$chr:$pos
echo $pos
tput bold
tput setaf 4 ### blue
echo $line
tput sgr0
# if [[ $# -eq 4 ]]; then
(
# echo $(list_join "@" "${bam_files[@]}")
echo "b@n1@n2@t1@t2"
paste -d"@" \
<(printf '%'$offset'sV\n';$samtools tview -d text -p $pos ${bam_files[0]} $ref_samtools_genome | cut -c1-$width) \
<(printf '%'$offset'sV\n';$samtools tview -d text -p $pos ${bam_files[1]} $ref_samtools_genome | cut -c1-$width) \
<(printf '%'$offset'sV\n';$samtools tview -d text -p $pos ${bam_files[2]} $ref_samtools_genome | cut -c1-$width) \
<(printf '%'$offset'sV\n';$samtools tview -d text -p $pos ${bam_files[3]} $ref_samtools_genome | cut -c1-$width) \
<(printf '%'$offset'sV\n';$samtools tview -d text -p $pos ${bam_files[4]} $ref_samtools_genome | cut -c1-$width) \
) \
| sed ':x s/\(^\|@\)@/\1 @/; t x' | column -ts$"@"
# else
# (
# echo 'TUMOR@NORMAL';
# # printf '%'$offset'sV@%'$offset'sV\n';'
# paste -d"@" \
# <( $samtools tview -d text -p $pos $tumor $ref_samtools_genome | cut -c1-$width) \
# <( $samtools tview -d text -p $pos $normal $ref_samtools_genome | cut -c1-$width) \
# ) \
# | sed 's/^@/\ @/' | column -ts$"@"
# fi
done
### echo *.dat | sed 's/\S*/<(cut -f2 &)/g; s/^/paste /' | bash >all.dat