Biopython Tutorial and Cookbook Japanese translation (4.4)

4.4 Comparison To 4.3

The SeqRecord objects can be very complex, but here’s a simple example: ** SeqRecord is very complex, but there is a simple example: **

>>> 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? ** What happens if I compare the same record? ** **

>>> 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! ** Older versions of Biopython use the python default object comparison, so comparing record1 and record2 pointing to the same point in memory returns True. This example returns 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: ** In Biopython 1.67, SeqRecord comparisons raise an explicit exception. *** ***

>>> 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: ** Please try the others yourself. For example, when comparing array identifiers: **

>>> record1.id == record2.id
True
>>> record1.seq == record2.seq
True

Beware that comparing complex objects quickly gets complicated (see also Section 3.11). ** Beware that comparing complex objects can be confusing. ** **

Recommended Posts

Biopython Tutorial and Cookbook Japanese translation (4.1)
Biopython Tutorial and Cookbook Japanese translation (4.5)
Biopython Tutorial and Cookbook Japanese translation (4.8)
Biopython Tutorial and Cookbook Japanese translation (4.9)
Biopython Tutorial and Cookbook Japanese translation (4.6)
Biopython Tutorial and Cookbook Japanese translation (4.2)
Biopython Tutorial and Cookbook Japanese translation (4.4)
Biopython Tutorial and Cookbook Japanese translation (Chapter 1, 2)
streamlit tutorial Japanese translation
sosreport Japanese translation
[Translation] hyperopt tutorial
man systemd Japanese translation
man systemd.service Japanese translation
man nftables Japanese translation
Dockerfile reference Japanese translation
docker-compose --help Japanese translation
docker help Japanese translation
SymPy tutorial Japanese notebook
[PyTorch] Tutorial (Japanese version) ② ~ AUTOGRAD ~
docker build --help Japanese translation
Chainer, RNN and machine translation
Japanese translation of sysstat manual
[PyTorch] Tutorial (Japanese version) ① ~ Tensor ~
docker run --help Japanese translation
Pandas User Guide "Table Formatting and PivotTables" (Official Document Japanese Translation)