ashander / ftprime

Forward-time simulation of the msprime data structure (for development)
2 stars 1 forks source link

Add mutations (again) #61

Closed ashander closed 5 years ago

ashander commented 6 years ago

We previously had code to do this but only for ArgRecorder (e.g., in 0fd9c76 ) but the relevant tables have changed. This code could be updated but more work is needed to figure out how to get the relevant info from simuPOP. Perhaps this should wait for msprime 0.5.0

hyanwong commented 5 years ago

I'm hitting this problem now. Is there any easy solution?

hyanwong commented 5 years ago

If I reintroduce the code for add_mutation() in https://github.com/ashander/ftprime/pull/62/files#diff-31f00c08541e8f1ed735675895069f40R247 it appears to work at first, but then I get:

Traceback (most recent call last):
  File "/home/yan/treeseq-inference/src/selective_sweep.py", line 258, in <lambda>
    mutations_after_simulation)),
  File "/home/yan/treeseq-inference/src/selective_sweep.py", line 72, in output_to_msprime
    ts = recomb_collector.tree_sequence(diploid_samples)
  File "/home/yan/ftprime/ftprime/recomb_collector.py", line 184, in tree_sequence
    return self.args.tree_sequence(haploid_ids)
  File "/home/yan/ftprime/ftprime/argrecorder.py", line 323, in tree_sequence
    sequence_length=self.sequence_length)
  File "/home/yan/.local/lib/python3.4/site-packages/msprime/trees.py", line 1271, in load_tables
    return TreeSequence.load_tables(tables.TableCollection(ll_tables=ll_tables))
  File "/home/yan/.local/lib/python3.4/site-packages/msprime/trees.py", line 1741, in load_tables
    ts.load_tables(tables.ll_tables)
_msprime.LibraryError: Population ID out of bounds.
2018-10-17 13:50:08,875 Function call failed

Do you by any chance know what is going on here? Jerome and I would like to get this fixed ASAP (sorry!)

petrelharp commented 5 years ago

This should be easy to put in, yes. But the first thing to do is update the code to the latest msprime. What version of msprime are you using with it?

hyanwong commented 5 years ago
>>> msprime.__version__
'0.6.1'

Actually, I've managed to get this working now by keeping a reference to the table_collection (https://github.com/ashander/ftprime/pull/63/commits/26397f0c1a27fc2373cd9a6cd913a75487e6b9c1): the issue I had wasn't in the add_mutation() code after all, and I think it can go back in as-is, at least for my purposes.

hyanwong commented 5 years ago

@petrelharp thanks for the comment. I'm not sure why the tests are failing on my PR that gets all this working again with msprime 0.6.1 (https://github.com/ashander/ftprime/pull/63), as it works on my installation now. I'm afraid I won't have time to sort this out for the next week or so, but hopefully there's some useful stuff in the PR.

petrelharp commented 5 years ago

Hm: "not sure why tests are failing" makes me nervous, but OK. This should be quick to fix; see #64, #65.

petrelharp commented 5 years ago

I think this is fixed in #65.