Skip to content

Commit

Permalink
Merge pull request #33 from openvar/develop_2_0
Browse files Browse the repository at this point in the history
Add a genomic liftover cache for direct g_to_g liftovers issue is #204
  • Loading branch information
Peter J. Freeman authored Jun 29, 2022
2 parents 5973c52 + e0ae224 commit 726ebad
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
Binary file modified .DS_Store
Binary file not shown.
6 changes: 4 additions & 2 deletions VariantFormatter/simpleVariantFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def format(batch_input, genome_build, transcript_model=None, specify_transcripts
vcf_list = pseudo_vcf.split('-')
delimiter = '-'
if len(vcf_list) != 4:
error = '%s is an unsupported format: For assistance, submit variant description to https://rest.variantvalidator.org' % str(pseudo_vcf)
error = ('%s is an unsupported format: For assistance, submit variant description '
'to https://rest.variantvalidator.org' % str(pseudo_vcf))
formatted_variants[variant]['errors'].append(error)
formatted_variants[variant]['flag'] = 'submission_warning'
continue
Expand All @@ -70,7 +71,8 @@ def format(batch_input, genome_build, transcript_model=None, specify_transcripts
try:
format_these.append(variant)
except Exception:
error = '%s is an unsupported format: For assistance, submit variant description to https://rest.variantvalidator.org' % variant
error = ('%s is an unsupported format: For assistance, submit variant description '
'to https://rest.variantvalidator.org' % variant)
formatted_variants[variant]['errors'].append(error)
formatted_variants[variant]['flag'] = 'submission_warning'
continue
Expand Down
49 changes: 27 additions & 22 deletions VariantFormatter/variantformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ def __init__(self, variant_description, genome_build, vfo, transcript_model=None
else:
transcript_list.append(tx)

# Create a variable to trap direct g_g liftover
g_to_g_lift = {}

# Create transcript level descriptions
for tx_alignment_data in transcript_list:
tx_id = tx_alignment_data[0]
Expand All @@ -360,19 +363,12 @@ def __init__(self, variant_description, genome_build, vfo, transcript_model=None
if hgvs_transcript_dict['error'] == '':
hgvs_transcript_dict['error'] = None

am_i_gapped = {'hgvs_transcript': None,
'position_lock': False,
'gapped_alignment_warning': None,
'corrective_action': None,
'gap_position':None,
'transcript_accession': tx_id,
'error': hgvs_transcript_dict['error']
}
am_i_gapped = {'hgvs_transcript': None, 'position_lock': False, 'gapped_alignment_warning': None,
'corrective_action': None, 'gap_position': None, 'transcript_accession': tx_id,
'error': hgvs_transcript_dict['error'], 'hgvs_protein_tlc': None,
'hgvs_protein_slc': None}

# add to dictionary
am_i_gapped['hgvs_protein_tlc'] = None
am_i_gapped['hgvs_protein_slc'] = None

# add to dictionary
else:
if hgvs_transcript_dict['error'] == '':
hgvs_transcript_dict['error'] = None
Expand Down Expand Up @@ -443,16 +439,25 @@ def __init__(self, variant_description, genome_build, vfo, transcript_model=None
== 'GRCh38':
build_to = 'GRCh37'

current_lift = lo.liftover(self.genomic_descriptions.g_hgvs,
self.genomic_descriptions.selected_build,
build_to,
vfo.splign_normalizer,
vfo.reverse_splign_normalizer,
None,
vfo,
specify_tx=tx_id,
liftover_level=self.liftover
)
# Look for previous g_to_g lift
if (order_my_tp['transcript_variant_error'] is not None and g_to_g_lift == {}) or (
order_my_tp['transcript_variant_error'] is None):

current_lift = lo.liftover(self.genomic_descriptions.g_hgvs,
self.genomic_descriptions.selected_build,
build_to,
vfo.splign_normalizer,
vfo.reverse_splign_normalizer,
None,
vfo,
specify_tx=tx_id,
liftover_level=self.liftover
)
if g_to_g_lift == {}:
g_to_g_lift = current_lift

elif order_my_tp['transcript_variant_error'] is not None and g_to_g_lift != {}:
current_lift = g_to_g_lift

# Copy the liftover and split into primary and alt
cp_current_lift = copy.deepcopy(current_lift)
Expand Down

0 comments on commit 726ebad

Please sign in to comment.