Пример #1
0
    def xxxtest_check_consanguinity(self):
        ped = Pedigree()
        ped.load('../cplex/pedigree_50_4_8_2_G3.ped')
        print(ped.all_consanguineous_ped(3))
        print(ped.is_consanguineous('1','7',2))
        print(ped.old_gen('1',4).intersection(ped.old_gen('7',4)))
        print(ped.old_gen('7', 4))
        print('---------------------------')
        nb_ped = 50
        nb_people = [10,20,50,100,200,300,500,1000,1500,2000,2200,2400]
        nb_Gen_Max = [3,3,4,4,4,4,4,5,5,6,6,6]
        # nb_people = [50]
        # nb_Gen_Max = [4]
        nb_Gen_Min = [math.ceil(x/2) for x in nb_Gen_Max]
        cl = 3
        cpt = 0
        for p, g_max, g_min in zip(nb_people, nb_Gen_Max, nb_Gen_Min):
            for nb in range(nb_ped):
                nbChild = random.randint(4, 8)
                g = random.randint(g_min, g_max)
                ped = Pedigree()
                ped.gen_ped(nb, p, g, nbChild, cl)

                if len(ped.all_consanguineous_ped(cl)) != 0:
                    cpt+=1
                    print('ICI IL Y A UN PB',ped.all_consanguineous_ped(3))
                    print('le pedigree en question',ped)
                    pview.save(ped, f'../pedigree_{p}_{g}_{nbChild}_{cl - 1}_G{nb}')
                    pview.graph(ped, f'../generate_graph_{p}_{g}_{nbChild}_{cl - 1}_G{nb}', False)
            print(cpt)
            self.assertEqual(cpt,0)
Пример #2
0
 def test_new_gen(self): #OK
     nb_ped = 1
     nb_people = [50]
     nb_Gen_Max = [4]
     nb_Gen_Min = [math.ceil(x/2) for x in nb_Gen_Max]
     cl = 3
     ped1 = Pedigree()
     ped1.load("../data/ped/senegal2013.ped")
     bn_sen = pview.ped_to_bn_compact(ped1,0.05)
     print('clique sen',pview.max_clique_size(bn_sen))
     print('uho', ped1.all_consanguineous_ped(cl))
     for p, g_max, g_min in zip(nb_people, nb_Gen_Max, nb_Gen_Min):
         for nb in range(nb_ped):
             nbChild = random.randint(4, 8)
             g = random.randint(g_min, g_max)
             ped = Pedigree()
             ped.gen_ped(nb, p, g, nbChild, cl)
             # print('-------------------------')
             # print(ped)
             print('-------------------------')
             print('Consanguin',ped.all_consanguineous_ped(cl))
             bn = pview.ped_to_bn_compact(ped,0.05)
             print('clique',pview.max_clique_size(bn))
             print('-------------------------')
             pview.save(ped, f'../pedigree_{p}_{g}_{nbChild}_{cl-1}_G{nb}')
             pview.graph(ped, f'../generate_graph_{p}_{g}_{nbChild}_{cl-1}_G{nb}', False)
Пример #3
0
ie.setEpsilon(5e-4)
t1 = process_time()
ie.makeInference()
t2 = process_time()
time_sen_compact = t2 - t1

for p, g_max, g_min in zip(nb_people, nb_Gen_Max, nb_Gen_Min):
    tab_lis = np.zeros(nb_ped)
    tab_diff = np.zeros(nb_ped)
    for nb in range(nb_ped):
        nbChild = random.randint(6, 12)
        g = random.randint(g_min, g_max)
        ped = Pedigree()
        ped.gen_ped(nb, p, g, nbChild, cl, 0.03)
        bn_compact = pview.ped_to_bn_compact(ped, f)
        pview.save(
            ped, f'../cplex/samples/IS/pedigree_{p}_{g}_{nbChild}_{cl}_G{nb}')
        pview.save_bn(
            bn_compact,
            f'../cplex/bn/IS/bn_compact_{p}_{g}_{nbChild}_{cl}_G{nb}')

        t1 = process_time()
        ie1 = imp.lisPosterior(
            f'../cplex/bn/IS/bn_compact_{p}_{g}_{nbChild}_{cl}_G{nb}.bif')
        t2 = process_time()
        t2 = t2 - t1
        tab_lis[nb] = t2
        ie2 = laz.lazyPosterior(
            f'../cplex/bn/IS/bn_compact_{p}_{g}_{nbChild}_{cl}_G{nb}.bif')

        error_lbp_laz = []
        for i in ped.get_pedigree().keys():
Пример #4
0
for p, g_max, g_min in zip(nb_people, nb_Gen_Max, nb_Gen_Min):

    for nb in range(nb_ped):

        nbChild = random.randint(6, 12)

        g = random.randint(g_min, g_max)
        ped = Pedigree()
        ped.gen_ped(nb, p, g, nbChild, cl, 0.03)

        for i in range(gene_depart, gene + 1):

            #bn = pview.bn_multi_pb(ped, f, i, distance[:i-1])
            bn = pview.bn_multi_morgans(ped, f, i, centimorgans[:i])
            pview.save(ped, f'./samples/pedigree_{p}_{g}_{nbChild}_{cl}_G{nb}')
            pview.save_bn(bn, f'./bn/bn_{p}_{g}_{nbChild}_{cl}_G{nb}')

            ie1 = laz.lazyPosterior(
                f"./bn/bn_{p}_{g}_{nbChild}_{cl}_G{nb}.bif", evidence)
            ie2 = lbp.lbpPosterior(f"./bn/bn_{p}_{g}_{nbChild}_{cl}_G{nb}.bif",
                                   evidence)

            for j in ped.get_pedigree().keys():
                #for g in range(1, 3):
                for g in range(1, gene + 1):
                    p1 = ie1.posterior(f'X{j}_{g}')
                    p2 = ie2.posterior(f'X{j}_{g}')
                    x = [
                        abs(p1[0] - p2[0]),
                        abs(p1[1] - p2[1]),
Пример #5
0
 def test_save(self):#OK
     ped = Pedigree()
     ped.load("../data/ped/fam9.ped")
     pview.save(ped,"../data/ped/tanto.ped")
     self.assertEqual(os.path.exists("../data/ped/tanto.ped"),1)