Skip to content

Instantly share code, notes, and snippets.

@alexpreynolds
Last active December 17, 2015 02:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexpreynolds/5535721 to your computer and use it in GitHub Desktop.
Save alexpreynolds/5535721 to your computer and use it in GitHub Desktop.
eulergrid.pl is a wrapper script to call plotEulergrid.R
#!/usr/bin/env perl
use warnings;
use strict;
use Getopt::Long;
# -------------------------------------------------------------------------------------------
# options
my ($plotTitle, $offCellColor, $onCellColor, $setNames, $setCardinalities, $setTotal, $setTotalWithout, $outputFilename, $showWholeSets, $rGraphScript, $ctsCounts);
my $optResult = GetOptions ("plotTitle=s" => \$plotTitle, "offCellColor=s" => \$offCellColor, "onCellColor=s" => \$onCellColor, "setNames=s" => \$setNames, "setCardinalities=s" => \$setCardinalities, "setTotal=s" => \$setTotal, "setTotalWithout=s" => \$setTotalWithout, "outputFilename=s" => \$outputFilename, "showWholeSets=s" => \$showWholeSets, "rGraphScript=s" => \$rGraphScript, "ctsCounts=s" => \$ctsCounts);
if (!$plotTitle) { die "specify --plotTitle=str\n"; }
if (!$offCellColor) { $offCellColor = "red"; }
if (!$onCellColor) { $onCellColor = "green"; }
if (!$setNames) { die "specify --setNames=a1,a2,a3,...,aN\n"; }
if (!$setCardinalities) { die "specify --setCardinalities=c1,c2,c3,...,cN,c1^c2,c1^c3,...,c1^c2^c3^...^cN\n"; }
if (!$setTotal) { die "specify --setTotal=n\n"; }
if (!$setTotalWithout) { $setTotalWithout = -1; }
if (!$outputFilename) { die "specify --outputFilename=str.png|ps\n"; }
if (!$ctsCounts) { die "specify --ctsCounts=cts1,cts2,...,ctsN\n"; }
if (!$showWholeSets) { $showWholeSets = -1; } else { $showWholeSets = 1; }
if (!$rGraphScript) { $rGraphScript = "/home/areynolds/proj/eulergrid/src/plotEulergrid.R"; }
# -------------------------------------------------------------------------------------------
# main
my $rScriptSys = "R CMD BATCH --no-save --no-restore \"--args plotTitle=\\\"$plotTitle\\\" offCellColor=\\\"$offCellColor\\\" onCellColor=\\\"$onCellColor\\\" setNames=\\\"$setNames\\\" setCardinalities=\\\"$setCardinalities\\\" setTotal=\\\"$setTotal\\\" setTotalWithout=\\\"$setTotalWithout\\\" outputFilename=\\\"$outputFilename\\\" showWholeSets=\\\"$showWholeSets\\\" ctsCounts=\\\"$ctsCounts\\\"\" $rGraphScript runtime.log 2>&1";
system ($rScriptSys) == 0 or die "R script failed $?";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment