Skip to content

Other Models

SgffNotes

File-level metadata (block 6). Inherits from SgffModel.

python
from sgffp import SgffNotes

BLOCK_IDS: (6,)

Properties

PropertyTypeDescription
dataDictRaw notes dict
descriptionstrFile description (settable)
createdstr | NoneCreation timestamp
last_modifiedstr | NoneLast modification timestamp

Methods

MethodDescription
get(key, default=None)Get value by key
set(key, value)Set value and sync
remove(key) → boolRemove key and sync

Example

python
sgff.notes.description = "My plasmid"
sgff.notes.set("Type", "Synthetic")
print(sgff.notes.created)         # "2024-01-15.12:00:00"
sgff.notes.remove("CustomMapLabel")

SgffProperties

Sequence properties (block 8). Inherits from SgffModel.

python
from sgffp import SgffProperties

BLOCK_IDS: (8,)

Properties

PropertyTypeDescription
dataDictRaw properties dict

Methods

MethodDescription
get(key, default=None)Get value by key
set(key, value)Set value and sync

Example

python
props = sgff.properties
print(props.get("UpstreamModification"))  # "Unmodified"
props.set("UpstreamStickiness", "4")

SgffAlignmentList

Alignable sequences (block 17). Inherits from SgffListModel[SgffAlignment].

python
from sgffp import SgffAlignmentList, SgffAlignment

BLOCK_IDS: (17,)

Provides standard list operations: add(), remove(), clear(), indexing, iteration.

SgffAlignment

Single alignable sequence.

FieldTypeDefaultDescription
namestr""Sequence name
sequencestr""Sequence string
extrasDict{}Unmodeled attributes

Methods: from_dict(data), to_dict().


SgffTraceList

Chromatogram traces (block 16 containers). Inherits from SgffListModel[SgffTrace].

python
from sgffp import SgffTraceList

BLOCK_IDS: (16,)

Loads traces from block 16 containers — each container wraps a block 18 ZTR trace with optional block 8 properties. Block 18 never appears at the top level.

Provides standard list operations: add(), remove(), clear(), indexing, iteration.

SgffTrace

Single sequence trace (Sanger chromatogram).

python
from sgffp import SgffTrace
FieldTypeDefaultDescription
basesstr""Base calls
positionsList[int][]Base-to-sample positions
confidenceList[int][]Confidence scores per base
samplesSgffTraceSamples | NoneNoneACGT channel intensities
clipSgffTraceClip | NoneNoneQuality clip boundaries
textDict[str, str]{}Metadata key-value pairs
commentsList[str][]Comment strings

Properties

PropertyTypeDescription
sequencestrAlias for bases
lengthintNumber of bases
sample_countintNumber of sample points

Methods

MethodDescription
get_metadata(key, default="")Get metadata value
get_confidence_at(index) → int | NoneConfidence at base index
get_position_at(index) → int | NoneSample position at base index
from_dict(data)Create from parsed dict
to_dict()Serialize to dict

SgffTraceClip

Quality clip boundaries.

FieldTypeDefaultDescription
leftint0Left clip position
rightint0Right clip position

SgffTraceSamples

Trace sample intensities for each channel.

FieldTypeDefaultDescription
aList[int][]Adenine channel
cList[int][]Cytosine channel
gList[int][]Guanine channel
tList[int][]Thymine channel
PropertyDescription
lengthNumber of sample points

Example

python
for trace in sgff.traces:
    print(f"{trace.length} bases, {trace.sample_count} samples")
    if trace.clip:
        print(f"  clip: {trace.clip.left}..{trace.clip.right}")
    if trace.samples:
        print(f"  A channel: {trace.samples.a[:5]}...")

Released under the MIT License.