Skip to main content

vcf-handler

This repo is an installable python package and command line tool built for creating .csv files of annotated variants from VCF files. Currently the main process annotates variants with the following information either found within the VCF or pulled from external sources:

  1. Depth of sequence coverage at the site of variation.
  2. Number of reads supporting the variant.
  3. Percentage of reads supporting the variant versus those supporting reference reads.
  4. Gene ID of the variant, type of variation (substitution, insertion, CNV, etc.) and their effect (missense, silent, intergenic, etc.) using the VEP hgvs API
  5. The minor allele frequency of the variant if available.

This process supports handling of multi-allelic sites. No pre-decomposition needed.

This package is publicly installable from PyPI. Once installed, the vcf-handler can be ran by importing the installed package:

>>> from vcf_handler.process import process_vcf
>>> process_vcf('test_vcf_data.txt')
INFO:vcf-handling:Checking VCF file
INFO:vcf-handling:Writing annotated variants to output.csv

Or, if the repo is cloned to your local environment and you have PDM installed, running pdm install from the root directory will install all dependencies, allowing you to run the tooling from the command line:

pdm run vcf-handler -i "{path_to_vcf}" -o "{desired_path_out}"

Code Walkthrough

The main VCF to CSV runner in this package is process.py. Here we pass through a light VCF file formatting check prior to reading in our variants. Reading and writing of variants is managed through generators in order to allow easy scaling in the instance of VCF files that are multiple GBs in size. This low-memory reading and writing can prevent exceeding of resource caps in comparison to methods which read the entire file into memory as a bytes, strings, or dataframes. All reading / writing is managed in utils/read_write.py

Once read in, each variant line is cast to a custom Variant class (utils/Variant.py) which has a handful of operations performed on it in order to scrape the necessary annotations. These are performed as class methods, and occasionally rely on outside helper functions (utils/vep_helpers.py).

The command line interfacing is managed through the click and argparse modules, and is all handled in cli.py

Developing

This repo uses PDM. Install PDM and then install dependencies with pdm install.

Running test suite: pdm run test Running auto-linter: pdm run lint-fix

Releases

This package is published on PyPI. In order to create a new release, bump the version in the pyproject.toml file, create a PR, and merge that change into main. When that change is merged into main, the new version will be automatically recognized and published.

Metadata

Release files for gabry-vcf-handler 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gabry-vcf-handler 1.3.0
File Size Uploaded
gabry-vcf-handler-1.3.0.tar.gz 694.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gabry-vcf-handler 1.3.0
File Interpreter ABI Platform
gabry_vcf_handler-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 702.5 kB

Release files / gabry-vcf-handler-1.3.0.tar.gz

Download URL gabry-vcf-handler-1.3.0.tar.gz
Size 694.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2004b9f6927a543187dff02a6217bff9aac1a13801f9f7e648705ea003d82289
BLAKE2b-256 checksum
How to use checksums
933fd8c76f4b77fe9e783884e7ec80b5dc45cc1dfc7305dfd5e0bbbb907c1639
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / gabry_vcf_handler-1.3.0-py3-none-any.whl

Download URL gabry_vcf_handler-1.3.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c16f88fa7eaae6c9191f1db04ad5d5fbb394b2c99feaa7f516e26d1f3aae925a
BLAKE2b-256 checksum
How to use checksums
9f1a3da1a8c5447f20e5a49b071fbf7192c1685df75c6968c5e1fd764b5a3477
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page