annotate html_preprocess.pl @ 0:87fe81de0931 draft default tip

Uploaded
author bigrna
date Sun, 04 Jan 2015 02:47:25 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
1 #!/usr/bin/perl -w
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
2 #Filename:
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
3 #Author: Tian Dongmei
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
4 #Email: tiandm@big.ac.cn
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
5 #Date: 2014-5-29
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
6 #Modified:
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
7 #Description:
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
8 my $version=1.00;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
9
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
10 use strict;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
11 use Getopt::Long;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
12 use File::Basename;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
13
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
14 my %opts;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
15 GetOptions(\%opts,"i=s","format=s","min=i","max=i","o=s","h");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
16 if (!(defined $opts{o} and defined $opts{format} and defined $opts{i} ) || defined $opts{h}) { #necessary arguments
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
17 &usage;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
18 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
19 my ($config,$prepath,$rfampath,$knownpath,$genomepath,$novelpath);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
20 my ($predir,$rfamdir,$knowndir,$genomedir,$noveldir);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
21 open IN,"<$opts{i}";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
22 $config=<IN>; chomp $config;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
23 $prepath=<IN>; chomp $prepath;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
24 $genomepath=<IN>; chomp $genomepath;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
25 $rfampath=<IN>;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
26 close IN;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
27 my @tmp=split/\//,$prepath;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
28 $predir=$tmp[-1];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
29 @tmp=split/\//,$genomepath;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
30 $genomedir=$tmp[-1];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
31
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
32 my $dir=dirname($opts{'o'});
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
33
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
34 open OUT ,">$opts{'o'}";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
35 print OUT "<HTML>\n <HEAD>\n <TITLE> Analysis Report </TITLE>\n </HEAD>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
36 <BODY bgcolor=\"lightgray\">\n <h1 align=\"center\">\n <font face=\"ºÚÌå\">\n <b>Preprocess Report</b>\n </font>\n </h1>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
37 <h2>1. Sequence No. and quality</h2>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
38 <h3>1.1 Sequece No.</h3>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
39 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
40
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
41 ### raw data no
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
42 open IN,"<$config";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
43 my @files;my @marks; my @rawNo;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
44 while (my $aline=<IN>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
45 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
46 my @tmp=split/\t/,$aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
47 push @files,$tmp[0];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
48
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
49 my $no=`less $tmp[0] |wc -l `;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
50 chomp $no;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
51 if ($opts{'format'} eq "fq" || $opts{'format'} eq "fastq") {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
52 $no=$no/4;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
53 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
54 else{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
55 $no=$no/2;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
56 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
57 push @rawNo,$no;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
58
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
59 push @marks,$tmp[1];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
60 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
61 close IN;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
62
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
63 ### preprocess
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
64 unless ($prepath=~/\/$/) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
65 $prepath .="/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
66 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
67
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
68 my @trimNo;my @collapse;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
69 my $collapsefile=$prepath."collapse_reads.fa";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
70 open IN,"<$collapsefile";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
71 while (my $aline=<IN>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
72 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
73 <IN>;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
74 $aline=~/:([\d|_]+)_x(\d+)$/;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
75 my @lng=split/_/,$1;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
76 for (my $i=0;$i<@lng;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
77 if ($lng[$i]>0) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
78 $trimNo[$i] +=$lng[$i];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
79 $collapse[$i] ++;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
80 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
81 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
82 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
83 close IN;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
84
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
85 my @cleanR;my @cleanT;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
86 my $clean=$prepath."collapse_reads_$opts{min}_$opts{max}.fa";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
87 open IN,"<$clean";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
88 while (my $aline=<IN>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
89 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
90 <IN>;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
91 $aline=~/:([\d|_]+)_x(\d+)$/;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
92 my @lng=split/_/,$1;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
93 for (my $i=0;$i<@lng;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
94 if ($lng[$i]>0) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
95 $cleanR[$i] +=$lng[$i];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
96 $cleanT[$i] ++;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
97 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
98 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
99 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
100 close IN;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
101
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
102 print OUT "<table border=\"1\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
103 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
104 <th>&nbsp;</th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
105 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
106 foreach (@marks) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
107 print OUT "<th> $_ </th>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
108 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
109 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
110 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
111 <th align=\"left\">Raw Reads No. </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
112 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
113 foreach (@rawNo) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
114 print OUT "<td> $_ </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
115 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
116 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
117 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
118 <th align=\"left\">Reads No. After Trimed 3\' adapter </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
119 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
120 foreach (@trimNo) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
121 print OUT "<td> $_ </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
122 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
123 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
124 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
125 <th align=\"left\">Unique Tags No. </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
126 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
127 foreach (@collapse) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
128 print OUT "<td> $_ </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
129 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
130 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
131 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
132 <th align=\"left\">Clean Reads No. </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
133 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
134 foreach (@cleanR) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
135 print OUT "<td> $_ </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
136 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
137 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
138 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
139 <th align=\"left\">Clean Tags No. </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
140 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
141 foreach (@cleanT) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
142 print OUT "<td> $_ </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
143 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
144 print OUT "</tr>\n</table>";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
145 print OUT "<p>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
146 Note:<br />
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
147 The raw data file path is: <b>$files[0]</b><br />
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
148 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
149 for (my $i=1;$i<@files;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
150 print OUT "&nbsp;&nbsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<b>$files[$i]</b><br />";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
151 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
152 print OUT "The collapsed file path is: <b>$collapsefile</b><br />
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
153 The clean data file path is: <b>$clean</b><br />
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
154 </p>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
155 <h2> 1. Sequence length count</h2>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
156 <h3> 1.1 Reads length count </h3>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
157 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
158 print OUT "\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
159
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
160 my (%length); my $key="Tags Length";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
161 open IN,"<$prepath/reads_length_distribution.txt";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
162 while (my $aline=<IN>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
163 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
164 next if($aline=~/^\s*$/);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
165 if ($aline=~/^Reads/) { $key="Reads Length";}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
166 my @tmp=split/\t/,$aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
167 my @array=split/\s/,$tmp[1];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
168 push @{$length{$key}},[$tmp[0],@array];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
169 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
170 close IN;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
171
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
172 print OUT "<table border=\"1\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
173 <tr align=\"center\">";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
174 my $hashkey="Reads Length";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
175 foreach (@{$length{$hashkey}[0]}) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
176 print OUT "<th> $_ </th>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
177 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
178 print OUT "</tr>";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
179
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
180 for (my $i=1;$i<@{$length{$hashkey}};$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
181 print OUT "<tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
182 <th >$length{$hashkey}[$i][0] </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
183 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
184 for(my $j=1;$j<@{$length{$hashkey}[$i]};$j++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
185 print OUT "<td> $length{$hashkey}[$i][$j] </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
186 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
187 print OUT "</tr>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
188 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
189 print OUT "</table>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
190
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
191 print OUT "<h3> 1.2 Tags length count </h3>";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
192
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
193 print OUT "<table border=\"1\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
194 <tr align=\"center\">";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
195 $hashkey="Tags Length";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
196 foreach (@{$length{$hashkey}[0]}) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
197 print OUT "<th> $_ </th>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
198 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
199 print OUT "</tr>";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
200
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
201 for (my $i=1;$i<@{$length{$hashkey}};$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
202 print OUT "<tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
203 <th > $length{$hashkey}[$i][0] </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
204 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
205 for(my $j=1;$j<@{$length{$hashkey}[$i]};$j++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
206 print OUT "<td> $length{$hashkey}[$i][$j] </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
207 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
208 print OUT "</tr>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
209 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
210
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
211 print OUT "</table>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
212
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
213 print OUT "<h2> 2. Sequence length distribution </h2>";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
214 my $length=$prepath."length.html";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
215 open IN,"<$length";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
216 while (my $aline=<IN>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
217 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
218 print OUT "$aline\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
219 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
220
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
221 #print OUT "<p> Note:<br />The sequence length data: <a href=\"./$predir/reads_length_distribution.txt\"> length file</a>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
222 #</p>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
223 #";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
224
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
225
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
226
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
227
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
228 ####genome map
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
229 #unless ($genomedir=~/\/$/) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
230 # $genomedir .="/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
231 #}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
232
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
233 print OUT "<h2>2. Genome Alignment Result</h2>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
234 <h3>2.1 Mapping count</h3>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
235 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
236
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
237 open IN,"<$genomepath/genome_mapped.fa";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
238 my (@gread,@gtag);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
239 while (my $aline=<IN>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
240 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
241 <IN>;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
242 $aline=~/:([\d|_]+)_x(\d+)$/;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
243 my @sss=split/_/,$1;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
244 for (my $i=0;$i<@sss;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
245 if ($sss[$i]>0) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
246 $gread[$i] +=$sss[$i];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
247 $gtag[$i] ++;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
248 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
249 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
250 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
251 close IN;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
252
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
253 print OUT "<table border=\"1\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
254 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
255 <th>&nbsp;</th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
256 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
257 foreach (@marks) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
258 print OUT "<th> $_ </th>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
259 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
260 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
261 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
262 <th align=\"left\">Genome Mapped Reads No. </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
263 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
264 foreach (@gread) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
265 print OUT "<td> $_ </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
266 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
267 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
268 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
269 <th align=\"left\">Genome Mapped Reads Percent </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
270 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
271
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
272 for (my $i=0;$i<@gread;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
273 my $per=sprintf ("%.2f",$gread[$i]/$cleanR[$i]*100);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
274 print OUT "<td> $per\%</td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
275 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
276
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
277 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
278 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
279 <th align=\"left\">Genome Mapped Tags No. </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
280 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
281 foreach (@gtag) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
282 print OUT "<td> $_ </td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
283 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
284 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
285 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
286 <th align=\"left\">Genome Mapped Tags Percent </th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
287 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
288
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
289 for (my $i=0;$i<@gtag;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
290 my $per=sprintf ("%.2f",$gtag[$i]/$cleanT[$i]*100);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
291 print OUT "<td> $per\%</td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
292 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
293 print OUT "</tr>\n</table>";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
294 print OUT "<p>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
295 Note:<br />
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
296 The genome mapped bwt file path is: <b>$genomedir/genome_mapped.bwt</b><br />
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
297 The genome mapped FASTA file path is: <b>$genomedir/genome_mapped.fa</b>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
298 <br />
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
299 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
300
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
301
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
302
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
303 #### rfam
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
304 if(defined $rfampath && $rfampath=~/rfam_match/){
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
305 chomp $rfampath;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
306 @tmp=split/\//,$rfampath;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
307 $rfamdir=$tmp[-1];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
308
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
309 unless ($rfampath=~/\/$/) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
310 $rfampath .="/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
311 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
312 print OUT "<h2>3. Rfam non-miRNA annotation</h2>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
313 <h3>3.1 Reads count</h3>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
314 <table border=\"1\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
315 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
316 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
317
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
318 my @rfamR; my @rfamT;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
319 my $tag=1;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
320 open IN,"<$dir/rfam_non-miRNA_annotation.txt";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
321 while (my $aline=<IN>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
322 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
323 $tag=0 if($aline=~/tags\s+number/);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
324 next if($aline=~/^\#/);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
325 next if($aline=~/^\s*$/);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
326 my @tmp=split/\s+/,$aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
327 if($tag == 1){push @rfamR,[@tmp];}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
328 else{push @rfamT,[@tmp];}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
329 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
330 close IN;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
331
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
332
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
333 print OUT "<th>RNA Name</th>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
334 foreach (@marks) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
335 print OUT "<th> $_ </th>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
336 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
337 for (my $i=0;$i<@rfamR;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
338 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
339 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
340 <th align=\"left\">$rfamR[$i][0]</th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
341 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
342 for (my $j=1;$j<@{$rfamR[$i]} ;$j++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
343 print OUT "<td> $rfamR[$i][$j]</td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
344 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
345 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
346
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
347 print OUT "</tr>\n</table>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
348 <h3>3.2 Tags count</h3>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
349 <table border=\"1\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
350 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
351 <th>RNA Name</th>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
352 foreach (@marks) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
353 print OUT "<th> $_ </th>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
354 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
355 for (my $i=0;$i<@rfamT;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
356 print OUT "</tr>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
357 <tr align=\"center\">
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
358 <th align=\"left\">$rfamT[$i][0]</th>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
359 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
360 for (my $j=1;$j<@{$rfamT[$i]} ;$j++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
361 print OUT "<td> $rfamT[$i][$j]</td>\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
362 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
363 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
364 print OUT "</tr>\n</table>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
365 <p>Note:<br />The rfam mapping results is: <b>$rfampath</b>";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
366 print OUT "<b>rfam_mapped.bwt</b></p>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
367 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
368 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
369
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
370
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
371 print OUT "
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
372 </BODY>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
373 </HTML>
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
374 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
375 close OUT;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
376
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
377 sub usage{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
378 print <<"USAGE";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
379 Version $version
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
380 Usage:
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
381 $0 -o
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
382 options:
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
383 -o output file
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
384 -h help
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
385 USAGE
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
386 exit(1);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
387 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
388