[Bioperl-l] Detecting type of an object.

hilmar.lapp@pharma.Novartis.com hilmar.lapp@pharma.Novartis.com
Thu, 12 Oct 2000 12:28:35 +0100

I'm not sure why you want to test the object type in this case. Anyway, you
can ask

   $class_name = ref($obj);
   # branch depending on the value of class_name


   if(! $obj->isa('Bio::PrimarySeqI')) {
      print "Object $obj is not a BioPerl seq object\n";

Does this help?


gert thijs <gert.thijs@esat.kuleuven.ac.be>@bioperl.org on 12.10.2000

Sent by:  bioperl-l-admin@bioperl.org

To:   bioperl mailinglist <bioperl-l@bioperl.org>
Subject:  [Bioperl-l] Detecting type of an object.

I am wondering if it is possible to detect the type of an object.
For instance, I have written a module that parses a blast report to select
sequence. The module returns the sequence as a Bio::Seq object if the
was succesful and some error message when there was no good hit found.
Now when I use this module in a script I would like to test whether or not
there is a sequence found before doing something with the sequence. Is
there a
proper way to tackle such a problem?

Gert Thijs

+ Gert Thijs              gert.thijs@esat.kuleuven.ac.be +
+                                                        +
+ Dept. Elektrotechniek ESAT-SISTA                       +
+ Kardinaal Mercierlaan, 94                              +
+ B-3001 HEVERLEE  Belgium                               +
+ Tel :  +32-16-32 18 84 ---- Fax : +32-16-32 19 70      +
Bioperl-l mailing list