:mod:`biotransformers.utils.compute_utils` ========================================== .. py:module:: biotransformers.utils.compute_utils Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: biotransformers.utils.compute_utils.Mutation Functions ~~~~~~~~~ .. autoapisummary:: biotransformers.utils.compute_utils.validate_position_str biotransformers.utils.compute_utils.get_list_probs biotransformers.utils.compute_utils.mutation_score biotransformers.utils.compute_utils.split_list Attributes ~~~~~~~~~~ .. autoapisummary:: biotransformers.utils.compute_utils.ProbTuple biotransformers.utils.compute_utils.TokenProbsDict biotransformers.utils.compute_utils.SequenceProbsList .. data:: ProbTuple .. data:: TokenProbsDict .. data:: SequenceProbsList .. exception:: InvalidPositionStringError Bases: :py:obj:`Exception` Raised when a position string is passed with incorrect format .. function:: validate_position_str(position_str: str) Checks positions str format .. class:: Mutation(mutation_str: str) register a mutation from a string :param mutation: string mutation format "A8U" -> "NativeIdMutant" :type mutation: str .. method:: __repr__(self) -> str Return repr(self). .. method:: is_valid_mutation(self, sequence: str) Check if mutation is valid for the sequence of AA :param sequence: protein sequence string :type sequence: str .. function:: get_list_probs(mutation_list: List[Tuple[Mutation]], mutate_probs: SequenceProbsList, length_mutations: List[int]) -> Tuple[List[List[float]], List[List[float]]] This function build a list of mutate and native probabilities to compute the mutate_score. For each position in the mutate list, we catch the native probability and the mutate probability of this position. We do this for each sequence and return two lists : native_probs and mutate probs. :param mutation_list: list with integer which are mutations :type mutation_list: List[Mutation] :param mutate_probs: probabilities for mutate sequence :type mutate_probs: List[Dict[Any]] :param length_mutations: length of indivual mutation for each sequence :type length_mutations: List[int] .. function:: mutation_score(native_probs: List[float], mutate_probs: List[float]) -> float Compute mutate score based on Masked marginal probability Sum(log(p(xi=xi_mutate|x-M))-log(p(xi=xi_native|x-M))) over M (M s a mutation set) :param native_probs: [description] :type native_probs: List[ProbTuple] :param mutate_probs: [description] :type mutate_probs: List[ProbTuple] :returns: [description] :rtype: List[float] .. function:: split_list(list_to_split: List, lengths_list: List) -> List[List] split a list in sublist :param list_to_split: native list :type list_to_split: List :param lengths_list: length of each sublist :type lengths_list: List :returns: List of sublist :rtype: [type]