Skip to content

Commit

Permalink
Update pyvcf.has_chr_prefix:
Browse files Browse the repository at this point in the history
* Update :meth:`pyvcf.has_chr_prefix` method to ignore the HLA contigs for GRCh38.
  • Loading branch information
sbslee committed Jun 6, 2024
1 parent 541c186 commit 9c2c066
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
0.38.0 (in development)
-----------------------

* Update :meth:`pyvcf.has_chr_prefix` method to ignore the HLA contigs for GRCh38.

0.37.0 (2023-09-09)
-------------------

Expand Down
4 changes: 4 additions & 0 deletions fuc/api/pyvcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,8 @@ def has_chr_prefix(file, size=1000):
Return True if all of the sampled contigs from a VCF file have the
(annoying) 'chr' string.
For GRCh38, the HLA contigs will be ignored.
Parameters
----------
file : str
Expand All @@ -779,6 +781,8 @@ def has_chr_prefix(file, size=1000):
vcf = VariantFile(file)
for record in vcf.fetch():
n += 1
if record.chrom.startswith('HLA'):
continue
if 'chr' not in record.chrom:
return False
if n > size:
Expand Down

0 comments on commit 9c2c066

Please sign in to comment.