[BioRuby] New Bio::Sequence organization (Re: (no subject)
Toshiaki Katayama
ktym at hgc.jp
Mon Feb 6 14:41:52 UTC 2006
Hi,
I have changed subseq method to raise exception as Pjotr suggested.
lib/bio/sequence.rb is largely refactord after the BioRuby 0.7.1 release
and is now split into several pieces under the lib/bio/sequence/ directory.
Bio::Sequence is now became a container of rich sequence annotations
and stores the sequence itself in @seq instance variable.
This will enable users (including Jan Aerts) to write format converter etc.
Bio::Sequence::Format module will do the job when our implementation is finished.
Several common methods for NA and AA (previously in the Bio::Sequence class) are
separated into the module Bio::Sequence::Common, and lib/bio/sequence/na.rb and
aa.rb include this module.
I think the APIs of Bio::Sequence::NA and AA are not affected by this change.
Bio::Sequence::Generic is a new simple object to store an intact string
like gapped sequence or case conscious sequence mainly for alignment
(Bio::Sequence::NA or AA removes non alphabet chars in contrast).
Toshiaki
On 2006/02/01, at 2:25, Moses Hohman wrote:
> Hi Pjotr,
>
> I completely agree. We should throw an exception.
>
> Moses
>
> On Jan 31, 2006, at 1:30 AM, Pjotr Prins wrote:
>
>> Dear all,
>>
>> In the tutorial we write:
>>
>> So when using String methods, you should subtract 1 from positions
>> conventionally used in biology. (subseq method returns nil if you
>> specify positions smaller than or equal to 0 for either one of the
>> "from" or "to".)
>>
>> and I added:
>>
>> (EDITOR'S NOTE: should 'subseq' not throw an exception instead?)
>>
>> Can someone state what is the preferred design? I personally think an
>> exception should be thrown to warn a programmer something is wrong -
>> i.e. this is an exceptional situation ;-). Returning a nil may lead to
>> nicer looking loops, but it does not help writing good programs.
>>
>> Regarding the exception vs return code issue, I think Martin Fowler's
>> Refactoring says all that need to be said :
>>
>> - Returning an error code to indicate an error is a code smell because
>> you could miss the error checking
>> (http://www.refactoring.com/catalog/...hException.html)
>>
>> - Throwing an exception on a condition the caller could have checked
>> first is another code smell because it makes the caller code hard
>> to read
>> (http://www.refactoring.com/catalog/...onWithTest.html)
>>
>> Pj.
>> _______________________________________________
>> BioRuby mailing list
>> BioRuby at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/bioruby
>>
>
More information about the BioRuby
mailing list