Skip to content

Commit

Permalink
[hail][feature] Pass through args on import_locus_intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoterba committed May 15, 2019
1 parent 5f09f8f commit 96a2e05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions hail/python/hail/methods/impex.py
Expand Up @@ -449,8 +449,9 @@ def export_vcf(dataset, output, append_to_header=None, parallel=None, metadata=N

@typecheck(path=str,
reference_genome=nullable(reference_genome_type),
skip_invalid_intervals=bool)
def import_locus_intervals(path, reference_genome='default', skip_invalid_intervals=False) -> Table:
skip_invalid_intervals=bool,
kwargs=anytype)
def import_locus_intervals(path, reference_genome='default', skip_invalid_intervals=False, **kwargs) -> Table:
"""Import a locus interval list as a :class:`.Table`.
Examples
Expand Down Expand Up @@ -509,6 +510,10 @@ def import_locus_intervals(path, reference_genome='default', skip_invalid_interv
skip_invalid_intervals : :obj:`bool`
If ``True`` and `reference_genome` is not ``None``, skip lines with
intervals that are not consistent with the reference genome.
**kwargs
Additional optional arguments to :func:`import_table` are valid
arguments here except: `no_header`, `comment`, `impute`, and
`types`, as these are used by :func:`import_locus_intervals`.
Returns
-------
Expand All @@ -518,7 +523,8 @@ def import_locus_intervals(path, reference_genome='default', skip_invalid_interv

t = import_table(path, comment="@", impute=False, no_header=True,
types={'f0': tstr, 'f1': tint32, 'f2': tint32,
'f3': tstr, 'f4': tstr})
'f3': tstr, 'f4': tstr},
**kwargs)

if t.row.dtype == tstruct(f0=tstr):
if reference_genome:
Expand Down Expand Up @@ -658,7 +664,7 @@ def import_bed(path, reference_genome='default', skip_invalid_intervals=False, *
skip_invalid_intervals : :obj:`bool`
If ``True`` and `reference_genome` is not ``None``, skip lines with
intervals that are not consistent with the reference genome.
**kwargs :
**kwargs
Additional optional arguments to :func:`import_table` are valid arguments here except:
`no_header`, `delimiter`, `impute`, `skip_blank_lines`, `types`, and `comment` as these
are used by import_bed.
Expand Down
5 changes: 5 additions & 0 deletions hail/python/test/hail/methods/test_impex.py
Expand Up @@ -1210,6 +1210,11 @@ def test_import_bed_badly_defined_intervals(self):
t = hl.import_bed(bed_file, reference_genome=None, skip_invalid_intervals=True)
self.assertTrue(t.count() == 4)

def test_pass_through_args(self):
interval_file = resource('example3.interval_list')
t = hl.import_locus_intervals(interval_file, reference_genome='GRCh37', min_partitions=10)
assert t.n_partitions() == 10


class ImportMatrixTableTests(unittest.TestCase):
@skip_unless_spark_backend()
Expand Down

0 comments on commit 96a2e05

Please sign in to comment.