annotate splicetrap/bin/mapping_bowtie.sh @ 7:37a16ff93dd9 draft default tip

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