Datatypes#

physquirrel defines two core datatypes for representing quartet information, both extending the corresponding phylozoo base classes. For serialization formats (psq JSON and profile_list plain-text), see I/O.

SqQuartetProfile#

class physquirrel.datatypes.sqprofile.SqQuartetProfile(quartets: dict[Quartet, float] | Mapping[Quartet, float] | list[Quartet] | list[tuple[Quartet, float]], reticulation_leaf: str | None = None)#

Bases: QuartetProfile

Squirrel quartet profile: exactly 1 or 2 resolved quartets.

If it contains 2 quartets (forming a 4-cycle), it may have an optional reticulation_leaf identifying the leaf below the hybrid node.

property circular_ordering: CircularOrdering | None#
property reticulation_leaf: str | None#

SqQuartetProfileSet#

class physquirrel.datatypes.sqprofileset.SqQuartetProfileSet(profiles: list[SqQuartetProfile | Quartet | tuple[SqQuartetProfile, float] | tuple[Quartet, float]] | None = None, taxa: frozenset[str] | None = None)#

Bases: QuartetProfileSet, IOMixin

Collection of SqQuartetProfile objects with .psq/.txt I/O support.

Accepts SqQuartetProfile objects, Quartet objects (auto-grouped by taxa), or tuples of (profile/quartet, weight).

get_profile(taxa: frozenset[str]) SqQuartetProfile | None#

Get the profile for a 4-taxon set.

Parameters:

taxa (frozenset[str]) – The 4-taxon set.

Returns:

The profile for the taxa, or None if not found.

Return type:

QuartetProfile | None

property profiles: Mapping[frozenset[str], tuple[SqQuartetProfile, float]]#

Get the profiles and their weights (read-only).

Returns:

Read-only mapping of 4-taxon sets to (profile, profile_weight) tuples.

Return type:

Mapping[frozenset[str], tuple[QuartetProfile, float]]