Update Roy's email
[bioperl-live.git] / scripts / tree / nexus2nh.PLS
blob4f12bcb925f0f04057daaa49795128901047a9a2
1 #!perl -w
3 =head1 NAME
5 nexus2nh - convert nexus format trees (from PAUP* and MrBayes) to new hampshire
7 =head1 SYNOPSIS
9  nexus2nh file.nexus > file.nh
11  # OR pipe in through STDIN
13  cat file.nexus | nexus2nh > file.nh
15  # OR specify an output
17  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 Bio::TreeIO;
28 use Getopt::Long;
30 my $outfile;
32 GetOptions('o|out|outfile:s' => \$outfile);
34 my $in = Bio::TreeIO->new(-format => 'nexus', -fh => \*ARGV);
35 my $out;
36 if( $outfile ) { 
37     $out= Bio::TreeIO->new(-format => 'newick',
38                            -file   => ">$outfile");
39 } else { 
40     # write to STDOUT
41     $out= Bio::TreeIO->new(-format => 'newick');
44 while( my $t = $in->next_tree ) {
45     $out->write_tree($t);