Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for pandas>=1.2 #74

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v1
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Markers and population frequency data (1000 Genomes and proprietary) for the mMHseq 90-plex panel (see #68).
- New `--extend-mode` option when displaying markers in `fasta` or `detail` mode (see #72).

### Changed
- Support for pandas>=1.2 added, support for Python 3.6 dropped (see #74).

### Fixed
- Error message when detail view is requested for a marker without frequency information (see #67).
- Problematic haplotype frequencies for 4 mMHseq markers including SNPs whose rsIDs are not present in the original 1KGP data (see #73).
Expand Down
100 changes: 52 additions & 48 deletions microhapdb/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def test_main_pop_query(capsys):
microhapdb.cli.main(args)
out, err = capsys.readouterr()
testout = '''
ID Name Source
MHDBP-3dab7bdd14 Africa 10.1016/j.fsigen.2018.05.008
MHDBP-936bc36f79 Asia 10.1016/j.fsigen.2018.05.008
MHDBP-383d86606a NL 10.1016/j.fsigen.2018.05.008
ID Name Source
MHDBP-3dab7bdd14 Africa 10.1016/j.fsigen.2018.05.008
MHDBP-936bc36f79 Asia 10.1016/j.fsigen.2018.05.008
MHDBP-383d86606a NL 10.1016/j.fsigen.2018.05.008
'''
print(out)
assert testout.strip() == out.strip()
Expand All @@ -120,24 +120,26 @@ def test_main_marker_detail(capsys):
def test_main_marker_query(capsys):
args = get_parser().parse_args(['marker', '--query', 'Chrom == "chr19"'])
microhapdb.cli.main(args)
out, err = capsys.readouterr()
testout = '''
Name PermID Reference Chrom Offsets Ae In Fst Source
mh19USC-19pA MHDBM-2d713eab GRCh38 chr19 561778,561795,561815 2.7453 0.0870 0.0733 10.1016/j.fsigen.2019.102213
mh19KK-056 MHDBM-d6ff8635 GRCh38 chr19 4852124,4852324 2.4391 0.0773 0.1760 ALFRED
mh19CP-007 MHDBM-49dbcc57 GRCh38 chr19 14310739,14310772,14310780 3.0813 0.0466 0.0776 ALFRED
mh19USC-19pB MHDBM-76427274 GRCh38 chr19 16040864,16040894,16040899,16040921,16040929 3.5107 0.1647 0.0731 10.1016/j.fsigen.2019.102213
mh19NH-23 MHDBM-dd72537b GRCh38 chr19 22052723,22052774,22052817 1.9380 0.0414 -0.0124 10.1016/j.legalmed.2015.06.003
mh19KKCS-299 MHDBM-a70896aa GRCh38 chr19 22546697,22546702,22546748,22546779,22546810,22546829,22546850 NaN NaN NaN 10.1016/j.fsigen.2020.102275
mh19KK-299 MHDBM-8cbeb11c GRCh38 chr19 22546697,22546748,22546779,22546810,22546850 4.1592 0.2335 0.1102 ALFRED
mh19AT-47 MHDBM-8f439540 GRCh38 chr19 22546697,22546748,22546779 2.4025 0.1298 0.1170 ISFG2019:P597
mh19USC-19qA MHDBM-f757e745 GRCh38 chr19 33273771,33273785,33273811,33273816 3.3219 0.1127 0.0880 10.1016/j.fsigen.2019.102213
mh19KK-301 MHDBM-2069446a GRCh38 chr19 50938487,50938502,50938526,50938550 1.9707 0.2673 0.1698 ALFRED
mh19KKCS-300 MHDBM-bc8b7213 GRCh38 chr19 50947786,50947789,50947790,50947830,50947876,50947877,50947967 NaN NaN NaN 10.1016/j.fsigen.2020.102275
mh19KK-057 MHDBM-eb558c37 GRCh38 chr19 51654948,51655025,51655062 2.3266 0.0667 0.0428 ALFRED
mh19USC-19qB MHDBM-7b40359b GRCh38 chr19 53714387,53714389,53714413 4.0756 0.1368 0.0163 10.1016/j.fsigen.2019.102213
terminal = capsys.readouterr()
exp_out = '''
Name PermID Reference Chrom Offsets Ae In Fst Source
mh19USC-19pA MHDBM-2d713eab GRCh38 chr19 561778,561795,561815 2.7453 0.0870 0.0733 10.1016/j.fsigen.2019.102213
mh19KK-056 MHDBM-d6ff8635 GRCh38 chr19 4852124,4852324 2.4391 0.0773 0.1760 ALFRED
mh19CP-007 MHDBM-49dbcc57 GRCh38 chr19 14310739,14310772,14310780 3.0813 0.0466 0.0776 ALFRED
mh19USC-19pB MHDBM-76427274 GRCh38 chr19 16040864,16040894,16040899,16040921,16040929 3.5107 0.1647 0.0731 10.1016/j.fsigen.2019.102213
mh19NH-23 MHDBM-dd72537b GRCh38 chr19 22052723,22052774,22052817 1.9380 0.0414 -0.0124 10.1016/j.legalmed.2015.06.003
mh19KKCS-299 MHDBM-a70896aa GRCh38 chr19 22546697,22546702,22546748,22546779,22546810,22546829,22546850 NaN NaN NaN 10.1016/j.fsigen.2020.102275
mh19KK-299 MHDBM-8cbeb11c GRCh38 chr19 22546697,22546748,22546779,22546810,22546850 4.1592 0.2335 0.1102 ALFRED
mh19AT-47 MHDBM-8f439540 GRCh38 chr19 22546697,22546748,22546779 2.4025 0.1298 0.1170 ISFG2019:P597
mh19USC-19qA MHDBM-f757e745 GRCh38 chr19 33273771,33273785,33273811,33273816 3.3219 0.1127 0.0880 10.1016/j.fsigen.2019.102213
mh19KK-301 MHDBM-2069446a GRCh38 chr19 50938487,50938502,50938526,50938550 1.9707 0.2673 0.1698 ALFRED
mh19KKCS-300 MHDBM-bc8b7213 GRCh38 chr19 50947786,50947789,50947790,50947830,50947876,50947877,50947967 NaN NaN NaN 10.1016/j.fsigen.2020.102275
mh19KK-057 MHDBM-eb558c37 GRCh38 chr19 51654948,51655025,51655062 2.3266 0.0667 0.0428 ALFRED
mh19USC-19qB MHDBM-7b40359b GRCh38 chr19 53714387,53714389,53714413 4.0756 0.1368 0.0163 10.1016/j.fsigen.2019.102213
'''
assert testout.strip() == out.strip()
obs_out = terminal.out
print(obs_out)
assert exp_out.strip() == obs_out.strip()


def test_main_marker_fasta_default_delta(capsys):
Expand Down Expand Up @@ -205,10 +207,10 @@ def test_main_marker_panel(capsys):
microhapdb.cli.main(args)
terminal = capsys.readouterr()
testout = '''
Name PermID Reference Chrom Offsets Ae In Fst Source
mh06KK-101 MHDBM-8a2c760e GRCh38 chr6 170280714,170280900 1.6705 0.2296 0.2590 ALFRED
mh15KK-058 MHDBM-d6c594d2 GRCh38 chr15 28120284,28120471,28120586 2.2110 0.3799 0.0862 ALFRED
mh20KK-035 MHDBM-92f3685a GRCh38 chr20 2088698,2088728 2.1328 0.2104 0.2180 ALFRED
Name PermID Reference Chrom Offsets Ae In Fst Source
mh06KK-101 MHDBM-8a2c760e GRCh38 chr6 170280714,170280900 1.6705 0.2296 0.2590 ALFRED
mh15KK-058 MHDBM-d6c594d2 GRCh38 chr15 28120284,28120471,28120586 2.2110 0.3799 0.0862 ALFRED
mh20KK-035 MHDBM-92f3685a GRCh38 chr20 2088698,2088728 2.1328 0.2104 0.2180 ALFRED
'''
print(terminal.out)
assert testout.strip() == terminal.out.strip()
Expand Down Expand Up @@ -318,8 +320,8 @@ def test_lookup(capsys):
args = get_parser().parse_args(arglist)
microhapdb.cli.main(args)
out, err = capsys.readouterr()
assert 'mh09KK-033 MHDBM-8458b727 GRCh38 chr9 680713,680762,680790 2.9343 0.1008 0.0504 ALFRED' in out
assert ' mh09AT-15 MHDBM-b46abf2e GRCh38 chr9 680713,680762,680767,680790 2.9471 0.1160 0.0602 ISFG2019:P597' in out
assert 'mh09KK-033 MHDBM-8458b727 GRCh38 chr9 680713,680762,680790 2.9343 0.1008 0.0504 ALFRED' in out
assert ' mh09AT-15 MHDBM-b46abf2e GRCh38 chr9 680713,680762,680767,680790 2.9471 0.1160 0.0602 ISFG2019:P597' in out


def test_ae_pop(capsys):
Expand All @@ -328,14 +330,15 @@ def test_ae_pop(capsys):
microhapdb.cli.main(args)
terminal = capsys.readouterr()
exp_out = '''
Name PermID Reference Chrom Offsets Ae In Fst Source
mh18PK-87558 MHDBM-1e5374f1 GRCh38 chr18 1960542,1960557,1960561,1960566,1960582,1960588 1.9767 0.1325 0.0494 10.1016/j.fsigen.2018.05.008
mh18USC-18pA MHDBM-56dfa93b GRCh38 chr18 5280017,5280020,5280070,5280071,5280093 1.8402 0.2130 0.1818 10.1016/j.fsigen.2019.102213
mh18CP-005 MHDBM-a85754d3 GRCh38 chr18 8892864,8892893,8892896,8892907 3.3873 0.0904 0.0059 ALFRED
mh18KK-285 MHDBM-ea520d26 GRCh38 chr18 24557354,24557431,24557447,24557489 2.6188 0.1721 0.0836 ALFRED
mh18AT-38 MHDBM-db09ec41 GRCh38 chr18 24557431,24557447,24557489 2.6144 0.1419 0.0837 ISFG2019:P597
Name PermID Reference Chrom Offsets Ae In Fst Source
mh18PK-87558 MHDBM-1e5374f1 GRCh38 chr18 1960542,1960557,1960561,1960566,1960582,1960588 1.9767 0.1325 0.0494 10.1016/j.fsigen.2018.05.008
mh18USC-18pA MHDBM-56dfa93b GRCh38 chr18 5280017,5280020,5280070,5280071,5280093 1.8402 0.2130 0.1818 10.1016/j.fsigen.2019.102213
mh18CP-005 MHDBM-a85754d3 GRCh38 chr18 8892864,8892893,8892896,8892907 3.3873 0.0904 0.0059 ALFRED
mh18KK-285 MHDBM-ea520d26 GRCh38 chr18 24557354,24557431,24557447,24557489 2.6188 0.1721 0.0836 ALFRED
mh18AT-38 MHDBM-db09ec41 GRCh38 chr18 24557431,24557447,24557489 2.6144 0.1419 0.0837 ISFG2019:P597
'''
obs_out = terminal.out
print(obs_out)
assert exp_out.strip() == obs_out.strip()


Expand All @@ -352,15 +355,16 @@ def test_hg37(capsys):
microhapdb.cli.main(args)
terminal = capsys.readouterr()
exp_out = '''
Name PermID Reference Chrom Offsets Ae In Fst Source
mh18PK-87558 MHDBM-1e5374f1 GRCh37 chr18 1960543,1960558,1960562,1960567,1960583,1960589 2.3659 0.1325 0.0494 10.1016/j.fsigen.2018.05.008
mh18USC-18pA MHDBM-56dfa93b GRCh37 chr18 5280016,5280019,5280069,5280070,5280092 3.4330 0.2130 0.1818 10.1016/j.fsigen.2019.102213
mh18CP-005 MHDBM-a85754d3 GRCh37 chr18 8892862,8892891,8892894,8892905 3.6722 0.0904 0.0059 ALFRED
mh18KK-285 MHDBM-ea520d26 GRCh37 chr18 22137318,22137395,22137411,22137453 2.7524 0.1721 0.0836 ALFRED
mh18AT-38 MHDBM-db09ec41 GRCh37 chr18 22137395,22137411,22137453 2.7093 0.1419 0.0837 ISFG2019:P597
mh18CP-003 MHDBM-6fdf83f9 GRCh37 chr18 23068395,23068425,23068433 3.1124 0.1061 0.0183 ALFRED
Name PermID Reference Chrom Offsets Ae In Fst Source
mh18PK-87558 MHDBM-1e5374f1 GRCh37 chr18 1960543,1960558,1960562,1960567,1960583,1960589 2.3659 0.1325 0.0494 10.1016/j.fsigen.2018.05.008
mh18USC-18pA MHDBM-56dfa93b GRCh37 chr18 5280016,5280019,5280069,5280070,5280092 3.4330 0.2130 0.1818 10.1016/j.fsigen.2019.102213
mh18CP-005 MHDBM-a85754d3 GRCh37 chr18 8892862,8892891,8892894,8892905 3.6722 0.0904 0.0059 ALFRED
mh18KK-285 MHDBM-ea520d26 GRCh37 chr18 22137318,22137395,22137411,22137453 2.7524 0.1721 0.0836 ALFRED
mh18AT-38 MHDBM-db09ec41 GRCh37 chr18 22137395,22137411,22137453 2.7093 0.1419 0.0837 ISFG2019:P597
mh18CP-003 MHDBM-6fdf83f9 GRCh37 chr18 23068395,23068425,23068433 3.1124 0.1061 0.0183 ALFRED
'''
obs_out = terminal.out
print(obs_out)
assert exp_out.strip() == obs_out.strip()


Expand Down Expand Up @@ -416,19 +420,19 @@ def test_hg37_detail(capsys):
assert exp_out.strip() == obs_out.strip()


def test_h37_ae_pop(capsys):
def test_hg37_ae_pop(capsys):
arglist = ['marker', '--region=chr18:50000000-80000000', '--GRCh37', '--ae-pop=PJL']
args = get_parser().parse_args(arglist)
microhapdb.cli.main(args)
terminal = capsys.readouterr()
exp_out = '''
Name PermID Reference Chrom Offsets Ae In Fst Source
mh18USC-18qB MHDBM-14fcada5 GRCh37 chr18 50547498,50547528,50547540 3.8565 0.1449 0.0500 10.1016/j.fsigen.2019.102213
mh18USC-18qC MHDBM-6bf74efc GRCh37 chr18 63842523,63842541,63842557,63842562 3.5570 0.1436 -0.0049 10.1016/j.fsigen.2019.102213
mh18KKCS-293 MHDBM-350bd971 GRCh37 chr18 76089731,76089843,76089884,76089885,76089906,76089944,76089967 NaN NaN NaN 10.1016/j.fsigen.2020.102275
mh18KK-293 MHDBM-13ed6da8 GRCh37 chr18 76089885,76089906,76089944,76089967 2.6445 0.2495 0.0837 ALFRED
mh18AT-39 MHDBM-13ed6da8 GRCh37 chr18 76089885,76089906,76089944,76089967 2.6445 0.2495 0.0837 ISFG2019:P597

Name PermID Reference Chrom Offsets Ae In Fst Source
mh18USC-18qB MHDBM-14fcada5 GRCh37 chr18 50547498,50547528,50547540 3.8565 0.1449 0.0500 10.1016/j.fsigen.2019.102213
mh18USC-18qC MHDBM-6bf74efc GRCh37 chr18 63842523,63842541,63842557,63842562 3.5570 0.1436 -0.0049 10.1016/j.fsigen.2019.102213
mh18KKCS-293 MHDBM-350bd971 GRCh37 chr18 76089731,76089843,76089884,76089885,76089906,76089944,76089967 NaN NaN NaN 10.1016/j.fsigen.2020.102275
mh18KK-293 MHDBM-13ed6da8 GRCh37 chr18 76089885,76089906,76089944,76089967 2.6445 0.2495 0.0837 ALFRED
mh18AT-39 MHDBM-13ed6da8 GRCh37 chr18 76089885,76089906,76089944,76089967 2.6445 0.2495 0.0837 ISFG2019:P597
'''
obs_out = terminal.out
print(obs_out)
assert exp_out.strip() == obs_out.strip()
10 changes: 5 additions & 5 deletions microhapdb/tests/test_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def test_allele_frequencies():


@pytest.mark.parametrize('marker,pop,allele,data', [
('mh22KK-064', 'SA000009J', 'A,A,T,AATAATT', 'mh22KK-064 SA000009J A,A,T,AATAATT 0.828'),
('mh06PK-24844', 'MHDBP-383d86606a', 'C,C,G,C,C,C,A,A,A,A', 'mh06PK-24844 MHDBP-383d86606a C,C,G,C,C,C,A,A,A,A 0.005'),
('mh20AT-40', 'MHDBP-7c055e7ee8', 'T,C,G', 'mh20AT-40 MHDBP-7c055e7ee8 T,C,G 0.0806'),
('mh11NH-17', 'MHDBP-63967b883e', 'C,G,G', 'mh11NH-17 MHDBP-63967b883e C,G,G 0.153'),
('mh01CP-016', 'MHDBP-48c2cfb2aa', 'T,G,A', 'mh01CP-016 MHDBP-48c2cfb2aa T,G,A 0.2916'),
('mh22KK-064', 'SA000009J', 'A,A,T,AATAATT', 'mh22KK-064 SA000009J A,A,T,AATAATT 0.828'),
('mh06PK-24844', 'MHDBP-383d86606a', 'C,C,G,C,C,C,A,A,A,A', 'mh06PK-24844 MHDBP-383d86606a C,C,G,C,C,C,A,A,A,A 0.005'),
('mh20AT-40', 'MHDBP-7c055e7ee8', 'T,C,G', 'mh20AT-40 MHDBP-7c055e7ee8 T,C,G 0.0806'),
('mh11NH-17', 'MHDBP-63967b883e', 'C,G,G', 'mh11NH-17 MHDBP-63967b883e C,G,G 0.153'),
('mh01CP-016', 'MHDBP-48c2cfb2aa', 'T,G,A', 'mh01CP-016 MHDBP-48c2cfb2aa T,G,A 0.2916'),
])
def test_all_sources(marker, pop, allele, data, capsys):
arglist = ['frequency', '--marker', marker, '--population', pop, '--allele', allele]
Expand Down
Loading