<s> from __future__ import ( print_function ) <EOL> import logging <EOL> from genmod . utils import INTERESTING_SO_TERMS , EXONIC_SO_TERMS <EOL> def check_vep_annotation ( variant ) : <EOL> """<STR_LIT>""" <EOL> annotation = set ( ) <EOL> vep_info = variant . get ( '<STR_LIT>' , { } ) <EOL> for allele in vep_info : <EOL> for vep_annotation in variant [ '<STR_LIT>' ] [ allele ] : <EOL> for consequence in vep_annotation . get ( '<STR_LIT>' , { } ) . split ( '<STR_LIT:&>' ) : <EOL> if consequence in INTERESTING_SO_TERMS : <EOL> annotation . add ( vep_annotation . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> return annotation <EOL> def get_annotation ( variant , annotation_key = "<STR_LIT>" , vep = False ) : <EOL> """<STR_LIT>""" <EOL> logger = logging . getLogger ( __name__ ) <EOL> annotation = set ( ) <EOL> variant_id = variant . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> logger . debug ( "<STR_LIT>" . format ( variant_id ) ) <EOL> if vep : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> annotation = check_vep_annotation ( variant ) <EOL> else : <EOL> info_dict = variant . get ( '<STR_LIT>' , { } ) <EOL> if info_dict . get ( annotation_key , None ) : <EOL> annotation = set ( info_dict [ annotation_key ] . split ( '<STR_LIT:U+002C>' ) ) <EOL> logger . debug ( "<STR_LIT>" . format ( <EOL> variant_id , '<STR_LIT:U+002C>' . join ( annotation ) <EOL> ) ) <EOL> return annotation <EOL> def check_exonic ( variant , vep = False ) : <EOL> """<STR_LIT>""" <EOL> exonic = False <EOL> if vep : <EOL> for allele in variant . get ( '<STR_LIT>' , { } ) : <EOL> for vep_annotation in variant [ '<STR_LIT>' ] [ allele ] : <EOL> for consequence in vep_annotation . get ( '<STR_LIT>' , { } ) . split ( '<STR_LIT:&>' ) : <EOL> if consequence in EXONIC_SO_TERMS : <EOL> exonic = True <EOL> elif "<STR_LIT>" in variant [ '<STR_LIT>' ] : <EOL> exonic = True <EOL> return exonic </s>
