@@ -365,7 +365,7 @@ def full_beacon_search(search_json, headers=None):
365365
366366 try :
367367 variants_by_file = variants .find_variants_in_files (potential_hits , reference_name = actual_params ['reference_name' ], start = actual_params ['start' ], end = actual_params ['end' ], headers = headers )
368- resultset = compile_beacon_resultset (variants_by_file , actual_params ['reference_genome' ], authed_programs )
368+ resultset = compile_beacon_resultset (variants_by_file , actual_params ['reference_name' ], actual_params [ ' reference_genome' ], authed_programs )
369369 except Exception as e :
370370 raise Exception (f"exception in compile_beacon_resultset for { actual_params } : { type (e )} { str (e )} " )
371371 # others are for filtering after:
@@ -456,7 +456,7 @@ def full_beacon_search(search_json, headers=None):
456456 return response
457457
458458
459- def compile_beacon_resultset (variants_by_obj , reference_genome = "hg38" , authed_programs = None ):
459+ def compile_beacon_resultset (variants_by_obj , reference_name = None , reference_genome = "hg38" , authed_programs = None ):
460460 """
461461 Each beacon result describes a variation at a specific position:
462462 resultset = [
@@ -491,6 +491,10 @@ def compile_beacon_resultset(variants_by_obj, reference_genome="hg38", authed_pr
491491 }
492492 ]
493493 """
494+
495+ # find the correct sequence_id for the chromosome:
496+ seqid = database .get_refseq_for_chromosome (reference_genome = reference_genome , contig = database .normalize_contig (reference_name ))
497+
494498 resultset = {}
495499 for drs_obj in variants_by_obj .keys ():
496500 # check to see if this drs_object is authorized:
@@ -507,7 +511,7 @@ def compile_beacon_resultset(variants_by_obj, reference_genome="hg38", authed_pr
507511 continue
508512 for variant in variants_by_obj [drs_obj ]['variants' ]:
509513 # parse the variants beacon-style
510- variant ['variations' ] = compile_variations_from_record (ref = variant .pop ('ref' ), alt = variant .pop ('alt' ), chrom = variant . pop ( 'chrom' ), pos = variant .pop ('pos' ), reference_genome = reference_genome )
514+ variant ['variations' ] = compile_variations_from_record (ref = variant .pop ('ref' ), alt = variant .pop ('alt' ), pos = variant .pop ('pos' ), seqid = seqid )
511515 assign_info_to_variations (variant )
512516
513517 # the variations in each variant need to be copied out first:
@@ -594,7 +598,7 @@ def compile_beacon_resultset(variants_by_obj, reference_genome="hg38", authed_pr
594598 return final_resultset
595599
596600
597- def compile_variations_from_record (ref = "" , alt = ["" ], chrom = "" , pos = "" , reference_genome = "hg38" ):
601+ def compile_variations_from_record (ref = "" , alt = ["" ], pos = "" , seqid = None ):
598602 start = int (pos )
599603 end = int (pos )
600604 variations = [
@@ -622,8 +626,6 @@ def compile_variations_from_record(ref="", alt=[""], chrom="", pos="", reference
622626 }
623627 ]
624628
625- # find the correct sequence_id for the chromosome:
626- seqid = database .get_refseq_for_chromosome (reference_genome = reference_genome , contig = database .normalize_contig (chrom ))
627629 hgvsid_base = ""
628630 if seqid is not None :
629631 variations [0 ]['location' ]['sequence_id' ] = "refseq:" + seqid
0 commit comments