mutcleaner.core.sequence#
Classes
|
Base class for biological sequences |
|
DNA sequence with nucleotide validation |
|
Protein sequence with amino acid validation |
|
RNA sequence with nucleotide validation |
- class mutcleaner.core.sequence.BaseSequence(sequence, alphabet=None, name=None, metadata=None)[source]#
Bases:
ABCBase class for biological sequences
Methods
apply_mutation(mutation)Apply a mutation or set of mutations to the sequence and return a new sequence.
Subclasses may override this method to provide a default alphabet.
get_subsequence(start[, end])get subsequence (0-indexed, inclusive)
infer_mutation(other)Infer a mutation that leads to a specific sequence
- apply_mutation(mutation)[source]#
Apply a mutation or set of mutations to the sequence and return a new sequence.
- Parameters:
mutation (
Union[BaseMutation,MutationSet,MutationSet[BaseMutation]]) – A single mutation or a set of mutations to apply- Return type:
TypeVar(SequenceType, bound= BaseSequence)- Returns:
A new sequence with the mutation(s) applied
- Raises:
ValueError – If mutation position is invalid or mutation is incompatible
TypeError – If mutation type is not supported
- classmethod default_alphabet()[source]#
Subclasses may override this method to provide a default alphabet.
By default, it returns None, indicating no default is provided and callers must pass alphabet explicitly.
- Return type:
Optional[BaseAlphabet]
- get_subsequence(start, end=None)[source]#
get subsequence (0-indexed, inclusive)
- Return type:
TypeVar(SequenceType, bound= BaseSequence)
- class mutcleaner.core.sequence.DNASequence(sequence, alphabet=None, name=None, metadata=None)[source]#
Bases:
BaseSequenceDNA sequence with nucleotide validation
Methods
apply_mutation(mutation)Apply a mutation or set of mutations to the sequence and return a new sequence.
Subclasses may override this method to provide a default alphabet.
get_subsequence(start[, end])get subsequence (0-indexed, inclusive)
infer_mutation(other)Infer a mutation that leads to a specific sequence
Get reverse complement of DNA sequence
Transcribe DNA sequence into RNA sequence
translate([codon_table, start_at_first_met, ...])Translate DNA sequence into amino acid sequence using this codon table.
- classmethod default_alphabet()[source]#
Subclasses may override this method to provide a default alphabet.
By default, it returns None, indicating no default is provided and callers must pass alphabet explicitly.
- Return type:
Optional[BaseAlphabet]
- translate(codon_table=None, start_at_first_met=False, stop_at_stop_codon=False, require_mod3=True, start=None, end=None)[source]#
Translate DNA sequence into amino acid sequence using this codon table.
- Parameters:
codon_table (
Optional[CodonTable]) – Codon table to use for translation. If None, uses standard genetic code.start_at_first_met (
bool) – Start translation at the first start codon if found.stop_at_stop_codon (
bool) – Stop translation when a stop codon is encountered.require_mod3 (
bool) – Whether the sequence must be a multiple of 3 in length.start (
Optional[int]) – Custom 0-based start position. Overrides start_at_first_met.end (
Optional[int]) – Custom 0-based end position. Overrides stop_at_stop_codon.
- Return type:
- Returns:
Translated amino acid sequence.
- class mutcleaner.core.sequence.ProteinSequence(sequence, alphabet=None, name=None, metadata=None)[source]#
Bases:
BaseSequenceProtein sequence with amino acid validation
Methods
apply_mutation(mutation)Apply a mutation or set of mutations to the sequence and return a new sequence.
Subclasses may override this method to provide a default alphabet.
find_motif(motif)Find all positions where motif occurs (0-indexed)
get_residue(position)Get amino acid at specific position (0-indexed)
get_subsequence(start[, end])get subsequence (0-indexed, inclusive)
infer_mutation(other)Infer a mutation that leads to a specific sequence
- classmethod default_alphabet()[source]#
Subclasses may override this method to provide a default alphabet.
By default, it returns None, indicating no default is provided and callers must pass alphabet explicitly.
- Return type:
Optional[BaseAlphabet]
- class mutcleaner.core.sequence.RNASequence(sequence, alphabet=None, name=None, metadata=None)[source]#
Bases:
BaseSequenceRNA sequence with nucleotide validation
Methods
apply_mutation(mutation)Apply a mutation or set of mutations to the sequence and return a new sequence.
Back-transcribe RNA sequence into DNA sequence
Subclasses may override this method to provide a default alphabet.
get_subsequence(start[, end])get subsequence (0-indexed, inclusive)
infer_mutation(other)Infer a mutation that leads to a specific sequence
Get reverse complement of RNA sequence
translate([codon_table, start_at_first_met, ...])Translate RNA sequence into amino acid sequence using this codon table.
- classmethod default_alphabet()[source]#
Subclasses may override this method to provide a default alphabet.
By default, it returns None, indicating no default is provided and callers must pass alphabet explicitly.
- Return type:
Optional[BaseAlphabet]
- translate(codon_table=None, start_at_first_met=False, stop_at_stop_codon=False, require_mod3=True, start=None, end=None)[source]#
Translate RNA sequence into amino acid sequence using this codon table.
- Parameters:
codon_table (
Optional[CodonTable]) – Codon table to use for translation. If None, uses standard genetic code.start_at_first_met (
bool) – Start translation at the first start codon if found.stop_at_stop_codon (
bool) – Stop translation when a stop codon is encountered.require_mod3 (
bool) – Whether the sequence must be a multiple of 3 in length.start (
Optional[int]) – Custom 0-based start position. Overrides start_at_first_met.end (
Optional[int]) – Custom 0-based end position. Overrides stop_at_stop_codon.
- Return type:
- Returns:
Translated amino acid sequence.