| 1 | #!/usr/bin/env perl | ||
| 2 | # PODNAME: tab2mapper.pl | ||
| 3 | # ABSTRACT: Build an id mapper from a tabular file giving annotation strings | ||
| 4 | # CONTRIBUTOR: Loic MEUNIER <loic.meunier@doct.uliege.be> | ||
| 5 | |||
| 6 | use Modern::Perl '2011'; | ||
| 7 | use autodie; | ||
| 8 | |||
| 9 | use Getopt::Euclid qw(:vars); | ||
| 10 | use Smart::Comments; | ||
| 11 | |||
| 12 | use Bio::MUST::Core; | ||
| 13 | use Bio::MUST::Core::Utils qw(change_suffix); | ||
| 14 | use aliased 'Bio::MUST::Core::IdMapper'; | ||
| 15 | use aliased 'Bio::MUST::Core::Taxonomy'; | ||
| 16 | |||
| 17 | die <<'EOT' if !$ARGV_taxdir && $ARGV_gi2taxid; | ||
| 18 | Missing required arguments: | ||
| 19 | --taxdir=<dir> | ||
| 20 | EOT | ||
| 21 | |||
| 22 | # optionally build taxonomy object | ||
| 23 | my $tax; | ||
| 24 | if ($ARGV_taxdir) { | ||
| 25 | $tax = Taxonomy->new_from_cache( tax_dir => $ARGV_taxdir ); | ||
| 26 | } | ||
| 27 | |||
| 28 | for my $infile (@ARGV_infiles) { | ||
| 29 | |||
| 30 | ### Processing: $infile | ||
| 31 | my $mapper = $tax->tab_mapper( $infile, { | ||
| 32 | column => $ARGV_column, | ||
| 33 | gi2taxid => $ARGV_gi2taxid, | ||
| 34 | } ); | ||
| 35 | |||
| 36 | my $outfile = change_suffix($infile, '.idm'); | ||
| 37 | $mapper->store($outfile); | ||
| 38 | } | ||
| 39 | |||
| 40 | __END__ |