#
# 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::BlastMiniGenewise

=head1 SYNOPSIS

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

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

Since The RunnableDB that this config controls can be used to run genewise or 
exonerate alignments seeded by protein align features and several uses may be required
in the same pipeline this Config contains one primary config variable 
GENEWISE_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::BlastMiniGenewise;

use strict;
use vars qw( %Config );

# Hash containing config info
%Config = (

           GENEWISE_CONFIG_BY_LOGIC => 
           {
            DEFAULT =>
            {
                     MAKE_SIMGW_INPUT_ID_PARMAMS => {
                       # regex which should match the logic-name of your analysis you use to 
                       # create the simgw input_ids ( for MakeSimiliartyInputIDS runnable ) 
                       creation_analysis => 'create_',
                       # pattern - $1 should match the logic_name of the submission analysis for your BlastMiniGenewise runs 
                       submission_logic_name => "create_(.*)",
                       # pattern - $1 should match the name of your bmg -logic name 
                       bmg_logic_name =>"create_(.*)",
                       protein_count => 20,
                     },

             PAF_LOGICNAMES => [], #an array of logic names found in the 
             #protein align feature table,
             PAF_MIN_SCORE_THRESHOLD => 0,
             PAF_UPPER_SCORE_THRESHOLD => undef, 
             PAF_SOURCE_DB => 'REFERENCE_DB', 
             GENE_SOURCE_DB => 'GENEWISE_DB',
             OUTPUT_DB => 'GENEWISE_DB',
             OUTPUT_BIOTYPE => '',
             GENEWISE_PARAMETERS => {},
             MINIGENEWISE_PARAMETERS => {},
             MULTIMINIGENEWISE_PARAMETERS => {},
             BLASTMINIGENEWISE_PARAMETERS => {
                                              -fullseq => 1,
                                             },
             EXONERATE_PARAMETERS => {},
             #example exonerate parameters => {
             #                                 -options => '--model protein2genome 
             #                                              --bestn 1
             #                                              --maxintron 700000'
             #                                 }
             FILTER_OBJECT => 'Bio::EnsEMBL::Analysis::Tools::Filter::BlastMiniGenewise', 
             #path to object
             FILTER_PARAMS => {},
             BIOTYPES_TO_MASK => [], #empty means no masking
             #specified types will be masked,
             EXON_BASED_MASKING => 1,
             GENE_BASED_MASKING => 0,
             PRE_GENEWISE_MASK => 1,
             POST_GENEWISE_MASK => 1,
             REPEATMASKING => [],
             SOFTMASKING => 0,
             SEQFETCHER_OBJECT => 'Bio::EnsEMBL::Pipeline::SeqFetcher::OBDAIndexSeqFetcher',
             SEQFETCHER_PARAMS => {},
             USE_KILL_LIST => 1,
             LIMIT_TO_FEATURE_RANGE => undef,
             FEATURE_RANGE_PADDING => 0,
             WRITE_REJECTED => 0,
             REJECTED_BIOTYPE => 'rejected',
            }, 

            TargettedGenewise => 
            {
             PAF_LOGICNAMES => ['Best_Pmatch'],
             OUTPUT_BIOTYPE => ' targetted',
             GENEWISE_PARAMETERS => { 
                                     # pass parameters go genewise here, i.e. -program =>"/usr/local/ensembl/bin/genewiseXXX"
                                     # for more options which can be passed see Runnable/Genewise.pm 
                                     -endbias => 1,
                                     -matrix => 'BLOSUM80.bla',
                                     -gap => 20,
                                    -extension => 8,
                                    -splice_model => 0
                                    },
             MINIGENEWISE_PARAMETERS => {
                                         -terminal_padding => 20000,
                                         -exon_padding => 200,
                                         -minimum_intron => 1000,
                                        },
             MULTIMINIGENEWISE_PARAMETERS =>{
                                              -minimum_feature_length => 50,
                                            }, 
             FILTER_PARAMS => {
                               -max_exon_length => '20000',
                               -multi_exon_min_coverage => '25',
                               -single_exon_min_coverage => '80',
                               -max_intron_length => '200000',
                               -min_split_coverage => 95,
                               -max_low_complexity => 101,
                              },
             SEQFETCHER_PARAMS => {
                                   -db => ['/path/to/index/file/']
                                  },
             BLASTMINIGENEWISE_PARAMETERS => {},        
             LIMIT_TO_FEATURE_RANGE => 1,
             FEATURE_RANGE_PADDING => 20000,
            },
            Similarity => 
            {
             PAF_LOGICNAMES => ['Uniprot'],
             PAF_SOURCE_DB => 'REFERENCE_DB',
             OUTPUT_BIOTYPE => 'similarity',
             BIOTYPES_TO_MASK => ['targetted'],
             SEQFETCHER_PARAMS => {
                                   -db => ['/data/blastdb/Ensembl/uniprot_index']
                                  },
             PAF_MIN_SCORE_THRESHOLD => 200,
             FILTER_PARAMS => {
                               -max_exon_length => '20000',
                               -multi_exon_min_coverage => '70',
                               -single_exon_min_coverage => '90',
                               -max_intron_length => '100000',
                               -min_split_coverage => '90',
                               -max_low_complexity => '60',
                              },
             REPEATMASKING => ['RepeatMask'],
            },
            TargettedExonerate 
            => {
                PAF_LOGICNAMES => ['Best_Pmatch'], 
                OUTPUT_BIOTYPE => 'new_exonerate',
                EXONERATE_PARAMETERS => {
                                         -options => '--model protein2genome --bestn 1 --maxintron 700000'
                                        },
                FILTER_OBJECT => 'Bio::EnsEMBL::Analysis::Tools::Filter::BlastMiniGenewise', 
                #path to object
                FILTER_PARAMS => {
                                  -max_exon_length => '20000',
                                  -multi_exon_min_coverage => '25',
                                  -single_exon_min_coverage => '80',
                                  -max_intron_length => '700000',
                                  -min_split_coverage => 95,
                                  -max_low_complexity => 101,
                                 },
                BIOTYPES_TO_MASK => [], #empty means no masking
                #specified types will be masked,
                EXON_BASED_MASKING => 1,
                GENE_BASED_MASKING => 0,

                REPEATMASKING => [],
                SEQFETCHER_OBJECT => 'Bio::EnsEMBL::Pipeline::SeqFetcher::OBDAIndexSeqFetcher',
                SEQFETCHER_PARAMS =>{
                                     -db => ['/path/to/index/file']
                                    },
                USE_KILL_LIST => 1,
                LIMIT_TO_FEATURE_RANGE => 1,
                FEATURE_RANGE_PADDING => 1400000,
                WRITE_REJECTED => 0,
                REJECTED_BIOTYPE => 'rejected',
               },
           }
          );

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;
