@@ -73,6 +73,17 @@ def dummy_matches(locus: HLA_LOCUS) -> dict[HLACombinedStandard, HLAMatchDetails
7373 }
7474
7575
76+ def dummy_matches_no_mismatches (
77+ locus : HLA_LOCUS ,
78+ ) -> dict [HLACombinedStandard , HLAMatchDetails ]:
79+ return {
80+ HLACombinedStandard (
81+ standard_bin = (2 , 2 , 1 , 2 , 1 , 4 , 4 , 2 , 8 ),
82+ possible_allele_pairs = ((f"{ locus } *01:01:01" , f"{ locus } *02:02:02" ),),
83+ ): HLAMatchDetails (mismatch_count = 0 , mismatches = []),
84+ }
85+
86+
7687DUMMY_FREQUENCIES : Final [dict [HLAProteinPair , int ]] = {
7788 HLAProteinPair (
7889 first_field_1 = "01" ,
@@ -119,6 +130,33 @@ def test_hla_sequence_a_build_from_interpretation():
119130 assert seq_a == expected_result
120131
121132
133+ def test_hla_sequence_a_build_from_interpretation_no_mismatches ():
134+ interp : HLAInterpretation = HLAInterpretation (
135+ hla_sequence = dummy_hla_sequence ("A" ),
136+ matches = dummy_matches_no_mismatches ("A" ),
137+ allele_frequencies = DUMMY_FREQUENCIES ,
138+ )
139+ processing_datetime : datetime = datetime (2025 , 5 , 9 , 11 , 0 , 0 )
140+
141+ seq_a : HLASequenceA = HLASequenceA .build_from_interpretation (
142+ interp , processing_datetime
143+ )
144+
145+ expected_result : HLASequenceA = HLASequenceA (
146+ enum = "dummy_seq" ,
147+ alleles_clean = "A*01:01:01 - A*02:02:02" ,
148+ alleles_all = "A*01:01:01 - A*02:02:02" ,
149+ ambiguous = "False" ,
150+ homozygous = "False" ,
151+ mismatch_count = 0 ,
152+ mismatches = None ,
153+ seq = "CCACAGGCT" ,
154+ enterdate = processing_datetime ,
155+ )
156+
157+ assert seq_a == expected_result
158+
159+
122160def test_hla_sequence_b_build_from_interpretation_non_b5701 ():
123161 b5701_standards : list [HLAStandard ] = [
124162 # "Forgiving distance" from sequence: 8
@@ -175,6 +213,58 @@ def test_hla_sequence_b_build_from_interpretation_non_b5701():
175213 assert seq_b == expected_result
176214
177215
216+ def test_hla_sequence_b_build_from_interpretation_no_mismatches ():
217+ b5701_standards : list [HLAStandard ] = [
218+ # "Forgiving distance" from sequence: 8
219+ HLAStandard (
220+ allele = "B*57:01:01" ,
221+ two = (8 , 8 , 8 , 8 ),
222+ three = (8 , 8 , 8 , 8 , 8 ),
223+ ),
224+ # "Forgiving distance" from sequence: 7
225+ HLAStandard (
226+ allele = "B*57:01:02:01N" ,
227+ two = (4 , 8 , 4 , 8 ),
228+ three = (8 , 4 , 8 , 4 , 8 ),
229+ ),
230+ # "Forgiving distance" from sequence: 6, because 12 "contains" 8
231+ HLAStandard (
232+ allele = "B*57:01:03" ,
233+ two = (4 , 4 , 8 , 8 ),
234+ three = (8 , 4 , 4 , 8 , 12 ),
235+ ),
236+ ]
237+ interp : HLAInterpretation = HLAInterpretation (
238+ hla_sequence = dummy_hla_sequence ("B" ),
239+ matches = dummy_matches_no_mismatches ("B" ),
240+ allele_frequencies = DUMMY_FREQUENCIES ,
241+ b5701_standards = b5701_standards ,
242+ )
243+ processing_datetime : datetime = datetime (2025 , 5 , 9 , 11 , 0 , 0 )
244+
245+ seq_b : HLASequenceB = HLASequenceB .build_from_interpretation (
246+ interp , processing_datetime
247+ )
248+
249+ expected_result : HLASequenceB = HLASequenceB (
250+ enum = "dummy_seq" ,
251+ alleles_clean = "B*01:01:01 - B*02:02:02" ,
252+ alleles_all = "B*01:01:01 - B*02:02:02" ,
253+ ambiguous = "False" ,
254+ homozygous = "False" ,
255+ mismatch_count = 0 ,
256+ mismatches = None ,
257+ b5701 = "False" ,
258+ b5701_dist = 6 ,
259+ seqa = "CCAC" ,
260+ seqb = "AGGCT" ,
261+ reso_status = None ,
262+ enterdate = processing_datetime ,
263+ )
264+
265+ assert seq_b == expected_result
266+
267+
178268MATCHES_FOR_B5701_CASES : dict [HLACombinedStandard , HLAMatchDetails ] = {
179269 HLACombinedStandard (
180270 standard_bin = (1 , 4 , 9 , 4 ),
@@ -241,6 +331,7 @@ def test_hla_sequence_b_build_from_interpretation_non_b5701():
241331 ),
242332]
243333
334+
244335def test_hla_sequence_b_build_from_interpretation_is_b5701 ():
245336 interp : HLAInterpretation = HLAInterpretation (
246337 hla_sequence = dummy_hla_sequence ("B" ),
@@ -307,6 +398,34 @@ def test_hla_sequence_c_build_from_interpretation():
307398 assert seq_c == expected_result
308399
309400
401+ def test_hla_sequence_c_build_from_interpretation_no_mismatches ():
402+ interp : HLAInterpretation = HLAInterpretation (
403+ hla_sequence = dummy_hla_sequence ("C" ),
404+ matches = dummy_matches_no_mismatches ("C" ),
405+ allele_frequencies = DUMMY_FREQUENCIES ,
406+ )
407+ processing_datetime : datetime = datetime (2025 , 5 , 9 , 11 , 0 , 0 )
408+
409+ seq_c : HLASequenceC = HLASequenceC .build_from_interpretation (
410+ interp , processing_datetime
411+ )
412+
413+ expected_result : HLASequenceC = HLASequenceC (
414+ enum = "dummy_seq" ,
415+ alleles_clean = "C*01:01:01 - C*02:02:02" ,
416+ alleles_all = "C*01:01:01 - C*02:02:02" ,
417+ ambiguous = "False" ,
418+ homozygous = "False" ,
419+ mismatch_count = 0 ,
420+ mismatches = None ,
421+ seqa = "CCAC" ,
422+ seqb = "AGGCT" ,
423+ enterdate = processing_datetime ,
424+ )
425+
426+ assert seq_c == expected_result
427+
428+
310429@pytest .mark .parametrize (
311430 "raw_contents, locus, sample_name, expected_sanitized_contents" ,
312431 [
0 commit comments