annotate mgescan.sh @ 7:b14f55bb20be draft

Uploaded
author hyungrolee
date Mon, 15 Feb 2016 03:33:48 -0500
parents
children 1a143426370c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
1 #!/bin/bash
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
2 # mgescan.sh $input $input.name 3 $output L None None None $ltr_gff3 None None $sw_rm "$scaffold" $min_dist $max_dist $min_len_ltr $max_len_ltr $ltr_sim_condition $cluster_sim_condition $len_condition $repeatmasker
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
3 if [ "" == "$MGESCAN_SRC" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
4 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
5 echo "\$MGESCAN_SRC is not defined."
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
6 exit
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
7 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
8
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
9 script_program=`which python`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
10 script=$MGESCAN_SRC/mgescan/cmd.py
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
11 input_file=$1
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
12 #input_file_name=$2
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
13 input_file_name=`basename $input_file`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
14 hmmsearch_version=$3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
15 output_file=$4
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
16 program=$5 # N is nonLTR, L is LTR and B is both
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
17 # Optional output parameters for nonLTR
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
18 clade=$6
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
19 en=$7
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
20 rt=$8
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
21 ltr_gff3=$9
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
22 nonltr_gff3=${10}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
23 both_gff3=${11}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
24 #### for ltr between $11 and $20
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
25 if [ "$program" == "L" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
26 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
27 sw_rm=${12}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
28 scaffold=${13}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
29 min_dist=${14}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
30 max_dist=${15}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
31 min_len_ltr=${16}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
32 max_len_ltr=${17}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
33 ltr_sim_condition=${18}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
34 cluster_sim_condition=${19}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
35 len_condition=${20}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
36 repeatmasker=${21}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
37 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
38
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
39 #elif [ "$program" == "B" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
40 if [ $# -eq 12 ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
41 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
42 nmpi=${12}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
43 if [ ! -z $nmpi ] && [ $nmpi -ge 1 ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
44 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
45 mpi_enabled="--mpi=$nmpi"
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
46 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
47
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
48 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
49
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
50 # /nfs/nfs4/home/lee212/mgescan/galaxy-dist/tools/mgescan/find_ltr.sh /nfs/nfs4/home/lee212/mgescan/galaxy-dist/database/files/000/dataset_1.dat /nfs/nfs4/home/lee212/mgescan/galaxy-dist/database/files/000/dataset_3.dat
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
51
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
52 #set path for transeq
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
53 #export PATH=$user_dir/mgescan/EMBOSS/bin:/usr/bin:$PATH
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
54 transeq --version 2> /dev/null
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
55 res=$?
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
56 if [ 0 -ne $res ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
57 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
58 echo "EMBOSS is not available."
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
59 exit
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
60 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
61
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
62 #move to the working directory
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
63 work_dir=`dirname $script`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
64 cd $work_dir
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
65
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
66 #create directory for input and output
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
67 mkdir -p input
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
68 t_dir=`mktemp -p input -d` #relative path
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
69 input_dir="$work_dir/$t_dir/seq" # full path
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
70 output_dir="$work_dir/$t_dir/data"
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
71 mkdir -p $input_dir
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
72 mkdir -p $output_dir
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
73
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
74 #make a copy of input
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
75 #/bin/cp $input_file $input_dir/$input_file_name
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
76
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
77 # Check tar.gz
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
78 tar tf $input_file &> /dev/null
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
79 ISGZ=$?
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
80 if [ 0 -eq $ISGZ ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
81 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
82 # It seems pre_process.pl creates ./data/genome directory and makes a copy of a genome file.
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
83 # Due to this reason, extracts compressed inputs to output directory.
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
84 tar xzf $input_file -C $input_dir 2> /dev/null
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
85 if [ $? -ne 0 ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
86 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
87 tar xf $input_file -C $input_dir 2> /dev/null
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
88 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
89 else
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
90 /bin/ln -s $input_file $input_dir/$input_file_name
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
91 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
92
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
93 VERSION2=`hmmsearch -h|grep "HMMER 2" 2> /dev/null`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
94 VERSION3=`hmmsearch -h|grep "HMMER 3" 2> /dev/null`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
95 if [ "2" == "$hmmsearch_version" ] && [ "" != "$VERSION2" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
96 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
97 echo $VERSION2 selected.
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
98 elif [ "3" == "$hmmsearch_version" ] && [ "" != "$VERSION3" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
99 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
100 echo $VERSION3 selected.
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
101 else
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
102 echo HMMER is not available.
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
103 exit
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
104 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
105
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
106 if [ "$program" == "L" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
107 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
108 program_name="ltr"
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
109 elif [ "$program" == "N" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
110 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
111 program_name="nonltr"
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
112 else
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
113 program_name="both"
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
114 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
115
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
116 #run
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
117 $script_program $script $program_name $input_dir/ --output=$output_dir/ $mpi_enabled #-hmmerv=$hmmsearch_version -sw_rm=${11} -scaffold=${12} -min_dist=${13} -max_dist=${14} -min_len_ltr=${15} -max_len_ltr=${16} -ltr_sim_condition=${17} -cluster_sim_condition=${18} -len_condition=${19}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
118 #/usr/bin/perl $script -genome=$input_dir/ -data=$output_dir/ -hmmerv=$hmmsearch_version -program=$program -sw_rm=${11} -scaffold=${12} -min_dist=${13} -max_dist=${14} -min_len_ltr=${15} -max_len_ltr=${16} -ltr_sim_condition=${17} -cluster_sim_condition=${18} -len_condition=${19}
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
119
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
120 #RES=`ssh -i $user_dir/.ssh/.internal silo.cs.indiana.edu "/usr/bin/perl $script -genome=$input_dir/ -data=$output_dir/ -hmmerv=$hmmsearch_version -program=$program > /dev/null"`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
121
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
122 #make a copy of output
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
123 if [ "$program" != "N" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
124 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
125 /bin/cp $output_dir/ltr/ltr.out $output_file
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
126 if [ "$ltr_gff3" != "None" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
127 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
128 /bin/cp $output_dir/ltr/ltr.gff3 $ltr_gff3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
129 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
130
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
131 if [ "$repeatmasker" != "None" ] && [ "$repeatmasker" != "" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
132 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
133 # chr2L.fa.cat.gz chr2L.fa.masked chr2L.fa.out chr2L.fa.out.pos chr2L.fa.tbl
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
134 /bin/cp $output_dir/repeatmasker/${input_file_name}.out $repeatmasker
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
135 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
136 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
137 if [ "$program" != "L" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
138 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
139
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
140 tmp=`mktemp`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
141 RANDOM=`basename $tmp`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
142 compressed_file=$output_dir/$RANDOM.tar.gz
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
143 /bin/tar czfP $compressed_file $output_dir/info
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
144 #/bin/cp $compressed_file $output_file
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
145 #RES=`/bin/cp $output_dir/info/full/*/* $clade 2> /dev/null`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
146 RES=`/bin/cp $compressed_file $clade 2> /dev/null`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
147 RES=`/bin/cp $output_dir/info/validation/en $en 2> /dev/null`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
148 RES=`/bin/cp $output_dir/info/validation/rt $rt 2> /dev/null`
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
149 if [ "$nonltr_gff3" != "None" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
150 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
151 /bin/cp $output_dir/info/nonltr.gff3 $nonltr_gff3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
152 # nonltr.gff3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
153 ##gff-version 3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
154 #chr2L.fa MGEScan_nonLTR mobile_genetic_element 19670384 19676921 . . . ID=chr2L.fa_19670384
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
155 #chr2L.fa MGEScan_nonLTR mobile_genetic_element 17689430 17695994 . . . ID=chr2L.fa_17689430
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
156 #chr2L.fa MGEScan_nonLTR mobile_genetic_element 11897186 11903717 . . . ID=chr2L.fa_11897186
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
157 #chr2L.fa MGEScan_nonLTR mobile_genetic_element 49574 56174 . . . ID=chr2L.fa_49574
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
158 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
159
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
160 #else
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
161 # Both LTR, nonLTR executed
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
162 #compressed_file=$output_dir/$RANDOM.tar.gz
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
163 #/bin/tar czfP $compressed_file $output_dir
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
164 #/bin/cp $compressed_file $output_file
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
165 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
166
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
167 if [ "$program" == "B" ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
168 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
169 #echo "track name=LTR description=\"MGEScan-LTR\" color=0,0,255," > $both_gff3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
170 /bin/cat $output_dir/ltr/ltr.gff3 >> $both_gff3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
171 #echo "track name=nonLTR description=\"MGEScan-nonLTR\" color=255,0,0" >> $both_gff3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
172 /bin/cat $output_dir/info/nonltr.gff3 >> $both_gff3
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
173 fi
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
174
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
175 # delete temp directory
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
176 if [ $? -eq 0 ]
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
177 then
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
178 rm -rf $work_dir/$t_dir
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
179 #echo
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
180 else
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
181 #echo cp -pr $work_dir/$t_dir $work_dir/error-cases/
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
182 cp -pr $work_dir/$t_dir $work_dir/error-cases/
b14f55bb20be Uploaded
hyungrolee
parents:
diff changeset
183 fi