package Bio::EnsEMBL::Analysis::Config::GeneBuild::IncrementalBuild;

use strict;
use vars qw(%Config);



%Config = (
           INCREMENTAL_HASH => {
                                DEFAULT => 
                                {
                                 PRIMARY_BIOTYPES => [],
                                 SECONDARY_BIOTYPES => [],
                                 PRIMARY_DB => '',
                                 SECONDARY_DB => '',
                                 OUTPUT_DB => '',
                                 SECONDARY_FILTER => { 
                                                      OBJECT => '',
                                                      PARAMETERS => {},
                                                     },
                                 SECONDARY_PADDING => 0,
                                 PRE_FILTER => 0,
                                 POST_FILTER => 0,
                                 STORE_PRIMARY => 1,
                                 CALCULATE_TRANSLATION => 0,
                                 DISCARD_IF_NO_ORF => 0,
                                 NEW_BIOTYPE => '',
                                },
                               example_config => 
                                {
                                 PRIMARY_BIOTYPES => ['ensembl'],
                                 SECONDARY_BIOTYPES => ['cdna_exonerate'],
                                 PRIMARY_DB => 'GENEBUILD_DB',
                                 SECONDARY_DB => 'EXONERATE_DB',
                                 OUTPUT_DB => 'OUTPUT_DB',
                                 SECONDARY_FILTER => { 
                                                      OBJECT => '',
                                                      PARAMETERS => {},
                                                     },
                                 SECONDARY_PADDING => 0,
                                 PRE_FILTER => 0,
                                 POST_FILTER => 0,
                                 STORE_PRIMARY => 1,
                                 CALCULATE_TRANSLATION => 0,
                                 DISCARD_IF_NO_ORF => 0,
                                 NEW_BIOTYPE => 'cdnagene',
                                }
                               },
);

sub import {
  my ($callpack) = caller(0); # Name of the calling package
  my $pack = shift; # Need to move package off @_

  # Get list of variables supplied, or else everything
  my @vars = @_ ? @_ : keys( %Config );
  return unless @vars;
  
  # Predeclare global variables in calling package
  eval "package $callpack; use vars qw("
    . join(' ', map { '$'.$_ } @vars) . ")";
    die $@ if $@;


    foreach (@vars) {
	if ( defined $Config{$_} ) {
            no strict 'refs';
	    # Exporter does a similar job to the following
	    # statement, but for function names, not
	    # scalar variables:
	    *{"${callpack}::$_"} = \$Config{ $_ };
	} else {
	    die "Error: Config: $_ not known\n";
	}
    }
}

1;
