Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jigold committed Jan 5, 2024
1 parent 1d812ee commit 8124e28
Showing 1 changed file with 17 additions and 22 deletions.
Expand Up @@ -8,9 +8,16 @@
from ...helpers import test_timeout, qobtest


def plinkify(ds, min=None, max=None):
@pytest.fixture(scope='module')
def ds():
dataset = hl.balding_nichols_model(1, 100, 100)
dataset = dataset.key_cols_by(s=hl.str(dataset.sample_idx + 1))
return dataset


def plinkify(dataset, min=None, max=None):
vcf = utils.new_temp_file(prefix="plink", extension="vcf")
hl.export_vcf(ds, vcf)
hl.export_vcf(dataset, vcf)

local_tmpdir = utils.new_local_temp_dir()
plinkpath = f'{local_tmpdir}/plink-ibd'
Expand Down Expand Up @@ -45,18 +52,10 @@ def plinkify(ds, min=None, max=None):
return results


def random_dataset():
ds = hl.balding_nichols_model(1, 100, 1000)
ds = ds.key_cols_by(s=hl.str(ds.sample_idx + 1))
return ds


@qobtest
@unittest.skipIf('HAIL_TEST_SKIP_PLINK' in os.environ, 'Skipping tests requiring plink')
@test_timeout(local=10 * 60, batch=10 * 60)
def test_ibd_default_arguments():
ds = random_dataset()

def test_ibd_default_arguments(ds):
plink_results = plinkify(ds)
hail_results = hl.identity_by_descent(ds).collect()

Expand All @@ -74,9 +73,7 @@ def test_ibd_default_arguments():
@qobtest
@unittest.skipIf('HAIL_TEST_SKIP_PLINK' in os.environ, 'Skipping tests requiring plink')
@test_timeout(local=10 * 60, batch=10 * 60)
def test_ibd_0_and_1():
ds = random_dataset()

def test_ibd_0_and_1(ds):
plink_results = plinkify(ds, min=0.0, max=1.0)
hail_results = hl.identity_by_descent(ds).collect()

Expand All @@ -93,15 +90,13 @@ def test_ibd_0_and_1():

@qobtest
@test_timeout(local=10 * 60, batch=10 * 60)
def test_ibd_does_not_error_with_dummy_maf_float64():
dataset = random_dataset()
dataset = dataset.annotate_rows(dummy_maf=0.01)
hl.identity_by_descent(dataset, dataset['dummy_maf'], min=0.0, max=1.0)
def test_ibd_does_not_error_with_dummy_maf_float64(ds):
ds = ds.annotate_rows(dummy_maf=0.01)
hl.identity_by_descent(ds, ds['dummy_maf'], min=0.0, max=1.0)


@qobtest
@test_timeout(local=10 * 60, batch=10 * 60)
def test_ibd_does_not_error_with_dummy_maf_float32():
dataset = random_dataset()
dataset = dataset.annotate_rows(dummy_maf=0.01)
hl.identity_by_descent(dataset, hl.float32(dataset['dummy_maf']), min=0.0, max=1.0)
def test_ibd_does_not_error_with_dummy_maf_float32(ds):
ds = ds.annotate_rows(dummy_maf=0.01)
hl.identity_by_descent(ds, hl.float32(ds['dummy_maf']), min=0.0, max=1.0)

0 comments on commit 8124e28

Please sign in to comment.