#!/usr/bin/perl
#--------------------------------------------------
# Predict secondary structure and solvent
# accessibility from sequece
#
# Author: hoenigschmid@rostlab.org
#-------------------------------------------------- 
use strict;
use warnings;
use Carp;
use Getopt::Long;
use Cwd;
use Pod::Usage;

use RG::Reprof;

# popularity contest
if( system('pp_popcon_cnt', '-p', 'reprof') == -1 ){ warn("The Rost Lab recommends you install the pp-popularity-contest package that provides pp_popcon_cnt:\n\nsudo apt-get install pp-popularity-contest\n"); }

# Parameters
my $input_file;
my $out_file;
my $mutation_file;
my %specific_models;
my $model_dir = "__pkgdatadir__";
if (! -e $model_dir) {
    $model_dir = "/mnt/project/reprof/share/";
}

GetOptions(
    "input=s"       => \$input_file,
    "out=s"         => \$out_file,
    "modeldir=s"    => \$model_dir,
    "mutations=s"   => \$mutation_file,
    "spec=s"        => \%specific_models,
);

# Check if either blastPsiMat or fasta file is present
if( !defined $input_file || !-e $input_file ){ pod2usage(-verbose => 1); }

my $reprof = RG::Reprof::Reprof->new( model_dir => $model_dir );
my $ret = $reprof->run( input_file => $input_file, out_file => $out_file, mutation_file => $mutation_file, specific_models => \%specific_models );
exit $ret;

__END__

=head1 NAME

reprof - predict protein secondary structure and solvent accessibility

=head1 SYNOPSIS

reprof -i [query.blastPsiMat] [OPTIONS]

reprof -i [query.fasta] [OPTIONS]

reprof -i [query.blastPsiMat|query.fasta] --mutations [mutations.txt] [OPTIONS]

=head1 DESCRIPTION

Predict protein secondary structure and solvent accessibility.

=head2 Output Format

The output format is self-explanatory, i.e. the colums of the output are described in the output file itself.

=head1 OPTIONS

=over

=item B<-i, --input>=I<FILE>

Input BLAST PSSM matrix file (from Blast -Q option) or input (single) FASTA file.

=item B<-o, --out>=I<FILE>

Either an output file or a directory. If not provided or a directory, the suffix of the input filename (i.e. .fasta or .blastPsiMat) is replaced to create an output filename.

=item B<--mutations>=I<[all|FILE]>

Either the keyword "all" to predict all possible mutations or a file containing mutations one per line such as "C12M" for C is mutated to M on position 12:

 C30Y
 R31W
 G48D

This mutation code is also attached to the output filename using "_".
An additional file ending "_ORI" contains the prediction using no evolutionary information even if a BLAST PSSM matrix was provided.

=item B<--modeldir>=I<DIR>

Directory where the model and feature files are stored.  Default: F<__pkgdatadir__>.

=back

=head1 AUTHOR

Peter Hoenigschmid L<hoenigschmid@rostlab.org>, Burkhard Rost

=head1 EXAMPLES

=over

=item Prediction from BLAST PSSM matrix for best results:

 reprof -i __docdir__/examples/example.Q -o /tmp/example.Q.reprof

=item Prediction from FASTA file:

 reprof -i __docdir__/examples/example.fasta -o /tmp/example.fasta.reprof

=item Prediction from BLAST PSSM matrix file using the mutation mode:

 reprof -i __docdir__/examples/example.Q -o /tmp/mutations_example.Q.reprof --mutations __docdir__/examples/mutations.txt
 # Result files for the above call are going to be:
 # /tmp/mutations_example.Q.{reprof,reprof_F172P,reprof_M1Q,reprof_N34Y,reprof_ORI} - see --mutations for a description of the extensions.

=back

=head1 COPYRIGHT

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.

=head1 BUGS

https://rostlab.org/bugzilla3/enter_bug.cgi?product=reprof

=head1 SEE ALSO

blast2(1)

http://rostlab.org/

=cut
