4.4 Comparison Vers 4.3
The SeqRecord objects can be very complex, but here’s a simple example: ** SeqRecord est très complexe, mais il existe un exemple simple: **
>>> from Bio.Seq import Seq
>>> from Bio.SeqRecord import SeqRecord
>>> record1 = SeqRecord(Seq("ACGT"), id="test")
>>> record2 = SeqRecord(Seq("ACGT"), id="test")
What happens when you try to compare these “identical” records? ** Que se passe-t-il si je compare le même enregistrement? ** **
>>> record1 == record2
...
Perhaps surprisingly older versions of Biopython would use Python’s default object comparison for the SeqRecord, meaning record1 == record2 would only return True if these variables pointed at the same object in memory. In this example, record1 == record2 would have returned False here! ** Les versions plus anciennes de Biopython utilisent la comparaison d'objets par défaut de python, donc comparer record1 et record2 pointant vers le même point de la mémoire renvoie True. Cet exemple renvoie False. ** **
>>> record1 == record2 # on old versions of Biopython!
False
As of Biopython 1.67, SeqRecord comparison like record1 == record2 will instead raise an explicit error to avoid people being caught out by this: ** Dans Biopython 1.67, les comparaisons SeqRecord lèvent une exception explicite. *** ***
>>> record1 == record2
Traceback (most recent call last):
...
NotImplementedError: SeqRecord comparison is deliberately not implemented. Explicitly compare the attributes of interest.
Instead you should check the attributes you are interested in, for example the identifier and the sequence: ** Veuillez essayer les autres vous-même. Par exemple, comparer les identificateurs de tableau: **
>>> record1.id == record2.id
True
>>> record1.seq == record2.seq
True
Beware that comparing complex objects quickly gets complicated (see also Section 3.11). ** Attention, comparer des objets complexes peut être déroutant. ** **
Recommended Posts