comparison html.pl @ 10:5ac42e277c76 draft

Uploaded
author big-tiandm
date Fri, 25 Jul 2014 05:20:34 -0400
parents
children 0c4e11018934
comparison
equal deleted inserted replaced
9:0a69f39fa9ff 10:5ac42e277c76
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 $rfampath=<IN>;chomp $rfampath;
25 $knownpath=<IN>; chomp $knownpath;
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>&nbsp;</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 "&nbsp;&nbsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<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 <h3> 1.1 Reads length</h3>
165 ";
166
167 print OUT "<img src=\"./$predir/Reads_length.png\" alt=\"Reads_length.png\" width=\"400\" height=\"300\"/>
168 <h3> 1.2 Tags length count</h3>
169 <img src=\"./$predir/Tags_length.png\" alt=\"Tags_length.png\" width=\"400\" height=\"300\"/>
170 <p> Note:<br />The sequence length data: <a href=\"./$predir/reads_length_distribution.txt\"> length file</a>
171 </p>
172 ";
173
174 #### rfam
175 unless ($rfampath=~/\/$/) {
176 $rfampath .="/";
177 }
178 print OUT "<h2>2. Rfam non-miRNA annotation</h2>
179 <h3>2.1 Reads count</h3>
180 <table border=\"1\">
181 <tr align=\"center\">
182 ";
183
184 my @rfamR; my @rfamT;
185 my $tag=1;
186 open IN,"<$dir/rfam_non-miRNA_annotation.txt";
187 while (my $aline=<IN>) {
188 chomp $aline;
189 $tag=0 if($aline=~/tags\s+number/);
190 next if($aline=~/^\#/);
191 next if($aline=~/^\s*$/);
192 my @tmp=split/\s+/,$aline;
193 if($tag == 1){push @rfamR,[@tmp];}
194 else{push @rfamT,[@tmp];}
195 }
196 close IN;
197
198
199 print OUT "<th>RNA Name</th>\n";
200 foreach (@marks) {
201 print OUT "<th> $_ </th>\n";
202 }
203 for (my $i=0;$i<@rfamR;$i++) {
204 print OUT "</tr>
205 <tr align=\"center\">
206 <th align=\"left\">$rfamR[$i][0]</th>
207 ";
208 for (my $j=1;$j<@{$rfamR[$i]} ;$j++) {
209 print OUT "<td> $rfamR[$i][$j]</td>\n";
210 }
211 }
212
213 print OUT "</tr>\n</table>
214 <h3>2.2 Tags count</h3>
215 <table border=\"1\">
216 <tr align=\"center\">
217 <th>RNA Name</th>\n";
218 foreach (@marks) {
219 print OUT "<th> $_ </th>\n";
220 }
221 for (my $i=0;$i<@rfamT;$i++) {
222 print OUT "</tr>
223 <tr align=\"center\">
224 <th align=\"left\">$rfamT[$i][0]</th>
225 ";
226 for (my $j=1;$j<@{$rfamT[$i]} ;$j++) {
227 print OUT "<td> $rfamT[$i][$j]</td>\n";
228 }
229 }
230 print OUT "</tr>\n</table>
231 <p>Note:<br />The rfam mapping results is: <b>$rfampath</b>";
232 print OUT "<b>rfam_mapped.bwt</b></p>
233 <h2>3. MicroRNA result</h2>
234 <h3>3.1 known microRNA</h3>
235 <p>The known microRNA express list: <a href=\"./known_microRNA_express.txt\"> known_microRNA_express.txt</a><br/>
236 The known microRNA alngment file: <a href=\"./known_microRNA_express.aln\"> known_microRNA_express.aln</a><br/>
237 The known moRs file: <a href=\"./known_microRNA_express.moRs\"> known_microRNA_express.moRs</a><br/>
238 The known microRNA mature sequence file: <a href=\"./known_microRNA_mature.fa\"> known_microRNA_mature.fa</a><br/>
239 The knowm microRNA precursor sequence file: <a href=\"./known_microRNA_precursor.fa\"> known_microRNA_precursor.fa</a>
240 </p>
241
242 <h3>3.2 novel microRNA</h3>
243 <p>The novel microRNA prediction file:<a href=\"./microRNA_prediction.mrd\"> microRNA_prediction.mrd</a><br/>
244 The novel microRNA express list: <a href=\"./novel_microRNA_express.txt\"> novel_microRNA_express.txt</a><br/>
245 The novel microRNA mature sequence file: <a href=\"./novel_microRNA_mature.fa\"> novel_microRNA_mature.fa</a><br/>
246 The novel microRNA precursor sequence file: <a href=\"./novel_microRNA_precursor.fa\"> novel_microRNA_precursor.fa</a>
247 </p>
248 ";
249
250
251
252 print OUT "
253 </BODY>
254 </HTML>
255 ";
256 close OUT;
257
258 sub usage{
259 print <<"USAGE";
260 Version $version
261 Usage:
262 $0 -o
263 options:
264 -o output file
265 -h help
266 USAGE
267 exit(1);
268 }
269