comparison html.pl @ 15:0e4b6b0c6e9d draft

Uploaded
author big-tiandm
date Wed, 29 Oct 2014 04:20:16 -0400
parents 07745c0958dd
children e0884a4b996b
comparison
equal deleted inserted replaced
14:36ba71d63988 15:0e4b6b0c6e9d
23 $prepath=<IN>; chomp $prepath; 23 $prepath=<IN>; chomp $prepath;
24 $rfampath=<IN>;chomp $rfampath; 24 $rfampath=<IN>;chomp $rfampath;
25 $genomepath=<IN>; chomp $genomepath; 25 $genomepath=<IN>; chomp $genomepath;
26 $clusterpath=<IN>; chomp $clusterpath; 26 $clusterpath=<IN>; chomp $clusterpath;
27 $annotatepath=<IN>; chomp $annotatepath; 27 $annotatepath=<IN>; chomp $annotatepath;
28 $degpath=<IN>; chomp $degpath; 28 my $deg_tag=1;
29 if(eof){$deg_tag=0;}
30 else{
31 $degpath=<IN>; chomp $degpath;
32 }
29 close IN; 33 close IN;
30 my @tmp=split/\//,$prepath; 34 my @tmp=split/\//,$prepath;
31 $predir=$tmp[-1]; 35 $predir=$tmp[-1];
32 @tmp=split/\//,$rfampath; 36 @tmp=split/\//,$rfampath;
33 $rfamdir=$tmp[-1]; 37 $rfamdir=$tmp[-1];
35 $genomedir=$tmp[-1]; 39 $genomedir=$tmp[-1];
36 @tmp=split/\//,$clusterpath; 40 @tmp=split/\//,$clusterpath;
37 $clusterdir=$tmp[-1]; 41 $clusterdir=$tmp[-1];
38 @tmp=split/\//,$annotatepath; 42 @tmp=split/\//,$annotatepath;
39 $annotatedir=$tmp[-1]; 43 $annotatedir=$tmp[-1];
40 @tmp=split/\//,$degpath; 44 #@tmp=split/\//,$degpath;
41 $degdir=$tmp[-1]; 45 #$degdir=$tmp[-1];
42 46
43 my $dir=dirname($opts{'o'}); 47 my $dir=dirname($opts{'o'});
44 48
45 open OUT ,">$opts{'o'}"; 49 open OUT ,">$opts{'o'}";
46 print OUT "<HTML>\n <HEAD>\n <TITLE> Analysis Report </TITLE>\n </HEAD> 50 print OUT "<HTML>\n <HEAD>\n <TITLE> Analysis Report </TITLE>\n </HEAD>
477 $phase[$j]=0; 481 $phase[$j]=0;
478 $long[$j]=0; 482 $long[$j]=0;
479 $repeat[$j]=0; 483 $repeat[$j]=0;
480 $nat[$j]=0; 484 $nat[$j]=0;
481 } 485 }
486
487 my $class_anno=6;
482 open ANNO,"<$annotate"; 488 open ANNO,"<$annotate";
483 while (my $aline=<ANNO>) { 489 while (my $aline=<ANNO>) {
484 next if($aline=~/^\#/);
485 chomp $aline; 490 chomp $aline;
486 my @temp=split/\t/,$aline; 491 my @temp=split/\t/,$aline;
487 for (my $i=3+@marks+6;$i<@temp;$i++) { 492 if($aline=~/^\#/){
493 if (@temp != 10+@marks) {
494 $class_anno=0;
495 }
496 next;
497 }
498 for (my $i=3+@marks+$class_anno;$i<@temp;$i++) {
488 my @posit=split/\;/,$temp[$i]; 499 my @posit=split/\;/,$temp[$i];
489 for (my $j=0;$j<@marks ;$j++) { 500 for (my $j=0;$j<@marks ;$j++) {
490 if ($temp[3+$j]>0) { 501 if ($temp[3+$j]>0) {
491 $posit{$posit[0]}[$j]++; 502 $posit{$posit[0]}[$j]++;
492 } 503 }
495 $posit{$posit[0]}[$j]=0; 506 $posit{$posit[0]}[$j]=0;
496 } 507 }
497 } 508 }
498 } 509 }
499 } 510 }
500 for (my $j=0;$j<@marks ;$j++) { 511 if ($class_anno) {
501 if ($temp[3+$j]>0) { 512 for (my $j=0;$j<@marks ;$j++) {
502 if ($temp[6] eq "phase") { 513 if ($temp[3+$j]>0) {
503 $phase[$j]++; 514 if ($temp[6] eq "phase") {
504 } 515 $phase[$j]++;
505 if ($temp[7] eq "long") {
506 $long[$j]++;
507 }
508 if ($temp[8] ne "\/") {
509 $repeat[$j]++;
510 my @rr=split/\;/,$temp[8];
511 foreach (@rr) {
512 $repeat{$_}[$j]++;
513 } 516 }
514 } 517 if ($temp[7] eq "long") {
515 if ($temp[9] ne "\/") { 518 $long[$j]++;
516 $nat[$j]++; 519 }
517 my @nn1=split/\;/,$temp[9]; 520 if ($temp[8] ne "\/") {
518 my @nn2=split/\;/,$temp[10]; 521 $repeat[$j]++;
519 for (my $k=0;$k<@nn1 ;$k++) { 522 my @rr=split/\;/,$temp[8];
520 $nat1{$nn1[$k]}[$j]++; 523 foreach (@rr) {
521 $nat2{$nn2[$k]}[$j]++; 524 $repeat{$_}[$j]++;
525 }
526 }
527 if ($temp[9] ne "\/") {
528 $nat[$j]++;
529 my @nn1=split/\;/,$temp[9];
530 my @nn2=split/\;/,$temp[10];
531 for (my $k=0;$k<@nn1 ;$k++) {
532 $nat1{$nn1[$k]}[$j]++;
533 $nat2{$nn2[$k]}[$j]++;
534 }
522 } 535 }
523 } 536 }
524 } 537 }
525 } 538 }
526 } 539 }
549 print OUT "<p> 562 print OUT "<p>
550 Note:<br /> 563 Note:<br />
551 One cluster mybe annotate to multiple genes<br /> 564 One cluster mybe annotate to multiple genes<br />
552 "; 565 ";
553 566
554 print OUT "<h3>5.2 Cluster source mechanism annotate</h3> 567 if ($class_anno) {
555 <table border=\"1\"> 568 print OUT "<h3>5.2 Cluster source mechanism annotate</h3>
556 <tr align=\"center\"> 569 <table border=\"1\">
557 <th align=\"left\">clusters number</th>\n 570 <tr align=\"center\">
558 "; 571 <th align=\"left\">clusters number</th>\n
559 572 ";
560 foreach (@marks) { 573
561 print OUT "<th> $_ </th>\n"; 574 foreach (@marks) {
562 } 575 print OUT "<th> $_ </th>\n";
563 print OUT "</tr> 576 }
564 <tr align=\"center\"> 577 print OUT "</tr>
565 <th align=\"left\">Phase</th>\n 578 <tr align=\"center\">
566 "; 579 <th align=\"left\">Phase</th>\n
567 foreach (@phase) { 580 ";
568 print OUT "<td> $_ </td>\n"; 581 foreach (@phase) {
569 } 582 print OUT "<td> $_ </td>\n";
570 583 }
571 print OUT "</tr> 584
572 <tr align=\"center\"> 585 print OUT "</tr>
573 <th align=\"left\">Long</th>\n 586 <tr align=\"center\">
574 "; 587 <th align=\"left\">Long</th>\n
575 foreach (@long) { 588 ";
576 print OUT "<td> $_ </td>\n"; 589 foreach (@long) {
577 } 590 print OUT "<td> $_ </td>\n";
578 591 }
579 print OUT "</tr> 592
580 <tr align=\"center\"> 593 print OUT "</tr>
581 <th align=\"left\">Repeat</th>\n 594 <tr align=\"center\">
582 "; 595 <th align=\"left\">Repeat</th>\n
583 foreach (@repeat) { 596 ";
584 print OUT "<td> $_ </td>\n"; 597 foreach (@repeat) {
585 } 598 print OUT "<td> $_ </td>\n";
586 599 }
587 print OUT "</tr> 600
588 <tr align=\"center\"> 601 print OUT "</tr>
589 <th align=\"left\">Nat</th>\n 602 <tr align=\"center\">
590 "; 603 <th align=\"left\">Nat</th>\n
591 foreach (@nat) { 604 ";
592 print OUT "<td> $_ </td>\n"; 605 foreach (@nat) {
593 } 606 print OUT "<td> $_ </td>\n";
594 print OUT "</tr>\n</table>"; 607 }
595 608 print OUT "</tr>\n</table>";
596 print OUT "<p> 609
597 Repeat subclass annotate: 610 print OUT "<p>
598 "; 611 Repeat subclass annotate:
599 612 ";
600 print OUT "<table border=\"1\"> 613
601 <tr align=\"center\"> 614 print OUT "<table border=\"1\">
602 <th align=\"left\">Repeat subclass</th>\n 615 <tr align=\"center\">
603 "; 616 <th align=\"left\">Repeat subclass</th>\n
604 foreach (@marks) { 617 ";
605 print OUT "<th> $_ </th>\n"; 618 foreach (@marks) {
606 } 619 print OUT "<th> $_ </th>\n";
607 620 }
608 foreach my $key (sort keys %repeat) { 621
609 print OUT "</tr> 622 foreach my $key (sort keys %repeat) {
610 <tr align=\"center\"> 623 print OUT "</tr>
611 <th align=\"left\">$key</th> 624 <tr align=\"center\">
612 "; 625 <th align=\"left\">$key</th>
613 for (my $i=0;$i<@marks ;$i++) { 626 ";
614 if (defined($repeat{$key}[$i])) { 627 for (my $i=0;$i<@marks ;$i++) {
615 print OUT "<td> $repeat{$key}[$i] </td>\n"; 628 if (defined($repeat{$key}[$i])) {
616 } 629 print OUT "<td> $repeat{$key}[$i] </td>\n";
617 else{print OUT "<td> 0 </td>\n";} 630 }
618 } 631 else{print OUT "<td> 0 </td>\n";}
619 } 632 }
620 print OUT "</tr>\n</table>"; 633 }
621 634 print OUT "</tr>\n</table>";
622 635
623 print OUT "<p> 636
624 Nat subclass1 annotate: 637 print OUT "<p>
625 "; 638 Nat subclass1 annotate:
626 639 ";
627 print OUT "<table border=\"1\"> 640
628 <tr align=\"center\"> 641 print OUT "<table border=\"1\">
629 <th align=\"left\">Nat subclass1</th>\n 642 <tr align=\"center\">
630 "; 643 <th align=\"left\">Nat subclass1</th>\n
631 foreach (@marks) { 644 ";
632 print OUT "<th> $_ </th>\n"; 645 foreach (@marks) {
633 } 646 print OUT "<th> $_ </th>\n";
634 foreach my $key (sort keys %nat1) { 647 }
635 print OUT "</tr> 648 foreach my $key (sort keys %nat1) {
636 <tr align=\"center\"> 649 print OUT "</tr>
637 <th align=\"left\">$key</th> 650 <tr align=\"center\">
638 "; 651 <th align=\"left\">$key</th>
639 for (my $i=0;$i<@marks ;$i++) { 652 ";
640 if (defined($nat1{$key}[$i])) { 653 for (my $i=0;$i<@marks ;$i++) {
641 print OUT "<td> $nat1{$key}[$i] </td>\n"; 654 if (defined($nat1{$key}[$i])) {
642 } 655 print OUT "<td> $nat1{$key}[$i] </td>\n";
643 else{print OUT "<td> 0 </td>\n";} 656 }
644 } 657 else{print OUT "<td> 0 </td>\n";}
645 } 658 }
646 print OUT "</tr>\n</table>"; 659 }
647 660 print OUT "</tr>\n</table>";
648 print OUT "<p> 661
649 Nat subclass2 annotate: 662 print OUT "<p>
650 "; 663 Nat subclass2 annotate:
651 664 ";
652 print OUT "<table border=\"1\"> 665
653 <tr align=\"center\"> 666 print OUT "<table border=\"1\">
654 <th align=\"left\">Nat subclass2</th>\n 667 <tr align=\"center\">
655 "; 668 <th align=\"left\">Nat subclass2</th>\n
656 foreach (@marks) { 669 ";
657 print OUT "<th> $_ </th>\n"; 670 foreach (@marks) {
658 } 671 print OUT "<th> $_ </th>\n";
659 foreach my $key (sort keys %nat2) { 672 }
660 print OUT "</tr> 673 foreach my $key (sort keys %nat2) {
661 <tr align=\"center\"> 674 print OUT "</tr>
662 <th align=\"left\">$key</th> 675 <tr align=\"center\">
663 "; 676 <th align=\"left\">$key</th>
664 for (my $i=0;$i<@marks ;$i++) { 677 ";
665 if (defined($nat2{$key}[$i])) { 678 for (my $i=0;$i<@marks ;$i++) {
666 print OUT "<td> $nat2{$key}[$i] </td>\n"; 679 if (defined($nat2{$key}[$i])) {
667 } 680 print OUT "<td> $nat2{$key}[$i] </td>\n";
668 else{print OUT "<td> 0 </td>\n";} 681 }
669 } 682 else{print OUT "<td> 0 </td>\n";}
670 } 683 }
671 print OUT "</tr>\n</table>"; 684 }
672 print OUT "<p> 685 print OUT "</tr>\n</table>";
673 Note:<br /> 686 print OUT "<p>
674 One cluster mybe annotate to multiple repeats or nats<br /> 687 Note:<br />
675 "; 688 One cluster mybe annotate to multiple repeats or nats<br />
676 689 ";
677 my $deg_file=`ls $degpath`; 690 }
678 chomp $deg_file; 691 else {
679 my @deg_file=split/\n/,$deg_file; 692 print OUT "<h3>5.2 Cluster source mechanism annotate</h3>
680 my %deg; 693 <br />Do not do source mechanism annotate <br />";
681 foreach (@deg_file) { 694
682 my $output="$degpath/$_/output_score.txt"; 695 }
683 open IN,"<$output"; 696
684 $deg{$_}[0]=0; 697 if ($deg_tag) {
685 $deg{$_}[1]=0; 698 my $deg_file=`ls $degpath`;
686 $deg{$_}[2]=0; 699 chomp $deg_file;
687 while (my $aline=<IN>) { 700 my @deg_file=split/\n/,$deg_file;
688 next if ($aline=~/^\"/); 701 my %deg;
689 chomp $aline; 702 foreach (@deg_file) {
690 my @temp=split/\t/,$aline; 703 my $output="$degpath/$_/output_score.txt";
691 if ($temp[9] eq "TRUE") { 704 open IN,"<$output";
692 $deg{$_}[0]++; 705 $deg{$_}[0]=0;
693 if ($temp[4] >0) { 706 $deg{$_}[1]=0;
694 $deg{$_}[1]++; 707 $deg{$_}[2]=0;
695 } 708 while (my $aline=<IN>) {
696 if ($temp[4] <0) { 709 next if ($aline=~/^\"/);
697 $deg{$_}[2]++; 710 chomp $aline;
698 } 711 my @temp=split/\t/,$aline;
699 } 712 if ($temp[9] eq "TRUE") {
700 } 713 $deg{$_}[0]++;
701 close IN; 714 if ($temp[4] >0) {
702 } 715 $deg{$_}[1]++;
703 716 }
704 717 if ($temp[4] <0) {
705 print OUT "<h2>6. DEG</h2> 718 $deg{$_}[2]++;
706 <table border=\"1\"> 719 }
707 <tr align=\"center\"> 720 }
708 <th align=\"left\">Genes number</th>\n 721 }
709 <th> DEG </th>\n 722 close IN;
710 <th> UP </th>\n 723 }
711 <th> DOWN </th>\n 724
712 "; 725 print OUT "<h2>6. DEG</h2>
713 726 <table border=\"1\">
714 foreach my $key (sort keys %deg) { 727 <tr align=\"center\">
715 print OUT "</tr> 728 <th align=\"left\">Genes number</th>\n
716 <tr align=\"center\"> 729 <th> DEG </th>\n
717 <th align=\"left\">$key</th> 730 <th> UP </th>\n
718 "; 731 <th> DOWN </th>\n
719 for (my $i=0;$i<@{$deg{$key}} ;$i++) { 732 ";
720 print OUT "<td> $deg{$key}[$i] </td>\n"; 733
721 } 734 foreach my $key (sort keys %deg) {
722 } 735 print OUT "</tr>
723 print OUT "</tr>\n</table>"; 736 <tr align=\"center\">
737 <th align=\"left\">$key</th>
738 ";
739 for (my $i=0;$i<@{$deg{$key}} ;$i++) {
740 print OUT "<td> $deg{$key}[$i] </td>\n";
741 }
742 }
743 print OUT "</tr>\n</table>";
744 }
745 else{
746 print OUT "<h2>6. DEG</h2>
747 <br />Do not do DE clusters <br />";
748 }
724 749
725 print OUT " 750 print OUT "
726 </BODY> 751 </BODY>
727 </HTML> 752 </HTML>
728 "; 753 ";