~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to scripts/tree/bp_nexus2nh.pl

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!perl
 
2
 
 
3
=head1 NAME
 
4
 
 
5
bp_nexus2nh - convert nexus format trees (from PAUP* and MrBayes) to new hampshire
 
6
 
 
7
=head1 SYNOPSIS
 
8
 
 
9
 bp_nexus2nh file.nexus > file.nh
 
10
 
 
11
 # OR pipe in through STDIN
 
12
 
 
13
 cat file.nexus | bp_nexus2nh > file.nh
 
14
 
 
15
 # OR specify an output
 
16
 
 
17
 bp_nexus2nh -o file.nh file.nexus
 
18
 
 
19
=head1 DESCRIPTION
 
20
 
 
21
Convert Nexus Tree files into Newick/New Hampshire format tree files.
 
22
 
 
23
 
 
24
=cut
 
25
 
 
26
use strict;
 
27
use warnings;
 
28
use Bio::TreeIO;
 
29
use Getopt::Long;
 
30
 
 
31
my $outfile;
 
32
 
 
33
GetOptions('o|out|outfile:s' => \$outfile);
 
34
 
 
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');
 
43
}
 
44
 
 
45
while( my $t = $in->next_tree ) {
 
46
    $out->write_tree($t);
 
47
}