annotate mytools/makebigwig.sh @ 9:87eb5c5ddfe9

Uploaded
author xuebing
date Fri, 09 Mar 2012 20:01:43 -0500
parents f0dc65e7f6c0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
1 # use of output: move to public_html and visualize in ucsc genome browser with the following:
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
2 # track name="xxx" color=0,0,255 type=bigWig bigDataUrl=http://rous.mit.edu/~wuxbl/xxx.bw
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
3
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
4 if [ $# -lt 6 ]
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
5 then
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
6 echo "./bigwig.sh infile outtag bam/bed sorted/none genome strand/none [-split]"
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
7 exit
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
8 fi
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
9
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
10 f=$1
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
11 outf=$2
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
12 extension=$3
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
13 sorted=$4
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
14 genome=$5
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
15 strand=$6
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
16 split=$7
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
17 i=i
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
18 if [ $extension = bam ]
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
19 then
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
20 i=ibam
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
21 if [ $sorted != sorted ]
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
22 then
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
23 echo 'sorting bam file...=>' $f.sorted.bam
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
24 samtools sort $f $f.sorted
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
25 f=$f.sorted.bam
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
26 fi
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
27 else
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
28 if [ $sorted != sorted ]
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
29 then
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
30 echo 'sorting bed file...=>' $f.sorted.bed
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
31 sort -k1,1 $f > $f.sorted.bed
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
32 f=$f.sorted.bed
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
33 fi
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
34 fi
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
35
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
36 echo 'making bedgraph file...=>' $f.bedgraph
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
37 if [ $strand != strand ]
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
38 then
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
39 genomeCoverageBed -bg -$i $f -g $genome $split > $f.bedgraph
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
40 echo 'making bigwig file...=>' $outf.bw
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
41 bedGraphToBigWig $f.bedgraph $genome $outf
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
42 else
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
43 genomeCoverageBed -bg -$i $f -g $genome $split -strand + > $f+.bedgraph
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
44 genomeCoverageBed -bg -$i $f -g $genome $split -strand - > $f-.bedgraph
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
45 echo 'making bigwig file for + strand...=>' $outf+.bw
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
46 bedGraphToBigWig $f+.bedgraph $genome $outf+.bw
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
47 echo 'making bigwig file for - strand...=>' $outf-.bw
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
48 bedGraphToBigWig $f-.bedgraph $genome $outf-.bw
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
49 fi
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
50
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
51 # remove intermediate files
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
52 if [ $sorted != sorted ]
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
53 then
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
54 rm $f
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
55 fi
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
56 rm $f*.bedgraph
f0dc65e7f6c0 Uploaded
xuebing
parents:
diff changeset
57