Skip to content

Feature/update grouped db profiling 20260717#59

Merged
cschu merged 11 commits into
mainfrom
feature/update_grouped_db_profiling_20260717
Jul 18, 2026
Merged

Feature/update grouped db profiling 20260717#59
cschu merged 11 commits into
mainfrom
feature/update_grouped_db_profiling_20260717

Conversation

@cschu

@cschu cschu commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added support for processing grouped annotation records when calculating gene counts.
  • Bug Fixes
    • Fixed grouped count handling by aggregating group counts first, then distributing appropriately.
    • Improved compatibility with annotation data returned in different record formats.
  • Chores
    • Updated the package version to 2.18.6.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 725eef6f-d734-41c0-b3aa-44e82ba2aa94

📥 Commits

Reviewing files that changed from the base of the PR and between 9f92379 and fbed08e.

📒 Files selected for processing (3)
  • gffquant/annotation/count_annotator.py
  • gffquant/db/annotation_db.py
  • gffquant/db/models/db.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • gffquant/db/models/db.py
  • gffquant/db/annotation_db.py
  • gffquant/annotation/count_annotator.py

📝 Walkthrough

Walkthrough

The PR updates the package version, adds an AnnotationGroup database model, extends grouped annotation queries, and changes grouped counting to aggregate counts before distributing them across group features.

Changes

Grouped annotation counting

Layer / File(s) Summary
Grouped annotation database contract
gffquant/db/models/db.py, gffquant/db/annotation_db.py
Adds the AnnotationGroup model and supports grouped database lookups with flexible annotation, strand, and feature identifier extraction.
Grouped count accumulation and distribution
gffquant/annotation/count_annotator.py
Aggregates counts by gene group, handles unannotated groups, and distributes annotated group totals after grouped database lookup.
Package version metadata
gffquant/__init__.py
Updates the package version from 2.18.5 to 2.18.6.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GeneCountAnnotator
  participant AnnotationDatabaseManager
  participant SQL_ADM
  participant AnnotationGroup
  GeneCountAnnotator->>GeneCountAnnotator: Accumulate counts by group
  GeneCountAnnotator->>AnnotationDatabaseManager: Query grouped annotation
  AnnotationDatabaseManager->>SQL_ADM: Request grouped sequence
  SQL_ADM->>AnnotationGroup: Query group by id
  AnnotationGroup-->>SQL_ADM: Return group annotation
  SQL_ADM-->>AnnotationDatabaseManager: Return parsed annotation
  AnnotationDatabaseManager-->>GeneCountAnnotator: Return grouped features
  GeneCountAnnotator->>GeneCountAnnotator: Distribute aggregated counts
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is related to the main grouped-db processing changes and accurately reflects the feature update, though it is slightly noisy.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/update_grouped_db_profiling_20260717

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@gffquant/annotation/count_annotator.py`:
- Around line 330-335: Handle a None result from db.query_sequence in the
grouped_counts loop before unpacking it. For missing annotations, add the
current counts to self.unannotated_counts, matching the existing single-gene
safety behavior; otherwise unpack the result and call distribute_feature_counts
as before.

In `@gffquant/db/annotation_db.py`:
- Around line 62-78: Update both
AnnotationDatabaseManager.query_sequence_internal and
Dict_ADM.query_sequence_internal to accept the grouped_db keyword argument,
preserving their existing behavior while allowing query_sequence to forward it
without raising TypeError.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9dd649f8-e598-4182-9009-31e065b413e2

📥 Commits

Reviewing files that changed from the base of the PR and between cc8870e and 9f92379.

📒 Files selected for processing (4)
  • gffquant/__init__.py
  • gffquant/annotation/count_annotator.py
  • gffquant/db/annotation_db.py
  • gffquant/db/models/db.py

Comment thread gffquant/annotation/count_annotator.py Outdated
Comment on lines +62 to +78
def query_sequence(self, seqid, start=None, end=None, grouped_db=False,):
""" Returns strand, seq-feature id (e.g. contig id), functional categories """
db_sequence = self.query_sequence_internal(seqid, start=start, end=end)
db_sequence = self.query_sequence_internal(seqid, start=start, end=end, grouped_db=grouped_db,)

if db_sequence is None:
return None
categories = tuple()
for cat_features in db_sequence.annotation_str.strip().split(";"):

annotation_str = db_sequence.annotation_str if hasattr(db_sequence, "annotation_str") else db_sequence.annotation
strand = db_sequence.strand if hasattr(db_sequence, "strand") else None
featureid = db_sequence.feature_id if hasattr(db_sequence, "feature_id") else None

# for cat_features in db_sequence.annotation_str.strip().split(";"):
for cat_features in annotation_str.strip().split(";"):
category, features = cat_features.split("=")
categories += ((category, tuple(feature.strip() for feature in features.split(",") if feature.strip())),)
return db_sequence.strand, db_sequence.featureid, categories
return strand, featureid, categories

@coderabbitai coderabbitai Bot Jul 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify all query_sequence_internal implementations accept `grouped_db`.

rg 'def query_sequence_internal' -A 2

Repository: cschu/gff_quantifier

Length of output: 158


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== annotation_db.py =="
wc -l gffquant/db/annotation_db.py
sed -n '1,220p' gffquant/db/annotation_db.py

echo
echo "== search for query_sequence_internal =="
rg -n "query_sequence_internal|class .*AnnotationDatabaseManager|class .*Dict_ADM" gffquant -S

echo
echo "== file list around db package =="
find gffquant -maxdepth 3 -type f | sort

Repository: cschu/gff_quantifier

Length of output: 10728


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Dict_ADM implementation =="
sed -n '230,290p' gffquant/db/annotation_db.py

echo
echo "== grouped_db references =="
rg -n "grouped_db" gffquant -S

echo
echo "== query_sequence calls =="
rg -n "query_sequence\(" gffquant -S

Repository: cschu/gff_quantifier

Length of output: 3229


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
text = Path('gffquant/db/annotation_db.py').read_text()

# Extract the abstract/base and subclass signatures in a simple read-only way.
for needle in [
    'def query_sequence_internal(self, seqid, start=None, end=None):',
    'def query_sequence_internal(self, seqid, start=None, end=None, grouped_db=False,):',
]:
    print(needle, '->', text.count(needle))

print("\nRelevant lines:")
for i, line in enumerate(text.splitlines(), 1):
    if 'query_sequence_internal' in line or 'grouped_db' in line:
        print(f"{i}: {line}")
PY

Repository: cschu/gff_quantifier

Length of output: 787


Update query_sequence_internal to accept grouped_db: add the new kwarg to AnnotationDatabaseManager.query_sequence_internal and Dict_ADM.query_sequence_internal; query_sequence() now always forwards it, so Dict_ADM will raise TypeError as-is.

🤖 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 `@gffquant/db/annotation_db.py` around lines 62 - 78, Update both
AnnotationDatabaseManager.query_sequence_internal and
Dict_ADM.query_sequence_internal to accept the grouped_db keyword argument,
preserving their existing behavior while allowing query_sequence to forward it
without raising TypeError.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cschu, you’re welcome! 🐇

@cschu
cschu merged commit 5c8ed2a into main Jul 18, 2026
1 check passed
@cschu
cschu deleted the feature/update_grouped_db_profiling_20260717 branch July 18, 2026 21:50
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