gnomad.utils.parse
This module contains utility functions for general parsing.
Create a Struct with the locus and alleles from a variant string or contig, position, ref, and alt. |
|
Parse interval(s) string into Hail locus intervals. |
This module contains utility functions for general parsing.
- gnomad.utils.parse.parse_variant(variant_str=None, contig=None, position=None, ref=None, alt=None, build=None)[source]
Create a Struct with the locus and alleles from a variant string or contig, position, ref, and alt.
- Parameters:
variant_str (
Optional
[str
]) – Variant string in the format contig-position-ref-alt or contig:position:ref:alt.contig (
Optional
[str
]) – Chromosome of the variant.position (
Optional
[int
]) – Variant position.ref (
Optional
[str
]) – Reference allele.alt (
Optional
[str
]) – Alternate allele.build (
Optional
[str
]) – Reference genome build. If not provided, will infer from the variant string or contig. If ‘chr’ is present in the contig, will assume GRCh38, otherwise GRCh37.
- Return type:
- Returns:
Struct with the locus and alleles.
- gnomad.utils.parse.parse_locus_intervals(intervals, reference_genome=None)[source]
Parse interval(s) string into Hail locus intervals.
Note
If no reference genome is provided, the function will infer the reference genome build from the interval string. If the interval string starts with ‘chr’, it will assume GRCh38, otherwise GRCh37.
- Parameters:
intervals (
Union
[str
,List
[str
]]) – Interval string or list of interval strings. The interval string format has to be “contig:start-end”, e.g.,”1:1000-2000” (GRCh37) or “chr1:1000-2000” (GRCh38).reference_genome (
Optional
[str
]) –
- Return type:
Union
[IntervalExpression
,List
[IntervalExpression
]]- Returns:
Hail locus interval(s).