Bio-MUST-Core
view release on metacpan or search on metacpan
bin/export-itol.pl view on Meta::CPAN
#!/usr/bin/env perl
# PODNAME: export-itol.pl
# ABSTRACT: Download formatted trees from iTOL
# CONTRIBUTOR: Valerian LUPO <valerian.lupo@uliege.be>
use Modern::Perl '2011';
use autodie;
use Getopt::Euclid qw(:vars);
use Smart::Comments '###';
use Config::Any;
use HTTP::Request::Common;
use LWP::UserAgent;
use Bio::MUST::Core;
use Bio::MUST::Core::Constants qw(:files);
use Bio::MUST::Core::Utils qw(change_suffix insert_suffix);
my $download_url = "https://itol.embl.de/batch_downloader.cgi";
my $suffix_like = qr{ \bsvg\b | \bpdf\b | \beps\b | \bps\b | \bpng\b
| \bnewick\b | \bnexus\b | \bphyloxml\b }xms;
FILE:
for my $infile (@ARGV_infiles) {
### Processing: $infile
my $id_for = read_tree_ids($infile);
# determine config file (global or infile-dependent)
$infile =~ s/$_//xms for @ARGV_in_strip;
my $cfgfile = $ARGV_config ? $ARGV_config : change_suffix($infile, '.ini');
### config file: $cfgfile
my $config = Config::Any->load_files( {
files => [ $cfgfile ],
flatten_to_hash => 1,
use_ext => 1,
} );
my %param_for = %{ $config->{$cfgfile} };
if ($param_for{'format'} !~ $suffix_like) {
warn <<"EOT";
Warning: unspecified or invalid output format: $param_for{format}; skipping!
EOT
next FILE;
}
TREE:
while ( my ($outfile, $tree) = each %{$id_for} ) {
unless ($outfile && $tree) {
warn <<'EOT';
Warning: missing tree filename or id; skipping!
EOT
next TREE;
}
$outfile .= q{.} . $param_for{'format'};
$outfile = insert_suffix($outfile, $ARGV_out_suffix)
if $ARGV_out_suffix;
$param_for{'outFile'} = $outfile;
( run in 0.745 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )