squash waffling test
[bioperl-live.git] / Bio / TreeIO / nhx.pm
blobde7616c9517426ba655833426c10f94d65a27f12
2 # BioPerl module for Bio::TreeIO::nhx
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Aaron Mackey <amackey@virginia.edu>
8 # Copyright Aaron Mackey
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::TreeIO::nhx - TreeIO implementation for parsing
17 Newick/New Hampshire eXtendend (NHX) format.
19 =head1 SYNOPSIS
21 # do not use this module directly
22 use Bio::TreeIO;
23 my $treeio = Bio::TreeIO->new(-format => 'nhx', -file => 'tree.dnd');
24 my $tree = $treeio->next_tree;
26 =head1 DESCRIPTION
28 This module handles parsing and writing of Newick/New Hampshire eXtended (NHX) format.
30 =head1 FEEDBACK
32 =head2 Mailing Lists
34 User feedback is an integral part of the evolution of this and other
35 Bioperl modules. Send your comments and suggestions preferably to the
36 Bioperl mailing list. Your participation is much appreciated.
38 bioperl-l@bioperl.org - General discussion
39 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
41 =head2 Support
43 Please direct usage questions or support issues to the mailing list:
45 I<bioperl-l@bioperl.org>
47 rather than to the module maintainer directly. Many experienced and
48 reponsive experts will be able look at the problem and quickly
49 address it. Please include a thorough description of the problem
50 with code and data examples if at all possible.
52 =head2 Reporting Bugs
54 Report bugs to the Bioperl bug tracking system to help us keep track
55 of the bugs and their resolution. Bug reports can be submitted viax the
56 web:
58 https://github.com/bioperl/bioperl-live/issues
60 =head1 AUTHOR - Aaron Mackey
62 Email amackey-at-virginia.edu
64 =head1 CONTRIBUTORS
66 Email jason-at-bioperl-dot-org
68 =head1 APPENDIX
70 The rest of the documentation details each of the object methods.
71 Internal methods are usually preceded with a _
73 =cut
76 # Let the code begin...
79 package Bio::TreeIO::nhx;
80 use strict;
82 # Object preamble - inherits from Bio::Root::Root
84 use Bio::Tree::NodeNHX;
85 use Bio::Event::EventGeneratorI;
86 #use XML::Handler::Subs;
88 use base qw(Bio::TreeIO::newick);
90 sub _initialize {
91 my($self, %args) = @_;
92 $args{-nodetype} ||= 'Bio::Tree::NodeNHX';
93 $self->SUPER::_initialize(%args);
96 sub _node_as_string {
97 my $self = shift;
98 my $node = shift;
99 my $params = shift;
101 my $label_stringbuffer = $self->SUPER::_node_as_string($node,$params);
103 my @tags = $node->get_all_tags;
104 if( scalar(@tags) > 0 ) {
105 @tags = sort @tags;
106 $label_stringbuffer .= '[' .
107 join(":", "&&NHX",
108 map { "$_=" .join(',',$node->get_tag_values($_)) }
109 @tags ) . ']';
111 return $label_stringbuffer;