A SeqRecord object is the primary container in Biopython used to hold a biological sequence (as a Seq object) along with its associated metadata. It includes identifiers (id and name), a description, and optional annotations and features (sub-features).
While most users obtain SeqRecord objects by parsing files using the Bio.SeqIO module, they can also be instantiated manually.
Key components of a SeqRecord include:
- Sequence: The actual biological sequence, stored as a
Bio.Seq.Seq object. - Identifiers: String attributes for
id, name, and description. - Annotations: A dictionary containing metadata (e.g., taxonomy, source, or references).
- Features: A list of
SeqFeature objects representing specific regions of the sequence. - Database Cross-references: A list of database identifiers (
dbxrefs).
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
record = SeqRecord(
Seq("MKQHKAMIVALIVICITAVVAALVTRKDLCEVHIRTGQTEVAVF"),
id="YP_025292.1",
name="HokC",
description="toxic membrane protein, small",
)
print(record)