[Biopython-dev] SeqRecord comparison suggestion

Iddo Friedberg idoerg at gmail.com
Tue Feb 4 17:57:49 UTC 2014


Thanks!

My initial thoughts are that seqrecord instances should not have an __eq__
operator. The equality operation here is somewhat meaningless when you
consider the number of parameters that can constitute a seqrecord,
especially when dealing with a genomic record or  a contig. This can lead
to unexpected behavior.

That being said, it may be a good idea to allow for a function that
performs a comprehensive comparison using all attributes.

Specifically to answer your question: I don't think the address comparison
is by design. It's a Python feature.

My $0.02

Iddo Friedberg
http://iddo-friedberg.net/contact.html
Sent from a device that promotes typos
On Feb 4, 2014 12:46 PM, "Brian Lin" <bylin at ucsc.edu> wrote:

> Hi everyone,
>
> In the past I have spent hours debugging my code because I expected
> different SeqRecord objects to evaluate as equal if all their attributes
> (id, seq, etc) were the same. Unfortunately the "==" operator only compares
> the address in memory.
>
> Is there a reason (e.g. some tradeoff, design elements, etc) that this
> behavior is tolerated? If not, I'd like to submit a pull request - I
> overloaded the __eq__ and __ne__ operators and wrote a quick test for it,
> then pushed it to:
>
> https://github.com/bylin/biopython
>
> Best,
> Brian
>
> Brian Lin | bylin at ucsc.edu | Brian's
> LinkedIn<http://www.linkedin.com/in/brianylin>
> B.S., Genetics and Computer Science, University of California at Davis
> Ph.D Program in Bioinformatics, University of California at Santa Cruz
> _______________________________________________
> Biopython-dev mailing list
> Biopython-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biopython-dev
>



More information about the Biopython-dev mailing list