#!/usr/bin/perl -w

=pod

=head1  NAME
run_mitoprot.pl
 
=head1  SYNOPSIS

run_mitoprot.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	
	--delta string, value between 0 and 1. Discriminant for the score comparison. (0.5 per default)
	--execommand string, the command to execute with global path to the command	
		

=head1 DESCRIPTION

run_mitoprot.pl - This program is part of a pipeline of programs for SNP annotation.
				It uses a program called mitoprot and predicts proteins with signaling to the mitochondria
				http://ihg.gsf.de/ihg/mitoprot.html which analyse sequences, 1 sequence per file.
				if the 2 alleles of a protein show a different signal then there is loss or gain of signal.
				if protein with allele1 has a prediction and protein with allele2 doesn't, then there is loss of signal.
				if protein with allele2 has a prediction and protein with allele1 doesn't, then there is gain of signal.
				Moreover, the delta of the score between allele1 and 2 is measured. If the delta is > to the delta set by
				the user, then loss? or gain? are retrieved.


=head1 VERSION

Version 1

=head1 DATE

27/02/2012

=head1 AUTHORS

Sabrina Rodriguez

=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 runmitoprot;
use Getopt::Long;
use Pod::Usage;


#~ perl /usr/local/bioinfo/src/ergatisdev/current/bin/AnnotationPipelines/bin/run_mitoprot.pl --infile /home/sigenae/work/Sabrina/fic/res/list_snps_coded6_1.fasta  --outpath /home/sigenae/work/Sabrina/fic/test --execommand /usr/local/bioinfo/src/mitoprot/mitoprotII-v1.101/mitoprot --delta 0.5 --encodingfile /home/sigenae/work/Sabrina/fic/saved_names.txt --workpath /home/sigenae/work/Sabrina/fic/WORK

#~ perl /usr/local/bioinfo/src/ergatisdev/current/bin/AnnotationPipelines/bin/run_mitoprot.pl --infile /home/sigenae/work/Sabrina/horse_outputs/horse.fasta  --outpath /home/sigenae/work/Sabrina/horse_outputs/mitoprot --execommand /usr/local/bioinfo/src/mitoprot/mitoprotII-v1.101/mitoprot --delta 0.5 --encodingfile /home/sigenae/work/Sabrina/horse_outputs/names_encoding.txt --workpath /home/sigenae/work/Sabrina/horse_outputs/mitoprot

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

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

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

my $outpath = $options{'outpath'};
my $workpath = $options{'workpath'};
my $infile = $options{'infile'};
my $execommand = $options{'execommand'};
my $delta = $options{'delta'};
my $encodingfile = $options{'encodingfile'};

runmitoprot($delta,$workpath,$outpath,$infile,$execommand,$encodingfile);






























