# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

Bio::EnsEMBL::Pipeline::Config::ProteinAnnotation 
    - imports global variables used by EnsEMBL protein annotation

=head1 SYNOPSIS
    use Bio::EnsEMBL::Pipeline::Config::ProteinAnnotation;

=head1 DESCRIPTION

General is a pure ripoff of humConf written by James Gilbert.

humConf is based upon ideas from the standard perl Env environment
module.

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 decalared 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<%ProteinAnnotation> hash is asked to be set.

The variables can also be references to arrays or hashes.

Edit C<%Proteinannotation> to add or alter variables.

All the variables are in capitals, so that they resemble environment
variables.

=head1 CONTACT

=cut


package Bio::EnsEMBL::Analysis::Config::ProteinAnnotation;

use strict;
use vars qw( %ProteinAnnotation );

# Hash containing config info
%ProteinAnnotation = (

   PROTEINANNOTATION_CONFIG_BY_LOGIC => {

     DEFAULT => {
       # connection details for database from which genes will
       # be fetched and results written to. Leave undefined
       # if genes are in pipeline database
       GENEDB => undef, 
       # if you don't have DNA in your pipeline- or GENEDB, you have to add a DNA_DB 
       # otherwise the proteins won't get dumped for analysis which run on translation_ids 
       DNA_DB => undef,
       # most analyses are chunks, so default to chunk dir
       BASE_DIR      => '/directory/containing/chunks',
     },

     Seg => {
       # only specify DIR where the file with all translations lives - 
       # Seg get's the filename out of table input_id_analysis.input_id 
       BASE_DIR      => '/directory/containing/proteme/directory',
     },
     Signalp => {
     },
     Ncoils => {
     },
     Tmhmm => {
     },
     Prints => {
     },
     scanprosite => {
     },
     pfscan => {
     },
     Pfam => {
     },
     Tigrfam => {
     },
     Superfamily => {
     },
     Smart => {
     },
     PIRSF => {
     },
   }                      
);

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
  # all of General:
  my @vars = @_ ? @_ : keys( %ProteinAnnotation );
  return unless @vars;
  
  # Predeclare global variables in calling package
  eval "package $callpack; use vars qw("
    . join(' ', map { '$'.$_ } @vars) . ")";
    die $@ if $@;


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

1;
