[Bioperl-l] out or toString method

Chad Matsalla chad@sausage.usask.ca
Fri, 7 Dec 2001 10:28:40 -0600 (CST)


I mentioned this before but it might have been lost in the voluminous
amount of other text I wrapped around it.

I think that we should have a toString method defined someplace like
Bio::Root so that all classes inherit it. toString would print out a
textual representation of all of the data in the object where
printing that data as a string is reasonable. Java people would call this
as
String contents_as_string = SomeObject.toString();

This would work well for objects that have arrays and other structures
that are hard to print out on the screen (for debugging purposes).

I seem to cause some shifting from foot to foot when I rely on things like
dumpvar.pl and I think that toString would be a more consistent and
reliable way to get information in a rough form from an object. For many
cases the simple statement:
print $sequence_with_quality_object->toString();

would be a lot easier then:

print ("Sequence:".$sequence_with_quality_object->seq()."\nQuality:";
print $swq->qual()."AccessionNumber:";
print $sequence_with_quality_object->accession_number()."\n");

Any other opinions?


Chad Matsalla