Final installation of methylseq analysis.
[htsworkflow.git] / htswanalysis / scripts / Summarize_Methylseq.pm
index 044f6c911cc1797c9d4bda9056bbf3d171d62a0a..d5f84efaae9e7fd96e4d7306efdb30aa487f8967 100755 (executable)
@@ -7,21 +7,33 @@ my $name = shift;
 if(!defined($name)) { print STDERR "Error: No name provided to summarize methylseq\n"; exit(1); }
 my $task = shift;
 if(!defined($task)) { print STDERR "Error: No task provided to summarize methylseq\n"; exit(1); }
+my $tasks_root = shift;
+if(!defined($tasks_root)) { print STDERR "Error: No root task directory provided to summarize methylseq\n"; exit(1); }
 my $msp1_lib = shift;
 if(!defined($msp1_lib)) { print STDERR "Error: No msp1 library provided to summarize methylseq\n"; exit(1); }
 my $hpa2_lib = shift;
 if(!defined($hpa2_lib)) { print STDERR "Error: No hpa2 library provided to summarize methylseq\n"; exit(1); }
 my $genome = shift;
 
-my $assayed_bed = "Assayed.bed";
-my $methylated_bed = "Methylated.bed";
+my $methylseq_bed = "MethylseqCalls.bed";
 my $methylseq_calls = "MethylseqCalls.tab";
 my $summary = "methylseq_summary";
-if(!defined($summary)) { return; }
 
-open(FILE,$summary);
+if(! -e $tasks_root."/".$task."/".$summary) {
+  printf "<TR><TD BGCOLOR=#FFCCCC>Processing...</TD></TR>\n";
+  exit;
+}
 
-my $tag_count = <FILE>; chomp $tag_count;
+open(FILE,$tasks_root."/".$task."/".$summary);
+
+my $tag_count = <FILE>;
+
+if(!defined($tag_count)) {
+  printf "<TR><TD BGCOLOR=#FFCCCC>Processing...</TD></TR>\n";
+  exit;
+}
+
+chomp $tag_count;
 $tag_count =~ /^(\d+) MSP1 tags, (\d+) HPA2 tags$/;
 my($msp_count,$hpa_count) = ($1,$2);
 
@@ -37,6 +49,7 @@ my $error_count = <FILE>; chomp $error_count;
    $error_count =~ /^(\d+) of \d+ regions with error/;
    my $n_error = $1;
 
+
 my $pcnt_assayed = $n_assayed / $n_regions;
 my $pcnt_methylated = $n_methylated / $n_assayed;
 my $pcnt_error = $n_error / $n_regions;
@@ -57,10 +70,8 @@ elsif($pcnt_error > 0.01) { $error_color = "4444FF"; }
 else {$error_color= "66FF66"; }
 
 print "<TR>";
-printf "<TD>$msp1_lib</TD><TD>$hpa2_lib</TD><TD>$n_assayed (%.4f)</TD><TD>$n_methylated (%0.4f)</TD><TD>$n_error (%0.4f)</TD>",$pcnt_assayed,$pcnt_methylated,$pcnt_error;
-print "<TD><A HREF=../../Tasks/$task/$methylseq_calls>Calls</A><BR>\n";
-print "<A HREF=../../Tasks/$task/Assayed.bed>Assayed Regions</A>";
-print "<A HREF=http://genome.ucsc.edu/cgi-bin/hgTracks?db=$genome&position=chr1:1000-2000&hgt.customText=http://illumina-mac.stanford.edu/Tasks/$task/Assayed.bed TARGET=\"_blank\">(Genome Browser)</A></BR>\n";
-print "<A HREF=../../Tasks/$task/Methylated.bed>Methylated Regions</A> ";
-print "<A HREF=http://genome.ucsc.edu/cgi-bin/hgTracks?db=$genome&position=chr1:1000-2000&hgt.customText=http://illumina-mac.stanford.edu/Tasks/$task/Methylated.bed TARGET=\"_blank\">(Genome Browser)</A></TD>\n";
+printf "<TD>$name</TD><TD>$msp1_lib</TD><TD>$hpa2_lib</TD><TD BGCOLOR=#$assayed_color>$n_assayed (%.4f)</TD><TD BGCOLOR=#$methylated_color>$n_methylated (%0.4f)</TD><TD BGCOLOR=$error_color>$n_error (%0.4f)</TD>",$pcnt_assayed,$pcnt_methylated,$pcnt_error;
+print "<TD><A HREF=../../Tasks/$task/$methylseq_calls>Results</A><BR>\n";
+print "<A HREF=http://genome.ucsc.edu/cgi-bin/hgTracks?db=$genome&position=chr1:1000-2000&hgt.customText=http://illumina-mac.stanford.edu/Tasks/$task/$methylseq_bed TARGET=\"_blank\">(Genome Browser)</A></BR>\n";
+print "</TD>";
 print "</TR>";