annotate miRPlant.pl @ 42:3b9a6381e6bf draft

Uploaded
author big-tiandm
date Tue, 28 Oct 2014 01:35:17 -0400
parents 554fbaf5f451
children 0c4e11018934
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
1 #!/usr/bin/perl -w
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
2 #Filename:
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
3 #Author: Tian Dongmei
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
4 #Email: tiandm@big.ac.cn
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
5 #Date: 2014-4-22
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
6 #Modified:
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
7 #Description: plant microRNA prediction
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
8 my $version=1.00;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
9
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
10 use strict;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
11 use Getopt::Long;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
12 use threads;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
13 use threads::shared;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
14 use File::Path;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
15 use File::Basename;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
16 #use RNA;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
17 use Term::ANSIColor;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
18
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
19 my %opts;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
20 GetOptions(\%opts,"i:s@","tag:s@","format=s","gfa=s","pre=s","mat=s","rfam:s","dis:i","flank:i","mfe:f","idx:s","idx2:s","mis:i","r:i","v:i","e:i","f:i","a:s","M:i","t:i","min:i","max:i","o:s","path:s","D","h");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
21 if (!(defined $opts{i} and defined $opts{format} and defined $opts{gfa} and defined $opts{pre} and defined $opts{mat}) || defined $opts{h}) { #necessary arguments
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
22 &usage;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
23 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
24
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
25 my $time=&Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
26 print "miPlant program start:\n The time is $time!\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
27 print "Command line:\n $0 @ARGV\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
28
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
29 my $format=$opts{'format'};
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
30 if ($format ne "fastq" && $format ne "fq" && $format ne "fasta" && $format ne "fa") {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
31 &printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
32 die "Parameter \"-format\" is error! Parameter is fastq, fq, fasta or fa\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
33 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
34
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
35 my $phred_qv=64;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
36
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
37
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
38 my @inputfiles=@{$opts{'i'}};
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
39 my @inputtags=@{$opts{'tag'}};
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
40
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
41 my $mypath=`pwd`;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
42 chomp $mypath;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
43
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
44 my $dir=defined $opts{'o'} ? $opts{'o'} : "$mypath/miRPlant_out/";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
45
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
46
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
47 unless ($dir=~/\/$/) {$dir.="/";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
48 if (not -d $dir) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
49 mkdir $dir;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
50 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
51 my $config=$dir."/input_config";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
52 open CONFIG,">$config";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
53 for (my $i=0;$i<@inputfiles;$i++) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
54 print CONFIG $inputfiles[$i],"\t",$inputtags[$i],"\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
55 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
56 close CONFIG;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
57
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
58 my $scipt_path=defined $opts{'path'} ? $opts{'path'} : "/Users/big/galaxy-dist/tools/myTools/";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
59
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
60 my $a="ATCTCGTATG"; #adapter
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
61 if (defined $opts{'a'}) {$a=$opts{'a'};}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
62
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
63 my $m=6; #adapter minimum mapped nt
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
64 if (defined $opts{'M'}) {$m=$opts{'M'};}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
65
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
66 my $t=1; #threads number
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
67 if (defined $opts{'t'}) {$t=$opts{'t'};}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
68
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
69 my $min_nt=19; # minimum reads length
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
70 if (defined $opts{'min'}) {$min_nt=$opts{'min'};}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
71
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
72 my $max_nt=28; #maximum reads length
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
73 if (defined $opts{'max'}) {$max_nt=$opts{'max'};}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
74
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
75 my $mis=0; #mismatch number for microRNA
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
76 if (defined $opts{'mis'}) {$mis=$opts{'mis'};}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
77
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
78 my $mis_rfam=0;# mismatch number for rfam
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
79 if (defined $opts{'v'}) {$mis_rfam=$opts{'v'};}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
80
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
81 my $hit=25; # maximum reads mapping hits in genome
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
82 if (defined $opts{'r'}) {$hit=$opts{'r'};}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
83
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
84 my $upstream = 2; # microRNA 5' extension
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
85 $upstream = $opts{'e'} if(defined $opts{'e'});
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
86
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
87 my $downstream = 5;# microRNA 3' extension
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
88 $downstream = $opts{'f'} if(defined $opts{'f'});
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
89
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
90 my $maxd=defined $opts{'dis'} ? $opts{'dis'} : 200;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
91 my $flank=defined $opts{'flank'} ? $opts{'flank'} :10;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
92 my $mfe=defined $opts{'mfe'} ? $opts{'mfe'} : -20;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
93
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
94 $time=&Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
95 print "$time, Checking input file!\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
96
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
97 my (@filein,@mark,@clean);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
98 #&read_config();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
99 @filein=@inputfiles;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
100 @mark=@inputtags;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
101
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
102 &checkfa($opts{pre});
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
103 &checkfa($opts{mat});
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
104 &checkfa($opts{gfa});
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
105
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
106
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
107 ##### clip adpter --> clean data start
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
108 $time=&Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
109 print "$time, Preprocess:\n trim adapter, reads collapse and filter reads by length.\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
110
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
111 $time=~s/:/-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
112 $time=~s/ /-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
113 my $preprocess=$dir."preProcess_${time}/";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
114 mkdir $preprocess;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
115 my $can_use_threads = eval 'use threads; 1';
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
116 if ($can_use_threads) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
117 # Do processing using threads
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
118 print "Do processing using threads\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
119 my @filein1=@filein; my @mark1=@mark;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
120 while (@filein1>0) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
121 my @thrs; my @res;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
122 for (my $i=0;$i<$t ;$i++) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
123 last if(@filein1==0);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
124 my $in=shift @filein1;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
125 my $out=shift @mark1;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
126 push @clean,$preprocess.$out."_clips_adapter.fq";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
127 $thrs[$i]=threads->create(\&clips,$in,$out);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
128 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
129 for (my $i=0;$i<@thrs;$i++) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
130 $res[$i]=$thrs[$i]->join();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
131 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
132 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
133 } else {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
134 # Do not processing using threads
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
135 print "Do not processing using threads\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
136 for (my $i=0;$i<@filein ;$i++) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
137 my $in=$filein[$i];
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
138 my $out=$mark[$i];
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
139 push @clean,$preprocess.$out."_clips_adapter.fq";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
140 &clips($in,$out);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
141 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
142 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
143
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
144 ##### clip adpter --> clean data end
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
145
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
146 my $collapsed=$preprocess."collapse_reads.fa";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
147 my $data=$preprocess."collapse_reads_${min_nt}_${max_nt}.fa"; ## raw clean data
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
148 my $data2; ### mirbase not mapped reads
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
149 my $data3; ### rfam not mapped reads
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
150 &collapse(\@clean,$collapsed); #collapse reads to tags
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
151
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
152 &filterbylength(); # filter <$min_nt && >$max_nt
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
153
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
154 print "The final clean data file is $data, only contains reads which length is among $min_nt\~$max_nt\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
155
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
156 $time=Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
157 print "$time: known microRNA quantify!\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
158
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
159 chdir $dir;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
160
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
161 $time=~s/:/-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
162 $time=~s/ /-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
163 my $known_result=$dir."miRNA_Express_${time}/";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
164 &quantify(); ### known microRAN quantify
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
165
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
166
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
167 #my $miR_exp_dir=&search($known_result,"miRNA_Express_");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
168 $data2=$known_result."/mirbase_not_mapped.fa";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
169
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
170 my $pathfile="$dir/path.txt";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
171 open PA,">$pathfile";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
172 print PA "$config\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
173 print PA "$preprocess\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
174 print PA "$known_result\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
175
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
176 if (defined $opts{'rfam'}) { #rfam mapping and analysis
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
177 $time=Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
178 print "$time: RNA annotate!\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
179 $time=~s/:/-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
180 $time=~s/ /-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
181 my $rfam_exp_dir=$dir."rfam_match_${time}";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
182 &rfam();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
183 #my $rfam_exp_dir=&search($dir,"rfam_match_");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
184 $data3=$rfam_exp_dir."/rfam_not_mapped.fa";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
185 print PA "$rfam_exp_dir\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
186
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
187 my $tag=join "\\;" ,@mark;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
188 system("perl $scipt_path/count_rfam_express.pl -i $rfam_exp_dir/rfam_mapped.bwt -tag $tag -o rfam_non-miRNA_annotation.txt");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
189 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
190
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
191 my $data4=$data;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
192 if (defined $opts{'D'}) { #genome mapping
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
193 $data4=$data3;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
194 }else{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
195 $data4=$data2;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
196 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
197
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
198 $time=Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
199 print "$time: Genome alignment!\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
200 $time=~s/:/-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
201 $time=~s/ /-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
202 my $genome_map=$dir."genome_match_${time}";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
203 &genome($data4);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
204 print PA "$genome_map\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
205 #my $genome_map=&search($dir,"genome_match_");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
206 my $mapfile=$genome_map."/genome_mapped.bwt";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
207 my $mapfa=$genome_map."/genome_mapped.fa";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
208 my $unmap=$genome_map."/genome_not_mapped.fa";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
209
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
210 #$time=Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
211 #print "$time: Novel microRNA prediction!\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
212
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
213 &predict($mapfa);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
214
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
215 close PA;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
216 system("perl $scipt_path/html.pl -i $pathfile -format $format -o $dir/result.html");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
217
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
218 $time=Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
219 print "$time: Program end!!\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
220
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
221 ############################## sub programs ###################################
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
222 sub predict{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
223 my ($file)=@_;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
224 $time=&Time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
225 print "$time: Novel microRNA prediction!\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
226 $time=~s/:/-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
227 $time=~s/ /-/g;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
228 my $predict=$dir."miRNA_predict_${time}";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
229 print PA "$predict\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
230 mkdir $predict;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
231 chdir $predict;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
232 system("perl $scipt_path/precursors.pl -map $mapfile -g $opts{gfa} -d $maxd -f $flank -o $predict/excised_precursor.fa -s $predict/excised_precursor_struc.txt -e $mfe");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
233 # print "\nprecursors.pl -map $mapfile -g $opts{gfa} -d $maxd -f $flank -o $predict/excised_precursor.fa -s $predict/excised_precursor_struc.txt -e $mfe\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
234
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
235 system("bowtie-build -f excised_precursor.fa excised_precursor");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
236 # print "\nbowtie-build -f excised_precursor.fa excised_precursor\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
237
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
238 system("bowtie -v $mis -f -p $t -m $hit -a --best --strata excised_precursor $file > precursor_mapped.bwt");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
239 # print "\nbowtie -v $mis -f -p $t -m $hit -a --best --strata excised_precursor $file > precursor_mapped.bwt\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
240
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
241 system("perl $scipt_path/convert_bowtie_to_blast.pl precursor_mapped.bwt $file excised_precursor.fa > precursor_mapped.bst");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
242 # print "\nconvert_bowtie_to_blast.pl precursor_mapped.bwt $file excised_precursor.fa > precursor_mapped.bst\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
243
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
244 system("sort +3 -25 precursor_mapped.bst > signatures.bst");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
245 # print "\nsort +3 -25 precursor_mapped.bst > ../signatures.bst\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
246
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
247 chdir $dir;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
248 system("perl $scipt_path/miRDeep_plant.pl $predict/signatures.bst $predict/excised_precursor_struc.txt novel_tmp_dir -y > microRNA_prediction.mrd");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
249 # print "\nmiRDeep_plant.pl $dir/signatures.bst $predict/excised_precursor_struc.txt tmp_dir -y > microRNA_prediction.txt\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
250 system("rm novel_tmp_dir -rf");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
251 my $tag=join "," ,@mark;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
252 system("perl $scipt_path/miRNA_Express_and_sequence.pl -i microRNA_prediction.mrd -list novel_microRNA_express.txt -fa novel_microRNA_mature.fa -pre novel_microRNA_precursor.fa -tag $tag");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
253 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
254
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
255 sub genome{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
256 my ($file)=@_;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
257 if(defined $opts{'idx'}){
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
258 system("perl $scipt_path/matching.pl -i $file -g $opts{gfa} -v $mis -p $t -r $hit -o $dir -index $opts{idx} -time $time") ;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
259 # print "\nmatching.pl -i $file -g $opts{gfa} -v $mis -p $t -r $hit -o $dir -index $opts{idx} -time $time\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
260 }else{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
261 system("perl $scipt_path/matching.pl -i $file -g $opts{gfa} -v $mis -p $t -r $hit -o $dir -time $time") ;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
262 # print "\nmatching.pl -i $file -g $opts{gfa} -v $mis -p $t -r $hit -o $dir -time $time\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
263 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
264 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
265 sub rfam{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
266 if (defined $opts{'idx2'}) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
267 system("perl $scipt_path/rfam.pl -i $data2 -ref $opts{rfam} -v $mis_rfam -p $t -o $dir -index $opts{idx2} -time $time");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
268 # print "\nrfam.pl -i $data2 -ref $opts{rfam} -v $mis_rfam -p $t -o $dir -index $opts{idx2} -time $time\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
269 }else{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
270 system("perl $scipt_path/rfam.pl -i $data2 -ref $opts{rfam} -v $mis_rfam -p $t -o $dir -time $time");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
271 # print "\nrfam.pl -i $data2 -ref $opts{rfam} -v $mis_rfam -p $t -o $dir -time $time\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
272 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
273 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
274 sub quantify{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
275 my $tag=join "\\;" ,@mark;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
276 system("perl $scipt_path/quantify.pl -p $opts{pre} -m $opts{mat} -r $data -o $dir -time $time -mis $mis -t $t -e $upstream -f $downstream -tag $tag");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
277 # print "\nquantify.pl -p $opts{pre} -m $opts{mat} -r $data -o $dir -time $time -mis $mis -t $t -e $upstream -f $downstream -tag $tag\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
278 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
279 sub filterbylength{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
280 my $tmpmark=join ",", @mark;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
281 system("perl $scipt_path/filterReadsByLength.pl -i $collapsed -o $data -min $min_nt -max $max_nt -mark $tmpmark");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
282 # print "\nfilterReadsByLength.pl -i $collapsed -o $data -min $min_nt -max $max_nt -mark $tmpmark\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
283
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
284 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
285 sub collapse{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
286 my ($ins,$data)=@_;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
287 my $str="";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
288 for (my $i=0;$i<@{$ins};$i++) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
289 $str .="-i $$ins[$i] ";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
290 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
291 system ("perl $scipt_path/collapseReads2Tags.pl $str -mark seq -o $data -format $format");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
292 # print "\ncollapseReads2Tags.pl $str -mark seq -o $data -format $format\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
293 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
294
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
295 sub clips{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
296 my ($in,$out)=@_;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
297 my $adapter=$preprocess.$out."_clips_adapter.fq";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
298 if($format eq "fq" || $format eq "fastq"){
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
299 system("fastx_clipper -a $a -M $m -Q $phred_qv -i $in -o $adapter") ;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
300 print "\nfastx_clipper -a $a -M $m -Q $phred_qv -i $in -o $adapter\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
301 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
302 if($format eq "fa" || $format eq "fasta"){
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
303 system("fastx_clipper -a $a -M $m -i $in -o $adapter") ;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
304 # print "\nfastx_clipper -a $a -M $m -i $in -o $adapter\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
305 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
306 #my $clean=$preprocess.$out."_clean.fq";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
307 #system("filterReadsByLength.pl -i $adapter -o $clean -min $min_nt -max $max_nt ");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
308
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
309 return;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
310 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
311
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
312 sub read_config{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
313 open CON,"<$config";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
314 while (my $aline=<CON>) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
315 chomp $aline;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
316 my @tmp=split/\t/,$aline;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
317 push @filein,$tmp[0];
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
318 push @mark,$tmp[1];
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
319 &check_rawdata($tmp[0]);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
320 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
321 close CON;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
322 if (@filein != @mark) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
323 &printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
324 die "Maybe config file have some wrong!!!\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
325 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
326 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
327 sub check_rawdata{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
328 my ($fileforcheck)=@_;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
329 if (!(-s $fileforcheck)) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
330 &printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
331 die "Can not find $fileforcheck, or file is empty!!!\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
332 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
333 if ($format eq "fasta" || $format eq "fa") {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
334 &checkfa($fileforcheck);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
335 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
336 if ($format eq "fastq" || $format eq "fq") {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
337 &checkfq($fileforcheck);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
338 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
339 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
340 sub checkfa{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
341 my ($file_reads)=@_;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
342 open N,"<$file_reads";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
343 my $line=<N>;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
344 chomp $line;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
345 if($line !~ /^>\S+/){
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
346 printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
347 die "The first line of file $file_reads does not start with '>identifier'
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
348 Reads file $file_reads is not a valid fasta file\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
349 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
350 if(<N> !~ /^[ACGTNacgtn]*$/){
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
351 printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
352 die "File $file_reads contains not allowed characters in sequences
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
353 Allowed characters are ACGTN
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
354 Reads file $file_reads is not a fasta file\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
355 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
356 close N;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
357 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
358 sub checkfq{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
359 my ($file_reads)=@_;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
360
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
361 open N,"<$file_reads";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
362 for (my $i=0;$i<10;$i++) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
363 my $a=<N>;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
364 my $b=<N>;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
365 my $c=<N>;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
366 my $d=<N>;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
367 chomp $a;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
368 chomp $b;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
369 chomp $c;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
370 chomp $d;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
371 if($a!~/^\@/){
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
372 &printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
373 die "$file_reads is not a fastq file\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
374 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
375 if($b!~ /^[ACGTNacgtn]*$/){
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
376 &printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
377 die "File $file_reads contains not allowed characters in sequences
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
378 Allowed characters are ACGTN
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
379 Reads file $file_reads is not a fasta file\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
380 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
381 if ($c!~/^\@/ && $c!~/^\+/) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
382 &printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
383 die "$file_reads is not a fastq file\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
384 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
385 if ((length $b) != (length $d)) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
386 &printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
387 die "$file_reads is not a fastq file\n\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
388 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
389 my @qv=split //,$d;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
390 for (my $j=0;$j<@qv ;$j++) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
391 my $q=ord($qv[$j])-64;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
392 if($q<0){$phred_qv=33;}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
393 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
394 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
395 close N;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
396 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
397
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
398 sub search{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
399 my ($dir,$str)=@_;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
400 opendir I,$dir;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
401 my @ret;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
402 while (my $file=readdir I) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
403 if ($file=~/$str/) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
404 push @ret, $file;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
405 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
406 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
407 closedir I;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
408 if (@ret != 1) {
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
409 &printErr();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
410
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
411 die "Can not find directory or file which name has string: $str !!!\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
412 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
413 return $ret[0];
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
414 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
415
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
416 sub printErr{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
417 print STDERR color 'bold red';
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
418 print STDERR "Error: ";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
419 print STDERR color 'reset';
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
420 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
421 =cut
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
422 sub Time{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
423 my $time=time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
424 my ($sec,$min,$hour,$day,$month,$year) = (localtime($time))[0,1,2,3,4,5,6];
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
425 $month++;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
426 $year+=1900;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
427 if (length($sec) == 1) {$sec = "0"."$sec";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
428 if (length($min) == 1) {$min = "0"."$min";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
429 if (length($hour) == 1) {$hour = "0"."$hour";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
430 if (length($day) == 1) {$day = "0"."$day";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
431 if (length($month) == 1) {$month = "0"."$month";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
432 #print "$year-$month-$day $hour:$min:$sec\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
433 return("$year-$month-$day-$hour-$min-$sec");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
434 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
435 =cut
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
436 sub Time{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
437 my $time=time();
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
438 my ($sec,$min,$hour,$day,$month,$year) = (localtime($time))[0,1,2,3,4,5,6];
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
439 $month++;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
440 $year+=1900;
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
441 if (length($sec) == 1) {$sec = "0"."$sec";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
442 if (length($min) == 1) {$min = "0"."$min";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
443 if (length($hour) == 1) {$hour = "0"."$hour";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
444 if (length($day) == 1) {$day = "0"."$day";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
445 if (length($month) == 1) {$month = "0"."$month";}
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
446 #print "$year-$month-$day $hour:$min:$sec\n";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
447 return("$year-$month-$day $hour:$min:$sec");
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
448 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
449
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
450
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
451 sub usage{
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
452 print <<"USAGE";
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
453 Version $version
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
454 Usage:
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
455 $0 -i -format -gfa -index -pre -mat -rfam -D -a -M -min -max -mis -e -f -v -t -o -path
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
456 options:
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
457 -i string, input file#input files information file
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
458 /path/filename mark
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
459 /path/filename mark
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
460 ...
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
461
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
462 -format string,#specific input rawdata file format : fastq|fq|fasta|fa
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
463
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
464 -gfa string, input file # genome fasta. sequence file
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
465 -idx string, genome file index, file-prefix #(must be indexed by bowtie-build) The parameter
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
466 string must be the prefix of the bowtie index. For instance, if
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
467 the first indexed file is called 'h_sapiens_37_asm.1.ebwt' then
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
468 the prefix is 'h_sapiens_37_asm'.##can be null
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
469
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
470 -pre string, input file #species specific microRNA precursor sequences
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
471 -mat string, input file #species specific microRNA mature sequences
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
472
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
473 -rfam string, input file# rfam database file, microRNAs must not be contained in this file## if not define, rfam small RNA will not be count.
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
474 -idx2 string, rfam file index, file-prefix #(must be indexed by bowtie-build) The parameter
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
475 string must be the prefix of the bowtie index. For instance, if
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
476 the first indexed file is called 'h_sapiens_37_asm.1.ebwt' then
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
477 the prefix is 'h_sapiens_37_asm'.##can be null
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
478
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
479 -D If [-D] is specified,will discard rfam mapped reads(nead -rfam).
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
480
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
481 -a string, ADAPTER string. default is ATCTCGTATG.
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
482 -M int, require minimum adapter alignment length of N. If less than N nucleotides aligned with the adapter - don't clip it.
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
483 -min int, reads min length,default is 19.
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
484 -max int, reads max length,default is 28.
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
485
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
486 -mis [int] number of allowed mismatches when mapping reads to precursors, default 0
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
487 -e [int] number of nucleotides upstream of the mature sequence to consider, default 2
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
488 -f [int] number of nucleotides downstream of the mature sequence to consider, default 5
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
489 -v <int> report end-to-end hits w/ <=v mismatches; ignore qualities,default 0; used in rfam alignment
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
490 -r int a read is allowed to map up to this number of positions in the genome,default is 25
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
491
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
492 -dis <int> Maximal space between miRNA and miRNA* (200)
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
493 -flank <int> Flank sequence length of miRNA precursor (10)
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
494 -mfe <folat> Maximal free energy allowed for a miRNA precursor (-20)
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
495
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
496 -t int, number of threads [1]
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
497
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
498 -o output directory# absolute path
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
499 -h help
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
500 USAGE
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
501 exit(1);
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
502 }
554fbaf5f451 Uploaded
big-tiandm
parents:
diff changeset
503