genotype_filters.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:varapp-backend-py 作者: varapp 项目源码 文件源码
def merge_conditions_array(conds):
    """If there are multiple affected samples sharing the same parents,
    the conditions can be redundant. Simplify the conditions array so that
    there is at most one for each genotype/sample. If there are several constraints
    for the same genotype, check that they are compatible and take the strongest
    (lowest bit value).
    :param conds: an array of couples [sample_index, genotype_bit]
    :rtype: same as input
    """
    merged = []
    if not conds:
        return merged
    # Group by sample index, and get a single common bit for all conds on that sample
    conds.sort(key=itemgetter(0))
    for idx,group in itertools.groupby(conds, itemgetter(0)):
        genbits = [x[1] for x in group]   # only the genotype bit
        common_bits = reduce(__and__, genbits)
        merged.append((idx, common_bits))
    return merged
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号