from typing import List
from typing import Tuple
from typing import Dict
from typing import Set


def calc_target_char_counts(
    query_seq: str,
    target_seq: str,
    target_chars: List[str],
) -> Tuple[Dict[str, int], Set[str]]:
    """
    Finds the char counts in the target sequence which will be used in the calculation
    to determine a character's contribution to the complexity adjusted score.

    input:
    query_seq: query sequence from alignment
    target_seq: target sequence from alignment
    target_chars: chars in the target sequence that will contribute to
    the complexity adjusted score

    output:
    target_char_counts: dictionary of the target chars to their count
    in the target sequence that will contribute to the adjusted score
    other_chars: other chars found in the target sequence that do not contribute
    to the complexity adjustment (gaps, padding)
    """
    target_char_counts: Dict[str, int] = {char: 0 for char in target_chars}
    other_chars = set()
    for q_base, t_base in zip(query_seq, target_seq):
        if t_base not in target_chars:
            other_chars.add(t_base)
            continue
        if q_base == "-":
            continue
        target_char_counts[t_base] += 1
    return target_char_counts, other_chars