# Path: pydigree/ibs.py
# def get_ibs_states(ind1, ind2, chromosome_index, missingval=64):
# def chromwide_ibs(a, b, c, d, missingval=64):


import pydigree
import itertools
import argparse
import numpy as np
from pydigree.ibs import ibs
peds.add_chromosome(c)


nulldist = {}

naff = sum(1 for ind in peds.individuals if ind.phenotypes['affected'])
print('{} affecteds'.format(naff))

if args.remove_mif:
    for ind in peds.individuals:
        if ind.is_marryin_founder(): 
            ind.phenotypes['affected'] = False
    naff = sum(1 for ind in peds.individuals if ind.phenotypes['affected'])
    print('{} affecteds after removing marry-in founders'.format(naff))

for i, ped in enumerate(sorted(peds, key=lambda q: q.label)):
    if args.onlypeds and ped.label not in args.onlypeds:
        continue


    # Clear the genotypes, if present
    ped.clear_genotypes()

    affs = {x for x in ped if x.phenotypes['affected']}

    if len(affs) < 2:
        print('Error in pedigree {}: '.format(ped.label), end='') 
        print('less than two affected individuals. Skipping.')
        continue


# Path: pydigree/ibs.py
# def get_ibs_states(ind1, ind2, chromosome_index, missingval=64):
# def chromwide_ibs(a, b, c, d, missingval=64):


# Path: scripts/genedrop.py
import pydigree
import itertools
import argparse
import numpy as np
from pydigree.ibs import ibs

peds.add_chromosome(c)


nulldist = {}

naff = sum(1 for ind in peds.individuals if ind.phenotypes['affected'])
print('{} affecteds'.format(naff))

if args.remove_mif:
    for ind in peds.individuals:
        if ind.is_marryin_founder(): 
            ind.phenotypes['affected'] = False
    naff = sum(1 for ind in peds.individuals if ind.phenotypes['affected'])
    print('{} affecteds after removing marry-in founders'.format(naff))

for i, ped in enumerate(sorted(peds, key=lambda q: q.label)):
    if args.onlypeds and ped.label not in args.onlypeds:
        continue


    # Clear the genotypes, if present
    ped.clear_genotypes()

    affs = {x for x in ped if x.phenotypes['affected']}

    if len(affs) < 2:
        print('Error in pedigree {}: '.format(ped.label), end='') 
        print('less than two affected individuals. Skipping.')
        continue


    print("Pedigree {} ({}/{}), ".format(ped.label, i+1, len(peds)), end='')