[Bioperl-l] Interface of the method
Dave Messina
David.Messina at sbc.su.se
Thu Jun 17 19:48:35 EDT 2010
Hi Jun,
Great! Glad to hear you're taking on this project.
> This may cause some confusion.So I propose that we should use a more
> consistent way for similar functions.
>
> For example, the methods of
>
> select_Seq
>
> select_columns
>
> remove_Seq
>
> remove_columns
>
> mask_columns
>
> .
>
> should have the same interface.
Agreed, absolutely. Consistency is important. I would further propose that select_Seq be select_seqs, if indeed multiple seqs are to be selected with this method. Also, capital letters are typically not used in BioPerl method names. For example, eachSeq was deprecated in favor of each_seq.
> So I suggest, we can do
>
> $new_aln=$aln->select_Seq([1,3,5..10,15],"toggle")
>
> Or
>
> $new_aln=$aln->select_columns([2.25,34,52..60])
BioPerl tends to use named parameters passed as a hash, e.g.:
my $in = Bio::SeqIO->new('-format' => 'fasta', '-file' => 'my.fasta');
So something more like:
$new_aln = $aln->select_seqs('-seqs' => (1, 3, 5..10,15), -toggle => 'yes);
$new_aln = $aln->select_columns('-columns' => (2, 25, 45, 52..60);
Admittedly, it's redundant to say -seqs when the method is named select_seqs, and maybe less redundant labels can be chosen.
Also, and this is perhaps a minor point, using () instead of [] here for the set of seqs or columns is better, since [] implies indexing into an array, which isn't what's being done.
Dave
More information about the Bioperl-l
mailing list