annotate mgescan.sh @ 0:755f9474b766 draft

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