Mercurial > repos > bigrna > gpsrna
comparison html_miRPlant.pl @ 0:87fe81de0931 draft default tip
Uploaded
author | bigrna |
---|---|
date | Sun, 04 Jan 2015 02:47:25 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:87fe81de0931 |
---|---|
1 #!/usr/bin/perl -w | |
2 #Filename: | |
3 #Author: Tian Dongmei | |
4 #Email: tiandm@big.ac.cn | |
5 #Date: 2014-5-29 | |
6 #Modified: | |
7 #Description: | |
8 my $version=1.00; | |
9 | |
10 use strict; | |
11 use Getopt::Long; | |
12 use File::Basename; | |
13 | |
14 my %opts; | |
15 GetOptions(\%opts,"i=s","format=s","o=s","h"); | |
16 if (!(defined $opts{o} and defined $opts{format} and defined $opts{i} ) || defined $opts{h}) { #necessary arguments | |
17 &usage; | |
18 } | |
19 my ($config,$prepath,$rfampath,$knownpath,$genomepath,$novelpath); | |
20 my ($predir,$rfamdir,$knowndir,$genomedir,$noveldir); | |
21 open IN,"<$opts{i}"; | |
22 $config=<IN>; chomp $config; | |
23 $prepath=<IN>; chomp $prepath; | |
24 $knownpath=<IN>; chomp $knownpath; | |
25 $rfampath=<IN>;chomp $rfampath; | |
26 $genomepath=<IN>; chomp $genomepath; | |
27 $novelpath=<IN>; chomp $novelpath; | |
28 close IN; | |
29 my @tmp=split/\//,$prepath; | |
30 $predir=$tmp[-1]; | |
31 @tmp=split/\//,$rfampath; | |
32 $rfamdir=$tmp[-1]; | |
33 @tmp=split/\//,$knownpath; | |
34 $knowndir=$tmp[-1]; | |
35 @tmp=split/\//,$genomepath; | |
36 $genomedir=$tmp[-1]; | |
37 @tmp=split/\//,$novelpath; | |
38 $noveldir=$tmp[-1]; | |
39 | |
40 my $dir=dirname($opts{'o'}); | |
41 | |
42 open OUT ,">$opts{'o'}"; | |
43 print OUT "<HTML>\n <HEAD>\n <TITLE> Analysis Report </TITLE>\n </HEAD> | |
44 <BODY bgcolor=\"lightgray\">\n <h1 align=\"center\">\n <font face=\"ºÚÌå\">\n <b>Small RNA Analysis Report</b>\n </font>\n </h1> | |
45 <h2>1. Sequence No. and quality</h2> | |
46 <h3>1.1 Sequece No.</h3> | |
47 "; | |
48 | |
49 ### raw data no | |
50 open IN,"<$config"; | |
51 my @files;my @marks; my @rawNo; | |
52 while (my $aline=<IN>) { | |
53 chomp $aline; | |
54 my @tmp=split/\t/,$aline; | |
55 push @files,$tmp[0]; | |
56 | |
57 my $no=`less $tmp[0] |wc -l `; | |
58 chomp $no; | |
59 if ($opts{'format'} eq "fq" || $opts{'format'} eq "fastq") { | |
60 $no=$no/4; | |
61 } | |
62 else{ | |
63 $no=$no/2; | |
64 } | |
65 push @rawNo,$no; | |
66 | |
67 push @marks,$tmp[1]; | |
68 } | |
69 close IN; | |
70 | |
71 ### preprocess | |
72 unless ($prepath=~/\/$/) { | |
73 $prepath .="/"; | |
74 } | |
75 | |
76 my @trimNo;my @collapse; | |
77 my $collapsefile=$prepath."collapse_reads.fa"; | |
78 open IN,"<$collapsefile"; | |
79 while (my $aline=<IN>) { | |
80 chomp $aline; | |
81 <IN>; | |
82 $aline=~/:([\d|_]+)_x(\d+)$/; | |
83 my @lng=split/_/,$1; | |
84 for (my $i=0;$i<@lng;$i++) { | |
85 if ($lng[$i]>0) { | |
86 $trimNo[$i] +=$lng[$i]; | |
87 $collapse[$i] ++; | |
88 } | |
89 } | |
90 } | |
91 close IN; | |
92 | |
93 my @cleanR;my @cleanT; | |
94 my $clean=$prepath."collapse_reads_19_28.fa"; | |
95 open IN,"<$clean"; | |
96 while (my $aline=<IN>) { | |
97 chomp $aline; | |
98 <IN>; | |
99 $aline=~/:([\d|_]+)_x(\d+)$/; | |
100 my @lng=split/_/,$1; | |
101 for (my $i=0;$i<@lng;$i++) { | |
102 if ($lng[$i]>0) { | |
103 $cleanR[$i] +=$lng[$i]; | |
104 $cleanT[$i] ++; | |
105 } | |
106 } | |
107 } | |
108 close IN; | |
109 | |
110 print OUT "<table border=\"1\"> | |
111 <tr align=\"center\"> | |
112 <th> </th> | |
113 "; | |
114 foreach (@marks) { | |
115 print OUT "<th> $_ </th>\n"; | |
116 } | |
117 print OUT "</tr> | |
118 <tr align=\"center\"> | |
119 <th align=\"left\">Raw Reads No. </th> | |
120 "; | |
121 foreach (@rawNo) { | |
122 print OUT "<td> $_ </td>\n"; | |
123 } | |
124 print OUT "</tr> | |
125 <tr align=\"center\"> | |
126 <th align=\"left\">Reads No. After Trimed 3\' adapter </th> | |
127 "; | |
128 foreach (@trimNo) { | |
129 print OUT "<td> $_ </td>\n"; | |
130 } | |
131 print OUT "</tr> | |
132 <tr align=\"center\"> | |
133 <th align=\"left\">Unique Tags No. </th> | |
134 "; | |
135 foreach (@collapse) { | |
136 print OUT "<td> $_ </td>\n"; | |
137 } | |
138 print OUT "</tr> | |
139 <tr align=\"center\"> | |
140 <th align=\"left\">Clean Reads No. </th> | |
141 "; | |
142 foreach (@cleanR) { | |
143 print OUT "<td> $_ </td>\n"; | |
144 } | |
145 print OUT "</tr> | |
146 <tr align=\"center\"> | |
147 <th align=\"left\">Clean Tags No. </th> | |
148 "; | |
149 foreach (@cleanT) { | |
150 print OUT "<td> $_ </td>\n"; | |
151 } | |
152 print OUT "</tr>\n</table>"; | |
153 print OUT "<p> | |
154 Note:<br /> | |
155 The raw data file path is: <b>$files[0]</b><br /> | |
156 "; | |
157 for (my $i=1;$i<@files;$i++) { | |
158 print OUT "          <b>$files[$i]</b><br />"; | |
159 } | |
160 print OUT "The collapsed file path is: <b>$collapsefile</b><br /> | |
161 The clean data file path is: <b>$clean</b><br /> | |
162 </p> | |
163 <h2> 1. Sequence length count</h2> | |
164 "; | |
165 print OUT "\n"; | |
166 | |
167 my $length=$prepath."length.html"; | |
168 open IN,"<$length"; | |
169 while (my $aline=<IN>) { | |
170 chomp $aline; | |
171 print OUT "$aline\n"; | |
172 } | |
173 | |
174 print OUT "<p> Note:<br />The sequence length data: <a href=\"./$predir/reads_length_distribution.txt\"> length file</a> | |
175 </p> | |
176 "; | |
177 | |
178 #### rfam | |
179 unless ($rfampath=~/\/$/) { | |
180 $rfampath .="/"; | |
181 } | |
182 print OUT "<h2>2. Rfam non-miRNA annotation</h2> | |
183 <h3>2.1 Reads count</h3> | |
184 <table border=\"1\"> | |
185 <tr align=\"center\"> | |
186 "; | |
187 | |
188 my @rfamR; my @rfamT; | |
189 my $tag=1; | |
190 open IN,"<$dir/rfam_non-miRNA_annotation.txt"; | |
191 while (my $aline=<IN>) { | |
192 chomp $aline; | |
193 $tag=0 if($aline=~/tags\s+number/); | |
194 next if($aline=~/^\#/); | |
195 next if($aline=~/^\s*$/); | |
196 my @tmp=split/\s+/,$aline; | |
197 if($tag == 1){push @rfamR,[@tmp];} | |
198 else{push @rfamT,[@tmp];} | |
199 } | |
200 close IN; | |
201 | |
202 | |
203 print OUT "<th>RNA Name</th>\n"; | |
204 foreach (@marks) { | |
205 print OUT "<th> $_ </th>\n"; | |
206 } | |
207 for (my $i=0;$i<@rfamR;$i++) { | |
208 print OUT "</tr> | |
209 <tr align=\"center\"> | |
210 <th align=\"left\">$rfamR[$i][0]</th> | |
211 "; | |
212 for (my $j=1;$j<@{$rfamR[$i]} ;$j++) { | |
213 print OUT "<td> $rfamR[$i][$j]</td>\n"; | |
214 } | |
215 } | |
216 | |
217 print OUT "</tr>\n</table> | |
218 <h3>2.2 Tags count</h3> | |
219 <table border=\"1\"> | |
220 <tr align=\"center\"> | |
221 <th>RNA Name</th>\n"; | |
222 foreach (@marks) { | |
223 print OUT "<th> $_ </th>\n"; | |
224 } | |
225 for (my $i=0;$i<@rfamT;$i++) { | |
226 print OUT "</tr> | |
227 <tr align=\"center\"> | |
228 <th align=\"left\">$rfamT[$i][0]</th> | |
229 "; | |
230 for (my $j=1;$j<@{$rfamT[$i]} ;$j++) { | |
231 print OUT "<td> $rfamT[$i][$j]</td>\n"; | |
232 } | |
233 } | |
234 print OUT "</tr>\n</table> | |
235 <p>Note:<br />The rfam mapping results is: <b>$rfampath</b>"; | |
236 print OUT "<b>rfam_mapped.bwt</b></p> | |
237 <h2>3. MicroRNA result</h2> | |
238 <h3>3.1 known microRNA</h3> | |
239 <p>The known microRNA express list: <a href=\"./known_microRNA_express.txt\"> known_microRNA_express.txt</a><br/> | |
240 The known microRNA alngment file: <a href=\"./known_microRNA_express.aln\"> known_microRNA_express.aln</a><br/> | |
241 The known moRs file: <a href=\"./known_microRNA_express.moRs\"> known_microRNA_express.moRs</a><br/> | |
242 The known microRNA mature sequence file: <a href=\"./known_microRNA_mature.fa\"> known_microRNA_mature.fa</a><br/> | |
243 The knowm microRNA precursor sequence file: <a href=\"./known_microRNA_precursor.fa\"> known_microRNA_precursor.fa</a> | |
244 </p> | |
245 | |
246 <h3>3.2 novel microRNA</h3> | |
247 <p>The novel microRNA prediction file:<a href=\"./microRNA_prediction.mrd\"> microRNA_prediction.mrd</a><br/> | |
248 The novel microRNA express list: <a href=\"./novel_microRNA_express.txt\"> novel_microRNA_express.txt</a><br/> | |
249 The novel microRNA mature sequence file: <a href=\"./novel_microRNA_mature.fa\"> novel_microRNA_mature.fa</a><br/> | |
250 The novel microRNA precursor sequence file: <a href=\"./novel_microRNA_precursor.fa\"> novel_microRNA_precursor.fa</a> | |
251 </p> | |
252 "; | |
253 | |
254 | |
255 | |
256 print OUT " | |
257 </BODY> | |
258 </HTML> | |
259 "; | |
260 close OUT; | |
261 | |
262 sub usage{ | |
263 print <<"USAGE"; | |
264 Version $version | |
265 Usage: | |
266 $0 -o | |
267 options: | |
268 -o output file | |
269 -h help | |
270 USAGE | |
271 exit(1); | |
272 } | |
273 |