Skip to content

Sequence & Features

SgffSequence

Wrapper for DNA, RNA, and Protein sequence blocks.

python
from sgffp import SgffSequence

BLOCK_IDS: (0, 1, 21, 32) — DNA, compressed DNA, protein, RNA

Properties

PropertyTypeDescription
valuestrSequence string (settable)
lengthintSequence length
topologystr"linear" or "circular" (settable)
strandednessstr"single" or "double" (settable)
is_circularboolTrue if circular topology
is_double_strandedboolTrue if double-stranded
block_idint | NoneActive block type (0, 1, 21, 32) (settable)
dataSgffSequenceDataUnderlying dataclass

Setting value, topology, or strandedness automatically syncs back to the blocks dict.

SgffSequenceData

Underlying dataclass for sequence data.

FieldTypeDefault
valuestr""
topologystr"linear"
strandednessstr"single"
dam_methylatedboolFalse
dcm_methylatedboolFalse
ecoki_methylatedboolFalse

Methods: from_dict(data), to_dict(), property length.


SgffFeatureList

List model for annotation features. Inherits from SgffListModel[SgffFeature].

python
from sgffp import SgffFeatureList

BLOCK_IDS: (10,)

Methods

MethodDescription
find_by_name(name) → SgffFeature | NoneFind first feature by name
find_by_type(type_) → List[SgffFeature]Find all features of a type
add(feature)Add a feature and sync
remove(idx) → boolRemove by index and sync
clear()Remove all features
len(fl)Count of features
fl[idx]Feature at index
for f in flIterate features

SgffFeature

Single annotation feature.

python
from sgffp import SgffFeature, SgffSegment
FieldTypeDefaultDescription
namestrFeature name
typestrFeature type (e.g., "CDS", "promoter")
strandstr"+""+", "-", "." (none), "=" (both)
segmentsList[SgffSegment][]Location ranges
qualifiersDict[str, Any]{}Parsed qualifiers
colorstr | NoneNoneColor from first segment
reading_frameint | NoneNoneReading frame offset (-3…-1, 1…3)
extrasDict{}Unmodeled XML attributes
raw_qualifiersList | NoneNoneRaw qualifier dicts for lossless roundtrip

Computed Properties

PropertyTypeDescription
startintFirst segment start (0-based)
endintLast segment end (1-based)

Methods

MethodReturnsDescription
length(seq_len=None)intFeature length. For origin-spanning features on circular sequences, pass seq_len to get the correct wrapped length.
from_dict(data)SgffFeatureCreate from dict
to_dict()DictSerialize to dict

SgffSegment

Single feature location range.

FieldTypeDefaultDescription
startintStart position (0-based)
endintEnd position (1-based)
colorstr | NoneNoneHex color (e.g., "#00ff00")
typestr"standard"Segment type: "standard" or "gap"
translatedboolFalseWhether this segment is translated
extrasDict{}Unmodeled XML attributes

Methods: from_dict(data), to_dict().


SgffPrimerList

List model for primers. Inherits from SgffListModel[SgffPrimer].

python
from sgffp import SgffPrimerList

BLOCK_IDS: (5,)

Provides the same list operations as SgffFeatureList: add(), remove(), clear(), indexing, iteration.

SgffPrimer

Single primer definition.

python
from sgffp import SgffPrimer
FieldTypeDefaultDescription
namestr""Primer name
sequencestr""Primer sequence
binding_sitesList[SgffBindingSite][]Parsed binding site data
extrasDict{}Unmodeled XML attributes

Computed Properties (backward compatible)

PropertyTypeDescription
bind_positionint | NoneStart position of first non-simplified binding site (0-based)
bind_strandstrStrand of first non-simplified binding site ("+" or "-")
melting_temperaturefloat | NoneMelting temperature of first non-simplified binding site

Methods

MethodDescription
clear_binding_sites()Remove all binding site data so SnapGene recalculates it
from_dict(data)Create from parsed dict
to_dict()Serialize to dict

SgffBindingSite

A single primer binding site on the target sequence. SnapGene stores both detailed and simplified versions of each site.

python
from sgffp import SgffBindingSite
FieldTypeDefaultDescription
startint0Start position (0-based)
endint0End position (1-based)
bound_strandstr"+""+" (forward/top) or "-" (reverse/bottom)
annealed_basesstr""Annealed base sequence
melting_temperaturefloat | NoneNoneMelting temperature in °C
simplifiedboolFalseWhether this is a simplified binding site
extrasDict{}Unmodeled data (e.g., Component elements)

Methods

MethodReturnsDescription
length(seq_len=None)intBinding site length. For origin-spanning sites on circular sequences, pass seq_len to get the correct wrapped length.
from_dict(data)SgffBindingSiteCreate from dict
to_dict()DictSerialize to dict

Released under the MIT License.