# 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::HavanaAdder - imports global variables used by EnsEMBL gene building

=head1 SYNOPSIS
    use Bio::EnsEMBL::Analysis::Config::HavanaAdder;
    use Bio::EnsEMBL::Analysis::Config::HavanaAdder qw(  );

=head1 DESCRIPTION

 HavanaAdder is based on Genebuilder.

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

The variables can also be references to arrays or hashes.

Edit C<%HavanaAdder> 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::HavanaAdder;

use strict;
use vars qw( %GeneBuilder );

# Hash containing config info
%GeneBuilder = (
  ##################
  # INPUT BIOTYPES #
  ##################
  # CODING
  #
  # Biotype of Ensembl Coding Genes and transcripts
  GB_ENSEMBL_INPUT_GENETYPE => ['protein_coding'],

  # Biotype of Havana Coding Genes and transcripts
  # NOTE! We don't want the IG genes in here!
  GB_HAVANA_INPUT_GENETYPE =>
    [ 'protein_coding', 'polymorphic_pseudogene', 'nonsense_mediated_decay' ],

  # Biotype of Havana transcripts
  #GB_HAVANA_INPUT_TRANSCRIPTTYPES => ['protein_coding'],

  #Processed transcripts
  #
  # Biotype of "processed transcripts" in Ensembl and transcripts
  GB_ENSEMBL_PROCESSED_GENETYPE => ['processed_transcript'],
  # Biotype of "processed transcripts" genes  and transcripts in Havana
  GB_HAVANA_PROCESSED_GENETYPE => [ 'processed_transcript', 'ambiguous_orf',
                                    'non_coding',           'artifact',
                                    'retained_intron',      'antisense'
  ],

  # PSEUDOGENES
  #
  # Biotype of Ensembl PseudoGenes and pseudotranscripts
  GB_ENSEMBL_PSEUDO_GENETYPE => [ 'pseudogene', 'retrotransposed' ],
  # Biotype of Havana Pseudogenes and pseudotranscripts
  GB_HAVANA_PSEUDO_GENETYPE => [ 'pseudogene',
                                 'IG_pseudogene',
                                 'processed_pseudogene',
                                 'transcribed_pseudogene',
                                 'transcribed_processed_pseudogene',
                                 'transcribed_unprocessed_pseudogene',
                                 'unitary_pseudogene',
                                 'unprocessed_pseudogene'
  ],

  ##################
  # OUTPUT BIOTYPES#
  ##################
# Here you select the suffix that you want to be added to the biotype of your genes and transcripts
# Genes with Havana transcripts only
  HAVANA_GENE_OUTPUT_BIOTYPE => '_Hav',

  # Genes with Havana and Ensembl transcripts
  MERGED_GENE_OUTPUT_BIOTYPE => '_Ens_Hav',

  # Genes with Ensembl transcripts only
  ENSEMBL_GENE_OUTPUT_BIOTYPE => '_Ens',

  # Output Biotype for merged transcripts
  MERGED_TRANSCRIPT_OUTPUT_TYPE => '_merged',

  ###############
  # LOGIC NAMES #
  ###############
  # For the Havana_merge update, leave the default values if
  # running the Merge for the first time
  # Beware the transcript logic_name in the havana database
  # have to be different that the logic_name of the
  # havana transcripts in the ensembl database
  HAVANA_LOGIC_NAME            => 'havana',
  MERGED_GENE_LOGIC_NAME       => 'ensembl_havana_gene',
  MERGED_TRANSCRIPT_LOGIC_NAME => 'ensembl_havana_transcript',

);

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


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

1;
