| 1 | #!/usr/bin/env perl | ||
| 2 | # PODNAME: extract-ali.pl | ||
| 3 | # ABSTRACT: Extract sequences from a FASTA database file 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); | ||
| 13 | use aliased 'Bio::MUST::Core::Ali::Stash'; | ||
| 14 | use aliased 'Bio::MUST::Core::IdList'; | ||
| 15 | |||
| 16 | |||
| 17 | my %args; | ||
| 18 | $args{truncate_ids} = 1 if $ARGV_truncate_ids; | ||
| 19 | |||
| 20 | # load database | ||
| 21 | my $db = Stash->load($ARGV_database, \%args); | ||
| 22 | |||
| 23 | for my $infile (@ARGV_infiles) { | ||
| 24 | |||
| 25 | ### Processing: $infile | ||
| 26 | my $list = IdList->load($infile); | ||
| 27 | |||
| 28 | # assemble Ali and store it as FASTA file | ||
| 29 | my $ali = $ARGV_reorder ? $list->reordered_ali($db) | ||
| 30 | : $list->filtered_ali($db) | ||
| 31 | ; | ||
| 32 | $ali->dont_guess; | ||
| 33 | my $outfile = change_suffix($infile, '.ali'); | ||
| 34 | $ali->store($outfile); | ||
| 35 | } | ||
| 36 | |||
| 37 | __END__ |