#!/usr/bin/perl
# -----------------------------------------------------------------------------
# COEVOLUTION
# -----------------------------------------------------------------------------
# Author, date and more information (ABOUT)
# -----------------------------------------------------------------------------

#                                   #---#                                    #

# -----------------------------------------------------------------------------
# Loading modules                                                      Chap.  1
# -----------------------------------------------------------------------------
use Molevol::Complex;
use Getopt::Long;
$ENV{PAMLDIR} = "/Users/ihector/Desktop/paml44/bin/";
# -----------------------------------------------------------------------------
#                                                                            1.

#                                   #---#                                    #

# -----------------------------------------------------------------------------
# Variable initialization                                              Chap.  2
# -----------------------------------------------------------------------------
# Required:
    my $pdb;            #or  # 1a. A valid path to pdb file or
    my $contact_file;        # 1b. A valid contact file
    my $chain_alignment;     # 2. The chain alignment
    my $chain;               # 3. Chain to analyze
# Optional:
    my $pth;                 # 1. Proximity threshold (Angstroms)
    my $sth;                 # 2. Exposition threshold (ASA fraction)
    my $th_margin;           # 3. Exposition threshold margin
    my $spec_chains;         # 4. Chains to contact with
    my $informat;            # 5. Alignment format
    my $oformat;             # 6. Output format for sub-alignments
    my $gc;                  # 7. Genetic code
    my $ocontact;            # 8. Contact output data file
    
GetOptions (                  # Getting options from command line                  
    "pdb=s"              => \$pdb,                  # --pdb
    "alignment=s"        => \$chain_alignment,      # --alignment
    "proximityth=f"      => \$pth,                  # --proximityth
    "exposureth=f"       => \$sth,                  # --exposureth
    "chain=s"            => \$chain,                # --chain
    "exposuretherror=f"  => \$th_margin,            # --exposuretherror
    "contactfile=s"      => \$contact_file,         # --contactfile
    "contactwith=s"      => \$spec_chains,          # --contactwith
    "informat=s"         => \$informat,             # --informat
    "oformat=s"          => \$oformat,              # --oformat
    "gc=i"               => \$gc,                   # --gc
    "ocontact=s"         => \$ocontact              # --ocontact
);
# -----------------------------------------------------------------------------

# New object
my $coe = Molevol::Complex->new(
                                    pdb         => $pdb,
                                    contactfile => $contact_file,
                                    alignment   => $chain_alignment,
                                    chain       => $chain,
                                    pth         => $pth,
                                    sth         => $sth,
                                    sthmargin   => $th_margin,
                                    contactwith => $spec_chains,
                                    informat    => $informat,
                                    oformat     => $oformat,
                                    gc          => $gc,
                                    ocontact    => $ocontact
                                    );

# Run calcs
$coe->run;

# Report
open REP, ">/Users/ihector/Desktop/report.html";
print REP $coe->run_report;
close REP;
#system ("open /Users/ihector/Desktop/report.html");

