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

=head1 SYNOPSIS

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

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

=head1 CONTACT

=cut

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

use strict;
use vars qw(%Config);

# Hash containing config info
%Config = (
           UTR_BUILDER_CONFIG_BY_LOGIC => {
             DEFAULT => {
	
                #DATABASES
                  INPUT_DB   =>'GENEWISE_DB',      # db with genes which have NO utr
                  OUTPUT_DB  =>'UTR_DB',           # write processed genes to this DB

                  # From which databases should we get the additional data from?
                  # each key points to a hash-key in Analysis/Config/GeneBuild/Databases.pm
                  # set to '' if not applicaple

                  CDNA_DB    => ['EXONERATE_DB'],    # dbs with cDNA's
                  EST_DB     => 'EST_CDNA_DB',     # db with est's
                  DITAG_DB   => 'DITAG_DB',        # db where ditags are stored
                  BLESSED_DB => 'BLESSED_DB' ,     # db with blessed genes

	       #INPUT GENETYPES
	          # targetted, similarity and other input gene-types
	          # format: ['exonerate_genes', 'other_great_genes']
	          INPUT_GENETYPES      => ['Similarity_gw', 'Targetted_gw'],

	          # input genes that need to go through without change of CDS (like CCDS genes)
	          BLESSED_GENETYPES    => ['ccds_gene'],

	          # input gene type for cDNAs aligned with exonerate & est2genome
	          cDNA_GENETYPE        => ['cDNA_update'],

	          # input gene type for ESTs aligned with exonerate & est2genome
	          EST_GENETYPE         => 'est_exonerate',

	       #OUTPUT GENETYPES
                  # decide if you like to keep the original biotype and extend it with 
                  # UTR_GENETYPE, rather than replacing the biotype 
                  EXTEND_ORIGINAL_BIOTYPE => 1,

	          # biotype  for UTR_Builder output genes
	          UTR_GENETYPE         => 'UTR_Analysis',

	          # biotype for UTR_Builder output genes using "known cdnas"
	          KNOWN_UTR_GENETYPE   => 'known_UTR_Analysis',

	          # biotype for blessed UTR_Builder output genes
	          BLESSED_UTR_GENETYPE => 'Blessed_UTR_Genes',

	          # the biotype of all genes where no UTR has been added will be
                  # extended to $biotype .= EXTEND_BIOTYPE_OF_UNCHANGED_GENES
                  # if you add a string in here.
                  EXTEND_BIOTYPE_OF_UNCHANGED_GENES => "_Analysis",

	       #OTHER PARAMETERS
	          # don't allow introns longer than this - transcripts are split
	          MAX_INTRON_LENGTH    => 200000,

                  MAX_EXON_LENGTH      => 20000,

	          #prune genes during filtering if desired (not recommended)
	          PRUNE_GENES          => 0,

	          #filtering the ESTs like the cDNAs; removes most, but is cleaner
	          FILTER_ESTS          => 0,

	          #try to find predefined pairing (between protein & cDNA) as the first step
	          LOOK_FOR_KNOWN       => 0,
		  KNOWNUTR_FILE        => '/tmp/human.protein.gpff',

                  # Ditags can be use ditags to add additional weights on alternative models
	          # format: ['SHC012', 'SHC013'],
	          DITAG_TYPE_NAMES     => [],

                  # size of window (basepairs)in which ditags are considered for a given cDNA position.
                  DITAG_WINDOW         => 30,

                  #output verbosity
	          VERBOSE              => 1,
             },


	     #define different sets of analysis if you need to
             UTR_Builder => {},

           }
          );


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
    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;
