changeset 15:0e4b6b0c6e9d draft

Uploaded
author big-tiandm
date Wed, 29 Oct 2014 04:20:16 -0400
parents 36ba71d63988
children 7d12d9b130bc
files html.pl
diffstat 1 files changed, 195 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/html.pl	Wed Oct 29 04:19:59 2014 -0400
+++ b/html.pl	Wed Oct 29 04:20:16 2014 -0400
@@ -25,7 +25,11 @@
 $genomepath=<IN>; chomp $genomepath;
 $clusterpath=<IN>; chomp $clusterpath;
 $annotatepath=<IN>; chomp $annotatepath;
-$degpath=<IN>; chomp $degpath;
+my $deg_tag=1;
+if(eof){$deg_tag=0;}
+else{
+	$degpath=<IN>; chomp $degpath;
+}
 close IN;
 my @tmp=split/\//,$prepath;
 $predir=$tmp[-1];
@@ -37,8 +41,8 @@
 $clusterdir=$tmp[-1];
 @tmp=split/\//,$annotatepath;
 $annotatedir=$tmp[-1];
-@tmp=split/\//,$degpath;
-$degdir=$tmp[-1];
+#@tmp=split/\//,$degpath;
+#$degdir=$tmp[-1];
 
 my $dir=dirname($opts{'o'});
 
@@ -479,12 +483,19 @@
 	$repeat[$j]=0;
 	$nat[$j]=0;
 }
+
+my $class_anno=6;
 open ANNO,"<$annotate";
 while (my $aline=<ANNO>) {
-	next if($aline=~/^\#/);
 	chomp $aline;
 	my @temp=split/\t/,$aline;
-	for (my $i=3+@marks+6;$i<@temp;$i++) {
+	if($aline=~/^\#/){
+		if (@temp != 10+@marks) {
+			$class_anno=0;
+		}
+		next;
+	}
+	for (my $i=3+@marks+$class_anno;$i<@temp;$i++) {
 		my @posit=split/\;/,$temp[$i];
 		for (my $j=0;$j<@marks ;$j++) {
 			if ($temp[3+$j]>0) {
@@ -497,28 +508,30 @@
 			}
 		}
 	}
-	for (my $j=0;$j<@marks ;$j++) {
-		if ($temp[3+$j]>0) {
-			if ($temp[6] eq "phase") {
-				$phase[$j]++;
-			}
-			if ($temp[7] eq "long") {
-				$long[$j]++;
-			}
-			if ($temp[8] ne "\/") {
-				$repeat[$j]++;
-				my @rr=split/\;/,$temp[8];
-				foreach  (@rr) {
-					$repeat{$_}[$j]++;
+	if ($class_anno) {
+		for (my $j=0;$j<@marks ;$j++) {
+			if ($temp[3+$j]>0) {
+				if ($temp[6] eq "phase") {
+					$phase[$j]++;
+				}
+				if ($temp[7] eq "long") {
+					$long[$j]++;
 				}
-			}
-			if ($temp[9] ne "\/") {
-				$nat[$j]++;
-				my @nn1=split/\;/,$temp[9];
-				my @nn2=split/\;/,$temp[10];
-				for (my $k=0;$k<@nn1 ;$k++) {
-					$nat1{$nn1[$k]}[$j]++;
-					$nat2{$nn2[$k]}[$j]++;
+				if ($temp[8] ne "\/") {
+					$repeat[$j]++;
+					my @rr=split/\;/,$temp[8];
+					foreach  (@rr) {
+						$repeat{$_}[$j]++;
+					}
+				}
+				if ($temp[9] ne "\/") {
+					$nat[$j]++;
+					my @nn1=split/\;/,$temp[9];
+					my @nn2=split/\;/,$temp[10];
+					for (my $k=0;$k<@nn1 ;$k++) {
+						$nat1{$nn1[$k]}[$j]++;
+						$nat2{$nn2[$k]}[$j]++;
+					}
 				}
 			}
 		}
@@ -551,176 +564,188 @@
 One cluster mybe annotate to multiple genes<br />
 ";
 
-print OUT "<h3>5.2 Cluster source mechanism annotate</h3>
-<table border=\"1\">
-<tr align=\"center\">
-<th align=\"left\">clusters number</th>\n
-";
+if ($class_anno) {
+	print OUT "<h3>5.2 Cluster source mechanism annotate</h3>
+	<table border=\"1\">
+	<tr align=\"center\">
+	<th align=\"left\">clusters number</th>\n
+	";
 
-foreach  (@marks) {
-	print OUT "<th> $_ </th>\n";
-}
-print OUT "</tr>
-<tr align=\"center\">
-<th align=\"left\">Phase</th>\n
-";
-foreach  (@phase) {
-	print OUT "<td> $_ </td>\n";
-}
+	foreach  (@marks) {
+		print OUT "<th> $_ </th>\n";
+	}
+	print OUT "</tr>
+	<tr align=\"center\">
+	<th align=\"left\">Phase</th>\n
+	";
+	foreach  (@phase) {
+		print OUT "<td> $_ </td>\n";
+	}
 
-print OUT "</tr>
-<tr align=\"center\">
-<th align=\"left\">Long</th>\n
-";
-foreach  (@long) {
-	print OUT "<td> $_ </td>\n";
-}
+	print OUT "</tr>
+	<tr align=\"center\">
+	<th align=\"left\">Long</th>\n
+	";
+	foreach  (@long) {
+		print OUT "<td> $_ </td>\n";
+	}
 
-print OUT "</tr>
-<tr align=\"center\">
-<th align=\"left\">Repeat</th>\n
-";
-foreach  (@repeat) {
-	print OUT "<td> $_ </td>\n";
-}
+	print OUT "</tr>
+	<tr align=\"center\">
+	<th align=\"left\">Repeat</th>\n
+	";
+	foreach  (@repeat) {
+		print OUT "<td> $_ </td>\n";
+	}
 
-print OUT "</tr>
-<tr align=\"center\">
-<th align=\"left\">Nat</th>\n
-";
-foreach  (@nat) {
-	print OUT "<td> $_ </td>\n";
-}
-print OUT "</tr>\n</table>";
+	print OUT "</tr>
+	<tr align=\"center\">
+	<th align=\"left\">Nat</th>\n
+	";
+	foreach  (@nat) {
+		print OUT "<td> $_ </td>\n";
+	}
+	print OUT "</tr>\n</table>";
 
-print OUT "<p>
-Repeat subclass annotate:
-";
+	print OUT "<p>
+	Repeat subclass annotate:
+	";
 
-print OUT "<table border=\"1\">
-<tr align=\"center\">
-<th align=\"left\">Repeat subclass</th>\n
-";
-foreach  (@marks) {
-	print OUT "<th> $_ </th>\n";
-}
+	print OUT "<table border=\"1\">
+	<tr align=\"center\">
+	<th align=\"left\">Repeat subclass</th>\n
+	";
+	foreach  (@marks) {
+		print OUT "<th> $_ </th>\n";
+	}
 
-foreach my $key (sort keys %repeat) {
-	print  OUT "</tr>
-		<tr align=\"center\">
-		<th align=\"left\">$key</th>
-	";
-	for (my $i=0;$i<@marks ;$i++) {
-		if (defined($repeat{$key}[$i])) {
-			print OUT "<td> $repeat{$key}[$i] </td>\n";
+	foreach my $key (sort keys %repeat) {
+		print  OUT "</tr>
+			<tr align=\"center\">
+			<th align=\"left\">$key</th>
+		";
+		for (my $i=0;$i<@marks ;$i++) {
+			if (defined($repeat{$key}[$i])) {
+				print OUT "<td> $repeat{$key}[$i] </td>\n";
+			}
+			else{print OUT "<td> 0 </td>\n";}
 		}
-		else{print OUT "<td> 0 </td>\n";}
 	}
-}
-print OUT "</tr>\n</table>";
+	print OUT "</tr>\n</table>";
 
 
-print OUT "<p>
-Nat subclass1 annotate:
-";
+	print OUT "<p>
+	Nat subclass1 annotate:
+	";
 
-print OUT "<table border=\"1\">
-<tr align=\"center\">
-<th align=\"left\">Nat subclass1</th>\n
-";
-foreach  (@marks) {
-	print OUT "<th> $_ </th>\n";
-}
-foreach my $key (sort keys %nat1) {
-	print  OUT "</tr>
-		<tr align=\"center\">
-		<th align=\"left\">$key</th>
+	print OUT "<table border=\"1\">
+	<tr align=\"center\">
+	<th align=\"left\">Nat subclass1</th>\n
 	";
-	for (my $i=0;$i<@marks ;$i++) {
-		if (defined($nat1{$key}[$i])) {
-			print OUT "<td> $nat1{$key}[$i] </td>\n";
+	foreach  (@marks) {
+		print OUT "<th> $_ </th>\n";
+	}
+	foreach my $key (sort keys %nat1) {
+		print  OUT "</tr>
+			<tr align=\"center\">
+			<th align=\"left\">$key</th>
+		";
+		for (my $i=0;$i<@marks ;$i++) {
+			if (defined($nat1{$key}[$i])) {
+				print OUT "<td> $nat1{$key}[$i] </td>\n";
+			}
+			else{print OUT "<td> 0 </td>\n";}
 		}
-		else{print OUT "<td> 0 </td>\n";}
 	}
-}
-print OUT "</tr>\n</table>";
+	print OUT "</tr>\n</table>";
+
+	print OUT "<p>
+	Nat subclass2 annotate:
+	";
 
-print OUT "<p>
-Nat subclass2 annotate:
-";
-
-print OUT "<table border=\"1\">
-<tr align=\"center\">
-<th align=\"left\">Nat subclass2</th>\n
-";
-foreach  (@marks) {
-	print OUT "<th> $_ </th>\n";
+	print OUT "<table border=\"1\">
+	<tr align=\"center\">
+	<th align=\"left\">Nat subclass2</th>\n
+	";
+	foreach  (@marks) {
+		print OUT "<th> $_ </th>\n";
+	}
+	foreach my $key (sort keys %nat2) {
+		print  OUT "</tr>
+			<tr align=\"center\">
+			<th align=\"left\">$key</th>
+		";
+		for (my $i=0;$i<@marks ;$i++) {
+			if (defined($nat2{$key}[$i])) {
+				print OUT "<td> $nat2{$key}[$i] </td>\n";
+			}
+			else{print OUT "<td> 0 </td>\n";}
+		}
+	}
+	print OUT "</tr>\n</table>";
+	print OUT "<p>
+	Note:<br />
+	One cluster mybe annotate to multiple repeats or nats<br />
+	";
 }
-foreach my $key (sort keys %nat2) {
-	print  OUT "</tr>
-		<tr align=\"center\">
-		<th align=\"left\">$key</th>
-	";
-	for (my $i=0;$i<@marks ;$i++) {
-		if (defined($nat2{$key}[$i])) {
-			print OUT "<td> $nat2{$key}[$i] </td>\n";
-		}
-		else{print OUT "<td> 0 </td>\n";}
-	}
+else {
+	print OUT "<h3>5.2 Cluster source mechanism annotate</h3>
+	<br />Do not do source mechanism annotate <br />";
+
 }
-print OUT "</tr>\n</table>";
-print OUT "<p>
-Note:<br />
-One cluster mybe annotate to multiple repeats or nats<br />
-";
 
-my $deg_file=`ls $degpath`;
-chomp $deg_file;
-my @deg_file=split/\n/,$deg_file;
-my %deg;
-foreach  (@deg_file) {
-	my $output="$degpath/$_/output_score.txt";
-	open IN,"<$output";
-	$deg{$_}[0]=0;
-	$deg{$_}[1]=0;
-	$deg{$_}[2]=0;
-	while (my $aline=<IN>) {
-		next if ($aline=~/^\"/);
-		chomp $aline;
-		my @temp=split/\t/,$aline;
-		if ($temp[9] eq "TRUE") {
-			$deg{$_}[0]++;
-			if ($temp[4] >0) {
-				$deg{$_}[1]++;
-			}
-			if ($temp[4] <0) {
-				$deg{$_}[2]++;
+if ($deg_tag) {
+	my $deg_file=`ls $degpath`;
+	chomp $deg_file;
+	my @deg_file=split/\n/,$deg_file;
+	my %deg;
+	foreach  (@deg_file) {
+		my $output="$degpath/$_/output_score.txt";
+		open IN,"<$output";
+		$deg{$_}[0]=0;
+		$deg{$_}[1]=0;
+		$deg{$_}[2]=0;
+		while (my $aline=<IN>) {
+			next if ($aline=~/^\"/);
+			chomp $aline;
+			my @temp=split/\t/,$aline;
+			if ($temp[9] eq "TRUE") {
+				$deg{$_}[0]++;
+				if ($temp[4] >0) {
+					$deg{$_}[1]++;
+				}
+				if ($temp[4] <0) {
+					$deg{$_}[2]++;
+				}
 			}
 		}
+		close IN;
 	}
-	close IN;
-}
 
+	print OUT "<h2>6. DEG</h2>
+	<table border=\"1\">
+	<tr align=\"center\">
+	<th align=\"left\">Genes number</th>\n
+	<th> DEG </th>\n
+	<th> UP </th>\n
+	<th> DOWN </th>\n
+	";
 
-print OUT "<h2>6. DEG</h2>
-<table border=\"1\">
-<tr align=\"center\">
-<th align=\"left\">Genes number</th>\n
-<th> DEG </th>\n
-<th> UP </th>\n
-<th> DOWN </th>\n
-";
-
-foreach my $key (sort keys %deg) {
-	print  OUT "</tr>
-		<tr align=\"center\">
-		<th align=\"left\">$key</th>
-	";
-	for (my $i=0;$i<@{$deg{$key}} ;$i++) {
-		print OUT "<td> $deg{$key}[$i] </td>\n";
+	foreach my $key (sort keys %deg) {
+		print  OUT "</tr>
+			<tr align=\"center\">
+			<th align=\"left\">$key</th>
+		";
+		for (my $i=0;$i<@{$deg{$key}} ;$i++) {
+			print OUT "<td> $deg{$key}[$i] </td>\n";
+		}
 	}
+	print OUT "</tr>\n</table>";
 }
-print OUT "</tr>\n</table>";
+else{
+	print OUT "<h2>6. DEG</h2>
+	<br />Do not do DE clusters <br />";
+}
 
 print OUT "
  </BODY>