comparison bin/mapping_bowtie.sh @ 1:adc0f7765d85 draft

planemo upload
author bioitcore
date Thu, 07 Sep 2017 15:06:58 -0400
parents
children
comparison
equal deleted inserted replaced
0:d4ca551ca300 1:adc0f7765d85
1 #!/bin/bash
2 #SrcFolder='/data/zhang/wuj/scripts/SpliceTrap.0.8'
3 InputFileName=$1
4 faorfq=$2
5 DatabasePrefix=$3
6 Outputfolder=$4
7 SrcFolder=$5
8 Threads=$6
9 DatabaseFolder=$SrcFolder'/../db/'$DatabasePrefix'/btw/TXdb'
10 TmpFolderName=`basename $1`
11 #fasta or fastq
12
13 cd $Outputfolder;
14 #prepare the folder
15 if [ -d $TmpFolderName.result ];then
16 echo "MAPPING: !!!Error, there is already a folder named "$TmpFolderName".result !"
17 echo "MAPPING: !!!change the name of that folder first in case I erase them..."
18 exit
19 fi
20 echo "MAPPING: Start mapping $InputFileName...Creating cache folder $TmpFolderName.result"
21 mkdir $TmpFolderName".result"
22 mkdir $TmpFolderName".result"/cache
23
24 cd $TmpFolderName".result"
25 cd cache
26 echo "MAPPING: Split to pieces ..."
27 split -l 1000000 $InputFileName
28 for name in x*
29 do
30
31 if [ $faorfq == "fasta" ];then
32 add="-f"
33 fi
34 # if [ $name != $InputFileName ];then
35 echo "bowtie -p $Threads -a -v 2 $DatabaseFolder $name $add >$name.btw; perl $SrcFolder/bowtie2eland.pl $name.btw $name $name.eland;rm $name.btw ;perl $SrcFolder/mark.mt.4eland.pl $name.eland >$name.nomt;rm $name.eland">>map.sh
36 echo $name >>checklist
37 # fi
38 done
39
40 echo "MAPPING: submit scripts..."
41 perl $SrcFolder/batchqsub.pl map.sh
42
43 tasknum=`wc -l map.sh |tr -d "\n"`
44 #checking..
45
46 echo "MAPPING: mapping $InputFileName to TXdb done...start to check.."
47 while [ 1 ]
48 do
49 if [ -f mapcheck.sh ];then
50 rm mapcheck.sh
51 fi
52 while read checklist
53 do
54
55 name=`echo $checklist |tr -d "\n"`
56 echo "MAPPING: checking $name...."
57 readnum=`wc -l $name | cut -f1 -d" "`
58 if [ $faorfq == "fasta" ];then
59 readnum=`echo "$readnum/2"|bc`
60 else
61 readnum=`echo "$readnum/4"|bc`
62 fi
63 if [ -f $name.nomt ];then
64 bowtienum=`wc -l $name.nomt | cut -f1 -d" "`
65 else
66 bowtienum=0
67 fi
68 if [ $bowtienum != $readnum ];then
69 echo "bowtie -p $Threads -a -v 2 $DatabaseFolder $name $add >$name.btw; perl $SrcFolder/bowtie2eland.pl $name.btw $name $name.eland;rm $name.btw ;perl $SrcFolder/mark.mt.4eland.pl $name.eland >$name.nomt;rm $name.eland">>mapcheck.sh
70
71 fi
72 done <checklist
73 if [ -f mapcheck.sh ];then
74 checktasknum=`wc -l mapcheck.sh |tr -d "\n"`
75 if [ $checktasknum == $tasknum ];then
76 echo "MAPPING: warning! none of the mapping tasks properly finished!"
77 fi
78 echo "MAPPING: resubmit TASKS...."
79 perl $SrcFolder/batchqsub.pl mapcheck.sh
80 else
81 break
82 fi
83 done
84 echo "MAPPING: Done.....merging files..."
85 cat *.nomt >$Outputfolder/$TmpFolderName.nomt
86 cd ../../
87 rm $TmpFolderName.result -rf
88 #/data/zhang/wuj/tools/bowtie-0.12.3/bowtie -a $DatabaseFolderTXdb -f
89