changeset 10:5ac42e277c76 draft

Uploaded
author big-tiandm
date Fri, 25 Jul 2014 05:20:34 -0400
parents 0a69f39fa9ff
children 861eb4fbfbd0
files html.pl
diffstat 1 files changed, 269 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/html.pl	Fri Jul 25 05:20:34 2014 -0400
@@ -0,0 +1,269 @@
+#!/usr/bin/perl -w
+#Filename:
+#Author: Tian Dongmei
+#Email: tiandm@big.ac.cn
+#Date: 2014-5-29
+#Modified:
+#Description: 
+my $version=1.00;
+
+use strict;
+use Getopt::Long;
+use File::Basename;
+
+my %opts;
+GetOptions(\%opts,"i=s","format=s","o=s","h");
+if (!(defined $opts{o} and defined $opts{format} and defined $opts{i} ) || defined $opts{h}) { #necessary arguments
+&usage;
+}
+my ($config,$prepath,$rfampath,$knownpath,$genomepath,$novelpath);
+my ($predir,$rfamdir,$knowndir,$genomedir,$noveldir);
+open IN,"<$opts{i}";
+$config=<IN>; chomp $config;
+$prepath=<IN>; chomp $prepath;
+$rfampath=<IN>;chomp $rfampath;
+$knownpath=<IN>; chomp $knownpath;
+$genomepath=<IN>; chomp $genomepath;
+$novelpath=<IN>; chomp $novelpath;
+close IN;
+my @tmp=split/\//,$prepath;
+$predir=$tmp[-1];
+@tmp=split/\//,$rfampath;
+$rfamdir=$tmp[-1];
+@tmp=split/\//,$knownpath;
+$knowndir=$tmp[-1];
+@tmp=split/\//,$genomepath;
+$genomedir=$tmp[-1];
+@tmp=split/\//,$novelpath;
+$noveldir=$tmp[-1];
+
+my $dir=dirname($opts{'o'});
+
+open OUT ,">$opts{'o'}";
+print OUT "<HTML>\n  <HEAD>\n  <TITLE> Analysis Report </TITLE>\n </HEAD>
+ <BODY bgcolor=\"lightgray\">\n  <h1 align=\"center\">\n    <font face=\"ºÚÌå\">\n	<b>Small RNA Analysis Report</b>\n  </font>\n  </h1>
+  <h2>1. Sequence No. and quality</h2>
+  <h3>1.1 Sequece No.</h3>
+";
+
+### raw data no
+open IN,"<$config";
+my @files;my @marks; my @rawNo;
+while (my $aline=<IN>) {
+	chomp $aline;
+	my @tmp=split/\t/,$aline;
+	push @files,$tmp[0];
+	
+	my $no=`less $tmp[0] |wc -l `;
+	chomp $no;
+	if ($opts{'format'} eq "fq" || $opts{'format'} eq "fastq") {
+		$no=$no/4;
+	}
+	else{
+		$no=$no/2;
+	}
+	push @rawNo,$no;
+
+	push @marks,$tmp[1];
+}
+close IN;
+
+### preprocess 
+unless ($prepath=~/\/$/) {
+	$prepath .="/";
+}
+
+my @trimNo;my @collapse;
+my $collapsefile=$prepath."collapse_reads.fa";
+open IN,"<$collapsefile";
+while (my $aline=<IN>) {
+	chomp $aline;
+	<IN>;
+	$aline=~/:([\d|_]+)_x(\d+)$/;
+	my @lng=split/_/,$1;
+	for (my $i=0;$i<@lng;$i++) {
+		if ($lng[$i]>0) {
+			$trimNo[$i] +=$lng[$i];
+			$collapse[$i] ++;
+		}
+	}
+}
+close IN;
+
+my @cleanR;my @cleanT;
+my $clean=$prepath."collapse_reads_19_28.fa";
+open IN,"<$clean";
+while (my $aline=<IN>) {
+	chomp $aline;
+	<IN>;
+	$aline=~/:([\d|_]+)_x(\d+)$/;
+	my @lng=split/_/,$1;
+	for (my $i=0;$i<@lng;$i++) {
+		if ($lng[$i]>0) {
+			$cleanR[$i] +=$lng[$i];
+			$cleanT[$i] ++;
+		}
+	}
+}
+close IN;
+
+print OUT "<table border=\"1\">
+<tr align=\"center\">
+<th>&nbsp;</th>
+";
+foreach  (@marks) {
+	print OUT "<th> $_ </th>\n";
+}
+print  OUT "</tr>
+<tr align=\"center\">
+<th align=\"left\">Raw Reads No. </th>
+";
+foreach  (@rawNo) {
+	print OUT "<td> $_ </td>\n";
+}
+print OUT "</tr>
+<tr align=\"center\">
+<th align=\"left\">Reads No. After Trimed 3\' adapter </th>
+";
+foreach  (@trimNo) {
+	print OUT "<td> $_ </td>\n";
+}
+print OUT "</tr>
+<tr align=\"center\">
+<th align=\"left\">Unique Tags No. </th>
+";
+foreach  (@collapse) {
+	print OUT "<td> $_ </td>\n";
+}
+print OUT  "</tr>
+<tr align=\"center\">
+<th align=\"left\">Clean Reads No. </th>
+";
+foreach  (@cleanR) {
+	print OUT "<td> $_ </td>\n";
+}
+print OUT "</tr>
+<tr align=\"center\">
+<th align=\"left\">Clean Tags No. </th>
+";
+foreach  (@cleanT) {
+	print OUT "<td> $_ </td>\n";
+}
+print OUT "</tr>\n</table>";
+print OUT "<p>
+Note:<br />
+The raw data file path is: <b>$files[0]</b><br />
+";
+for (my $i=1;$i<@files;$i++) {
+	print OUT "&nbsp;&nbsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<b>$files[$i]</b><br />";
+}
+print OUT "The collapsed file path is: <b>$collapsefile</b><br />
+The clean data file path is: <b>$clean</b><br />
+</p>
+<h2> 1. Sequence length count</h2>
+<h3> 1.1 Reads length</h3>
+";
+
+print OUT "<img src=\"./$predir/Reads_length.png\" alt=\"Reads_length.png\" width=\"400\" height=\"300\"/>
+<h3> 1.2 Tags length count</h3>
+<img src=\"./$predir/Tags_length.png\" alt=\"Tags_length.png\" width=\"400\" height=\"300\"/>
+<p> Note:<br />The sequence length data: <a href=\"./$predir/reads_length_distribution.txt\"> length file</a>
+</p>
+";
+
+#### rfam
+unless ($rfampath=~/\/$/) {
+	$rfampath .="/";
+}
+print OUT "<h2>2. Rfam non-miRNA annotation</h2>
+<h3>2.1 Reads count</h3>
+<table border=\"1\">
+<tr align=\"center\">
+";
+
+my @rfamR; my @rfamT;
+my $tag=1;
+open IN,"<$dir/rfam_non-miRNA_annotation.txt";
+while (my $aline=<IN>) {
+	chomp $aline;
+	$tag=0 if($aline=~/tags\s+number/);
+	next if($aline=~/^\#/);
+	next if($aline=~/^\s*$/);
+	my @tmp=split/\s+/,$aline;
+	if($tag == 1){push @rfamR,[@tmp];}
+	else{push @rfamT,[@tmp];}
+}
+close IN;
+
+
+print OUT "<th>RNA Name</th>\n";
+foreach  (@marks) {
+	print OUT "<th> $_ </th>\n";
+}
+for (my $i=0;$i<@rfamR;$i++) {
+	print  OUT "</tr>
+	<tr align=\"center\">
+	<th align=\"left\">$rfamR[$i][0]</th>
+	";
+	for (my $j=1;$j<@{$rfamR[$i]} ;$j++) {
+	print OUT "<td> $rfamR[$i][$j]</td>\n";
+	}
+}
+
+print OUT "</tr>\n</table>
+  <h3>2.2 Tags count</h3>
+  <table border=\"1\">
+   <tr align=\"center\">
+   <th>RNA Name</th>\n";
+foreach  (@marks) {
+	print OUT "<th> $_ </th>\n";
+}
+for (my $i=0;$i<@rfamT;$i++) {
+	print  OUT "</tr>
+	<tr align=\"center\">
+	<th align=\"left\">$rfamT[$i][0]</th>
+	";
+	for (my $j=1;$j<@{$rfamT[$i]} ;$j++) {
+	print OUT "<td> $rfamT[$i][$j]</td>\n";
+	}
+}
+print OUT "</tr>\n</table>
+<p>Note:<br />The rfam mapping results is: <b>$rfampath</b>";
+print OUT "<b>rfam_mapped.bwt</b></p>
+  <h2>3. MicroRNA result</h2>
+  <h3>3.1 known microRNA</h3>
+  <p>The known microRNA express list: <a href=\"./known_microRNA_express.txt\"> known_microRNA_express.txt</a><br/>
+  The known microRNA alngment file: <a href=\"./known_microRNA_express.aln\"> known_microRNA_express.aln</a><br/>
+  The known moRs file: <a href=\"./known_microRNA_express.moRs\"> known_microRNA_express.moRs</a><br/>
+  The known microRNA mature sequence file: <a href=\"./known_microRNA_mature.fa\"> known_microRNA_mature.fa</a><br/>
+  The knowm microRNA precursor sequence file: <a href=\"./known_microRNA_precursor.fa\"> known_microRNA_precursor.fa</a>
+  </p>
+
+  <h3>3.2 novel microRNA</h3>
+  <p>The novel microRNA prediction file:<a href=\"./microRNA_prediction.mrd\"> microRNA_prediction.mrd</a><br/>
+  The novel microRNA express list: <a href=\"./novel_microRNA_express.txt\"> novel_microRNA_express.txt</a><br/>
+  The novel microRNA mature sequence file: <a href=\"./novel_microRNA_mature.fa\"> novel_microRNA_mature.fa</a><br/>
+  The novel microRNA precursor sequence file: <a href=\"./novel_microRNA_precursor.fa\"> novel_microRNA_precursor.fa</a>
+  </p>
+";
+
+
+
+print OUT "
+ </BODY>
+</HTML>
+";
+close OUT;
+
+sub usage{
+print <<"USAGE";
+Version $version
+Usage:
+$0 -o
+options:
+-o output file
+-h help
+USAGE
+exit(1);
+}
+