4.4 Comparison Bis 4.3
The SeqRecord objects can be very complex, but here’s a simple example: ** SeqRecord ist sehr komplex, aber es gibt ein einfaches Beispiel: **
>>> 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? ** Was passiert, wenn ich denselben Datensatz vergleiche? ** ** **
>>> 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! ** Ältere Versionen von Biopython verwenden den Python-Standardobjektvergleich. Wenn Sie also record1 und record2 vergleichen, die auf denselben Punkt im Speicher verweisen, wird True zurückgegeben. Dieses Beispiel gibt False zurück. ** ** **
>>> 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: ** In Biopython 1.67 lösen SeqRecord-Vergleiche eine explizite Ausnahme aus. *** ***
>>> 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: ** Probieren Sie die anderen selbst aus. Vergleichen von Array-IDs: **
>>> record1.id == record2.id
True
>>> record1.seq == record2.seq
True
Beware that comparing complex objects quickly gets complicated (see also Section 3.11). ** Beachten Sie, dass der Vergleich komplexer Objekte verwirrend sein kann. ** ** **
Recommended Posts