Commit 8a0f540e authored by lcottret's avatar lcottret

Venn.pl

parent f10a884d
=head2 procedure
Title : CreateJsonVenn
Usage : my $rh_sets = {};
$rh_sets->{"set1"} = ["id1,id2"];
$rh_sets->{"set2"} = ["id2,id3,id4"];
$rh_sets->{"set3"} = ["id1,id2,id5,id6"];
$rh_sets->{"set4"} = ["id3,id1"];
&CreateJsonVenn($rh_sets,
"/home/lcottret/workspaces/workspaceBBRIC/bbric-bioinfo/orthomcl/site/data/examples/venn/",
"../../../../web/js/ext/jquery-min.js",
"../../../../web/js/ext/jvenn-min.js" );
Prerequisite : General, JSON, File::Path, the jvenn libray installed
Function : creates a json for jvenn from a set of ids
Returns : nothing
Args : 1. a hashref containing arrays of strings containing the ids separated by commas
2. a directory path to save the json and the js file
3. the path of jquery.js (relative to the directory path set above)
4. the path of jvenn.min.js (relative to the directory path set above)
Access : public
TODO :
Globals :
=cut
sub CreateJsonVenn {
my ( $rh_sets, $out_dir, $jquery_lib, $jvenn_lib ) = @_;
my %h_param = (
'series' => [],
'displayStat' => 'true'
);
foreach my $name ( keys %{$rh_sets} ) {
my $rh_serie = {};
$rh_serie->{"name"} = $name;
my $ra_set = $rh_sets->{$name};
$rh_serie->{"data"} = $ra_set;
push( @{ $h_param{'series'} }, $rh_serie );
}
my $json = to_json( \%h_param );
if ( !-d $out_dir ) {
make_path($out_dir);
}
# creates the js file
my $js_file = "$out_dir/series.js";
my $fh_output = &GetStreamOut($js_file);
print $fh_output
"\$(document).ready(function(){\$('#jvenn-container').jvenn(" . $json
. ");});";
$fh_output->close();
# creates the html file
my $html_file = "$out_dir/venn.html";
$fh_output = &GetStreamOut($html_file);
print $fh_output "<html>\n";
print $fh_output "<head>\n";
print $fh_output " <script src=\"" . $jquery_lib . "\"></script>\n";
print $fh_output " <script src=\"" . $jvenn_lib . "\"></script>\n";
print $fh_output " <script src=\"series.js\"></script>\n";
print $fh_output "</head>\n";
print $fh_output "<body>\n";
print $fh_output "<div id=\"jvenn-container\"></div><br /><br />\n";
print $fh_output "</body>\n";
print $fh_output "</html>\n";
$fh_output->close();
}
1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment