ivan-krukov / aligning-genealogies

The genealogy-coalescent alignment project
3 stars 0 forks source link

`Pedigree.sample_path` does not work #20

Closed ivan-krukov closed 4 years ago

ivan-krukov commented 4 years ago

Trying to sample a haploid path:

ped = Pedigree.from_balsac_table('data/test/simple.tsv')
tr = ped.sample_path(ploidy=1)

Leads to an error in get_parents:

UnboundLocalError                                      Traceback (most recent call last)
<ipython-input-374-5e6e17e6d5d4> in <module>
----> 1 ped.sample_path()

~/work/genealogies/genealogy_aligner/Pedigree.py in sample_path(self, probands, ploidy)
    534             for hap_obj, parent in zip(
    535                     hap_struct[n],
--> 536                     rnd.choice(self.get_parents(n), 2, replace=False)):
    537 
    538                 # If the parent is a node in the pedigree:

~/work/genealogies/genealogy_aligner/Pedigree.py in get_parents(self, n)
    169                 father, mother = rnd.choice(pred, 2, replace=False)
    170 
--> 171         return father, mother
    172 
    173 

UnboundLocalError: local variable 'father' referenced before assignment

Apropos: what are some "standard" paths through our code? We should document and test them

shz9 commented 4 years ago

This issue doesn't replicate for me in the latest update. There was an issue earlier in get_parents() where the variable father was inadvertently changed to fapther.