Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
More gradient heat map progress...
authorpreecej <preecej@localhost>
Mon, 17 Oct 2011 23:25:12 +0000 (23:25 +0000)
committerpreecej <preecej@localhost>
Mon, 17 Oct 2011 23:25:12 +0000 (23:25 +0000)
svn path=/; revision=187

preecej/perl_singletons/pathway_gene_swapper.pl

index 6ff71d825136102dca71599152b32e4021076aa9..c8a8bb74bcf3ed034b6fa942aaca9da31f7cff8e 100644 (file)
@@ -136,7 +136,7 @@ my $input_gpml_file;
 my $input_gene_file;
 my $input_config_file;
 my $output_file;
-my $apply_paralog_heat = 0;
+my $apply_homolog_heat = 0;
 my $remove_lit = 0; # flag to remove literature and lit references
 my $use_symbols = 0; # flag to indicate use of provided gene symbols
 my $verbose = 0; # flag for verbose output
@@ -148,6 +148,7 @@ my %configs; # configuration settings
 my %swap_genes; # original and swapped genes
 my $gpml_doc; # imported GPML data for manipulation and output
 my %unmapped_genes; # original genes not mapped to homologs 
+my %gradient; # blue-red gradient used for opt. heat map box-coloring  
 
 $Data::Dumper::Pad = "... "; 
 
@@ -263,7 +264,7 @@ sub init
                 }
             }
             case "s" { $use_symbols = 1; }
-            case "h" { $apply_paralog_heat = 1; }
+            case "h" { $apply_homolog_heat = 1; }
             case "L" { $remove_lit = 1; }
             case "v" { $verbose = 1; }
             case "G" { $doc_mode = 1; }
@@ -285,7 +286,7 @@ sub init
         . "Output File: $output_file\n"
         . "\n"
         . "Use provided gene symbols? " . ($use_symbols ? "Yes" : "No") . "\n"
-        . "Provide paralog heat-map? " . ($apply_paralog_heat ? "Yes" : "No") . "\n"
+        . "Provide homolog heat-map? " . ($apply_homolog_heat ? "Yes" : "No") . "\n"
         . "Remove literature references? " . ($remove_lit ? "Yes" : "No") . "\n"
         . "Running in verbose mode? " . ($verbose ? "Yes" : "No") . "\n"
         . "Running in document mode? " . ($doc_mode ? "Yes" : "No") . "\n"
@@ -300,6 +301,46 @@ sub init
 }
 
 
+# ---------------------------------------------------------------------------
+=item B<void set_gradient()>
+Sets the blue-red gradient
+=cut
+# ---------------------------------------------------------------------------
+sub set_gradient($)
+{
+    my @blue_red_array;
+    for (my $i=0; $i<256; $i++) {
+        push @blue_red_array, [$i, 0, (255-$i)];
+    }
+    
+    # print Dumper(@blue_red_array) . "\n\n";
+    
+    register_gradient("blue_red",\@blue_red_array);
+    
+    # print "[Available Gradients]";
+    # print Dumper(available_gradients()) . "\n\n";
+    # print Dumper(gradient("blue_red")) . "\n\n";
+    
+    my %blue_red_gradient;
+    
+    my $max_grad = $_[0];
+    my $inc = sprintf("%.2f", 1/$max_grad);
+    my $count = 1;
+    # print "Increment: $inc\n"; 
+    for (my $i=$inc; $i<=0.99; $i=$i+$inc) {
+        #print "$i\n";
+        #print grad2rgb("blue_red",$i) . "\n";
+        my $tmp_hex = grad2rgb("blue_red",$i);
+        $tmp_hex =~ s/\#//; 
+        $blue_red_gradient{$count} = $tmp_hex;
+        $count++;
+    }
+    # print "[My Gradient Hash]\n";
+    print Dumper(%blue_red_gradient) . "\n\n";
+    
+    return %blue_red_gradient;
+}
+
 
 # ---------------------------------------------------------------------------
 =item B<void import_data()>
@@ -400,6 +441,12 @@ sub import_data
     
     close(GENE_FILE);
 
+    # initialize the blue-red gradient for heat mapping
+    if ($apply_homolog_heat)
+    {
+        %gradient = set_gradient($max_homolog_count);
+    }
+    
     print "Opening GPML pathway file and reading data...\n\n";
 
     my $parser = new XML::DOM::Parser;
@@ -736,9 +783,9 @@ sub swap_genes
                         $curr_graphics->setAttribute("Color",$configs{"BoxBorder"}); }
 
                     # add "heat" to genes with multiple paralogs
-                    if ($apply_paralog_heat && ($gene_suffix_counter > 0))
+                    if ($apply_homolog_heat && ($gene_suffix_counter > 0))
                     {
-                        $curr_graphics->setAttribute("FillColor","cc0000");
+                        $curr_graphics->setAttribute("FillColor",$gradient{$gene_suffix_counter});
                     }
                     else
                     {
@@ -853,11 +900,6 @@ sub export_data
 # ---------------------------------------------------------------------------
 
 init;
-
-print "[Available Gradients]"
-print Dumper(available_gradients()) . "\n\n";
-exit
-
 import_data;
 show_input;
 swap_genes();