Bio::Root::RootI: deprecate deprecated() method (issue #294)
[bioperl-live.git] / bin / bp_nexus2nh
blob6ff5f66e6f0cbb92f253e9e3dd88120ba55fab90
1 #!/usr/bin/perl
3 =head1 NAME
5 bp_nexus2nh - convert nexus format trees (from PAUP* and MrBayes) to new hampshire
7 =head1 SYNOPSIS
9 bp_nexus2nh file.nexus > file.nh
11 # OR pipe in through STDIN
13 cat file.nexus | bp_nexus2nh > file.nh
15 # OR specify an output
17 bp_nexus2nh -o file.nh file.nexus
19 =head1 DESCRIPTION
21 Convert Nexus Tree files into Newick/New Hampshire format tree files.
24 =cut
26 use strict;
27 use warnings;
28 use Bio::TreeIO;
29 use Getopt::Long;
31 my $outfile;
33 GetOptions('o|out|outfile:s' => \$outfile);
35 my $in = Bio::TreeIO->new(-format => 'nexus', -fh => \*ARGV);
36 my $out;
37 if( $outfile ) {
38 $out= Bio::TreeIO->new(-format => 'newick',
39 -file => ">$outfile");
40 } else {
41 # write to STDOUT
42 $out= Bio::TreeIO->new(-format => 'newick');
45 while( my $t = $in->next_tree ) {
46 $out->write_tree($t);