Exemple #1
0
 def __get_translated_filter_and_variant_annotation(
     cls,
     call: SimpleCall,
     panel: Panel,
     call_reference_assembly: ReferenceAssembly,
     translated_reference_allele: Optional[str],
 ) -> Tuple[FullCallFilter, str]:
     annotated_alleles = cls.__get_annotated_alleles(
         call, call_reference_assembly, translated_reference_allele)
     if panel.has_ref_seq_difference_annotation(call.gene,
                                                call.start_coordinate,
                                                call.reference_allele,
                                                call_reference_assembly):
         annotate_as_ref = all(
             cls.
             __is_ref_allele_to_opposite_assembly_due_to_ref_sequence_difference(
                 annotated_allele, call_reference_assembly)
             for annotated_allele in annotated_alleles)
         all_variants_are_ref_to_a_reference_assembly = all(
             cls.__allele_is_ref_to_a_reference_assembly(
                 annotated_allele, call_reference_assembly)
             for annotated_allele in annotated_alleles)
         if annotate_as_ref:
             translated_variant_annotation = REF_CALL_ANNOTATION_STRING
             translated_filter = FullCallFilter.PASS
         elif all_variants_are_ref_to_a_reference_assembly:
             translated_variant_annotation = panel.get_ref_seq_difference_annotation(
                 call.gene, call.start_coordinate, call.reference_allele,
                 call_reference_assembly)
             if call.is_pass():
                 translated_filter = FullCallFilter.PASS
             else:
                 translated_filter = FullCallFilter.INFERRED_PASS
         else:
             translated_variant_annotation = call.variant_annotation + "?"
             translated_filter = FullCallFilter.UNKNOWN
             logging.warning(
                 f"Unexpected allele in ref seq difference location. Check whether annotation is correct: "
                 f"found alleles=({annotated_alleles[0]}, {annotated_alleles[1]}), "
                 f"annotation={translated_variant_annotation}")
     elif panel.contains_rs_id_matching_call(call, call_reference_assembly):
         # known variant and no ref seq differences involved
         translated_variant_annotation = call.variant_annotation
         if call.is_pass():
             translated_filter = FullCallFilter.PASS
         else:
             translated_filter = FullCallFilter.NO_CALL
     else:
         # unknown variant, no ref seq difference involved
         translated_variant_annotation = call.variant_annotation + "?"
         translated_filter = FullCallFilter.UNKNOWN
         logging.warning(
             f"Unknown variant. Check whether annotation is correct: "
             f"found alleles=({annotated_alleles[0]}, {annotated_alleles[1]}), "
             f"annotation={translated_variant_annotation}")
     return translated_filter, translated_variant_annotation
Exemple #2
0
 def __get_translated_reference_allele(
         cls, call: SimpleCall, panel: Panel,
         call_reference_assembly: ReferenceAssembly) -> Optional[str]:
     if panel.contains_rs_id_matching_call(call, call_reference_assembly):
         rs_id_info = panel.get_matching_rs_id_info(
             call.start_coordinate, call.reference_allele,
             call_reference_assembly)
         cls.__assert_rs_id_call_matches_info(call.rs_ids,
                                              (rs_id_info.rs_id, ))
         return rs_id_info.get_reference_allele(
             call_reference_assembly.opposite())
     else:
         # unknown variant
         return None
Exemple #3
0
 def __fill_in_rs_ids_if_needed(
         cls, call: SimpleCall, panel: Panel,
         reference_assembly: ReferenceAssembly) -> SimpleCall:
     rs_ids: Tuple[str, ...]
     if call.rs_ids == (".", ) and panel.contains_rs_id_matching_call(
             call, reference_assembly):
         rs_id_info = panel.get_matching_rs_id_info(call.start_coordinate,
                                                    call.reference_allele,
                                                    reference_assembly)
         rs_ids = (rs_id_info.rs_id, )
         new_simple_call = SimpleCall(
             call.start_coordinate,
             call.reference_allele,
             call.alleles,
             call.gene,
             rs_ids,
             call.variant_annotation,
             call.filter,
         )
         return new_simple_call
     else:
         return call