[Biopython] Private '_filenames' attribute in class _SQLiteManySeqFilesDict?

Peter Cock p.j.a.cock at googlemail.com
Mon May 6 13:26:20 UTC 2013


On Fri, May 3, 2013 at 5:42 PM, Carlos Borroto <carlos.borroto at gmail.com> wrote:
> Hi,
>
> I'm writing a tool to index and query a local database using
> SeqIO.index_db(). I want to provide something similar to:
> $ blastdbcmd -db nt -info
> Database: Nucleotide collection (nt)
>         17,200,582 sequences; 44,123,601,625 total bases
>
> Date: Feb 7, 2013  4:14 PM      Longest sequence: 65,476,681 bases
>
> Volumes:
>         /local/db/blast/nt.00
>         /local/db/blast/nt.01
>         /local/db/blast/nt.02
>         /local/db/blast/nt.03
>         /local/db/blast/nt.04
>         /local/db/blast/nt.05
>         /local/db/blast/nt.06
>         /local/db/blast/nt.07
>         /local/db/blast/nt.08
>         /local/db/blast/nt.09
>         /local/db/blast/nt.10
>         /local/db/blast/nt.11
>         /local/db/blast/nt.12
>
> I have limited Object-Oriented Python's skills, actually very low
> exposure to OO in general. The object returned by SeqIO.index_db() has
> an attribute '_filenames' which I could use to report "volumes". I
> recently read it is a common rule to mark private methods and
> attributes with the starting underscore. Would it be safe to use
> '_filenames' in this case? Could this attribute be converted to a
> public one so it can be safely use without fear of breaking the code
> in the future?
>
> Thanks,
> Carlos

Hi Carlos,

Yes, this use of the underscore is intended to indicate that the
attribute _filenames is private. This should be safe to use if you
treat it as read only, but the intent was to keep open the option
of changing the implementation without altering the public API.
In this case, there is no need to keep the list in memory since
it is also in the SQLite index file - and so a future optimisation
to reduce memory usage might remove the _filenames attribute.
However, that hasn't changed yet.

I would not like to make this a public (read write) attribute. It
might be reasonable to expose it as a read only attribute
(using a Python property).

For now I would just use it in your code, but comment that it
is a private attribute and could break in a future release of
Biopython.

Regards,

Peter



More information about the Biopython mailing list