tskit-dev / msprime

Simulate genealogical trees and genomic sequence data using population genetic models
GNU General Public License v3.0
170 stars 84 forks source link

AttributeErrors in verification.py: MsmsSweeps #2229

Closed GertjanBisschop closed 6 months ago

GertjanBisschop commented 6 months ago

l1409: pd.error.ParseError should be pd.errors.ParseError. l348: positions = [ mutation.position / msms_params["num_sites"] for mutation in tree_sequence.mutations() ] should probably be: positions = tree_sequence.sites_position.copy() (and then divide by "num_sites")

jeromekelleher commented 6 months ago

Can you show the full stack trace please? I don't understand why this wouldn't have shown up before.

GertjanBisschop commented 6 months ago

For the pd.error:

CRITICAL root: Traceback (most recent call last):
  File "verification.py", line 1408, in _cmp_msms_vs_msp
    df_msp = self._run_msp_sample_stats(cmd)
  File "verification.py", line 1348, in _run_msp_sample_stats
    positions = [
  File "verification.py", line 1349, in <listcomp>
    mutation.position / msms_params["num_sites"]
AttributeError: 'Mutation' object has no attribute 'position'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "verification.py", line 6373, in <module>
    main()
  File "verification.py", line 6369, in main
    run_tests(suite, args)
  File "verification.py", line 6308, in run_tests
    runner.run(tests, args.output_dir, args.num_threads, not args.no_progress)
  File "verification.py", line 6277, in run
    self.__run_sequential(tests, basedir, progress)
  File "verification.py", line 6249, in __run_sequential
    test.run(basedir)
  File "verification.py", line 6210, in run
    method()
  File "verification.py", line 1428, in test_neutral_msms_vs_msp
    self._cmp_msms_vs_msp("100 300 -t 200 -r 200 500000 -N 10000")
  File "verification.py", line 1409, in _cmp_msms_vs_msp
    except pd.error.ParserError:
  File "/home/gertjan/git/msprime/venv/lib/python3.8/site-packages/pandas/__init__.py", line 264, in __getattr__
    raise AttributeError(f"module 'pandas' has no attribute '{name}'")
AttributeError: module 'pandas' has no attribute 'error'
GertjanBisschop commented 6 months ago

For the mutations:

CRITICAL root: Traceback (most recent call last):
  File "verification.py", line 6373, in <module>
    main()
  File "verification.py", line 6369, in main
    run_tests(suite, args)
  File "verification.py", line 6308, in run_tests
    runner.run(tests, args.output_dir, args.num_threads, not args.no_progress)
  File "verification.py", line 6277, in run
    self.__run_sequential(tests, basedir, progress)
  File "verification.py", line 6249, in __run_sequential
    test.run(basedir)
  File "verification.py", line 6210, in run
    method()
  File "verification.py", line 1428, in test_neutral_msms_vs_msp
    self._cmp_msms_vs_msp("100 300 -t 200 -r 200 500000 -N 10000")
  File "verification.py", line 1408, in _cmp_msms_vs_msp
    df_msp = self._run_msp_sample_stats(cmd)
  File "verification.py", line 1348, in _run_msp_sample_stats
    positions = [
  File "verification.py", line 1349, in <listcomp>
    mutation.position / msms_params["num_sites"]
AttributeError: 'Mutation' object has no attribute 'position'
jeromekelleher commented 6 months ago

Hmm - I suspect this has been failing for a bit so and was masked by the pandas error check. Let's fix the obvious mutation problem, and see if we can drop the pandas pd.error.ParserError exception check (which I can't see a good reason for)

GertjanBisschop commented 6 months ago

Solved in #2230.