Skip to content

Commit

Permalink
fixed some issues and implemented a workaround for wrong hg38 positions
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed Aug 23, 2024
1 parent 52a7146 commit 4ffc467
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/common/db_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,10 @@ def get_variants_page_merged(self, page, page_size, sort_by, include_hidden, use

if len(ids_unknown_source) > 0:
placeholders = self.get_placeholders(len(ids_unknown_source))
new_constraints.append("id IN (SELECT variant_id FROM variant_ids WHERE external_id IN " + placeholders + " UNION SELECT id FROM variant WHERE id IN " + placeholders + ")")
actual_information += tuple(ids_unknown_source) * 2
annotation_type_ids_oi = list(self.get_recent_annotation_type_ids().values())
annotation_type_id_placeholders = self.get_placeholders(len(annotation_type_ids_oi))
new_constraints.append("id IN (SELECT variant_id FROM variant_ids WHERE external_id IN " + placeholders + " AND annotation_type_id IN " + annotation_type_id_placeholders + " UNION SELECT id FROM variant WHERE id IN " + placeholders + ")")
actual_information += tuple(ids_unknown_source) + tuple(annotation_type_ids_oi) + tuple(ids_unknown_source)
new_constraints = ' OR '.join(new_constraints)
postfix = self.add_constraints_to_command(postfix, new_constraints)

Expand All @@ -1085,7 +1087,7 @@ def get_variants_page_merged(self, page, page_size, sort_by, include_hidden, use
offset = (page - 1) * page_size
command = command + " LIMIT %s, %s"
actual_information += (offset, page_size)
print(command % actual_information)
#print(command % actual_information)
self.cursor.execute(command, actual_information)
variants_raw = self.cursor.fetchall()

Expand Down
20 changes: 19 additions & 1 deletion src/frontend_celery/webapp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,24 @@ def insert_variants_vcf_file(vcf_file, genome_build, user_id, import_queue_id, c
return status, message


# this is basically a workaround for a liftover error when the reference base was missing: ex: vid:9476493 chrom:22 pos_hg19:29090030 ref_hg19:GG alt_hg19:A
# some of these variants have an erroneous hg38 variant in heredicare. However, when lifting them from hg19 they are recovered correctly
def skip_hg38(variant) -> bool:
chrom = variant.get('CHROM')
pos_38 = variant.get('POS_HG38')
ref_38 = variant.get('REF_HG38')
alt_38 = variant.get('ALT_HG38')

pos_19 = variant.get('POS_HG19')
ref_19 = variant.get('REF_HG19')
alt_19 = variant.get('ALT_HG19')

if all([chrom, pos_38, ref_38, alt_38]):
if all([chrom, pos_19, ref_19, alt_19]):
if (ref_19[0] != alt_19[0]) and (len(ref_19) > 1 or len(alt_19) > 1) and (len(ref_19) != len(alt_19)):
return True

return False



Expand All @@ -411,7 +429,7 @@ def map_hg38(variant, user_id, conn:Connection, insert_variant = True, perform_a
genome_build = "GRCh38"

was_successful = False
if all([x is not None for x in [chrom, pos, ref, alt]]):
if all([x is not None for x in [chrom, pos, ref, alt]]) and not skip_hg38(variant):
was_successful, new_message, variant_id = validate_and_insert_variant(chrom, pos, ref, alt, genome_build, conn, user_id, allowed_sequence_letters = allowed_sequence_letters, insert_variant = insert_variant, perform_annotation=perform_annotation)
if new_message not in message:
message = functions.collect_info(message, "hg38_msg=", new_message, sep = " ~~ ")
Expand Down
1 change: 1 addition & 0 deletions src/frontend_celery/webapp/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ <h4>Changelog</h4>
<li>Fixed some minor issues with HerediCaRe up- and downloads</li>
<li>Downgraded CrossMap to v0.7.0 because v0.7.3 yields wrong results for specific variants</li>
<li>Fixed a bug where the tooltip of status pills would persist if the pill was updated</li>
<li>Fixed a bug where the user was able to search for deprecated variant ids using the browse variant table</li>
</ul>
</div>

Expand Down

0 comments on commit 4ffc467

Please sign in to comment.