biocantor.sequence.sequence
Module Contents
Classes
Attributes
- biocantor.sequence.sequence.Location
- biocantor.sequence.sequence.Sequence
- biocantor.sequence.sequence.ParentInputType
- class biocantor.sequence.sequence.Sequence(data: str, alphabet: inscripta.biocantor.sequence.alphabet.Alphabet, id: Optional[str] = None, type: Optional[Union[inscripta.biocantor.parent.SequenceType, str]] = None, parent: Optional[ParentInputType] = None, validate_alphabet: bool = True, validate_parent: bool = True)
Bases:
inscripta.biocantor.AbstractSequence
A sequence with an alphabet
- property parent_strand: Optional[inscripta.biocantor.location.strand.Strand]
Strand of this sequence
- __slots__ = []
- __eq__(other)
Return self==value.
- __hash__()
Return hash(self).
- __str__()
Returns the sequence data as a string
- __getitem__(key: Union[int, slice]) Sequence
Returns a slice of the current Sequence as a new Sequence object
- __repr__()
Return repr(self).
- _validate_alphabet()
Raises AlphabetError if this Sequence does not conform to its alphabet
- static validate_alphabet(sequence, alphabet)
- reverse_complement(new_id: str = None, new_type: str = None) Sequence
Returns a new Sequence corresponding to the reverse complement of this Sequence. Location on parent, if it exists, is converted appropriately.
- Parameters
new_id – ID for the returned Sequence. If no value is provided, None is used.
new_type – Sequence type for the returned Sequence. If no value is provided, None is used.
- append(other: Sequence, new_id: Optional[str] = None, data_only: bool = False) Sequence
Returns a new Sequence consisting of other sequence appended to the end of this Sequence
- Parameters
other – Other sequence
new_id – ID for the returned sequence
data_only – Only combine sequence data, ignoring and removing metadata such as sequence type and parent info. If False, all metadata for both sequences must be consistent, and the returned sequence will have appropriate combined metadata.
- first_ancestor_of_type(sequence_type: str, include_self: bool = True) inscripta.biocantor.parent.Parent
Returns the Parent object representing the closest ancestor (parent, parent of parent, etc.) of this sequence which has the given sequence type. If include_self is True and this sequence has the given type, returns a new Parent object representing this sequence. Raises NoSuchAncestorException if no ancestor with the given type exists.
- Parameters
sequence_type – Sequence type
include_self – Include this sequence as a candidate
- has_ancestor_of_type(sequence_type: str, include_self: bool = True) bool
Returns True if some ancestor (parent, parent of parent, etc.) of this sequence which has the given sequence type, or False otherwise. If include_self is True and this sequence has the given type, returns True.
- Parameters
sequence_type – Sequence type
include_self – Include this sequence as a candidate