utils

Utility functions for lookups and browser_handlers.

add_consequence_to_variant(variant: dict)[source]

Add information about variant consequence to a variant.

Parameters:variant (dict) – variant information
add_consequence_to_variants(variant_list: list)[source]

Add information about variant consequence to multiple variants.

Parameters:
  • variant_list (list) – list of variants
  • datatype (str) – type of data
  • item (str) – query item
annotation_severity(annotation: dict)[source]

Evaluate severity of the consequences; “bigger is more important”.

Parameters:annotation (dict) – vep_annotation from a variant
Returns:severity score
Return type:float
get_coverage(dataset: str, datatype: str, item: str, ds_version: str = None)[source]

Retrieve coverage for a gene/region/transcript.

Parameters:
  • dataset (str) – short name of the dataset
  • datatype (str) – type of “region” (gene/region/transcript)
  • item (str) – the datatype item to look up
  • ds_version (str) – the dataset version
Returns:

start, stop, coverage list

Return type:

dict

get_coverage_pos(dataset: str, datatype: str, item: str, ds_version: str = None)[source]

Retrieve coverage range.

Parameters:
  • dataset (str) – short name of the dataset
  • datatype (str) – type of “region” (gene/region/transcript)
  • item (str) – the datatype item to look up
Returns:

start, stop, chrom

Return type:

dict

get_flags_from_variant(variant: dict)[source]

Get flags from variant.

Checks for: * MNP * LoF (loss of function)

Parameters:variant (dict) – a variant
Returns:flags for the variant
Return type:list
get_proper_hgvs(annotation: dict)[source]

Get HGVS for change, either at transcript or protein level.

Parameters:annotation (dict) – VEP annotation with HGVS information
Returns:variant effect at aa level in HGVS format (p.), None if parsing fails
Return type:str
get_protein_hgvs(annotation)[source]

Aa changes in HGVS format.

Parameters:annotation (dict) – VEP annotation with HGVS information
Returns:variant effect at aa level in HGVS format (p.), None if parsing fails
Return type:str
get_transcript_hgvs(annotation: dict)[source]

Nucleotide change in HGVS format.

Parameters:annotation (dict) – VEP annotation with HGVS information
Returns:variant effect at nucleotide level in HGVS format (c.), None if parsing fails
Return type:str
get_variant_list(dataset: str, datatype: str, item: str, ds_version: str = None)[source]

Retrieve variants for a datatype.

Parameters:
  • dataset (str) – dataset short name
  • datatype (str) – type of data
  • item (str) – query item
  • ds_version (str) – dataset version
Returns:

{variants:list, headers:list}

Return type:

dict

is_region_too_large(start: int, stop: int)[source]

Evaluate whether the size of a region is larger than maximum query.

Parameters:
  • start (int) – Start position of the region
  • stop (int) – End position of the region
Returns:

True if too large

Return type:

bool

order_vep_by_csq(annotation_list: list)[source]

Will add “major_consequence” to each annotation and order by severity.

Parameters:annotation_list (list) – VEP annotations (as dict)
Returns:annotations ordered by major consequence severity
Return type:list
parse_dataset(dataset: str, ds_version: str = None)[source]

Check/parse if the dataset name is in the beacon form (reference:dataset:version).

Parameters:
  • dataset (str) – short name of the dataset
  • ds_version (str) – the dataset version
Returns:

(dataset, version)

Return type:

tuple

parse_region(region: str)[source]

Parse a region with either one or two positions

Parameters:region (str) – region, e.g. 3-100-200 or 3-100
Returns:(chrom, start, pos)
Return type:tuple
remove_extraneous_information(variant: dict)[source]

Remove information that is not used in the frontend from a variant.

Parameters:variant (dict) – variant data from database
remove_extraneous_vep_annotations(annotation_list: list)[source]

Remove annotations with low-impact consequences (less than intron variant).

Parameters:annotation_list (list) – VEP annotations (as dict)
Returns:VEP annotations with higher impact
Return type:list
worst_csq_from_csq(csq: str)[source]

Find worst consequence in a possibly &-filled consequence string.

Parameters:csq (str) – string of consequences, seperated with & (if multiple)
Returns:the worst consequence
Return type:str
worst_csq_from_list(csq_list: list)[source]

Choose the worst consequence.

Parameters:csq_list (list) – list of consequences
Returns:the worst consequence
Return type:str
worst_csq_index(csq_list: list)[source]

Find the index of the worst consequence.

Corresponds to the lowest value (index) from CSQ_ORDER_DICT.

Parameters:csq_list (list) – consequences
Returns:index in CSQ_ODER_DICT of the worst consequence
Return type:int
worst_csq_with_vep(annotation_list: list)[source]

Choose the vep annotation with the most severe consequence.

Add a”major_consequence” field for that annotation.

Parameters:annotation_list (list) – VEP annotations
Returns:the annotation with the most severe consequence
Return type:dict