comparison MACARON-GenMed-LabEx/MACARON_validate.sh @ 0:c9636a827049 draft default tip

Uploaded
author waqas
date Wed, 12 Sep 2018 08:45:03 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c9636a827049
1 #!/bin/bash
2
3 #sub1.chr22_21349676-21349677.sample02.bam
4
5 bam=$1;
6 name=$(echo $bam | cut -d'.' -f1)
7 region=$(echo $bam | cut -d'.' -f2)
8 sample=$(echo $bam | cut -d'.' -f3)
9
10 chr=$(echo $region | cut -d'_' -f1)
11 pos=$(echo $region | cut -d'_' -f2)
12
13 beg=$(echo $pos | cut -d'-' -f1)
14 end=$(echo $pos | cut -d'-' -f2)
15
16 #beg=$(($beg+50))
17 #end=$((end-50))
18
19 #echo "name $name"
20 #echo "region $region"
21 #echo "sample $sample"
22
23 echo "$name $chr:$beg-$end $sample"
24 echo "$name $chr:$beg-$end $sample" >> MACARON_validate.txt
25
26 samtools view $bam | awk -v start=$beg -v stop=$end '
27 {
28 pos=$4;
29 if(pos < start){
30 cstart=1+start-pos;
31 cstop=1+stop-pos;
32 print cstart"."cstop"."$10;
33 }
34 }' > tmp
35
36 while read line;
37 do
38 cb=$(echo $line | cut -d'.' -f1);
39 ce=$(echo $line | cut -d'.' -f2);
40 seq=$(echo $line | cut -d'.' -f3);
41 echo $seq | cut -c$cb-$ce;
42 done <tmp | sort | uniq -c | sort -n >> MACARON_validate.txt
43 rm tmp
44
45
46
47
48 exit 0
49