Пример #1
0
def test_intervals_to_array():
    from pydigree.sgs.sgs import intervals_to_array
    intervals = [[2, 4], [6, 10]]
    observed = intervals_to_array(intervals, 15)
    expected = np.array([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0])
    assert all(observed == expected)

    assert all(intervals_to_array([], 10) == np.zeros(10))
Пример #2
0
def test_intervals_to_array():
    from pydigree.sgs.sgs import intervals_to_array
    intervals = [[2,4], [6,10] ] 
    observed = intervals_to_array(intervals, 15)
    expected = np.array([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0])
    assert all(observed==expected)

    assert all(intervals_to_array([], 10) == np.zeros(10)) 
Пример #3
0
replicate = sys.argv[1]
ms = int(sys.argv[2])
prefix='null'

peds = pyd.io.plink.read_plink('{}-{}.ped'.format(prefix, replicate), '{}.map'.format(prefix))
ped = peds['1']
s = pyd.sgs.sgs_population(ped, seed_size=ms)


with smartopen('{}-{}.ibd.gz'.format(prefix, replicate)) as f:
    trueibd = {}
    for line in f:
        fam, id1, id2, ibd_states = line.strip().split(None, 3)
        trueibd[frozenset({id1,id2})] = np.array([int(x) for x in ibd_states.split()])

a = intervals_to_array(s[frozenset({ped['7'],ped['8']})][0], ped.chromosomes[0].nmark())
b = trueibd[frozenset({'7','8'})]


genos1 = zip(*ped['7'].genotypes[0])
genos2 = zip(*ped['8'].genotypes[0])
identical = [ibs(x,y) for x,y in zip(genos1, genos2)]

from pydigree.common import table, runs


for start, stop in runs(list(a), lambda x: x>0, ms):
    print('Predicted segment: {}-{}'.format(start, stop))

print()