#!/usr/bin/perl -w

=pod

=head1  NAME
extract_compara_results.pl
 
=head1  SYNOPSIS

extract_compara_results.pl -arg1 <> -arg2 <> -arg3 <> -arg4 <>

=head1  OPTIONS

  --infile string, the path to the vep query file 
  --outpath string, the path to the existing output directory that will contain the result file
  --registry string, path of the Ensembl core registry
  --species string, the specie which SNP were 
  --compara_user string, user to be used in API "compara_version" ex "Compara66"

=head1 DESCRIPTION

extract_compara_results.pl This program is part of a pipeline of programs for SNP annotation.
		It uses API Ensembl Compara for conservation SNP calculating
		its return conservation score for the amino acid involved in mutation
		
=head1 DATE

23/04/2012

=head1 AUTHORS

Legendre Rachel

=cut

use strict;

# find the absolute path to the local library
use FindBin;
# return the absolute path to the local library
use lib "$FindBin::RealBin/../lib";
#~ use lib '/usr/local/bioinfo/src/ergatisdev/current/bin/AnnotationPipelines/lib';

use Getopt::Long;
use Pod::Usage;
use formatAlleleSeq;
use conservation;


############################ OPTIONS / PARAMETERS ############################

my @getopt_args = (
                    '-infile=s',
                    '-species=s',
                    '-outpath=s',
                    '-registry=s',
                    '-compara_user=s'
                  );

my %options = ();

unless ( GetOptions( \%options, @getopt_args ) ) {
  usage();
}

sub usage {
  exec "pod2text $0";
  exit( 1 );
}

usage() if ( !exists $options{'infile'} );
usage() if ( !exists $options{'species'} );
#~ usage() if ( !exists $options{'workpath'} );
usage() if ( !exists $options{'outpath'} );
usage() if ( !exists $options{'registry'} );
usage() if ( !exists $options{'compara_user'} );

############################ PROGRAM ############################


my $infile = $options{'infile'};
my $species = $options{'species'};
#~ my $workpath = $options{'workpath'};
my $outpath = $options{'outpath'};
#~ my $registry_compara = $options{'registry_compara'};
my $registry_file = $options{'registry'};
my $compara_user = $options{'compara_user'};


getComparaScore($infile,$species,$outpath,$registry_file,$compara_user);

### perl extract_conservation_results.pl -infile  -species  -outpath /home/rlegendre/work/Module-SNP/Conservation -registry /usr/local/bioinfo/src/ensembl-api/variant_effect_predictor.registry

#~ perl /usr/local/bioinfo/src/ergatisdev/current/bin/AnnotationPipelines/bin/extract_conservation_results.pl --infile /work/sigenae/vmergatisdev/output_repository/SR_formatSNPeffect-protseq/116_default/vep_categories/NSC_file.vep --outpath /home/sigenae/work/Sabrina/TEST/ --registry /usr/local/bioinfo/src/ensembl-api/variant_effect_predictor.registry --species horse --compara_user Compara67

#~ perl /usr/local/bioinfo/src/ergatisdev/current/bin/AnnotationPipelines/bin/extract_conservation_results.pl --infile /work/sigenae/vmergatisdev/output_repository/SR_formatSNPeffect-protseq/148_default/vep_categories_NSC/NSC_file.vep --outpath /home/sigenae/work/Sabrina/TEST/ --registry /usr/local/bioinfo/src/ensembl-api/variant_effect_predictor.registry --species cow --compara_user Compara67

#~ perl /usr/local/bioinfo/src/ergatisdev/current/bin/AnnotationPipelines/bin/extract_conservation_results.pl --infile /home/sigenae/work/Sabrina/NSC_file.vep --outpath /home/sigenae/work/Sabrina/TEST/ --registry /usr/local/bioinfo/src/ensembl-api/variant_effect_predictor.registry --species cow --compara_user Compara67

