| 1 | #!/usr/bin/env perl | ||
| 2 | # PODNAME: prune-ali.pl | ||
| 3 | # ABSTRACT: Prune sequences from ALI files based on id lists | ||
| 4 | |||
| 5 | use Modern::Perl '2011'; | ||
| 6 | use autodie; | ||
| 7 | |||
| 8 | use Getopt::Euclid qw(:vars); | ||
| 9 | use Smart::Comments; | ||
| 10 | |||
| 11 | use Bio::MUST::Core; | ||
| 12 | use Bio::MUST::Core::Utils qw(change_suffix secure_outfile); | ||
| 13 | use aliased 'Bio::MUST::Core::Ali'; | ||
| 14 | use aliased 'Bio::MUST::Core::IdList'; | ||
| 15 | |||
| 16 | |||
| 17 | my $method = $ARGV_from_must ? 'load_lis' : 'load'; | ||
| 18 | |||
| 19 | for my $infile (@ARGV_infiles) { | ||
| 20 | |||
| 21 | ### Processing: $infile | ||
| 22 | my $list = IdList->$method($infile); | ||
| 23 | |||
| 24 | $infile =~ s/$_//xms for @ARGV_in_strip; | ||
| 25 | my $alifile = change_suffix($infile, '.ali'); | ||
| 26 | ### Filtering sequences in: $alifile | ||
| 27 | my $ali = Ali->load($alifile); | ||
| 28 | $ali->dont_guess if $ARGV_noguessing; | ||
| 29 | |||
| 30 | # optionally negate list | ||
| 31 | $list = $list->negative_list($ali) if $ARGV_negate_list; | ||
| 32 | |||
| 33 | # apply list to Ali | ||
| 34 | my $pruned_ali = $ARGV_reorder ? $list->reordered_ali($ali) | ||
| 35 | : $list->filtered_ali($ali) | ||
| 36 | ; | ||
| 37 | |||
| 38 | my $outfile = secure_outfile($alifile, $ARGV_out_suffix); | ||
| 39 | ### Output alignment in: $outfile | ||
| 40 | $pruned_ali->store($outfile); | ||
| 41 | } | ||
| 42 | |||
| 43 | __END__ |