lib/Bio/NEXUS/Tools/GraphicsParams.pm

filter: Statementstmt 19.2% 20 / 104 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 20.0% 5 / 25 Podpod 100% 19 / 19 totaltotal 26.3% 44 / 167 CC 15 SCAR 21.9
CC
15
Cov
16%
AUTOLOAD
30.0
set_maxTaxLabelwidth
12.0
set_longestCharLabelLength
12.0
CRAP 8.9
« lib/Bio/NEXUS/CodonsBlock.pm ↑ Summary lib/Bio/NEXUS/NotesBlock.pm »
1 #######################################################################
2 # Grahics.pm
3 #######################################################################
4 # Author: Chengzhi Liang, Weigang Qiu, Eugene Melamud, Peter Yang
5 # $Id: GraphicsParams.pm,v 1.2 2008/06/16 19:53:41 astoltzfus Exp $
6  
7 #################### START POD DOCUMENTATION ##########################
8  
9 =head1 NAME
10  
11 Graphics - represents a character block (Data or Characters) of a NEXUS file
12  
13 =head1 SYNOPSIS
14  
15  
16 =head1 DESCRIPTION
17  
18 This is a class representing a character block or data block in NEXUS file
19  
20 =head1 FEEDBACK
21  
22 All feedbacks (bugs, feature enhancements, etc.) are greatly appreciated.
23  
24 =head1 AUTHORS
25 Vivek Gopalan (gopalan@umbi.umd.edu)
26 Chengzhi Liang (liangc@umbi.umd.edu)
27 Weigang Qiu (weigang@genectr.hunter.cuny.edu)
28 Eugene Melamud (melamud@carb.nist.gov)
29 Peter Yang (pyang@rice.edu)
30  
31 =head1 VERSION
32  
33 $Revision: 1.2 $
34  
35 =head1 METHODS
36  
37 =cut
38  
39 package Bio::NEXUS::Tools::GraphicsParams;
40  
41 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 1 ▶use Bio::NEXUS; our $VERSION = $Bio::NEXUS::VERSION;
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 ### Class Variables
48  
49 1 our $DefaultTreeWidth = 5;
50 1 our $DefaultCharLabelBlockWidth = 5;
51 1 our $DefaultVerticalOtuSpacing = 1.2;
52  
53 =head2 new
54  
55 Title : new
56 Usage : block_object = new NEXUS::CharacterBlock($block_type, $block, $verbose, $wasdata);
57 Function: Creates a new NEXUS::CharacterBlock object
58 Returns : NEXUS::CharacterBlock object
59 Args : verbose flag (0 or 1), type (string) and the block to parse (string)
60  
61 =cut
62  
63 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
64 0 my $class = shift;
65 0 my $data ={
66 'Font' => 'Times-Roman',# font to use for OTU labels
67 'isVerbose' => 0,
68 'fontWidth' => 1,
69 'maximumWtvalue' => 10,
70 'fontHeight' => 1,
71 'PageHeightInches' => 11, # page height in inches for your default page size
72 'PageWidthInches' => 8.5, # page width in inches for your default page size
73 'SpacingToFontRatio' => 1, # ratio of space b/t rows to font height
74 'histoScale' => 3, # max histogram weight
75 'treeLineWidth' => 2, # width of tree lines
76 'boxLineWidth' => 1, # width of bounding box line
77 'labelMatrixGapWidth' => 10, # width of reference lines between tree & matrix
78 'charLabelMatrixGapWidth' => 10, # width of reference lines between tree & matrix
79 'treeNodeRadius' => 5, # radius of dot representing a node
80 'pieChartRadius' => 10, # radius of pie chart for intron history
81 'characterFont' => 'Courier', # font to use for character matrix
82 'lowerXMargin' => 15, # size of left margin
83 'upperXMargin' => 15, # size of right margin
84 'lowerYMargin' => 15, # size of upper margin
85 'upperYMargin' => 15, # size of bottom margin
86 'xsize' => 0,
87 'ysize' => 0,
88 'upperXbound' => 0,
89 'lowerXbound' => 0,
90 'lowerYbound' => 0,
91 'upperYbound' => 0,
92 'longestCharLabelLength' => 0,
93 'histogramHeight' => 0,
94 'charactersXwidth' => 0,
95 'characterStartXPos' => 0,
96 'maxTaxLabelwidth' => 0,
97 'paneHeight' => 0,
98 'TreeWidth' => 0, # width in inches of longest branch of tree
99 'verticalOtuSpacing' => 0, # in POINTS, vertical space between rows (tree tips)
100 'charLabelBlockWidth' => 0, # number of columns between space columns
101 };
102 0 bless ($data,$class);
103 0 return $data;
104 }
105  
106 =head2 AUTOLOAD
107  
108 Title : AUTOLOAD
109 Usage : NA
110 Function: NA
111 Returns : NA
112 Args : NA
113  
114 =cut
115  
116 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=5 SCAR=34.0
117 0 my $self = shift;
118 0 my $value = shift;
119 0 my $attrib = shift;
120 0 my $command = our $AUTOLOAD;
121  
122 0 $command =~ s/.*://;
123 0 $command = lc $command;
124 0 (my $parsed_var = $command) =~s/^.*_//;
125 0 foreach my $var (keys (%{$self})) {
126 0 ▶ next if ($parsed_var ne (lc $var));
Branch: 1 branch
BranchTrueFalseTotal
if $parsed_var ne lc $var 0 0 0
127 0 ▶ if ($command =~/get_/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($command =~ /get_/) { } 0 0 0
elsif ($command =~ /set_/) { } 0 0 0
128 0 return $self->{$var}
129 } elsif ($command =~/set_/) {
130 0 $self->{$var} = $value;
131 0 return ;
132 }
133 }
134 0 die "$! :Undefined subroutine &$AUTOLOAD called\n";
135
136 }
137  
138 =head2 set_upperXbound
139  
140 Title : set_upperXbound
141 Usage : NA
142 Function: NA
143 Returns : NA
144 Args : NA
145  
146 =cut
147  
148 0 ▶sub set_upperXbound {
Subroutine set_upperXbound: not called CC=1 SCAR=6.9
Pod documented
149 0 my $self = shift;
150 0 my $upperXbound = $self->get_lowerXbound + $self->get_TreeWidth + $self->get_maxTaxLabelwidth+ $self->get_labelMatrixGapWidth+ $self->get_charactersXwidth;
151 0 $self->{'upperXbound'} = $upperXbound;
152 0 $self->set_characterStartXpos;
153  
154 }
155  
156 =head2 set_lowerXbound
157  
158 Title : set_lowerXbound
159 Usage : NA
160 Function: NA
161 Returns : NA
162 Args : NA
163  
164 =cut
165  
166 0 ▶sub set_lowerXbound {
Subroutine set_lowerXbound: not called CC=1 SCAR=6.9
Pod documented
167 0 my $self = shift;
168 0 my $args = shift;
169 0 $self->{'lowerXbound'} = $self->get_lowerXMargin;
170 }
171  
172 =head2 set_upperYbound
173  
174 Title : set_upperYbound
175 Usage : NA
176 Function: NA
177 Returns : NA
178 Args : NA
179  
180 =cut
181  
182 0 ▶sub set_upperYbound {
Subroutine set_upperYbound: not called CC=1 SCAR=6.9
Pod documented
183 0 my $self = shift;
184 #$self->{'upperYbound'} = $self->get_lowerYbound + $self->get_TreeHeight;
185 0 $self->{'upperYbound'} = $self->get_lowerYbound + $self->get_paneHeight;
186  
187 }
188  
189 =head2 set_lowerYbound
190  
191 Title : set_lowerYbound
192 Usage : NA
193 Function: NA
194 Returns : NA
195 Args : NA
196  
197 =cut
198  
199 0 ▶sub set_lowerYbound {
Subroutine set_lowerYbound: not called CC=1 SCAR=6.9
Pod documented
200 0 my $self = shift;
201 0 $self->{'lowerYbound'} = $self->get_lowerYMargin + $self->get_longestCharLabelLength + $self->get_histogramHeight + $self->get_charLabelMatrixGapWidth;
202 }
203  
204 =head2 set_charactersXwidth
205  
206 Title : set_charactersXwidth
207 Usage : NA
208 Function: NA
209 Returns : NA
210 Args : NA
211  
212 =cut
213  
214 0 ▶sub set_charactersXwidth {
Subroutine set_charactersXwidth: not called CC=1 SCAR=1.2
Pod documented
215 1 ▶use POSIX qw(ceil);
Subroutine BEGIN: called CC=1 SCAR=0.0
216  
217 0 my $self = shift;
218 0 my $block = shift;
219 0 $self->{'charactersXwidth'} = $block->get_nchar * $self->get_fontWidth + ceil($block->get_nchar / $self->get_charLabelBlockWidth) * $self->get_fontWidth ;
220 }
221  
222 =head2 set_maxTaxLabelwidth
223  
224 Title : set_maxTaxLabelwidth
225 Usage : NA
226 Function: NA
227 Returns : NA
228 Args : NA
229  
230 =cut
231  
232 0 ▶sub set_maxTaxLabelwidth {
Subroutine set_maxTaxLabelwidth: not called CC=3 SCAR=24.8
Pod documented
233 0 my $self = shift;
234 0 my $taxlabels = shift;
235 0 my $max = 0;
236 0 foreach my $tax_labels (@$taxlabels) {
237 0 ▶ $max = length($tax_labels) if (length($tax_labels) > $max);
Branch: 1 branch
BranchTrueFalseTotal
if length $tax_labels > $max 0 0 0
238 }
239 0 $self->{'maxTaxLabelwidth'} = $max * $self->get_fontWidth;
240 }
241  
242 =head2 set_paneHeight
243  
244 Title : set_paneHeight
245 Usage : NA
246 Function: NA
247 Returns : NA
248 Args : NA
249  
250 =cut
251  
252 0 ▶sub set_paneHeight {
Subroutine set_paneHeight: not called CC=1 SCAR=6.9
Pod documented
253 0 my $self = shift;
254 0 my $ntax = shift;
255 0 $self->{'paneHeight'} = $ntax * ($self->get_verticalOtuSpacing);
256 }
257  
258 =head2 set_ysize
259  
260 Title : set_ysize
261 Usage : NA
262 Function: NA
263 Returns : NA
264 Args : NA
265  
266 =cut
267  
268 0 ▶sub set_ysize {
Subroutine set_ysize: not called CC=1 SCAR=6.9
Pod documented
269 0 my $self = shift;
270 0 $self->{'ysize'} = $self->get_upperYbound + $self->get_upperYMargin;
271  
272 }
273  
274 =head2 set_xsize
275  
276 Title : set_xsize
277 Usage : NA
278 Function: NA
279 Returns : NA
280 Args : NA
281  
282 =cut
283  
284 0 ▶sub set_xsize {
Subroutine set_xsize: not called CC=1 SCAR=6.9
Pod documented
285 0 my $self = shift;
286 0 $self->{'xsize'} = $self->get_upperXbound + $self->get_upperXMargin;
287  
288 }
289  
290 =head2 set_histogramHeight
291  
292 Title : set_histogramHeight
293 Usage : NA
294 Function: NA
295 Returns : NA
296 Args : NA
297  
298 =cut
299  
300 0 ▶sub set_histogramHeight {
Subroutine set_histogramHeight: not called CC=1 SCAR=6.9
Pod documented
301 0 my $self = shift;
302 0 $self->{'histogramHeight'} = $self->get_histoScale * $self->get_fontHeight; # height of histogram
303 }
304  
305 =head2 set_longestCharLabelLength
306  
307 Title : set_longestCharLabelLength
308 Usage : NA
309 Function: NA
310 Returns : NA
311 Args : NA
312  
313 =cut
314  
315 0 ▶sub set_longestCharLabelLength {
Subroutine set_longestCharLabelLength: not called CC=3 SCAR=24.8
Pod documented
316 0 my $self = shift;
317 0 my @array = @_;
318 0 my $max = 0;
319 0 foreach my $element (@array) {
320 0 ▶ $max = length($element) if (length($element) > $max);
Branch: 1 branch
BranchTrueFalseTotal
if length $element > $max 0 0 0
321 }
322 0 $self->{'longestCharLabelLength'} = $max * $self->get_fontHeight ;
323 }
324  
325 =head2 set_verticalOtuSpacing
326  
327 Title : set_verticalOtuSpacing
328 Usage : NA
329 Function: NA
330 Returns : NA
331 Args : NA
332  
333 =cut
334  
335 0 ▶sub set_verticalOtuSpacing {
Subroutine set_verticalOtuSpacing: not called CC=2 SCAR=17.9
Pod documented
336 0 my $self = shift;
337 0 ▶ my $arg = shift || 1.0 ;
Condition0%0/2
shift() || 1.0
l!l
00
MC/DC0%0/1
shift() || 1.0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
338 0 $self->{'verticalOtuSpacing'} = $arg * $self->get_fontHeight ;
339 }
340  
341 =head2 get_charLabelBlockWidth
342  
343 Title : get_charLabelBlockWidth
344 Usage : NA
345 Function: NA
346 Returns : NA
347 Args : NA
348  
349 =cut
350  
351 0 ▶sub get_charLabelBlockWidth {
Subroutine get_charLabelBlockWidth: not called CC=1 SCAR=6.9
Pod documented
352 0 my $self = shift;
353 0 return $self->{'charLabelBlockWidth'};
354 }
355  
356 =head2 set_charLabelBlockWidth
357  
358 Title : set_charLabelBlockWidth
359 Usage : NA
360 Function: NA
361 Returns : NA
362 Args : NA
363  
364 =cut
365  
366 0 ▶sub set_charLabelBlockWidth {
Subroutine set_charLabelBlockWidth: not called CC=1 SCAR=6.9
Pod documented
367 0 my $self = shift;
368 0 my $arg = shift;
369 0 $self->{'charLabelBlockWidth'} = $arg;
370 }
371  
372 =head2 set_TreeHeight (obsolete)
373  
374 Title : set_TreeHeight
375 Usage : NA
376 Function: NA
377 Returns : NA
378 Args : NA
379  
380 =cut
381 ##### Obsolete ####
382 0 ▶sub set_TreeHeight {
Subroutine set_TreeHeight: not called CC=3 SCAR=24.8
Pod documented
383 0 my $self = shift;
384 0 my $tree = shift;
385 0 my $tree_height = 0.0;
386 0 foreach my $node (@{$tree->node_list}) {
387 0 ▶ $tree_height = $node->ycoord if ($node->ycoord > $tree_height);
Branch: 1 branch
BranchTrueFalseTotal
if $node->ycoord > $tree_height 0 0 0
388 }
389 0 $self->{'TreeHeight'} = $tree_height;
390 }
391  
392 =head2 set_maxNodeWidth (obsolete)
393  
394 Title : set_maxNodeWidth
395 Usage : NA
396 Function: NA
397 Returns : NA
398 Args : NA
399  
400 =cut
401  
402 ##### Obsolete ####
403 0 ▶sub set_maxNodeWidth {
Subroutine set_maxNodeWidth: not called CC=3 SCAR=24.8
Pod documented
404 0 my $self = shift;
405 0 my $tree = shift;
406 0 my $maxNodeWidth = 0;
407 0 foreach my $otu (@{$tree->otu_list}){
408 0 ▶ $maxNodeWidth = length($otu) if ($maxNodeWidth < length($otu));
Branch: 1 branch
BranchTrueFalseTotal
if $maxNodeWidth < length $otu 0 0 0
409 }
410 0 $self->{'maxNodeWidth'} = ($maxNodeWidth* $self->get_fontWidth) + $self->get_fontWidth;
411 }
412  
413 =head2 set_characterStartXpos
414  
415 Title : set_characterStartXpos
416 Usage : NA
417 Function: NA
418 Returns : NA
419 Args : NA
420  
421 =cut
422  
423 0 ▶sub set_characterStartXpos {
Subroutine set_characterStartXpos: not called CC=1 SCAR=6.9
Pod documented
424 0 my $self = shift;
425 0 $self->{'characterStartXPos'} = $self->get_upperXbound - $self->get_charactersXwidth;
426 }
427  
428 =head2 is_number
429  
430 Title : is_number
431 Usage : NA
432 Function: NA
433 Returns : NA
434 Args : NA
435  
436 =cut
437  
438 0 ▶sub is_number {
Subroutine is_number: not called CC=2 SCAR=17.9
Pod documented
439 0 my $self = shift;
440 0 my $arg=$_[0];
441 0 my $var=$_[1];
442 0 ▶ if ($arg =~ /(\d+\.?\d*|\.\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /(\d+\.?\d*|\.\d+)/) { } 0 0 0
443 0 return 1;
444 } else {
445 0 return 0;
446 #die "Execution failed: Incorrect number: $arg for option $var\n";
447 }
448 }
449 1 1;
« lib/Bio/NEXUS/CodonsBlock.pm ↑ Summary lib/Bio/NEXUS/NotesBlock.pm »