A test to ensure Bio::PrimarySeqI->trunc() doesn't use clone() for a Bio::Seq::RichSe...
[bioperl-live.git] / scripts / tree / bp_nexus2nh.pl
blobb5eeabee165b58b26dc98a263f14a3dcdab0a6b5
1 #!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);