tidymut.core.mutation module
- class tidymut.core.mutation.AminoAcidMutation(wild_type: str, position: int, mutant_type: str, alphabet: ProteinAlphabet | None = None, metadata: Dict[str, Any] | None = None)[source]
Bases:
BaseMutation
Represents an amino acid mutation (e.g., A123V)
- property effect_type: Literal['synonymous', 'nonsense', 'missense']
Get the effect type of the mutation (synonymous, nonsense, or missense)
- classmethod from_string(mutation_str: str, is_zero_based: bool = False, alphabet: ProteinAlphabet | None = None) AminoAcidMutation [source]
Parse mutation from string format like ‘A123V’ or ‘Ala123Val’
- get_mutation_category() Literal['synonymous', 'nonsense', 'missense'] [source]
Get mutation classification
- property type: str
Get the type of mutation
- class tidymut.core.mutation.AminoAcidMutationSet(mutations: Sequence[AminoAcidMutation], name: str | None = None, metadata: Dict[str, Any] | None = None)[source]
Bases:
MutationSet
[AminoAcidMutation
]Represents a set of amino acid mutations
- get_missense_mutations() List[AminoAcidMutation] [source]
Get all missense mutations
- get_nonsense_mutations() List[AminoAcidMutation] [source]
Get all nonsense mutations
- get_synonymous_mutations() List[AminoAcidMutation] [source]
Get all synonymous mutations
- class tidymut.core.mutation.BaseMutation(wild_type: str, mutant_type: str, position: int, alphabet: BaseAlphabet | None = None, metadata: Dict[str, Any] | None = None)[source]
Bases:
ABC
Base class for all mutations
- abstractmethod classmethod from_string(mutation_string: str, is_zero_based: bool, alphabet: BaseAlphabet | None = None) BaseMutation [source]
Parse mutation from string format like ‘A123V’ or ‘Ala123Val’
- abstract property type: str
Get the type of mutation
- class tidymut.core.mutation.CodonMutation(wild_type: str, position: int, mutant_type: str, alphabet: BaseAlphabet | None = None, metadata: Dict[str, Any] | None = None)[source]
Bases:
BaseMutation
Represents a codon mutation
- classmethod from_string(mutation_str: str, is_zero_based: bool = False, alphabet: BaseAlphabet | None = None) CodonMutation [source]
Parse mutation from string format like ‘ATG123TAA’ or ‘AUG123UAA’
- to_amino_acid_mutation(codon_table: CodonTable | None = None) AminoAcidMutation [source]
Convert codon mutation to amino acid mutation
- property type: str
Get the type of mutation
- class tidymut.core.mutation.CodonMutationSet(mutations: Sequence[CodonMutation], name: str | None = None, metadata: Dict[str, Any] | None = None)[source]
Bases:
MutationSet
[CodonMutation
]Represents a set of codon mutations
- property seq_type: Literal['DNA', 'RNA', 'Both']
Get the sequence type (DNA, RNA, or Both) of the codon mutations
- to_amino_acid_mutation_set(codon_table: CodonTable | None = None) AminoAcidMutationSet [source]
Convert all codon mutations to amino acid mutations
- class tidymut.core.mutation.MutationSet(mutations: Sequence[MutationType], mutation_type: Type[MutationType] | None, name: str | None = None, metadata: Dict[str, Any] | None = None)[source]
Bases:
Generic
[MutationType
]Represents a set of mutations of the same type
- classmethod from_string(string: str, sep: str | None = None, is_zero_based: bool = False, mutation_type: Type[MutationType] | None = None, alphabet: BaseAlphabet | None = None, name: str | None = None, metadata: Dict[str, Any] | None = None) MutationSet [source]
Create a mutation set from a string
- Parameters:
string (str) – String containing mutations separated by delimiter
sep (Optional[str], default=None) – Separator to use. If None, will try to guess
is_zero_based (bool, default=False) – Whether origin mutation positions are zero-based
mutation_type (Type[MutationType], default=None) – The type of mutations to create. If None, will infer from first mutation
alphabet (Optional[BaseAlphabet], default=None) – Alphabet to use for mutation parsing (if applicable)
name (str, default=None) – Optional name for the mutation set
metadata (Optional[Dict[str, Any]], default=None) – Optional metadata for the mutation set
- Returns:
A MutationSet created from the input string. Returns AminoAcidMutationSet for amino acid mutations, CodonMutationSet for codon mutations, or generic MutationSet for others.
- Return type:
- Raises:
ValueError – If string is empty, no valid mutations found, or mutations are inconsistent
TypeError – If mutation_type is not a subclass of BaseMutation
- get_sorted_by_position() List[MutationType] [source]
Get mutations sorted by position without modifying the original list
- property mutation_subtype: str
Get the specific mutation subtype (e.g., ‘amino_acid’, ‘codon_dna’, ‘codon_rna’, ‘codon_both’)