#!/usr/bin/perl -w

=pod

=head1  NAME
extract_disorder_results.pl
 
=head1  SYNOPSIS

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

=head1  OPTIONS

  --infile string, the path to the protein sequence query file - !!!the sequence name should be the short name!!!
  --encodingfile string, the path of the file containing the encoded protein names (long name "..._allele1" <-> short name "_seq")
  --workpath string, the path to the existing working directory
  --outpath string, the path to the existing output directory that will contain the result file
  --param string, 8 8 4 1.2 1.4 1.2 (default)
  --execommand string, the command to execute with global path to the command

=head1 DESCRIPTION

extract_disorder_results.pl This program is part of a pipeline of programs for SNP annotation.
		It uses a program called DisEMBL and calculate intrinseq disorder in proteins: http://dis.embl.de/html/download.html
		if a difference exists between allele 1 and allele 2, this program done disorder indication
		
=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 runDisorder;

#~ perl extract_disorder_results.pl --infile /home/rlegendre/work/Module-SNP/protseq_horse/protNseq/list_snps_coded3000_1.fasta --encodingfile /home/rlegendre/work/Module-SNP/protseq_horse/names_encoding.txt --workpath /home/rlegendre/work/Module-SNP/Disorder --execommand /home/rlegendre/work/Module-SNP/DisEMBL.py --outpath /home/rlegendre/work/Module-SNP/Disorder

#perl /usr/local/bioinfo/src/ergatisdev/current/bin/AnnotationPipelines/bin/extract_disorder_results.pl --infile /work/sigenae/vmergatisdev/output_repository/SR_formatSNPeffect-protseq/71_default/seq_fastas_Nseq_Prot-min-size/SNP_proteins_encoded50_1.fasta --encodingfile /work/sigenae/vmergatisdev/output_repository/SR_formatSNPeffect-protseq/71_default/names_encoding.txt --workpath /home/sigenae/work/Sabrina/test_disembl --execommand /usr/local/bioinfo/src/DisEMBL/current/DisEMBL.py --outpath /home/sigenae/work/Sabrina/test_disembl/results

#~ perl /usr/local/bioinfo/src/ergatisdev/current/bin/AnnotationPipelines/bin/extract_disorder_results.pl --infile /home/sigenae/work/Sabrina/horse_outputs/horse.fasta --encodingfile /home/sigenae/work/Sabrina/horse_outputs/names_encoding.txt --workpath /home/sigenae/work/Sabrina/horse_outputs/disembl --execommand /usr/local/bioinfo/src/DisEMBL/current/DisEMBL.py --outpath /home/sigenae/work/Sabrina/horse_outputs/disembl

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

my @getopt_args = (
                    '-infile=s'  ,
                    '-encodingfile=s'  ,
                    '-workpath=s'  ,    
                    #~ '-param=s',
                    '-execommand=s',
                    '-outpath=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{'encodingfile'} );
usage() if ( !exists $options{'workpath'} );
usage() if ( !exists $options{'execommand'} );
usage() if ( !exists $options{'outpath'} );
#~ usage() if ( !exists $options{'param'} );

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

my $encodingfile = $options{'encodingfile'};
my $infile = $options{'infile'};
my $workpath = $options{'workpath'};
my $execommand = $options{'execommand'};
my $param = "8 8 4 1.2 1.4 1.2" ;
my $outpath = $options{'outpath'};

disorder_extract_result($workpath, $outpath, $infile, $execommand, $encodingfile, $param);



