Skip to content

Remove duplicate implementations in the classification app #1796 - #1798

Open
davmlaw wants to merge 1 commit into
masterfrom
issue_1796_classification_duplicate_code
Open

Remove duplicate implementations in the classification app #1796#1798
davmlaw wants to merge 1 commit into
masterfrom
issue_1796_classification_duplicate_code

Conversation

@davmlaw

@davmlaw davmlaw commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🤖 Written by Claude

Addresses #1796 — duplicated implementations in the classification app, found by a token-normalised clone scan plus AST structural-similarity pass over the codebase.

Two deletions and two extractions. Net -111 lines.

Deletions

classification/management/commands/evidence_key_cleaner.py — identical to unknown_evidence_key_cleaner.py apart from a --key argument that handle() never read and that made argparse raise ValueError: 'str' is not callable at add_argument time (type='str', the string rather than the builtin). The command could not run at all, including --help, and nothing referenced it. unknown_evidence_key_cleaner is unchanged and still registered.

Classification.get_allele_info_dict() — no callers anywhere; classification_json.get_allele_info_dict() is what actually runs, via populate_classification_json. The dead copy had already drifted: it never picked up the imported_g_hgvs_obj fallback added by #1063, nor VARIANT_COORDINATE in the per-build dict.

Extractions

EvidenceMixin.met_criteria_strengths()classification_groups.acmg_criteria and ClassificationSummaryCalculator.criteria_labels each had their own copy of the same walk (met criteria from EvidenceKeyMap.cached().criteria(), then AMP_LEVELS_TO_LEVEL expanded into custom-strength CriteriaStrengths). Both call sites hold a ClassificationModification, which is an EvidenceMixin, so the walk now lives on the mixin and each caller keeps only its own output shaping. Behaviour is unchanged — the one difference is that the AMP branch reuses the e_key it already looked up instead of calling EvidenceKeyMap.cached_key(amp_level) a second time for the same key.

DiscordanceReportAdminExport._describe_movement()_less_more_certain and _up_down_for shared a seven-line prelude and the withdrawn / same / ? guards. Those now live in one place, and each caller passes just the comparison that distinguishes it.

Left out

The near-identical context dicts in classifications and classification_groupings (classification/views/views.py) are untouched — #1765 proposes deleting the dead classification_groupings page outright, which removes that duplication properly.

The _variant_ids_by_gene / _zipf_weight pair shared with analysis/fake_variant_tags.py has moved out of this PR, and is handled with the rest of the cross-app duplication instead.

Testing

  • manage.py test --keepdb classification — 139 tests, OK
  • manage.py test --keepdb analysis annotation snpdb — 1168 tests, OK
  • manage.py check clean; ruff reports no new findings on any changed file
  • evidence_key_cleaner is gone from manage.py help, while unknown_evidence_key_cleaner remains

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKZV4Gh7ZXRjqx7ibPDTSd

- delete evidence_key_cleaner: an identical copy of unknown_evidence_key_cleaner,
  whose only extra argument was never read and made argparse raise at add_argument
- delete Classification.get_allele_info_dict: dead since classification_json took
  over, and had missed the g.HGVS fallback (#1063) and variant_coordinate since
- pull the met-criteria + AMP level walk up into EvidenceMixin.met_criteria_strengths
- share the discordance movement guards between _less_more_certain and _up_down_for
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant