Remove the remaining duplicate implementations: annotation, snpdb, cross-app #1801 - #1802
Merged
Merged
Conversation
- _ExternalDump holds what dump_external_annotation_runs and dump_existing_annotation_runs did identically once each run is in hand - FamilyGroupMixin holds the permissions and display Trio and Quad shared; their fields stay put, as the related_names differ - FamilyGroupListColumns and NamedCollectionColumns collapse the two pairs of near-identical snpdb grids - plot_chromosome_bin_values draws the per-chromosome heatmap band both the density and homozygosity graphs were building by hand - as_table/as_p share their row loop, each keeping its own return type - the create_fake_data subcommands share their variant/zipf helpers via annotation.fake_data (moved out of #1798) - popoverHoverStay replaces the two copies of the hover-stay handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Written by Claude
Addresses #1801, the last of the three (after #1798 and #1800). Net -142 lines, no migration (
makemigrations --checkclean across all apps)._ExternalDump(annotation/external_annotation.py)dump_external_annotation_runsanddump_existing_annotation_runsdiffer only in how they get hold of theirAnnotationRuns — one creates them from range locks, the other adopts existing CREATED ones. Everything after that was duplicated: the too-small rejection and revert, thedump_count == 0skip, the lazily-computed version identity, the sidecar write, and the wholewrite_snakemake_bundle/ re-dispatch / logging tail.Both now build a
_ExternalDump, feed each run toadd_run(), and returnfinish(). The two log lines that named the flavour ("Dumped external ..." / "Dumped existing ...") keep their wording via thedescribed_asargument.FamilyGroupMixin(snpdb/models/models_cohort.py)Ten identical methods across
TrioandQuad— permissions, preview,genome_build,data_archived,get_samples, and the member-details properties.__str__was the same bar the printed class name, so it now usestype(self).__name__and gives the same "Trio 5" / "Quad 5".mother_details/father_details/sibling_detailswere three copies of one two-line shape, now_member_details(member, affected).The fields deliberately stay where they are —
related_namediffers per model (trio_mothervsquad_mother), so they can't move to a shared abstract model without a migration. This is a plain mixin, so there is no schema change at all.FamilyGroupListColumns/NamedCollectionColumns(snpdb/grids.py)QuadsListColumnswasTriosListColumnsplus two sibling columns; both now declare their model, theirUserGridConfigname, and their family members.CustomColumnsCollectionColumnsandTagColorsCollectionColumnswere identical bar the model, and are now two-line subclasses.Verified the generated column lists are byte-for-byte what the old classes produced, in the same order.
plot_chromosome_bin_values(library/graphs/chromosomes_graph.py)The chromosome density and homozygosity percent graphs each built the same
pcolormeshband by hand — the dimension juggling, they_top/y_bottompadding, the masked array,set_clim. It moves next toplot_chromosomes, which both already use; the caller passes its ownvmax(computed vs. a flat 100.0), which was the only real difference.as_table/as_p(snpdb/templatetags/model_helpers.py)The shared row loop becomes
_display_rows. Each filter keeps its own return type —as_preturnsmark_safe,as_tablea plainstrbecause its callers apply|safeat the template — and I checked both still returnSafeString/strrespectively against a real model.annotation/fake_data.py_variant_ids_by_geneand_zipf_weightwere byte-identical inanalysis/fake_variant_tags.pyandclassification/fake_reclassifications.py. Both arecreate_fake_datasubcommands; the shared copy sits inannotation(which owns the models the query needs) so neither app has to import the other. Moved out of #1798 at review request.popoverHoverStay(global.js)The hover-stay handler with its 300ms
.popover:hovergrace check was bound in two places. Edited instatic_files/default_static, not the collectstatic output.Identified, deliberately not changed
annotation/tasks/calculate_sample_stats.pyrepeats the same ~15-line counter-bump three times. It is real duplication, but it is the innermost per-variant loop of a task that walks the whole database, and a helper call per bucket per variant is a throughput cost I didn't think worth paying for tidiness. Written up in the issue so it is on record.ClassificationAttachment.get_file_dict/PatientAttachment.get_file_dict— identical bar URL names, but sharing them properly means an abstract attachment model spanning two apps plus migrations. Bigger than the rest of this, and left for its own change.annotation/tests/has ~6 copies of the samesetUpTestData. Worth tidying, but sharing fixtures is a different exercise to deduplicating production code.Testing
manage.py test --keepdb(whole suite) — 2426 tests, OKmanage.py checkclean;makemigrations --checkreports no changes for any appruffshows no new findings on any changed filepreview_if_url_visible, the four grids' column lists, and the two template filters' return typesglobal.jshas no node/eslint available here, so I checked the edit by inspection — the brace and paren deltas against master are symmetric (-4/-4, -13/-13)🤖 Generated with Claude Code
https://claude.ai/code/session_01TKZV4Gh7ZXRjqx7ibPDTSd