[Bioperl-l] How to get rid of warnings

Sendu Bala bix at sendu.me.uk
Fri Aug 18 15:50:39 UTC 2006


Niels Larsen wrote:
> I am a casual user of bioperl with my own error handling. Is there
> a way to switch off bioperls error handling? I switch off my own
> with
> 
> $Common::Config::with_errors = 0;
> $Common::Config::with_warnings = 0;

There's no current sanctioned way of doing this.

It would be relatively easy to implement though. One possible way is to 
alter Bio::Root::RootI like:

104c104 (at top)
< use vars qw($DEBUG $ID $Revision $VERBOSITY);
---
 > use vars qw($DEBUG $ID $Revision $VERBOSITY $WARNINGS);
114a115 (in BEGIN)
 >     $WARNINGS  = 1;
174c175,180 (in &warn)
<     my ($self,$string) = @_;
---
 >     my ($self,$string,$switch) = @_;
 >
 >     if ($switch) {
 >         $WARNINGS = $WARNINGS ? 0 : 1;
 >     }
 >     return unless $WARNINGS;

Then you could do:
my $switcher = new Bio::Root::Root();
$switcher->warn(undef, 1); # globally switch all warnings off
$switcher->warn(undef, 1); # switch all warnings back on

Or something along those lines. There's probably a nicer way of doing it.



More information about the Bioperl-l mailing list