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

Allow genmod score to run on empty VCF #160

Merged
merged 6 commits into from
Mar 20, 2025
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ Try to use the following format:
- genmod annotate for mitochondrial variants when using the `chrM` notation ([#157](https://github.com/Clinical-Genomics/genmod/pull/157))
- Use `uv` with `hatchling` to build and publish ([#104](https://github.com/Clinical-Genomics/genmod/issues/143))
- Fix linting issues ([#154](https://github.com/Clinical-Genomics/genmod/issues/154))
- genmod models adds headers to VCF even if it contains no variants ([#160](https://github.com/Clinical-Genomics/genmod/pull/160))

## [3.9]
- Fixed wrong models when chromosome X was named `chrX` and not `X` ([#135](https://github.com/Clinical-Genomics/genmod/pull/135))
45 changes: 23 additions & 22 deletions genmod/commands/annotate_models.py
Original file line number Diff line number Diff line change
@@ -182,28 +182,7 @@ def models(
else:
break

# Add the first variant to the iterator
if not line.startswith("#"):
variant_file = itertools.chain([line], variant_file)
else:
print_headers(head=head, outfile=outfile, silent=silent)
sys.exit(0)

if vep:
if "CSQ" not in head.info_dict:
logger.warning("vep flag is used but there is no CSQ field specified in header")
logger.info("Please check VCF file")
context.abort()
else:
logger.info("Using VEP annotation")
else:
if keyword not in head.info_dict:
logger.warning("Annotation key {0} could not be found in VCF header".format(keyword))
logger.info("Please check VCF file")
context.abort()
else:
logger.info("Using {0} annotation".format(keyword))

# Check before adding models info to header
if "GeneticModels" in head.info_dict:
logger.warning("Genetic models are already annotated according to vcf header.")
context.abort()
@@ -254,6 +233,28 @@ def models(
)
logger.debug("Compounds added")

# Add the first variant to the iterator
if not line.startswith("#"):
variant_file = itertools.chain([line], variant_file)
else:
print_headers(head=head, outfile=outfile, silent=silent)
sys.exit(0)

if vep:
if "CSQ" not in head.info_dict:
logger.warning("vep flag is used but there is no CSQ field specified in header")
logger.info("Please check VCF file")
context.abort()
else:
logger.info("Using VEP annotation")
else:
if keyword not in head.info_dict:
logger.warning("Annotation key {0} could not be found in VCF header".format(keyword))
logger.info("Please check VCF file")
context.abort()
else:
logger.info("Using {0} annotation".format(keyword))

vcf_individuals = head.individuals
logger.debug("Individuals found in vcf file: {}".format(", ".join(vcf_individuals)))