* delete Bio::DB::SeqFeature::Store::DBI::Pg per Scott Cain
[bioperl-live.git] / scripts / tree / tree2pag.PLS
bloba1dee0aa79185e8f4f6941213c1e267545578f25
1 #!perl -w
3 =head1 NAME
5 tree2pag - convert Bio::TreeIO parseable format trees to pagel format
7 =head1 SYNOPSIS
9  tree2pag -if nexus -i file.nexus > file.pag
11  # OR pipe in through STDIN, and use newick format instead
13  cat file.newick | tree2pag -if newick > file.nh
15  # OR specify an output and input
17  tree2pag -o file.pag -i file.newick
19 =head1 DESCRIPTION
21 Convert TreeIO parseable files into Pagel format tree files.  Be
22 warned that pagel format only really supports a single tree per file
23 so.  Also Pagel parsing is not yet available in bioperl.
25 =cut
27 use strict;
28 use Bio::TreeIO;
29 use Getopt::Long;
30 my ($iformat,$oformat) = ('newick', 'pag');
31 my ($outfile,$infile);
32 GetOptions(
33            'if|informat:s'    => \$iformat,
34            'of|outformat:s'   => \$oformat,
35            'i|in:s'           => \$infile,
36            'o|out:s'          => \$outfile,
37            'h|help'           => sub { exec('perldoc', $0);
38                                        exit(0); },
39            );
40 my $in;
41 if( ! $infile ) {
42     $in = Bio::TreeIO->new(-format => $iformat,
43                            -fh     => \*ARGV);
44 } else { 
45     $in = Bio::TreeIO->new(-format => $iformat,
46                            -file   => $infile);
49 my $out;
50 if( $outfile) {
51     $out = Bio::TreeIO->new(-format => $oformat,
52                             -file   => ">$outfile");
53 } else { 
54     $out = Bio::TreeIO->new(-format => $oformat); #print to STDOUT instead
57 while( my $t = $in->next_tree ) {
58     $out->write_tree($t);