Commits

Sarah Richardson  committed 2729559

improved build file that handles command line input and defaults appropriately

  • Participants
  • Parent commits ca4ad1a

Comments (0)

Files changed (1)

 print "\n";
 
 my $llt = 0;
-my ($cpath,  $spath,  $tpath) =  (       q{},                 q{},        q{});
-my ($dcpath, $dspath, $dtpath) = ('/etc/GeneDesign/', '/usr/local/bin', '/tmp');
-my ($g, $dg) =  ( 0,   q{Y});
-
-my $check = eval
-{
-  require Bio::GeneDesign::ConfigData;
-};
-if ($check)
-{
-  $dcpath = Bio::GeneDesign::ConfigData->config('conf_path')        || $dcpath;
-  $dtpath = Bio::GeneDesign::ConfigData->config('tmp_path')         || $dtpath;
-  $dspath = Bio::GeneDesign::ConfigData->config('script_path')      || $dspath;
-  $dg =     Bio::GeneDesign::ConfigData->config('graphing_support') eq 'y' ? 'y' : 'n';
-}
+my ($cpath,  $spath,  $tpath, $g) =  (undef, undef, undef, undef);
 
 my $GDB = Module::Build->new
 (
-    module_name         => 'Bio::GeneDesign',
-    license             => 'bsd',
-    dist_author         => q{Sarah Richardson <SMRichardson@lbl.gov>},
-    dist_version        => '5.53',
-    dist_abstract       => 'Functions for the design of synthetic genes',
-    add_to_cleanup      => [ 'Bio::GeneDesign-*' ],
-    create_makefile_pl  => 'traditional',
-    build_requires      =>
+  module_name         => 'Bio::GeneDesign',
+  license             => 'bsd',
+  dist_author         => q{Sarah Richardson <SMRichardson@lbl.gov>},
+  dist_version        => '5.6',
+  dist_abstract       => 'Functions for the design of synthetic genes',
+  add_to_cleanup      => [ 'Bio::GeneDesign-*' ],
+  create_makefile_pl  => 'traditional',
+  build_requires      =>
+  {
+    'Test::More'      => 0.8,
+    'Test::Deep'      => 0.1,
+  },
+  requires            =>
+  {
+    'perl'                => 5.006,
+    'List::Util'          => 1.22,
+    'Math::Combinatorics' => 0.09,
+    'Text::Wrap'          => 2009.0305,
+    'Bio::Root::Root'     => 0
+  },
+  configure_requires  =>
+  {
+    'Module::Build'     => 0.38
+  },
+  auto_features       =>
+  {
+    graphing =>
     {
-        'Test::More'      => 0.8,
-        'Test::Deep'      => 0.1,
+      description => 'Use GD::Graphics to draw graphs',
+      requires    =>
+      {
+        'GD::Graph::lines'  => 1.15,
+        'GD::Graph::colour' => 1.10,
+        'GD::Image'         => 0
+      }
     },
-    requires            =>
+  },
+  script_files =>
+  [
+    'bin/GD_Filter_Enzymes.pl',
+    'bin/GD_Generate_RSCU_Table.pl',
+    'bin/GD_Graph_Dotplot.pl',
+    'bin/GD_Graph_RSCU_Values.pl',
+    'bin/GD_Juggle_Codons.pl',
+    'bin/GD_List_Codon_Tables.pl',
+    'bin/GD_Repeat_Smash.pl',
+    'bin/GD_Reverse_Translate.pl',
+    'bin/GD_Sequence_Subtraction.pl',
+  ],
+  get_options =>
+  {
+    like_last_time =>
     {
-        'perl'                => 5.006,
-        'List::Util'          => 1.22,
-        'Math::Combinatorics' => 0.09,
-        'Text::Wrap'          => 2009.0305,
-        'Bio::Root::Root'     => 0
+      store => \$llt,
+      default => 0,
     },
-    configure_requires  =>
+    conf_path =>
     {
-      'Module::Build'     => 0.38
+      store => \$cpath,
+      type => '=s',
     },
-    auto_features       =>
+    script_path =>
     {
-      graphing =>
-      {
-        description => 'Use GD::Graphics to draw graphs',
-        requires    =>
-        {
-          'GD::Graph::lines'  => 1.15,
-          'GD::Graph::colour' => 1.10,
-          'GD::Image'         => 0
-        }
-      },
+      store => \$spath,
+      type => '=s',
     },
-    script_files =>
-    [
-      'bin/GD_Filter_Enzymes.pl',
-      'bin/GD_Generate_RSCU_Table.pl',
-      'bin/GD_Graph_Dotplot.pl',
-      'bin/GD_Juggle_Codons.pl',
-      'bin/GD_List_Codon_Tables.pl',
-      'bin/GD_Reverse_Translate.pl',
-      'bin/GD_Repeat_Smash.pl',
-      'bin/GD_Sequence_Subtraction.pl',
-      'bin/GD_Graph_RSCU_Values.pl'
-    ],
-    get_options =>
+    tmp_path =>
     {
-      like_last_time =>
-      {
-        store => \$llt,
-        default => 0,
-      },
-      conf_path =>
-      {
-        store => \$cpath,
-        type => '=s',
-      },
-      script_path =>
-      {
-        store => \$spath,
-        type => '=s',
-      },
-      tmp_path =>
-      {
-        store => \$tpath,
-        type => '=s',
-      },
-      graphing_support =>
-      {
-        store => \$g,
-        type => '=s',
-      },
-    }
+      store => \$tpath,
+      type => '=s',
+    },
+    graphing_support =>
+    {
+      store => \$g,
+      type => '=i',
+    },
+  }
 );
 
+#  STUPID y_n TAKES y/n only as inputs BUT OUTPUTS 1/0!!!!!! AAAGHHGHGHGHGHGG  #
+my @on = ('Y', 1);
+my @off = ('N', 0);
+
+my ($dcpath, $dspath, $dtpath) = ('/etc/GeneDesign/', '/usr/local/bin/', '/tmp/');
+my ($dg, $lg) =  @on;
+
+my $check = eval
+{
+  require Bio::GeneDesign::ConfigData;
+};
+if ($check)
+{
+  $dcpath = Bio::GeneDesign::ConfigData->config('conf_path')        || $dcpath;
+  $dtpath = Bio::GeneDesign::ConfigData->config('tmp_path')         || $dtpath;
+  $dspath = Bio::GeneDesign::ConfigData->config('script_path')      || $dspath;
+  ($dg, $lg) = Bio::GeneDesign::ConfigData->config('graphing_support') ? @on : @off;
+}
+
+#If we're not using the like_last_time shortcut, prompt for anything that wasn't
+# provided on the command line
 if ($llt == 0)
 {
-  if (! $cpath)
+  if (! defined $cpath)
   {
     $cpath = $GDB->prompt('Where should configuration files be installed?', $dcpath);
   }
-  if (! $spath)
+  if (! defined $spath)
   {
     $spath = $GDB->prompt('Where should scripts be installed?', $dspath);
   }
-  if (! $tpath)
+  if (! defined $tpath)
   {
     $tpath = $GDB->prompt('Where should GeneDesign write tmp files?', $dtpath);
   }
-  if (! $g && $GDB->feature('graphing'))
+  if (! defined $g && $GDB->feature('graphing'))
   {
     $g = $GDB->y_n('Enable GD::Graphics support?', $dg);
   }
 }
+#If we are using the like_last_time shortcut, use the defaults if something
+# happens to not be defined.
 else
 {
-  $cpath = $cpath || $dcpath;
-  $tpath = $tpath || $dtpath;
-  $spath = $spath || $dspath;
-  $g = $g || $dg;
+  $cpath = defined $cpath ? $cpath : $dcpath;
+  $tpath = defined $tpath ? $tpath : $dtpath;
+  $spath = defined $spath ? $spath : $dspath;
+  $g = defined $g ? $g : $lg;
 }
 
-$GDB->config_data(conf_path => $cpath);
-$GDB->config_data(tmp_path => $tpath);
-$GDB->config_data(script_path => $spath);
-$GDB->config_data(graphing_support => $g) if ($GDB->feature('graphing'));
 
 #Prepare configuration directory
-my $tcp = $GDB->config_data('conf_path');
-$GDB->config_data(conf_path => $tcp);
+$GDB->config_data(conf_path => $cpath);
+print 'Configuration files will be in ', $GDB->config_data('conf_path'), "\n";
 my $confs =
 [
   'codon_tables/Arabidopsis_thaliana.rscu',
 $GDB->add_build_element('GeneDesign');
 process_conf_files($GDB, $confs);
 $GDB->install_path(GeneDesign => $GDB->config_data('conf_path'));
-print 'Configuration files will be in ', $GDB->config_data('conf_path'), "\n";
 
+
+$GDB->config_data(script_path => $spath);
 $GDB->install_path(script => $GDB->config_data('script_path'));
 print 'Scripts will be in ', $GDB->config_data('script_path'), "\n";
 
+$GDB->config_data(tmp_path => $tpath);
 print 'Temporary files will be written to ', $GDB->config_data('tmp_path'), "\n";
 
+$GDB->config_data(graphing_support => $g) if ($GDB->feature('graphing'));
 print "\n";
 
 $GDB->create_build_script();