agglovar.align.score ==================== .. py:module:: agglovar.align.score .. autoapi-nested-parse:: Alignment routines. Attributes ---------- .. autoapisummary:: agglovar.align.score.AFFINE_SCORE_GAP agglovar.align.score.AFFINE_SCORE_MATCH agglovar.align.score.AFFINE_SCORE_MISMATCH agglovar.align.score.AFFINE_SCORE_TS agglovar.align.score.DEFAULT_ALIGN_SCORE_MODEL Classes ------- .. autoapisummary:: agglovar.align.score.AffineScoreModel agglovar.align.score.ScoreModel Functions --------- .. autoapisummary:: agglovar.align.score.get_affine_by_params agglovar.align.score.get_score_model Module Contents --------------- .. py:class:: AffineScoreModel(match: float = AFFINE_SCORE_MATCH, mismatch: float = AFFINE_SCORE_MISMATCH, affine_gap: Iterable[tuple[float, float]] = AFFINE_SCORE_GAP, template_switch: float = AFFINE_SCORE_TS) Bases: :py:obj:`ScoreModel` Affine score model with default values modeled on minimap2 (2.26) default parameters. :ivar match: Match score. :ivar mismatch: Mismatch penalty. :ivar affine_gap: An iterable containing tuples of two elements (gap open, gap extend). :ivar template_switch: Template switch penalty. If none, defaults to 2x the penalty of a 50 bp gap. .. py:method:: __eq__(other: Any) -> bool Determine if this scoremodel is the same as another. :param other: Other object. :returns: True if this scoremodel is equivalent to `other`. .. py:method:: __repr__() Get a string representation of this score model. .. py:method:: gap(n: int = 1) -> float Score gap (insertion or deletion). Compute all affine alignment gap score for each affine segment and return the highest value (least negative). :param n: Size of gap. :returns: Gap score. .. py:method:: match(n: int = 1) -> float Score match. :param n: Number of matching bases. :returns: Match score. .. py:method:: mismatch(n: int = 1) -> float Score mismatch. :param n: Number of mismatched bases. :returns: Mismatch score. .. py:method:: mismatch_model() -> Self Get a mismatch model. :returns: A copy of this score model that does not penalize gaps. Used for computing the score of mismatches. .. py:method:: model_param_string() -> str Get score parameter string. :returns: A parameter string representing this score model. .. py:method:: score_operations(op_arr: numpy.ndarray) -> float Sum scores for affine models using a A vectorized implementation. :param op_arr: Array of alignment operations (op_code: first column, op_len: second column). :returns: Sum of scores for each CIGAR operation. .. py:method:: template_switch() -> float Score a template switch. :returns: Score for a single template switch. .. py:attribute:: score_affine_gap :type: tuple .. py:attribute:: score_match :type: float .. py:attribute:: score_mismatch :type: float .. py:attribute:: score_template_switch :type: float .. py:class:: ScoreModel Bases: :py:obj:`abc.ABC` Score model interface. .. py:method:: __eq__(other: Any) -> bool :abstractmethod: Determine if this scoremodel is the same as another. :param other: Other object. :returns: True if this scoremodel is equivalent to `other`. .. py:method:: __repr__() :abstractmethod: Get a string representation of this score model. .. py:method:: gap(n: int = 1) -> float :abstractmethod: Score gap (insertion or deletion). Compute all affine alignment gap score for each affine segment and return the highest value (least negative). :param n: Size of gap. :returns: Gap score. .. py:method:: match(n: int = 1) -> float :abstractmethod: Score match. :param n: Number of matching bases. :returns: Match score. .. py:method:: mismatch(n: int = 1) -> float :abstractmethod: Score mismatch. :param n: Number of mismatched bases. :returns: Mismatch score. .. py:method:: mismatch_model() -> Self :abstractmethod: Get a mismatch model. :returns: A copy of this score model that does not penalize gaps. Used for computing the score of mismatches. .. py:method:: model_param_string() -> str :abstractmethod: Get score parameter string. :returns: A parameter string representing this score model. .. py:method:: score(op_code: int | str, op_len: int) -> float Score an alignment operation. :param op_code: Operation code. Can be a symbol (e.g. "=", "X", "I", etc.) or the numeric operation code. :param op_len: Operation length. :returns: Score for this operation or 0.0 if the operation is not scored (S, H, N, and P operations). .. py:method:: score_operations(op_arr: numpy.ndarray) -> float Sum scores for affine models using a vectorized implementation. :param op_arr: Array of alignment operations (op_code: first column, op_len: second column). :returns: Sum of scores for each CIGAR operation. .. py:method:: template_switch() -> float Score a template switch. :returns: Score for a single template switch. .. py:function:: get_affine_by_params(param_string: str) -> AffineScoreModel Parse a string to get alignment parameters from it. :param param_string: Parameter string. :returns: A configured AffineScoreModel. .. py:function:: get_score_model(param_string: str = None) -> ScoreModel Get score model from a string of alignment parameters. :param param_string: Parameter string. Can be None or an empty string (default model is used). If the string is an instance of `ScoreModel`, then the `ScoreModel` object is returned. Otherwise, the string is parsed and a score model object is returned. :returns: A `ScoreModel` object. .. py:data:: AFFINE_SCORE_GAP :value: ((4.0, 2.0), (24.0, 1.0)) Default affine gap scores. .. py:data:: AFFINE_SCORE_MATCH :value: 2.0 Default match score. .. py:data:: AFFINE_SCORE_MISMATCH :value: 4.0 Default mismatch score. .. py:data:: AFFINE_SCORE_TS :value: None Default template switch score. .. py:data:: DEFAULT_ALIGN_SCORE_MODEL :value: 'affine::match=2.0,mismatch=4.0,gap=' Default alignment score model.