Bio-MUST-Tools-TreeParsing

 view release on metacpan or  search on metacpan

bin/tree-clan-splitter.pl  view on Meta::CPAN

#!/usr/bin/env perl
# PODNAME: tree-clan-splitter.pl
# ABSTRACT: Extract clans (FASTA files) from trees based on taxonomic filters
# CONTRIBUTOR: Mick VAN VLIERBERGHE <mvanvlierberghe@doct.uliege.be>

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

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

use Carp;
use File::Copy;
use File::Spec;
use Tie::IxHash;
use List::Compare;
use File::Basename;
use File::Find::Rule;
use Path::Class 'file', 'dir';
use List::AllUtils qw(min sum uniq any partition_by);

use Bio::MUST::Core;
use Bio::MUST::Core::Utils qw(change_suffix);
use aliased 'Bio::MUST::Core::Ali';
use aliased 'Bio::MUST::Core::Tree';
use aliased 'Bio::MUST::Core::SeqId';
use aliased 'Bio::MUST::Core::IdList';
use aliased 'Bio::MUST::Core::IdMapper';
use aliased 'Bio::MUST::Core::Taxonomy';
use aliased 'Bio::MUST::Core::Taxonomy::Filter';
use aliased 'Bio::MUST::Core::Taxonomy::Criterion';
use aliased 'Bio::MUST::Core::Taxonomy::Category';
use aliased 'Bio::MUST::Core::Taxonomy::Classifier';

## no critic (RequireLocalizedPunctuationVars)
BEGIN{
    $ENV{Smart_Comments} = $ARGV_verbosity
        ? join q{ }, map { '#' x (2 + $_) } 1..$ARGV_verbosity : q{} ;
}
use Smart::Comments -ENV;

# Collect tree(s)
my @intrees = File::Find::Rule
    ->file()
    ->name( qr{ .*  $ARGV_tree_suffix $ }xmsi )
    ->maxdepth(1)
    ->in($ARGV_indir)
;
### @intrees

#### Building classifier...
my $tax = Taxonomy->new_from_cache( tax_dir => $ARGV_taxdir );
my $classifier = _build_classifier();
### Done!

my @stripped_intrees;

TREE:
for my $intree (sort @intrees) {
    ### $intree

    my $tree = Tree->load($intree);
    my $stripped_intree = $intree;
       $stripped_intree =~ s/$_//xms for ($ARGV_tree_suffix);
    push @stripped_intrees, $stripped_intree;
    ### $stripped_intree

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

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