Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes and enhancements #186

Merged
merged 4 commits into from
Jan 31, 2025
Merged

Conversation

GavinHuttley
Copy link

@GavinHuttley GavinHuttley commented Jan 31, 2025

Summary by Sourcery

Add the ability to specify reference coordinates when retrieving homologs.

New Features:

  • Allow users to specify a list of chromosome/scaffold names to limit the homolog search.

Tests:

  • Added tests to verify that the homolog retrieval respects the specified coordinates.

[FIXED] a side-effect of using python magic to get local variables,
    needed to exclude the local_vars variable which was added to address
    a python 3.13 side-effect
[FIXED] Genome.get_features(name=) has to be changed to
    Annotation.get_features(stable_id=) the first one has that name to match
    the cogent3 API.

[CHANGED] the GeneView.get_features_matching() method now corrects for usage
    of name too
[CHANGED] Genome.get_ids_for_biotype() requires keyword args and now allows seqid
    to be a list of strings
[NEW] can provide a comma separated list of coordinate names, 'I,II'
    or a file with a coordinate name per line, to
    homologs --coord_names. Related to cogent3#168
Copy link

sourcery-ai bot commented Jan 31, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new feature to filter homologs by coordinate names and fixes a bug in the test suite.

Sequence diagram for homolog filtering by coordinate names

sequenceDiagram
    participant User
    participant CLI
    participant Genome
    participant AnnotationDB

    User->>CLI: homologs command with coord_names
    CLI->>CLI: _get_coord_names()
    Note over CLI: Parse coord_names from file or comma-separated list
    CLI->>Genome: get_ids_for_biotype()
    Genome->>AnnotationDB: get_ids_for_biotype()
    Note over AnnotationDB: Filter genes by biotype and seqid
    AnnotationDB-->>Genome: filtered gene IDs
    Genome-->>CLI: filtered gene IDs
    CLI-->>User: filtered homolog results
Loading

Class diagram showing updated Genome and AnnotationDB methods

classDiagram
    class Genome {
        +get_ids_for_biotype(biotype: str, seqid: str|list[str], limit: int) Iterator[str]
        +get_features(biotype: str, seqid: str, name: str, start: int, stop: int, limit: int) Iterator[Feature]
    }

    class AnnotationDB {
        +get_features_matching(stable_id: str, description: str, limit: int)
        +genes: GeneData
    }

    Genome --> AnnotationDB
    note for Genome "Modified to support filtering by seqid"
    note for AnnotationDB "Updated feature matching logic"
Loading

File-Level Changes

Change Details Files
Added support for filtering homologs by coordinate names.
  • Added a new --coord_names option to the homologs command.
  • Implemented a function to parse coordinate names from a comma-separated string or a file.
  • Modified the get_ids_for_biotype method in the Genome class to filter by coordinate names.
  • Updated the get_features_matching method in the AnnotationDb class to use stable_id instead of name.
  • Added a new test case for the homologs command with coordinate names.
  • Added a new test case for the get_ids_for_biotype method with coordinate names.
src/ensembl_tui/cli.py
src/ensembl_tui/_genome.py
tests/test_cli.py
tests/test_genome.py
src/ensembl_tui/_annotation.py
Fixed a bug in the test suite.
  • Modified the test_homologs test case to use a temporary directory.
tests/test_cli.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @GavinHuttley - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 13065303803

Details

  • 14 of 17 (82.35%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 87.651%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ensembl_tui/cli.py 9 10 90.0%
src/ensembl_tui/_genome.py 4 6 66.67%
Totals Coverage Status
Change from base Build 13022873967: -0.04%
Covered Lines: 2605
Relevant Lines: 2972

💛 - Coveralls

@GavinHuttley GavinHuttley merged commit 1d4b5a4 into cogent3:develop Jan 31, 2025
12 of 22 checks passed
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.

2 participants