Conversation
Extract the repeated information_schema existence check into a single sequences_table_exists helper in duckdb_index.py and use it in finalize_duckdb_index. Also drop the redundant str() inside the index-path f-strings in init/finalize. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reuse sequences_table_exists at the three existence checks; switch the per-chunk INSERT to INSERT ... BY NAME so a future column-order change surfaces as a bind error rather than silently misaligning columns; set eq=False on _RemapArrays so the frozen dataclass keeps a usable __hash__ despite its list fields; document the 0-based half-open start/end convention at the DuckDB boundary; drop a redundant str(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ORDER BY start, sequence_id so per-contig FASTA output is deterministic across runs (checksummable), with sequence_id as a unique tiebreak. Also add a missing-sequences-table ValueError for parity with finalize, and replace the deprecated fetch_record_batch with to_arrow_reader. Update test fixtures to the real schema (a start column) and add a genomic-ordering regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Log the count of samples dropped for an undefined population assignment (parity with the other count log lines). Document all five output tables in the docstring, and add comments for the biallelic call_stats assumption, the row_idx int32-downcast invariant, and the fixed output partition count. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reference the defaults constants for the HGDP+1KG table URIs in extract_gnomad_single_afs instead of duplicating them. Correct the stale 'sample metadata' docstrings (neither tool writes sample data), type freq_threshold as 0.0, and validate the .ht output path before starting Hail for parity with the TSV path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
parse_variants_string now raises a ValueError naming the offending token (and documents it) instead of an opaque unpack/int() error. Correct the classify_pair 'adjacent' docstring (it classifies any pair) and the REASONS comment (it is documentation only; classify_pair uses its own if/elif order and compatibility_flag emits alphabetically). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add the missing Raises: block for the ValueError raised when loci is empty. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace os.path.join/os.path.exists with pathlib for the connector JAR paths, keeping os only for environ. Validate the credentials path with is_file(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Parametrized test that driver/executor memory below 1GB raises before any credentials or JAR resolution. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PEP 695 'type' alias for HailPath; Hashable/Callable imported from collections.abc; lazy %s logging in main; Final on POPULATIONS and REFERENCE_GENOME with a provenance comment for the population set. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Use 'curl --fail' instead of wget in the analysis download rule (ships on macOS; fails loudly on HTTP errors); constrain the chromosomes config schema with a pattern so typos fail at validation; add a comment explaining the forced .fai name; fix an accidental implicit string concat; and correct the create_test_data credentials comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The helper only produced hashable dict keys for equality lookup, which frozenset of items does directly. Drops the function, its _V TypeVar, and its tests in favor of the inline stdlib call. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR updates DuckDB index and FASTA handling, haplotype ordering and frequency extraction, Hail path validation, type declarations, workflow validation, dependency constraints, logging, and related documentation and tests. ChangesDivRef consistency and workflow updates
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The group count was never used by any caller; return just the row_idx → locus_group mapping. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
get_haplo_sequence and haplo_coordinates sorted variants by (position, len(ref)), which ties a co-located SNP and insertion; the tie was resolved by input order and, when the insertion applied first, the SNP was silently dropped from the emitted sequence (a PASS row in the FASTA/DuckDB deliverable). Add a tertiary tiebreak on alt length so a substitution always composes before a pure insertion at the same position. Includes a reversed-order regression test, and removes an unused test helper (_make_haplotype_table). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
divref/divref/defaults.py (1)
28-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse a tuple to fully enforce immutability.
While
Finalprevents reassignment ofPOPULATIONS, the underlying list remains mutable. As per coding guidelines, prefer immutable data. Consider defining this as atuple(e.g.,tuple[str, ...]) and updating downstream function signatures that currently expect alist[str].🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@divref/divref/defaults.py` at line 28, Change the POPULATIONS constant from a mutable list to an immutable tuple, using an appropriate tuple type annotation. Update downstream functions that consume POPULATIONS, including their parameter annotations, to accept the tuple type without changing behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Line 33: Update the sentence introducing Hail-dependent tools to replace the
comma splice with clear wording, preserving the requirement that users log in
and install the gcloud CLI first.
---
Nitpick comments:
In `@divref/divref/defaults.py`:
- Line 28: Change the POPULATIONS constant from a mutable list to an immutable
tuple, using an appropriate tuple type annotation. Update downstream functions
that consume POPULATIONS, including their parameter annotations, to accept the
tuple type without changing behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 38a3c1ca-0de0-4a63-bce5-3c7f768146bf
📒 Files selected for processing (27)
.github/workflows/workflow_linting.ymlCONTRIBUTING.mdREADME.mddivref/divref/alias.pydivref/divref/defaults.pydivref/divref/duckdb_index.pydivref/divref/hail.pydivref/divref/haplotype.pydivref/divref/haplotype_compat.pydivref/divref/main.pydivref/divref/tools/append_contig_to_duckdb_index.pydivref/divref/tools/compute_haplotypes.pydivref/divref/tools/create_divref_fasta.pydivref/divref/tools/extract_gnomad_afs.pydivref/divref/tools/extract_gnomad_single_afs.pydivref/divref/tools/finalize_duckdb_index.pydivref/divref/tools/gnomad_hail_table_test_data.pydivref/divref/tools/init_duckdb_index.pydivref/tests/test_hail.pydivref/tests/test_haplotype.pydivref/tests/test_main.pydivref/tests/tools/test_create_divref_fasta.pypixi.tomlworkflows/compare_divref_gnomad.smkworkflows/config/config_schema.ymlworkflows/create_test_data.smkworkflows/generate_divref.smk
💤 Files with no reviewable changes (1)
- pixi.toml
| ``` | ||
|
|
||
| Log in before running any Hail-dependent tools: | ||
| Log in before running any Hail-dependent tools, requires [the gcloud cli be installed](https://docs.cloud.google.com/sdk/docs/install-sdk): |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Fix the sentence structure.
Replace the comma splice with clearer wording, for example: “Log in before running any Hail-dependent tools; the gcloud CLI must be installed first:”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` at line 33, Update the sentence introducing Hail-dependent tools
to replace the comma splice with clear wording, preserving the requirement that
users log in and install the gcloud CLI first.
Commit c87b97f removed the `check-lock` pixi task but left `check-all` and `fix-and-check-all` referencing it, breaking both. Restore the task definition and revert the CONTRIBUTING.md command back to `pixi run check-lock`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
create_divref_fasta streams results via DuckDBPyRelation.to_arrow_reader, which is only available on duckdb>=1.4.0; the prior >=1.0 bound could resolve an older version lacking the method. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Match the GCS-side check: a directory at the JAR path would pass `.exists()` but is not a usable connector JAR. `.is_file()` rejects it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Explain that a full tie (same position, ref length, and alt length) can only arise from two alleles at one site, which cannot occur on a single phased haplotype, so the input-order fallback is never exercised in practice. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The tool itself never deletes the intermediate `.variants/.blocks/.parents/ .hap_ac` checkpoints; the Snakemake rule removes them post-run. State that explicitly rather than "kept, not cleaned up". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Spell out why a sample is dropped: its population is outside the DivRef legend (a gnomAD ancestry not in the pop set, or an unassigned population marking an aneuploid karyotype). Include the legend in the message. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
A collection of small correctness, quality, and consistency changes across the
divreftoolkit and the Snakemake workflows. The bulk is non-behavioral (docstrings, typing, refactors, added tests), with two behavioral changes called out below. All checks pass (uv run poe check-all: format, lint, mypy, tests;snakefmtclean).Behavioral changes (worth a closer look)
fix(haplotype): break sort ties for co-located SNP + insertion—get_haplo_sequence/haplo_coordinatessorted component variants by(position, len(ref)), which ties a SNP and an insertion at the same position. The tie was resolved by input order, and when the insertion applied first the SNP was silently dropped from the emitted sequence (aPASSrow in the FASTA/DuckDB deliverable). Added a tertiary tiebreak on alt length so a substitution always composes before a pure insertion, plus a reversed-order regression test.feat(fasta): order FASTA output by genomic position—create_divref_fastanow emits rowsORDER BY start, sequence_id, making per-chromosome FASTA output deterministic/checksummable across runs. Same content, stable byte-ordering.Toolkit refactors & hardening
refactor(duckdb)— extract a sharedsequences_table_existshelper; reuse it infinalize,append_contig, andcreate_divref_fasta(dedups the repeatedinformation_schemacheck).refactor(append-contig)— reuse the helper; switch the per-chunk insert toINSERT ... BY NAME(guards against column-order drift);eq=Falseon_RemapArrays; document the 0-based half-open coordinate convention at the DuckDB boundary.refactor(extract)— single-source the HGDP+1KG table URIs fromdefaults; fix stale "sample metadata" docstrings; validate the.htoutput path before starting Hail; typefreq_thresholdas0.0.refactor(hail)— usepathlibfor connector-JAR path handling; validate the credentials path withis_file().fix(haplotype-compat)—parse_variants_stringraises an informativeValueErrornaming the offending token; corrected theclassify_pair/REASONSdocumentation.refactor— replaceto_hashable_itemswithfrozenset(d.items()); drop the unusedn_groupsfrom_compute_locus_groups's return.Observability
chore(compute-haplotypes)— log the count of samples dropped for an undefined population; document all five output tables; add comments for the bialleliccall_statsandrow_idxint32-downcast invariants.Tests
test(hail): parametrized sub-1GB Spark memory guards.Style & consistency
style— modern typing (PEP 695typealias,collections.abcimports), lazy%slogging,Finalconstants with a provenance comment for the population set.Workflows, CI & docs
refactor(workflows)—curl --failoverwget(macOS-safe, fails loudly);chromosomesconfig-schemapattern; comment on the forced.fainame; fix an implicit string concat; correct the credentials comment.--locked); pixi lock-file fixes.Not in this PR (tracked follow-ups)
Larger items surfaced in review, deliberately left for separate PRs:
remap_divrefpass: extract helpers to drop theC901complexity, and a pandas→polars streaming rewrite.extract_gnomad_single_afs: anin_sites_tableoverride + happy-path test for the default v4.1 JOINT path (currently untested), and a sharedpop_freq_indiceshelper.%.5fgnomAD-AF truncation,.fainaming convention,no_apply_filters→apply_filters, and softening theappend_contigmemory-bound docstrings.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation