[Biopython-dev] SeqFeature comparison for equality

Peter Cock p.j.a.cock at googlemail.com
Tue Oct 18 13:20:34 UTC 2011


On Tue, Oct 18, 2011 at 1:59 PM, Andrea Pierleoni
<andrea at biocomp.unibo.it> wrote:
> Hi,
> I don't know if this can help,
> but I've been subclassing seqfeature and seqrecord objects to assert
> equalities.
> I've attached the very simple code for the seqfeature equality
> Handling complex location equalities with a given set of rules could be
> misleading.
> a feature starting in position 11 is different, for me, from one located
> at position 12.
>
> Andrea

That looks reasonable for basic SeqFeature comparison, although
comparing the annotations in the qualifiers dict is debatable
(as with SeqRecord object's annotation).

Given the way join locations (etc) are currently handled, it
would be important to also compare the sub-features.

I think it would be more practical to first (and perhaps only)
implement equality testing for FeatureLocation (checking
start, end, strand, ref and db_ref), then you can compare
the location of a SeqFeature easily with:

f1.location == f2.location.

Peter



More information about the Biopython-dev mailing list