More than 1 year has passed since last update.

posted at

updated at

Biopython Tutorial and Cookbook和訳(4.9)

4.9 Reverse-complementing SeqRecord objects


One of the new features in Biopython 1.57 was the SeqRecord object’s reverse_complement method.
This tries to balance easy of use with worries about what to do with the annotation in the reverse complemented record.
Biopython 1.57に新機能reverse_complementメソッドを追加しました。

For the sequence, this uses the Seq object’s reverse complement method.
Any features are transferred with the location and strand recalculated.
Likewise any per-letter-annotation is also copied but reversed (which makes sense for typical examples like quality scores).
However, transfer of most annotation is problematical.

For instance, if the record ID was an accession, that accession should not really apply to the reverse complemented sequence, and transferring the identifier by default could easily cause subtle data corruption in downstream analysis.
Therefore by default, the SeqRecord’s id, name, description, annotations and database cross references are all not transferred by default.
例として、record IDはaccession(登録番号)の場合、そのaccessionが反転、補完された配列に使われるべきではない、そしてidentifierをデフォルトで変換したら下流プロセス分析時のデータ損害を起こすかもしれないです。
そのゆえデフォルトではSeqRecord’s id, name, description, annotationsおよびdatabase cross referencesの変換を行わないです。

The SeqRecord object’s reverse_complement method takes a number of optional arguments corresponding to properties of the record.
Setting these arguments to True means copy the old values, while False means drop the old values and use the default value.
You can alternatively provide the new desired value instead.

Consider this example record:

>>> from Bio import SeqIO
>>> record = SeqIO.read("NC_005816.gb", "genbank")
>>> print("%s %i %i %i %i" % (record.id, len(record), len(record.features), len(record.dbxrefs), len(record.annotations)))
NC_005816.1 9609 41 1 13

Here we take the reverse complement and specify a new identifier – but notice how most of the annotation is dropped (but not the features):
reverse_complementメソッドを使って新しいIDを指定します - 注意すべきなのは多くのannotationを失ったが、featuresは健在です。

>>> rc = record.reverse_complement(id="TESTING")
>>> print("%s %i %i %i %i" % (rc.id, len(rc), len(rc.features), len(rc.dbxrefs), len(rc.annotations)))
TESTING 9609 41 0 0


Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up