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