Exemplo n.º 1
0
def check_if_there_is_allele_with_4_diff_values(fam_d, alleles_names, invalid_cases):
    """
    if there are no parents, and there isn't an allele with 4 different values in the children,
    the algorithm could not be executed
    (because when no parents, we rely on the assumption that there are 4 different in one allele, at least)
    it's not an "invalid" input, but we reject the family because we can not analyze it
    """
    four_different_values = False  # flag to know if there is allele with 4 different values

    for al_name in alleles_names:
        if four_different_values:  # if there is allele with 4 diff, do not need to check more
            return

        alleles_values = Als()
        for child in fam_d:  # no parents, according the condition in the call to this function
            child_alleles = fam_d[child][al_name]
            if any(child_alleles):  # merge only if there is data in 'child_alleles'
                # merge the values of the current alleles_names _child_ to the values of the other children in this allele
                # e.g. : alleles_values: [02, 03]. child_alleles: [02:01, 04]. so the merging: [02, 03, 04]
                # note: the merging may save the low-res values (02 instead of 02:01),
                # but it's not matter, because just need the values amount
                alleles_values = alleles_values.merge(child_alleles)
        # after go over on all the children values in the current allele, check if there are 4 values
        if len(alleles_values) == 4:
            four_different_values = True

    if not four_different_values:
        invalid_cases.append(('6', 'All'))  # no parents, and no alleles_names with 4 diff values (algorithm can not executed)
Exemplo n.º 2
0
def create_merged_allele_values(children, al_name):
    """
    create a list (Als) with all the different value in children data about specific allele
    for example: if _child_ 1 has A : [02:01, 03:04], _child_ 2: A: [05, 03], _child_ 3: A: [02, 07],
    so lst will be [02:01, 03:04, 05, 07]
    :param children: children dict
    :param al_name: name of specific allele
    """
    lst = Als()
    for child in children:
        lst = lst.merge(children[child][al_name])
    return lst
Exemplo n.º 3
0
def check_too_much_alleles(fam_d, alleles_names, invalid_cases):
    """
    check if there are too much alleles_names in the family (more than 4 in an allele)
    """
    for al_name in alleles_names:
        lst = Als()
        for fam_member in fam_d:  # [F, M, 1 ...]
            if any(fam_d[fam_member][al_name]):  # not empty
                # lst = fam_d[fam_member][al_name].merge(lst)
                lst = lst.merge(fam_d[fam_member][al_name])
        if len(lst) > 4:
            invalid_cases.append(('4', 'All'))  # Too many alleles_names