Bio-App-SELEX-RNAmotifAnalysis
view release on metacpan or search on metacpan
lib/Bio/App/SELEX/RNAmotifAnalysis.pm view on Meta::CPAN
#!/usr/bin/env perl
package Bio::App::SELEX::RNAmotifAnalysis;
# ABSTRACT: Cluster SELEX sequences and calculate their structures
use 5.008;
use strict;
use warnings;
use Text::LevenshteinXS qw( distance );
use Config::Tiny;
use autodie;
use Hash::Util qw( lock_keys );
use List::Util qw( min );
use Getopt::Long;
use Carp qw( croak confess);
my $DEFAULT_CONFIG = 'cluster.cfg';
# CONSTANTS
my $TRUE = 1;
my $FALSE = 0;
my $SPACE = q{ };
my $EMPTY_STRING = q{};
my $VERBOSE = 1;
my $FASTQ_TYPE = 'fastq';
my $SIMPLE_TYPE = 'simple';
# Act like a script if called as one
unless ( caller() ) { main(); }
sub main {
my $max_clusters = 10;
my $num_cpus = 5;
my $max_distance = 5;
my $max_top_seqs = 300;
my $config_filename = $DEFAULT_CONFIG;
my $options = GetOptions(
# Required (one of these)
"$FASTQ_TYPE=s" => \my $fastq,
"$SIMPLE_TYPE=s" => \my $simple,
# Optional
'max_distance=i' => \$max_distance,
'max_clusters=i' => \$max_clusters,
'max_top_seqs=i' => \$max_top_seqs,
'seed=s' => \my $seed_filename,
'cpus=i' => \$num_cpus,
'config=s' => \$config_filename,
'run' => \my $run_scripts,
);
my $file_type;
my $infile;
if(defined $fastq){
if(defined $simple){
warn "--$FASTQ_TYPE and --$SIMPLE_TYPE flags are mutually exclusive!\n";
help();
}
$infile = $fastq;
$file_type = $FASTQ_TYPE;
}elsif(defined $simple){
$infile = $simple;
$file_type = $SIMPLE_TYPE;
}else{
warn "either --$FASTQ_TYPE or --$SIMPLE_TYPE must be used!\n";
help();
}
# Eliminate case sensitivity for 'type'
$file_type = lc $file_type;
my $config = get_config($config_filename);
open( my $fh_in, '<', $infile );
my $seed_fh;
if ( defined $seed_filename && -e $seed_filename ) {
open( $seed_fh, '<', $seed_filename );
}
my ($cluster_href, $distance_href) = cluster(
fh => $fh_in,
max_distance => $max_distance,
max_clusters => $max_clusters,
seed_fh => $seed_fh,
file_type => $file_type,
);
( run in 1.431 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )