Skip to content

Commit

Permalink
Allow non unique matches in the list.
Browse files Browse the repository at this point in the history
  • Loading branch information
abragtim committed May 5, 2023
1 parent 7757fe5 commit dc88839
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
9 changes: 5 additions & 4 deletions tests/web/test_do_crossmatch_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,13 @@ def test_do_crossmatch_for_assumed_hla_type(self):
headers=self.auth_headers)
self.assertEqual(200, res.status_code)

self.assertEqual(2, len(res.json['hla_to_antibody']))
res_assumed_hla_typing = \
[antibody_match['hla_types']
for antibody_match in res.json['hla_to_antibody']]
expected_assumed_hla_typing = [[asdict(create_hla_type('DPA1*01:04'))],
[asdict(create_hla_type('DPA1*02:01'))]]
[asdict(create_hla_type('DPA1*02:01'))],
[asdict(create_hla_type('DPA1*01:04'))]]
self.assertTrue(len(res_assumed_hla_typing) == len(json['assumed_donor_hla_typing']))
self.assertCountEqual(expected_assumed_hla_typing,
res_assumed_hla_typing)

Expand All @@ -256,7 +257,7 @@ def test_do_crossmatch_for_assumed_hla_type(self):
headers=self.auth_headers)
self.assertEqual(200, res.status_code)

self.assertEqual(3, len(res.json['hla_to_antibody']))
self.assertTrue(len(res.json['hla_to_antibody']) == len(json['assumed_donor_hla_typing']))
res_assumed_hla_typing = \
[antibody_match['hla_types']
for antibody_match in res.json['hla_to_antibody']]
Expand All @@ -283,7 +284,7 @@ def test_do_crossmatch_for_assumed_hla_type(self):
headers=self.auth_headers)
self.assertEqual(200, res.status_code)

self.assertEqual(3, len(res.json['hla_to_antibody']))
self.assertTrue(len(res.json['hla_to_antibody']) == len(json['assumed_donor_hla_typing']))
res_assumed_hla_typing = \
[antibody_match['hla_types']
for antibody_match in res.json['hla_to_antibody']]
Expand Down
5 changes: 0 additions & 5 deletions txmatching/web/api/crossmatch_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def get_parsing_issues_for_hla_typing(antibody_matches_for_hla_type):
))
return typing_parsing_issues

def get_unique_from_list(lst: list):
# this fancy approach is used to prevent reordering how it would be through the set()
return list(dict.fromkeys(lst).keys())

crossmatch_dto = request_body(CrossmatchDTOIn)
hla_antibodies, antibodies_parsing_issues = get_hla_antibodies_and_parsing_issues(
crossmatch_dto.recipient_antibodies)
Expand All @@ -74,7 +70,6 @@ def get_unique_from_list(lst: list):
self.__fulfill_with_common_matches(antibody_matches_for_hla_type,
crossmatched_antibodies_per_group)

antibody_matches_for_hla_type = get_unique_from_list(antibody_matches_for_hla_type)
antibody_matches_for_hla_type = self.__solve_uncrossmatched_assumed_hla_types(
antibody_matches_for_hla_type, hla_antibodies)

Expand Down

0 comments on commit dc88839

Please sign in to comment.