#
# package Bio::EnsEMBL::Analysis::Config::GeneBuild::BlastMiniGenewise
# 
# Cared for by EnsEMBL (ensembl-dev@ebi.ac.uk)
#
# Copyright GRL & EBI
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

Bio::EnsEMBL::Analysis::Config::GeneBuild::GeneBuilder

=head1 SYNOPSIS

    use Bio::EnsEMBL::Analysis::Config::GeneBuild::GeneBuilder;

=head1 DESCRIPTION

It imports and sets a number of standard global variables into the
calling package, which are used in many scripts in the human sequence
analysis system.  The variables are first declared using "use vars",
so that it can be used when "use strict" is in use in the calling
script.  Without arguments all the standard variables are set, and
with a list, only those variables whose names are provided are set.
The module will die if a variable which doesn\'t appear in its
C<%Config> hash is asked to be set.

Since The RunnableDB that this config controls how the genebuilder process is run and 
now several instances of the genebuilder can be run in the same pipeline this Config 
contains one primary config variable GENEBUILDER_CONFIG_BY_LOGIC. This is hash keyed 
off logic name, each entry of which is a hash containing the variable that affect the 
behaviour of the RunnableDB. When the RunnableDB instance is created, the correct 
entry is identified by logic name and value for a corresponding set of local variables 
are set.

=head1 CONTACT

=cut


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

use strict;
use vars qw( %Config );

# Hash containing config info
%Config = (

           GENEBUILDER_CONFIG_BY_LOGIC => 
           {
            DEFAULT => {
                        INPUT_GENES => { 
                                        UTR_DB => ['similarity', 'BestTargetted', 
                                                   'ccds_gene', 'UTR_Genes', 
                                                   'Blessed_UTR_Genes'],
                                       },
                        OUTPUT_DB => 'GENEBUILD_DB',
                        OUTPUT_BIOTYPE => 'ensembl',
                        MAX_TRANSCRIPTS_PER_CLUSTER => 10,
                        MIN_SHORT_INTRON_LEN => 7, #introns shorter than this seem
                        #to be real frame shifts and shoudn't be ignored
                        MAX_SHORT_INTRON_LEN => 15,
                        BLESSED_BIOTYPES => {
                                             'ccds_gene' => 1,
                                             'Blessed_UTR_Genes' => 1,
                                            },
                        #the biotypes of the best genes always to be kept
                        MAX_EXON_LENGTH => 20000,
                       },
            ensembl => {},
            }
					);

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;
