[Bioperl-l] global verbosity

Hilmar Lapp hlapp at gmx.net
Thu Dec 4 10:09:27 EST 2008

On Dec 3, 2008, at 10:23 AM, Mark A. Jensen wrote:

> I found $Bio::Root::Root:VERBOSITY, but saw that it didn't matter to  
> downstream objects when it was changed.

Interesting, but I agree.

> Digging in to the issue, found that global verbosity can't really be  
> set, though one can access the value of $VERBOSITY with
> Bio::Root::Root::verbose().

One can of course set $Bio::Root::Root::VERBOSITY.

> http://bugzilla.open-bio.org/show_bug.cgi?id=2696
> has a patch + .t to Root.pm that I
> think solves the issue, allowing getting and setting of global
> verbosity, so that the global value now propagates to new objects.

I guess the simple fix would have been

if (defined $value || ! defined $self->{'_root_verbose'}) {
- $self->{'_root_verbose'} = $value || 0;
+ $self->{'_root_verbose'} = $value || $VERBOSITY || 0;

But I like your patch in that it enables a static method call to set  
the global default. Except the line

+    $self->{'_root_verbose'} = $VERBOSITY;
+    # now look for flag and update if nec...

Doesn't that override any previously set value to the global default?  
I.e., I don't think the above would pass

ok ($seq->verbose(), 1);

Or am I missing something?

> There is a stickier issue (example using Bio::Seq and
> Bio::Seq->primary_seq() in the .t file), in which
> setting an object's verbosity post-construction does not propagate to
> sub-objects contained in the object, so that one might not get what
> one expects.

I think the run-time changing for an object not propagating to sub- 
objects is expected behavior. It would also be very difficult to solve  
this cleanly, as you would either have to expect derived objects to  
override some method to inject their own sub-objects into the chain,  
or you would need base objects to have knowledge about what their  
derivatives do.

For our records I responded that to the patch as well.

: Hilmar Lapp  -:-  Durham, NC  -:-  hlapp at gmx dot net :

More information about the Bioperl-l mailing list