alhambra.seq#

Module Contents#

Classes#

Seq

Functions#

revcomp(→ str)

Return the reverse complement of a string sequence. Preserves

is_null(→ bool)

Return True if a sequence consists only of Ns (or Xs), or is empty.

is_definite(→ bool)

Return True if a sequence consists only of defined bases. Return

check_seq(seq_str)

Raises an error (InvalidSequence) if the sequence has invalid elements.

count_ambiguous(→ int)

Return the number of ambiguous bases in a sequence.

dna_length(→ int)

Return the length of a sequence, stripping whitespace. This does not handle

merge(→ str)

Merge two sequences together, returning a single sequence that

Attributes#

_L_TO_N

_N_TO_L

_WC

_PUNC

_WC_WITH_PUNC

_AMBBASES

_VALID_NTS

_VALID_WITH_PUNC

alhambra.seq._L_TO_N[source]#
alhambra.seq._N_TO_L[source]#
alhambra.seq._WC[source]#
alhambra.seq._PUNC = Multiline-String[source]#
Show Value
"""-+
        """
alhambra.seq._WC_WITH_PUNC[source]#
alhambra.seq._AMBBASES[source]#
alhambra.seq._VALID_NTS[source]#
alhambra.seq._VALID_WITH_PUNC[source]#
alhambra.seq.revcomp(seq_str: str) str[source]#

Return the reverse complement of a string sequence. Preserves whitespace and capitalization. Does not do any sequence checking.

alhambra.seq.is_null(seq_str: str | None, _check_seq: bool = True) bool[source]#

Return True if a sequence consists only of Ns (or Xs), or is empty. Return False otherwise.

alhambra.seq.is_definite(seq_str: str | None, _check_seq: bool = True) bool[source]#

Return True if a sequence consists only of defined bases. Return False otherwise. If blank, return False.

alhambra.seq.check_seq(seq_str: str)[source]#

Raises an error (InvalidSequence) if the sequence has invalid elements.

alhambra.seq.count_ambiguous(seq_str: str, _check_seq: bool = True) int[source]#

Return the number of ambiguous bases in a sequence.

alhambra.seq.dna_length(seq_str: str, _check_seq: bool = True) int[source]#

Return the length of a sequence, stripping whitespace. This does not handle extended labels, etc.

alhambra.seq.merge(seq1: str, seq2: str, _check_seq: bool = True) str[source]#

Merge two sequences together, returning a single sequence that represents the constraint of both sequences. If the sequences can’t be merged, raise a MergeConflictError.

exception alhambra.seq.InvalidSequence[source]#

Bases: ValueError

Inappropriate argument value (of correct type).

sequence: str[source]#
invalids: List[Tuple[int, str]][source]#
exception alhambra.seq.MergeConflictError[source]#

Bases: ValueError

Merge of items failed because of conflicting information. Arguments are (item1, item2, location or property, value1, value2)

item1: str[source]#
item2: str[source]#
location: str | Tuple[int, int] | int[source]#
value1: str | int[source]#
value2: str | int[source]#
exception alhambra.seq.MergeConflictsError[source]#

Bases: ValueError

Merge of multiple items failed because individual merges raised MergeConflictErrors. Arguments are ([list of MergeConflictErrors])

class alhambra.seq.Seq(seq_str: Seq | str)[source]#
property revcomp: Seq[source]#
property is_null: bool[source]#
property is_definite: bool[source]#
property dna_length: int[source]#
property n_ambiguous: int[source]#
property base_str: str[source]#
seq_str: str[source]#
__add__(other: Seq | str) Seq[source]#
__radd__(other: Seq | str) Seq[source]#
merge(other: Seq | str | None) Seq[source]#
__or__(other: Seq | str | None) Seq[source]#
__ror__(other: Seq | str | None) Seq[source]#
__str__() str[source]#

Return str(self).

__repr__() str[source]#

Return repr(self).

__len__() int[source]#
abstract __getitem__(ix: int | slice) Seq[source]#