[Biopython-dev] [biopython-dev] SeqFeature comparison for equality

Peter Cock p.j.a.cock at googlemail.com
Mon Oct 17 14:07:27 EDT 2011


2011/10/17 Joshua Ismael Haase Hernández <hahj87 at gmail.com>:
> ...
>
> This positions would be the same:
>
> OneOfPosition(5, 11, 15),
> ExactPosition(11),
> AfterPosition(4),
> BeforePosition(16),
> WithinPosition(5, 16),

I don't understand what you are asking here. Those
positions do not look the same to me.

>>
>> No. Having tried this myself, it is very complicated.
>
> I think I'm missing something, why is it hard?,
> I see it as a cases listing.

Well, try it and write lots of unit tests, and I'll review it.

>>
>> Also, there are constraints with the Python language
>> about equality, hashing and comparisons (e.g. for
>> membership in lists, or use as dictionary keys).
>
> I don't think anyone should use Features as dictionary keys,
> they will use Feature Id for that, but maybe someona wants a
> set of features (which just now is like a list of all sequences)...
>
> I which cases that should be a problem? (I'm biothechnology
> engineer, so I don't see all caveats, and i don't really have
> deep undestanding about how python works)

Using positions as dictionary keys seems reasonable.

Using a SeqFeature as a key is not possible as they
are mutable objects.

>> The current behaviour of simple comparison of
>> the positions as an integer is at least simple.
>>
>> > About SeqFeature, I think they should be
>> > the same if they share all locations.
>>
>> You don't care about feature type and ID?  ;)
>
> maybe not, a comparison could skip iterating
> the locations if we have the same type and id,
> still not sure that's a good method (thus the comment
> «# Can we trust this?» on my patch) but a feature
> 'CDS' is sometimes equivalent to feature 'mRNA',
> in that case ID and type would both be different
> in seqfeatures.

A gene, mRNA and CDS might all have the same
position, but they are different features.

Peter



More information about the Biopython-dev mailing list