[Bioperl-l] Interface of the method

Chris Fields cjfields at illinois.edu
Fri Jun 18 09:41:32 EDT 2010


Jun, 

It all depends on optimization.  I like the named argument version myself.  The current bioperl named parameters implementation requires, in order to parse out the named parameters, you have to call either the core _rearrange() method or Lincoln's rearrange() utility for consistency (deals with all sorts of variants, and Lincoln's allows aliases).  Either way is a small hit, which is fine in most cases, but if the method is called possibly thousands of times it amplifies accordingly and may become a bottleneck on speed.  

You could have your cake and eat it too; check if the first argument is an arrayref and do it it the original way, otherwise use rearrange().  

BTW, this won't work:

'-seqs' => (1, 3, 5..10,15), -toggle => "yes"

The list flattens out into this:

'-seqs', 1, 3, 5, 6, 7, 8, 9, 10, 15, -toggle, "yes" (12 elems) 

So they don't pair up as you would expect; this is a silent bug, as rearrange() will happily assign 1 to 'seqs' and toss the rest unless they are asked for.  With and odd number of elements you would see warnings popping up.

You'll have to use arrayrefs to get proper name-value pairings:

'-seqs', [ 1, 3, 5, 6, 7, 8, 9, 10, 15], -toggle, "yes" (4 elems)

chris

On Jun 18, 2010, at 5:47 AM, Jun Yin wrote:

> Hi, Dave,
> 
> No problem. I think your suggestion of using 
> $newaln=$aln->select_Seqs('-seqs' => (1, 3, 5..10,15), -toggle => "yes"); 
> is more reasonable. It is a more BioPerl way of defined parameters.
> 
> And, $newaln=$aln->select_Seqs(1, 3, 5..10,15); 
> will also be recognized for the simplicity of use.
> 
> Cheers,
> Jun Yin
> Ph.D. student in U.C.D.
> 
> Bioinformatics Laboratory
> Conway Institute
> University College Dublin
> 
> 
> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-bounces at lists.open-bio.org] On Behalf Of Dave Messina
> Sent: Friday, June 18, 2010 10:38 AM
> To: Jun Yin
> Cc: bioperl-l at lists.open-bio.org
> Subject: Re: [Bioperl-l] Interface of the method
> 
> Hi Jun,
> 
> 
>> In the BioPerl guide,
>> http://www.bioperl.org/wiki/Advanced_BioPerl
>> 
>> They say that, Capital word should be used for methods returning  
>> objects,
> 
> You're absolutely right. My apologies — thanks for pointing that out.
> 
> 
>> Thus an array reference
>> [1,3,5..10] seems better than a list (1,3,5..10),
>> the latter will be hard to recognize the other parameters.
> 
> 
>> 
> Aaand, you're right here, too.
> 
> Again, sorry about that. It was quite late last night when I was  
> replying to your email, and I sure wasn't thinking clearly.
> 
> So, please don't mind me, ( carry on, as you were!) and thanks again  
> for your work on this.
> 
> 
> Dave 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
> 
> 
> __________ Information from ESET Smart Security, version of virus signature database 5099 (20100509) __________
> 
> The message was checked by ESET Smart Security.
> 
> http://www.eset.com
> 
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l





More information about the Bioperl-l mailing list