File Coverage

blib/lib/Bio/NEXUS/DataBlock.pm
Criterion Covered Total %
statement 26 34 76.4
branch 0 4 0.0
condition n/a
subroutine 8 9 88.8
pod 1 1 100.0
total 35 48 72.9


line stmt bran cond sub pod time code
1             #################################################################
2             # DataBlock.pm
3             #################################################################
4             # Author: Thomas Hladish
5             # $Id: DataBlock.pm,v 1.13 2007/09/21 23:09:09 rvos Exp $
6              
7             #################### START POD DOCUMENTATION ##################
8              
9             =head1 NAME
10              
11             Bio::NEXUS::DataBlock - Represents the deprecated DATA Block in NEXUS file.
12              
13             =head1 SYNOPSIS
14              
15             $block_object = new Bio::NEXUS::DataBlock($type, $block, $verbose, $taxlabels_ref);
16              
17             =head1 DESCRIPTION
18              
19             The DataBlock class represents the deprecated Data Block in a NEXUS file. Data Blocks are still used by some prominent programs, unfortunately, although they are essentially the same as a Characters Block and a Taxa Block combined. Data Blocks may be used as input, but are not output by the NEXPL library. For more information on Data Blocks, see the Characters Block documentation.
20              
21             =head1 COMMENTS
22              
23             Don't use this block type if you can help it.
24              
25             =head1 FEEDBACK
26              
27             All feedback (bugs, feature enhancements, etc.) are greatly appreciated.
28              
29             =head1 AUTHORS
30              
31             Thomas Hladish (tjhladish at yahoo)
32              
33             =head1 VERSION
34              
35             $Revision: 1.13 $
36              
37             =head1 METHODS
38              
39             =cut
40              
41             package Bio::NEXUS::DataBlock;
42              
43 34     34   188 use strict;
  34         71  
  34         1383  
44             #use Data::Dumper; # XXX this is not used, might as well not import it!
45             #use Carp; # XXX this is not used, might as well not import it!
46 34     34   185 use Bio::NEXUS::Functions;
  34         67  
  34         11286  
47 34     34   222 use Bio::NEXUS::CharactersBlock;
  34         74  
  34         988  
48 34     34   174 use Bio::NEXUS::Util::Logger;
  34         80  
  34         862  
49 34     34   346 use Bio::NEXUS::Util::Exceptions;
  34         88  
  34         2324  
50 34     34   203 use vars qw(@ISA $VERSION $AUTOLOAD);
  34         67  
  34         2257  
51 34     34   199 use Bio::NEXUS; $VERSION = $Bio::NEXUS::VERSION;
  34         97  
  34         10174  
52              
53             @ISA = qw(Bio::NEXUS::CharactersBlock);
54             my $logger = Bio::NEXUS::Util::Logger->new();
55              
56             =head2 new
57              
58             Title : new
59             Usage : block_object = new Bio::NEXUS::CharactersBlock($block_type, $block, $verbose, $taxa);
60             Function: Creates a new Bio::NEXUS::CharactersBlock object
61             Returns : Bio::NEXUS::CharactersBlock object
62             Args : verbose flag (0 or 1), type (string) and the block to parse (string)
63              
64             =cut
65              
66             sub new {
67 7     7 1 19 my $deprecated_class = shift;
68 7         13 my $deprecated_type = shift;
69 7         43 $logger->info("Read in Data Block (deprecated), creating Characters Block instead");
70 7         74 my $self = new Bio::NEXUS::CharactersBlock( 'characters', @_ );
71 6         33 return $self;
72             }
73              
74             sub AUTOLOAD {
75 0 0   0     return if $AUTOLOAD =~ /DESTROY$/;
76 0           my $package_name = __PACKAGE__ . '::';
77              
78             # The following methods are deprecated and are temporarily supported
79             # via a warning and a redirection
80 0           my %synonym_for = (
81              
82             # "${package_name}parse" => "${package_name}_parse_tree", # example
83             );
84              
85 0 0         if ( defined $synonym_for{$AUTOLOAD} ) {
86 0           $logger->warn("$AUTOLOAD() is deprecated; use $synonym_for{$AUTOLOAD}() instead");
87 0           goto &{ $synonym_for{$AUTOLOAD} };
  0            
88             }
89             else {
90 0           Bio::NEXUS::Util::Exceptions::UnknownMethod->throw(
91             'error' => "ERROR: Unknown method $AUTOLOAD called"
92             );
93             }
94             }
95              
96             1;