annotate miRPlant.pl @ 49:f008ab2cadc6 draft

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