Convert

Module for converting HGVS descriptions and lark parse trees to their equivalent dictionary models.

class mutalyzer_hgvs_parser.convert.Converter(visit_tokens: bool = True)

Bases: lark.visitors.Transformer

AA(name)
COORDINATE_SYSTEM(name)
ID(name)
INVERTED(name)
OFFSET(name)
OUTSIDE_CDS(name)
P_SEQUENCE(name)
SEQUENCE(name)
UNKNOWN(name)
conversion(children)
deletion(children)
deletion_insertion(children)
description(children)
description_dna(children)
description_protein(children)
duplication(children)
equal(children)
exact_range(children)
extension(children)
frame_shift(children)
insert(children)
inserted(children)
insertion(children)
inversion(children)
length(children)
location(children)
point(children)
range(children)
reference(children)
repeat(children)
repeat_mixed(children)
repeat_number(children)
substitution(children)
uncertain_point(children)
variant(children)
variant_certain(children)
variant_predicted(children)
variants(children)
variants_predicted(children)
mutalyzer_hgvs_parser.convert.parse_tree_to_model(parse_tree)

Convert a parse tree to a nested dictionary model.

Parameters:parse_tree (lark.Tree) – HGVS description.
Returns:Description dictionary model.
Return type:dict
mutalyzer_hgvs_parser.convert.to_model(description, start_rule=None)

Convert an HGVS description, or parts of it, e.g., a location, a variants list, etc., if an appropriate alternative start_rule is provided, to a nested dictionary model.

Parameters:
  • description (str) – HGVS description.
  • start_rule (str) – Alternative start rule.
Returns:

Description dictionary model.

Return type:

dict