Bio-App-SELEX-RNAmotifAnalysis

 view release on metacpan or  search on metacpan

lib/Bio/App/SELEX/selex_covarianceSearch  view on Meta::CPAN

#!/usr/bin/env perl

# ABSTRACT:

#=============================================================================
# STANDARD MODULES AND PRAGMAS
use 5.008;       # Require at least Perl version 5.08
use strict;      # Must declare all variables before using them
use warnings;    # Emit helpful warnings
use autodie;     # Fatal exceptions for common unrecoverable errors (e.g. open)
use Carp qw( croak );    # Throw errors from calling function

#=============================================================================
# ADDITIONAL MODULES
use Getopt::Long::Descriptive; # Parse @ARGV as command line flags and arguments
use lib 'lib';
use Bio::App::SELEX::RNAmotifAnalysis;

#=============================================================================
# CONSTANTS

my $TRUE  = 1;
my $FALSE = 0;

my $DEFAULT_ITERATIONS = 10;
my $DEFAULT_CONFIG     = 'cluster.cfg';
my $AWK_CMD            = '$1!~/^#/{print $2}';

my @REQUIRED_FLAGS = qw( cm fasta sto );

# CONSTANTS
#=============================================================================

#=============================================================================
# COMMAND LINE

# Run as a command-line program if not used as a module
main(@ARGV) if !caller();

sub main {

    #-------------------------------------------------------------------------
    # COMMAND LINE INTERFACE                                                 #
    #                                                                        #
    my ( $opt, $usage ) = describe_options(
        '%c %o <some-arg>',
        [ 'cm=s',     'file name for the input covariance model (required)', ],
        [ 'fasta=s',  'file name for the FASTA file (required)',             ],
        [ 'sto=s',    'file name for the Stockholm file (required)',         ],
        [ 'rounds=i', 'Rounds of covariance model searching (default=10)',   ],
        [ 'config=s', 'Configuration file (default="cluster.cfg")',          ],
        [],
        [ 'help', 'print usage message and exit'                             ],
    );

    my $exit_with_usage = sub {
        print "\nUSAGE:\n";
        print $usage->text();
        exit();
    };

    # If requested, give usage information regardless of other options
    $exit_with_usage->() if $opt->help;

    # Make some flags required
    my $missing_required = $FALSE;
    for my $flag (@REQUIRED_FLAGS) {
        if ( !defined $opt->$flag ) {
            print "Missing required option '$flag'\n";
            $missing_required = $TRUE;
        }
    }

    # Exit with usage statement if any required flags are missing
    $exit_with_usage->() if $missing_required;

    #                                                                        #
    # COMMAND LINE INTERFACE                                                 #
    #-------------------------------------------------------------------------

    #-------------------------------------------------------------------------
    #                                                                        #
    #                                                                        #

    my $config_file = $opt->config || $DEFAULT_CONFIG;
    my $config      = Bio::App::SELEX::RNAmotifAnalysis::get_config($config_file);

    process(
        {
            cm     => $opt->cm,
            fasta  => $opt->fasta,
            sto    => $opt->sto,
            rounds => $opt->rounds || $DEFAULT_ITERATIONS,
            config => $config,
        },
    );

    return;



( run in 1.280 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )