biocantor.parent.parent
Module Contents
Classes
Functions
|
Checks if a set of values contains more than one distinct non-null value. If so, raises ValueError. |
Attributes
- biocantor.parent.parent.Parent
- biocantor.parent.parent.ParentInputType
- biocantor.parent.parent.PARENT_CACHE_SIZE = 1000
- biocantor.parent.parent._unique_value_or_none(values: Iterable[Optional[str]]) Optional[str]
Checks if a set of values contains more than one distinct non-null value. If so, raises ValueError. Otherwise, returns the single unique non-null value (if there is one) or None if all values are None.
- class biocantor.parent.parent.Parent(*, id: Optional[str] = None, sequence_type: Optional[Union[inscripta.biocantor.SequenceType, str]] = None, strand: Optional[inscripta.biocantor.location.strand.Strand] = None, location: Optional[inscripta.biocantor.AbstractLocation] = None, sequence: Optional[inscripta.biocantor.AbstractSequence] = None, parent: Optional[ParentInputType] = None)
Bases:
inscripta.biocantor.AbstractParent
Holds information about a parent of some object. Typically the child object should hold a reference to this parent.
- property strand: Optional[inscripta.biocantor.location.strand.Strand]
Returns the Strand of this Parent. If this Parent has no explicit Strand, but has a Location, that Location’s Strand is returned.
- __slots__ = []
- __eq__(other)
Return self==value.
- equals_except_location(other, require_same_sequence: bool = True)
Checks that this Parent is equal to another Parent, ignoring the associated Location members.
By default also checks that any associated Sequence objects also match, but this can be toggled off.
- __hash__()
Return hash(self).
- __repr__()
Return repr(self).
- strip_location_info() Parent
Returns a new Parent object representing this Parent with information about child location removed
- first_ancestor_of_type(sequence_type: Union[str, inscripta.biocantor.SequenceType], include_self: bool = True) Parent
Returns the Parent object representing the closest ancestor (parent, parent of parent, etc.) of this Parent which has the given sequence type. If include_self is True and this Parent has the given type, returns this object. Raises NoSuchAncestorException if no ancestor with the given type exists.
- Parameters
sequence_type (str) – Sequence type
include_self – Include this sequence as a candidate
- has_ancestor_of_type(sequence_type: Union[str, inscripta.biocantor.SequenceType], include_self: bool = True) bool
Returns True if some ancestor (parent, parent of parent, etc.) of this Parent has the given sequence type, or False otherwise. If include_self is True and this Parent has the given type, returns True.
- Parameters
sequence_type (str) – Sequence type
include_self – Include this sequence as a candidate
- lift_child_location_to_parent()
Lifts location of child object on this parent to the parent of this parent. Raises ValueError if any required data is missing (child location or location of this parent on its parent).
- Returns
Child object location lifted to the parent of this parent
- Return type
- reset_location(location) Parent
Returns a new Parent object with child location set to the given location
- has_ancestor_sequence(sequence, include_self: bool = True) bool
Returns True iff this Parent has some ancestor (parent, parent of parent, etc.) whose sequence attribute is equal to the given sequence. If include_self is True and this Parent has sequence attribute equal to the given sequence, returns True.