Source code for gunz_cm.pipeline.sprite.downweighting

"""
Module.

Examples
--------
"""
__author__ = "Yeremia Gunawan Adhisantoso"
__email__ = "adhisant@tnt.uni-hannover.de"
__license__ = "Clear BSD"
__version__ = "1.0.0"
import enum
import typing as t

[docs] class Downweighting(enum.Enum): """An enumeration of downweighting schemes. NONE -- No downweighting. Each contact has a value of 1. N_MINUS_ONE -- A contact from a cluster of n reads has a value of 1 /(n - 1). TWO_OVER_N -- A contact form a cluster of n reads has a value of 2 / n. UNKNOWN -- A default downweighing scheme for error checking. Examples -------- """ NONE = None N_MINUS_ONE = 'n_minus_one' TWO_OVER_N = 'two_over_n' UNKNOWN = 'unknown'
[docs] @staticmethod def from_str( label: t.Optional[str] ) -> 'Downweighting': """ Converts a string label to the corresponding Downweighting enum member. Notes ----- This method is case-insensitive and returns `Downweighting.UNKNOWN` if no matching label is found. Parameters ---------- label : Optional[str] The string label to convert. Returns ------- Downweighting The corresponding Downweighting enum member. Examples -------- Authors ------- - Yeremia G. Adhisantoso (adhisant@tnt.uni-hannover.de) - Qwen2.5 72B - 4.25bpw Examples -------- """ if label is None: return Downweighting.NONE #? Convert the label to lowercase to ensure case-insensitive matching label = label.lower() #? Iterate through the enum members to find a match for member in Downweighting: if member.value == label: return member #? If no match is found, return Downweighting.UNKNOWN return Downweighting.UNKNOWN
[docs] def estimate_num_contacts(self, bins, ): """ Function estimate_num_contacts. Parameters ---------- Returns ------- Examples -------- Notes ----- """ if self.name == 'TWO_OVER_N': num_contacts = 2.0 / len(bins) elif self.name == 'N_MINUS_ONE': num_contacts = 1.0 / (len(bins) - 1) elif self.name == 'NONE': num_contacts = 1.0 else: raise ValueError("Unsupported downweighting!") return num_contacts