Bio-MUST-Apps-OmpaPa

 view release on metacpan or  search on metacpan

bin/ompa-pa.pl  view on Meta::CPAN

#!/usr/bin/env perl
# PODNAME: ompa-pa.pl
# ABSTRACT: Extract seqs from BLAST/HMMER interactively or in batch mode
# CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be>

use Modern::Perl '2011';
use autodie;

use Getopt::Euclid qw(:vars);
use Smart::Comments;

use IO::Prompter [
    -verbatim,
    -style => 'blue strong dark',
    -must  => { 'be a string' => qr{\S+}xms }
];

use Bio::MUST::Core;
use aliased 'Bio::MUST::Core::Ali::Stash';
use aliased 'Bio::MUST::Core::Taxonomy';
use aliased 'Bio::MUST::Core::Taxonomy::ColorScheme';
use aliased 'Bio::MUST::Apps::OmpaPa::Blast';
use aliased 'Bio::MUST::Apps::OmpaPa::Hmmer';

# TODO: re-implement BLAST parsing and nr extraction ; done?

# setup OmpaPa sub-class based on report type
my $class = $ARGV_report_type eq 'blastxml' ? Blast : Hmmer;

my $scheme;
if ($ARGV_taxdir) {
    my $tax = Taxonomy->new_from_cache( tax_dir => $ARGV_taxdir );
    $scheme = $ARGV_colorize ? $tax->load_color_scheme($ARGV_colorize)
            : ColorScheme->new(
                tax => $tax,
                names  => [ qw(Archaea Bacteria Eukaryota Viruses) ],
                colors => [ qw(   blue    green       red  orange) ],
            )
    ;
}

# build args hash for Bio::MUST::Apps::OmpaPa::XXX constructor
# TODO: update attribute names
my %args;
$args{database}           = $ARGV_database;
$args{extract_seqs}       = 1 if $ARGV_extract_seqs;
$args{extract_taxs}       = 1 if $ARGV_extract_tax;
$args{restore_last_param} = 1 if $ARGV_restore_last_params;
$args{nb_org}             = $ARGV_max_copy;
$args{align}              = $ARGV_min_cov;

# process infiles
for my $infile (@ARGV_infiles) {
    ### Processing: $infile

    # read and parse report
    my %new_args = (%args, file => $infile);
    $new_args{scheme}     = $scheme if $scheme;
    $new_args{parameters} = $ARGV_restore_params_from
        if $ARGV_restore_params_from;
    my $oum = $class->new(%new_args);

    say '[' . $oum->count_hits . ' hits processed] ';

    if ($ARGV_print_plots) {
        ### Printing graphical selection with all possible colorations...

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 2.023 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-72ae3ad1e6da )