File Coverage

Bio/TreeIO/nhx.pm
Criterion Covered Total %
statement 25 25 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 6 6 100.0
pod n/a
total 34 35 97.1


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::TreeIO::nhx
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Aaron Mackey
7             #
8             # Copyright Aaron Mackey
9             #
10             # You may distribute this module under the same terms as perl itself
11              
12             # POD documentation - main docs before the code
13              
14             =head1 NAME
15              
16             Bio::TreeIO::nhx - TreeIO implementation for parsing
17             Newick/New Hampshire eXtendend (NHX) format.
18              
19             =head1 SYNOPSIS
20              
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;
25              
26             =head1 DESCRIPTION
27              
28             This module handles parsing and writing of Newick/New Hampshire eXtended (NHX) format.
29              
30             =head1 FEEDBACK
31              
32             =head2 Mailing Lists
33              
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.
37              
38             bioperl-l@bioperl.org - General discussion
39             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
40              
41             =head2 Support
42              
43             Please direct usage questions or support issues to the mailing list:
44              
45             I
46              
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.
51              
52             =head2 Reporting Bugs
53              
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:
57              
58             https://github.com/bioperl/bioperl-live/issues
59              
60             =head1 AUTHOR - Aaron Mackey
61              
62             Email amackey-at-virginia.edu
63              
64             =head1 CONTRIBUTORS
65              
66             Email jason-at-bioperl-dot-org
67              
68             =head1 APPENDIX
69              
70             The rest of the documentation details each of the object methods.
71             Internal methods are usually preceded with a _
72              
73             =cut
74              
75              
76             # Let the code begin...
77              
78              
79             package Bio::TreeIO::nhx;
80 5     5   35 use strict;
  5         9  
  5         170  
81              
82             # Object preamble - inherits from Bio::Root::Root
83              
84 5     5   1462 use Bio::Tree::NodeNHX;
  5         9  
  5         158  
85 5     5   33 use Bio::Event::EventGeneratorI;
  5         8  
  5         120  
86             #use XML::Handler::Subs;
87              
88 5     5   21 use base qw(Bio::TreeIO::newick);
  5         8  
  5         1348  
89              
90             sub _initialize {
91 29     29   152 my($self, %args) = @_;
92 29   50     152 $args{-nodetype} ||= 'Bio::Tree::NodeNHX';
93 29         156 $self->SUPER::_initialize(%args);
94             }
95              
96             sub _node_as_string {
97 496     496   516 my $self = shift;
98 496         481 my $node = shift;
99 496         426 my $params = shift;
100            
101 496         812 my $label_stringbuffer = $self->SUPER::_node_as_string($node,$params);
102              
103 496         876 my @tags = $node->get_all_tags;
104 496 100       715 if( scalar(@tags) > 0 ) {
105 430         551 @tags = sort @tags;
106             $label_stringbuffer .= '[' .
107             join(":", "&&NHX",
108 430         594 map { "$_=" .join(',',$node->get_tag_values($_)) }
  674         1098  
109             @tags ) . ']';
110             }
111 496         1038 return $label_stringbuffer;
112             }
113              
114             1;