Previous changeset 14:8b7000eac6a0 (2017-10-16) Next changeset 16:2be918bf0efe (2017-10-16) |
Commit message:
Uploaded |
added:
bin/html.pm |
b |
diff -r 8b7000eac6a0 -r 16c3c1b0362a bin/html.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/html.pm Mon Oct 16 03:46:49 2017 -0400 |
[ |
b'@@ -0,0 +1,907 @@\n+package html;\n+\n+use strict;\n+use warnings;\n+use File::Basename;\n+\n+use Exporter;\n+our @ISA = qw( Exporter );\n+our @EXPORT_OK = qw( &main_page &details_pages &menu_page &ppp_page );\n+\n+sub main_page\n+{\n+\tmy ( $dir, $file, $list_mainTabP, $current, $ma, $ma_uni, $dir_root ) = @_;\n+\tmy ( $futHashP, $uniqueTabP, $randTabP, $pngTabP ) = get_genome ( $dir, $dir_root );\n+\n+\topen my $h, \'>\', $file || die "cannot create $file $!\\n";\n+\theader ( $h );\n+\tnavbar ( $h, $list_mainTabP, $current );\n+\tprint $h "<div class=\\"container\\"><p><a class=\\"btn\\" href=\\"$current-sub.html\\">View details »</a></p></div>\\n";\n+\tfuturette( $h, $current, $pngTabP, $futHashP );\n+\tprint $h "<div class=\\"container\\"><h2>mappers #: $ma</h2><h2>unique mappers #: $ma_uni</h2> </div>\\n";\n+\tcarousel2( $h, $uniqueTabP, $randTabP, $dir_root );\n+\tfooter($h);\n+\tclose $h;\n+}\n+\n+sub menu_page\n+{\n+\tmy ( $dir, $file, $list_mainTabP, $current, $min, $max, $simin, $simax, $pimin, $pimax, $dir_root ) = @_;\n+ my $html_ref = $1 if $dir =~ /$dir_root(.*)/;\n+\topen my $h, \'>\', $file || die "cannot create $file $!\\n";\n+ header($h);\n+ navbar ( $h, $list_mainTabP, $current );\n+ span( $h, $current, $min, $max, $simin, $simax, $pimin, $pimax );\n+ print $h " <div class=\\"container\\"> <div class=\\"row text-center\\"> <img src=\\"$html_ref/pie_chart.png\\"/><br />\\n";\n+ print $h " <A HREF=\\"$html_ref/repartition.txt\\">text file</A><br/>\\n </div></div>";\n+ footer($h);\n+ close $h;\n+}\n+\n+sub details_pages\n+{\n+\tmy ( $dir_details, $prefix, $list_mainTabP, $current, $misTE, $dir_root ) = @_;\n+ my ($Hex, $HTE, $HG, $NonUniTE, $NonUniG, $UniG ) = get_subgroups( $dir_details, $current, $misTE, $dir_root );\n+\n+ my $html_ref = $1.\'-PPP.html\' if $prefix =~ /$dir_root(.*)/;\n+ open my $h, \'>\', $prefix.\'-TEs.html\' || die "cannot create $prefix-TEs.html $!\\n";\n+ header($h);\n+ navbar ( $h, $list_mainTabP, $current );\n+ if ( $prefix =~ /bonafide_reads$/ )\n+ {\n+ \tprint $h " <div class=\\"container\\">";\n+ \tprint $h " <p><a class=\\"btn\\" href=\\"$html_ref\\">Ping Pong Partners</a></p>\\n";\n+ \tprint $h "</div>";\n+ }\n+ fut($h,\'Transposable elements\',$HTE);\n+ carousel($h,$NonUniTE,$dir_root);\n+ footer($h);\n+ close $h;\n+\n+ open $h, \'>\', $prefix.\'-genome.html\' || die "cannot create $prefix-genome.html $!\\n";\n+ header($h);\n+ navbar ( $h, $list_mainTabP, $current );\n+ fut($h,\'Genome\',$HG);\n+ carousel2($h,$UniG, $NonUniG,$dir_root);\n+ footer($h);\n+ close $h;\n+\n+ open $h, \'>\', $prefix.\'-exons.html\' || die "cannot create $prefix-exons.html $!\\n";\n+ header($h);\n+ navbar ( $h, $list_mainTabP, $current );\n+ fut($h,\'Exons\',$Hex);\n+ footer($h);\n+ close $h;\n+}\n+\n+sub ppp_page\n+{\n+\tmy ( $dir, $file, $list_mainTabP, $current, $ppp, $dir_root ) = @_;\n+\n+\tmy $ppp_file = $ppp.\'ppp.txt\';\n+\topen my $h, \'>\', $file || die "cannot create $file $!\\n";\n+\theader($h);\n+ \tnavbar ( $h, $list_mainTabP, $current );\n+ \tprint $h \'<div class="container"> <table class="wb-tables table table-striped table-hover">\'."\\n";\n+ \tprint $h \'<thead>\n+ <tr>\n+ <th data-sortable="true">ID</th>\n+ <th data-sortable="true">overlap sum</th>\n+ <th data-sortable="true">ten overlap sum</th>\n+ <th data-sortable="true">mean</th>\n+ <th data-sortable="true">standard deviation</th>\n+ \t<th data-sortable="true">z-score</th>\n+ \t<th data-sortable="true">p-value</th>\n+\t</tr>\n+ </thead>\n+ <tbody>\';\n+\n+ \topen my $f, \'<\', $ppp_file || die "cannot open $ppp_file $!\\n";\n+ \twhile ( <$f> )\n+ \t{\n+ \t\tchomp;\n+ \t\tprint $h \'<tr>\';\n+ \t\tmy ( $id, $sum, $ten, $mean, $sd, $zscore, $prob) = split /\\t/, $_;\n+ \t\tif( -d "$ppp/$id" ) \n+ \t\t{\n+ \t\t\tmy $sub_html = $ppp.$id.\'.html\';\n+ my $sub_html_ref = $1.$id if $ppp =~ /$dir_root(.*)/;\n+ \t\t\tprint $h "<td> <a href=\\"$sub_html_ref.html\\">$id</a> </td>";\n+\n+ \t\t\topen my $sub, \'>\', $sub_html || die "cannot create $sub_html\\n";\n+ \t\t\t{\n+ \t\t\t\theader($sub);\n+ \t\t\t\tprint $sub "\n+\t\t\t\t\t<div align=\\"center\\">\n+\t\t\t\t\t<h2>$id</h2>\n+\t\t\t\t\t<p> <img src=\\"$id/histogram.png\\" wi'..b'stri_TE\n+{\n+ my ($dir, $name) = @_;\n+ my (@out,@group);\n+ my $group = $dir.\'/\'.$name.\'-subgroups-bonafide_reads-TE-*distribution-*.png\';\n+ @group = glob $group;\n+ foreach (my $g =0; $g <= $#group; $g++)\n+ {\n+ if ($group[$g] =~ /.*($name-subgroups-bonafide_reads-TE-.*distribution-.*\\.png)/ )\n+ {\n+ my $tmp = $1;\n+ push @out, $1;\n+ }\n+ }\n+ return (\\@out);\n+}\n+\n+sub get_PPP\n+{\n+ my ($dir,$name) = @_;\n+ my (%distri,@group);\n+ my $group = $dir.\'/\'.$name.\'-subgroups-bonafide_reads-TE-PPPartners-*\';\n+ @group = glob $group;\n+ \n+ foreach (my $g =0; $g <= $#group; $g++)\n+ {\n+ if ($group[$g] =~ /.*($name-subgroups-bonafide_reads-TE-PPPartners-.*)/ )\n+ {\n+ my $tmp = $1;\n+ if ($tmp =~ /PPPartners-(.*?)-sens\\.txt$/)\n+ {\n+ $distri{$1} = [\'\',\'\',\'\',\'\',\'\',\'\'] unless exists $distri{$1};\n+ $distri{$1}->[0] = $tmp;\n+ }\n+ elsif ($tmp =~ /PPPartners-(.*?)-antisens\\.txt$/)\n+ {\n+ $distri{$1} = [\'\',\'\',\'\',\'\',\'\',\'\'] unless exists $distri{$1};\n+ $distri{$1}->[1] = $tmp;\n+ }\n+ elsif ($tmp =~ /PPPartners-(.*?)-sensPPP\\.txt$/)\n+ {\n+ $distri{$1} = [\'\',\'\',\'\',\'\',\'\',\'\'] unless exists $distri{$1};\n+ $distri{$1}->[2] = $tmp;\n+ }\n+ elsif ($tmp =~ /PPPartners-(.*?)-antisensPPP\\.txt$/)\n+ {\n+ $distri{$1} = [\'\',\'\',\'\',\'\',\'\',\'\'] unless exists $distri{$1};\n+ $distri{$1}->[3] = $tmp;\n+ }\n+ elsif ($tmp =~ /PPPartners-(.*?)-overlap_size\\.txt$/)\n+ {\n+ $distri{$1} = [\'\',\'\',\'\',\'\',\'\',\'\'] unless exists $distri{$1};\n+ $distri{$1}->[4] = $tmp;\n+ }\n+ elsif ($tmp =~ /PPPartners-(.*?)-histogram\\.png$/)\n+ {\n+ $distri{$1} = [\'\',\'\',\'\',\'\',\'\',\'\'] unless exists $distri{$1};\n+ $distri{$1}->[5] = $tmp;\n+ }\n+ }\n+ }\n+ return \\%distri;\n+}\n+\n+sub PPPrint\n+{\n+ my ($h, $hash) = @_;\n+ my $cmp = 0;\n+ \n+ print $h "<div class=\\"container\\">\\n";\n+ print $h "<div class=\\"row text-center\\">";\n+ while ( my ($k,$v) = each %{$hash} )\n+ {\n+ print $h "</div><div class=\\"row text-center\\">" if $cmp != 0 && $cmp % 2 == 0;\n+ print $h "\n+ \n+ <div class=\\"span6\\">\n+ <h2>$k</h2>\n+ <p class=\\"featurette-p\\"> <img src=\\"$v->[5]\\"/></p>\n+ <p class=\\"featurette-p\\"><a href=\\"$v->[4]\\">ping pong signature</a></p>\n+ <p class=\\"featurette-p\\"><a href=\\"$v->[2]\\">sens reads with PPP</a></p>\n+ <p class=\\"featurette-p\\"><a href=\\"$v->[3]\\">reverse reads with PPP</a></p>\n+ <p class=\\"featurette-p\\"><a href=\\"$v->[0]\\">sens reads without PPP</a></p>\n+ <p class=\\"featurette-p\\"><a href=\\"$v->[1]\\">reverse reads without PPP</a></p>\n+ </div>\n+ ";\n+ $cmp++;\n+ }\n+ \n+ print $h "</div></div>";\n+}\n+\n+sub printDistri\n+{\n+ my ($h, $tab) = @_;\n+ my ($txt, $name);\n+ my $cmp = 0;\n+ print $h "<div class=\\"container\\">\\n";\n+ print $h "<div class=\\"row text-center\\">";\n+ foreach my $k (@{$tab})\n+ {\n+ if ($k =~ /(.*)-(.*)\\.png$/)\n+ {\n+ $txt = $1.\'-\'.$2.\'.txt\';\n+ $name = $2;\n+ }\n+ print $h "</div><div class=\\"row text-center\\">" if $cmp != 0 && $cmp % 2 == 0;\n+ print $h "\n+ \n+ <div class=\\"span6\\">\n+ <h2>$name</h2>\n+ <p> <img src=\\"$k\\"/></p>\n+ <p class=\\"featurette-p\\"><a href=\\"$txt\\">text file</a></p>\n+ </div>\n+ ";\n+ $cmp++;\n+ }\n+ \n+ print $h "</div></div>";\n+}\n+\n+sub mapnum\n+{\n+ my $dupmapnum = shift;\n+ my $dupnum_genome = shift;\n+ open (my $dupTE, $dupmapnum) || die "cannot open ".$dupmapnum."\\n";\n+ my %dupnum_TE = ();\n+ my $header = <$dupTE>;\n+ while (<$dupTE>)\n+ {\n+ chomp $_;\n+ my @dupline = split /\\t/, $_;\n+ $dupnum_TE{$dupline[0]} = $dupline[2];\n+ }\n+ close $dupTE;\n+ open (my $du_TE, \'>\'.$dupmapnum) || die "cannot open to write ".$dupmapnum."\\n";\n+ print $du_TE "sequence\\tduplicate\\tgenome map num\\tmap num\\n";\n+ while (my ($k, $v) = each %dupnum_TE )\n+ {\n+ my $hashRef = ${$dupnum_genome}{$k};\n+ print $du_TE "$k\\t$hashRef->[0]\\t$hashRef->[1]\\t$v\\n";\n+ }\n+ close $du_TE;\n+}\n+\n+1;\n' |