diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index dfad507..9dd0b63 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -21,6 +21,5 @@ jobs: poetry config virtualenvs.create false poetry install --no-dev - name: Run tests - # Here other tests could be added, for now just the api entrypoints run: | - python -m unittest test_api.py + python -m unittest -v diff --git a/allele_fixes.py b/allele_fixes.py index 51dc94f..2370192 100644 --- a/allele_fixes.py +++ b/allele_fixes.py @@ -80,20 +80,29 @@ def old_coords_fix(coordinate_changes, targets): # We now remap from old coordinates to new ones. It may return None if the position in the old sequence # does not exist in the new one. target_remapped = change_to_new_indexes_from_old_coordinates(old_alignment, new_alignment, t) - # Special case where the given position is matched in the old sequence, but there is not an equivalent # position in the new sequence. Example: # # > current sequence # ----------------MLQRLEQL + # ^ # > old sequence # MPGSPSQEPLAEAESNMLQRLEQL + # ^ # # For instance, S4 is matched in the old sequence, but there is no equivalent position in the new sequence. + # + # This does not have to necessarily on a dash, it can be on a different aminoacid, e.g.: + # + # > current sequence + # MAAA------------MLQRLEQL + # ^ + # > old sequence + # MPGSPSQEPLAEAESNMLQRLEQL + # ^ - if target_remapped is None: + if target_remapped is None or not position_or_index_exists(target_remapped, new_sequence): this_revision['values'].append('?') - # For now, we also break in this case # break else: this_revision['values'].append(target_remapped) diff --git a/test_coordinate_change.py b/test_coordinate_change.py index 66584b3..389a212 100644 --- a/test_coordinate_change.py +++ b/test_coordinate_change.py @@ -95,6 +95,8 @@ def test_old_coords_fix(self): ] solutions = old_coords_fix(coordinate_changes, ['A1', 'P2']) - self.assertEqual(len(solutions), 2) + self.assertEqual(len(solutions), 4) self.assertEqual(solutions[0]['values'], 'A1,P4') self.assertEqual(solutions[1]['values'], 'A1,P3') + self.assertEqual(solutions[2]['values'], '?,P4') + self.assertEqual(solutions[3]['values'], '?,P3')